Skip to content

Commit 0a7ea50

Browse files
committed
fluxes, shapes fixed
1 parent c3be2f3 commit 0a7ea50

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

Sourcery/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
#### Shapes are corrected: sourcery able to assign pnt and Gau appropriately, and uses DC_Maj/Min as a model and Maj/Min for reliability computation.
77
#### The flux estimations are corrected. Uses masked image to create islands and the actual image for detection (model fitting)
88
#### Takes the radius of sources to exclude inside the reliability script (previously it was done inside main-- had problems)
9+
#### Has an option to remove sources with correlation < 0.002 and reliability > 0.60

Sourcery/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"do_psf_corr": true,
1010
"do_local_var": true,
1111
"do_nearsources":false,
12+
"reset_rel": false,
1213
"increase_beam_cluster": true,
1314
"psf_corr_region" : 5,
1415
"local_var_region" : 10,

Sourcery/main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ def main():
6767
default=True, help="Make reliability density plot. Default is True."
6868
" To disable add -dmp on the command line.")
6969

70-
add("-rel", "--rel-thresh", dest="rel_thresh", default=None, type=float,
71-
help= "Sets a reliability threshold. Default is None.")
70+
add("-drel", "--reset-rel", dest="reset_rel", action="store_true",
71+
default=False, help=" Assigns R=0 for sources with cf < 0.002 and"
72+
"R > 0.60.")
7273

7374
add("-beam", "--beam-cluster", dest="do_beam", default=False,
7475
action="store_true", help= "Increases the Gaussian groupings by 20 percent the"
@@ -268,7 +269,7 @@ def get_prefix(prefix, imagename, outdir):
268269
neg_smooth=args.neg_smooth, loglevel=args.log_level,
269270
thresh_isl=args.thresh_isl, thresh_pix=args.thresh_pix,
270271
neg_thresh_isl=args.neg_thresh_isl, neg_thresh_pix=
271-
args.neg_thresh_pix, prefix=prefix,
272+
args.neg_thresh_pix, prefix=prefix, reset_rel=args.reset_rel,
272273
do_nearsources=args.do_nearsources, increase_beam_cluster=
273274
args.do_beam, savemask_neg=args.savemask_neg,
274275
savemask_pos=args.savemask_pos, **pybdsm_opts)

Sourcery/reliabilityestimates.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ def __init__(self, imagename, psfname=None, sourcefinder_name='pybdsm',
2525
makeplots=True, do_psf_corr=True, do_local_var=True,
2626
psf_corr_region=5, local_var_region=10, rel_excl_src=None,
2727
pos_smooth=2, neg_smooth=2, loglevel=0, thresh_pix=5,
28-
thresh_isl=3, neg_thresh_isl=3, neg_thresh_pix=5,
29-
prefix=None, do_nearsources=False, increase_beam_cluster=False,
30-
savemask_pos=False, savemask_neg=False, **kw):
28+
thresh_isl=3, neg_thresh_isl=3, neg_thresh_pix=5, reset_rel=None,
29+
prefix=None, do_nearsources=False, savefits=False,
30+
increase_beam_cluster=False, savemask_pos=False, savemask_neg=False,
31+
**kw):
3132

3233
""" Takes in image and extracts sources and makes
3334
reliability estimations..
@@ -89,6 +90,10 @@ def __init__(self, imagename, psfname=None, sourcefinder_name='pybdsm',
8990
savefits: boolean. Default is False.
9091
If True a negative image is saved.
9192
93+
reset_rel: boolean. Default is False. If true then
94+
sources with correlation < 0.002 and rel >0.60
95+
have their reliabilities set to 0.
96+
9297
increase_beam_cluster: boolean, optional. If True, sources
9398
groupings will be increase by 20% the beam size. If False,
9499
the actual beam size will be used. Default is False.
@@ -137,7 +142,8 @@ def __init__(self, imagename, psfname=None, sourcefinder_name='pybdsm',
137142
self.do_psf_corr = do_psf_corr
138143
self.savemaskpos = savemask_pos
139144
self.savemaskneg = savemask_neg
140-
self.savefits = False
145+
self.savefits = savefits
146+
self.derel = reset_rel
141147

142148
if not self.psfname:
143149
self.log.info(" No psf provided, do_psf_corr is set to False.")
@@ -312,6 +318,9 @@ def params(self, modelfits, data_image):
312318
cf = (numpy.diag((numpy.rot90(c_region))**2)
313319
.sum())**0.5/2**0.5
314320
srs.setAttribute("cf", cf)
321+
#srs.setAttribute("ex", emaj)
322+
#srs.setAttribute("ey", emin)
323+
#srs.setAttribute("I_err", data["E_Total_flux"][i])
315324
corr.append(cf)
316325
model.sources.append(srs)
317326
peak.append(peak_flux)
@@ -320,6 +329,9 @@ def params(self, modelfits, data_image):
320329
loc.append(local)
321330
else:
322331
model.sources.append(srs)
332+
#srs.setAttribute("ex", emaj)
333+
#srs.setAttribute("ey", emin)
334+
#srs.setAttribute("I_err", data["E_Total_flux"][i])
323335
peak.append(peak_flux)
324336
total.append(flux)
325337
area.append(srcarea)
@@ -451,10 +463,10 @@ def get_reliability(self):
451463

452464
# remove sources with poor correlation and high reliability,
453465
# the values are currently arbitrary
454-
if self.do_psf_corr:
466+
if self.do_psf_corr and self.derel:
455467
for s in pmodel.sources:
456468
cf, r = s.cf, s.rel
457-
if cf < 0.01 and r > 0.70:
469+
if cf < 0.002 and r > 0.60:
458470
s.rel = 0.0
459471

460472
if self.makeplots:

0 commit comments

Comments
 (0)