Skip to content

Commit

Permalink
Add flag values to output (issue #139)
Browse files Browse the repository at this point in the history
  • Loading branch information
darafferty committed Oct 6, 2020
1 parent dbfca48 commit 99573ee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
24 changes: 20 additions & 4 deletions bdsf/gaul2srl.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __call__(self, img):
sources = []
dsources = []
no_gaus_islands = []
no_gaus_islands_flag_values = []
for iisl, isl in enumerate(img.islands):
isl_sources = []
isl_dsources = []
Expand All @@ -65,6 +66,10 @@ def __call__(self, img):
if not img.waveletimage:
dg = isl.dgaul[0]
no_gaus_islands.append((isl.island_id, dg.centre_pix[0], dg.centre_pix[1]))
flag_values = []
for fg in isl.fgaul:
flag_values.append(fg.flag)
no_gaus_islands_flag_values.append(flag_values)
# Put in the dummy Source as the source and use negative IDs
g_list = isl.dgaul
dsrc_index, dsource = self.process_single_gaussian(img, g_list, dsrc_index, code = 'S')
Expand All @@ -84,18 +89,29 @@ def __call__(self, img):
message += ':\n'
else:
message += 's:\n'
for isl_id in no_gaus_islands:
message += ' Island #%i (x=%i, y=%i)\n' % isl_id
for isl_id, flag_list in zip(no_gaus_islands, no_gaus_islands_flag_values):
message += ' Island #%i (x=%i, y=%i): ' % isl_id
if len(flag_list) > 0:
flags_str = '{}'.format(', '.join([str(f) for f in flag_list]))
if len(flag_list) == 1:
pl_str = ''
else:
pl_str = 's'
message += 'fit with {0} Gaussian{1} with flag{1} = {2}\n'.format(len(flag_list), pl_str, flags_str)
else:
message += '\n'
if len(no_gaus_islands) == 1:
message += 'Please check this island. If it is a valid island and\n'
else:
message += 'Please check these islands. If they are valid islands and\n'
if img.opts.atrous_do:
message += 'should be fit, try adjusting the flagging options (use\n'\
'show_fit with "ch0_flagged=True" to see the flagged Gaussians).'
'show_fit with "ch0_flagged=True" to see the flagged Gaussians\n'\
'and "help \'flagging_opts\'" to see the meaning of the flags).'
else:
message += 'should be fit, try adjusting the flagging options (use\n'\
'show_fit with "ch0_flagged=True" to see the flagged Gaussians)\n'\
'show_fit with "ch0_flagged=True" to see the flagged Gaussians\n'\
'and "help \'flagging_opts\'" to see the meaning of the flags)\n'\
'or enabling the wavelet module (with "atrous_do=True").'
message += '\nTo include empty islands in output source catalogs, set\n'\
'incl_empty=True in the write_catalog task.'
Expand Down
1 change: 1 addition & 0 deletions bdsf/islands.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ def __init__(self, img, mask, mean, rms, labels, bbox, idx,
self.total_fluxE = func.nanmean(bbox_rms_im[in_bbox_and_unmasked]) * N.sqrt(pixels_in_isl/beamarea) # Jy
self.border = self.get_border()
self.gaul = []
self.fgaul = []
self.sources = []
self.gresid_mean = 0.0
self.gresid_rms = 0.0
Expand Down

0 comments on commit 99573ee

Please sign in to comment.