Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
NIKA2 Cosmology Legacy Survey
PurityCompletness
Commits
62e8c3c8
Commit
62e8c3c8
authored
Apr 17, 2018
by
LUSTIG Peter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ready
parent
cd29a2a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
7 deletions
+56
-7
combine_catalogs.py
combine_catalogs.py
+56
-7
No files found.
combine_catalogs.py
View file @
62e8c3c8
...
...
@@ -11,7 +11,7 @@ print(os.getcwd())
def
CombineMeasurements
(
sourceslist
,
fakesourceslist
):
fake_sources
=
Table
()
sources
=
Table
()
for
_fake
,
_detected
in
zip
(
sourceslist
,
fake
sourceslist
):
for
_fake
,
_detected
in
zip
(
fake
sourceslist
,
sourceslist
):
n_fake
=
len
(
fake_sources
)
n_detected
=
len
(
sources
)
...
...
@@ -42,7 +42,8 @@ def LoadSingleFile(fname):
return
flux
,
sources
,
fsources
,
dthresh
def
Combine
(
directory
,
key
,
outfile
):
def
Combine
(
directory
,
key
,
outfile
,
precision
=
0.001
*
u
.
mJy
):
fnames
=
list
(
sorted
(
Path
(
directory
).
glob
(
key
)))
minthresh
=
None
...
...
@@ -69,14 +70,62 @@ def Combine(directory, key, outfile):
sourceslist
=
[
sourceslist
[
i
]
for
i
in
idxsort
]
fsourceslist
=
[
fsourceslist
[
i
]
for
i
in
idxsort
]
groupflux
=
[]
sourcegroup
=
[]
fsourcegroup
=
[]
'''
_fgroup = [fluxlist[0]]
_sgroup = [sourceslist[0]]
_fsgroup = [fsourceslist[0]]
'''
_fgroup
=
[]
_sgroup
=
[]
_fsgroup
=
[]
for
i
in
range
(
len
(
fluxlist
)):
_f
=
fluxlist
[
i
]
_s
=
sourceslist
[
i
]
_fs
=
fsourceslist
[
i
]
if
_fgroup
==
[]
or
(
_f
-
fluxlist
[
i
-
1
])
<
precision
:
_fgroup
.
append
(
_f
)
_sgroup
.
append
(
_s
)
_fsgroup
.
append
(
_fs
)
else
:
groupflux
.
append
(
np
.
mean
(
u
.
Quantity
(
_fgroup
)))
print
(
'combining'
,
_fgroup
)
_gs
,
_gfs
=
CombineMeasurements
(
_sgroup
,
_fsgroup
)
sourcegroup
.
append
(
_gs
)
fsourcegroup
.
append
(
_gfs
)
_fgroup
=
[
_f
]
_sgroup
=
[
_s
]
_fsgroup
=
[
_fs
]
groupflux
.
append
(
np
.
mean
(
u
.
Quantity
(
_fgroup
)))
print
(
'combining'
,
_fgroup
)
_gs
,
_gfs
=
CombineMeasurements
(
_sgroup
,
_fsgroup
)
sourcegroup
.
append
(
_gs
)
fsourcegroup
.
append
(
_gfs
)
phdu
=
PrimaryHDU
()
phdu
.
header
[
'dthresh'
]
=
minthresh
phdu
.
header
[
'nfluxes'
]
=
len
(
groupflux
)
hdul
=
[
phdu
]
for
i
in
range
(
len
(
groupflux
)):
hdul
.
append
(
BinTableHDU
(
sourcegroup
[
i
],
name
=
'detected_sources{}'
.
format
(
i
)))
hdul
.
append
(
BinTableHDU
(
fsourcegroup
[
i
],
name
=
'fake_sources{}'
.
format
(
i
)))
hdul
[
0
].
header
[
'flux{}'
.
format
(
i
)]
=
'{}'
.
format
(
groupflux
[
i
])
hdul
=
HDUList
(
hdul
)
hdul
.
writeto
(
outname
,
overwrite
=
True
)
print
(
'{} different fluxes, tables written to {}'
.
format
(
len
(
groupflux
),
outname
))
fluxlist
=
u
.
Quantity
(
fluxlist
)
directory
=
'montecarlo_results/700/'
outname
=
'NEWcombine
d_tables_long
.fits'
key
=
'*
182707*
'
outname
=
'NEW
_
combine
_fct_result
.fits'
key
=
'*
700.fits
'
Combine
(
directory
,
key
,
outname
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment