lofar-astron / PyBDSF

Python Blob Detector and Source Finder
https://pybdsf.readthedocs.io
GNU General Public License v3.0
50 stars 24 forks source link

'Image' object has no attribute 'island_labels' when using aperture #157

Closed tikk3r closed 3 years ago

tikk3r commented 3 years ago

When using PyBDSF 1.9.1 I encounter AttributeError: 'Image' object has no attribute 'island_labels' when trying to run it on an image using an aperture. The command I run is

apasec = 2.0 
pixscale = 0.11
aperture_coords = zip(tab_s['RA'], tab_s['DEC'])

res = bdsf.process_image(fitsname, detection_image=detectimage, thresh_isl=4.0, thresh_pix=5.0, rms_box=(4500,450), rms_map=True, mean_map='map', ini_method='intensity', adaptive_rms_box=True, adaptive_thresh=150, rms_box_bright=(1800,450), group_by_isl=False, group_tol=10.0, output_opts=True, output_all=True, atrous_do=True, atrous_jmax=5, flagging_opts=True, flag_maxsize_fwhm=0.5, advanced_opts=True, blank_limit=None, frequency=restfrq, aperture=True, src_ra_dec=aperture_coords, src_radius_pix=int(apasec/pixscale))

the full output is

--> Opened 'facet_13_kernel25-MFS-image-pb.fits'
Image size .............................. : (22700, 22700) pixels
Number of channels ...................... : 1
Number of Stokes parameters ............. : 1
Beam shape (major, minor, pos angle) .... : (1.05851e-04, 8.45167e-05, 175.0) degrees
Frequency of image ...................... : 144.627 MHz
Number of blank pixels .................. : 0 (0.0%)
Flux from sum of (non-blank) pixels ..... : 0.444 Jy
--> Calculating background rms and mean images
--> Using adaptive scaling of rms_box
Using user-specified rms_box ............ : (1800, 450) pixels (small scale)
Using user-specified rms_box ............ : (4500, 450) pixels (large scale)
Number of sources using small scale ..... : 9
--> Using 2D map for background rms
--> Using 2D map for background mean
Min/max values of background rms map .... : (3.42e-05, 3.95e-05) Jy/beam
Min/max values of background mean map ... : (-4.68e-07, 3.18e-07) Jy/beam
--> Expected 5-sigma-clipped false detection rate < fdr_ratio
--> Using sigma-clipping ('hard') thresholding
Minimum number of pixels per island ..... : 6

--> Determining islands from detection image
--> Opened 'facet_13_kernel25-MFS-image.fits'
Image size .............................. : (22700, 22700) pixels
Number of channels ...................... : 1
Number of Stokes parameters ............. : 1
Beam shape (major, minor, pos angle) .... : (1.05851e-04, 8.45167e-05, 175.0) degrees
Frequency of image ...................... : 144.627 MHz
Number of blank pixels .................. : 0 (0.0%)
--> Calculating background rms and mean images
--> Using adaptive scaling of rms_box
Using user-specified rms_box ............ : (1800, 450) pixels (small scale)
Using user-specified rms_box ............ : (4500, 450) pixels (large scale)
Number of sources using small scale ..... : 9
--> Using 2D map for background rms
--> Using 2D map for background mean
Min/max values of background rms map .... : (3.56e-05, 3.71e-05) Jy/beam
Min/max values of background mean map ... : (-4.56e-07, 3.26e-07) Jy/beam
--> Expected 5-sigma-clipped false detection rate < fdr_ratio
--> Using sigma-clipping ('hard') thresholding
Minimum number of pixels per island ..... : 6
--> Constructing islands at user-supplied source locations
Number of islands found ................. : 1052
Traceback (most recent call last):
  File "run_bdsf.py", line 31, in <module>
    res = bdsf.process_image(fitsname, detection_image=detectimage, thresh_isl=4.0, thresh_pix=5.0, rms_box=(4500,450), rms_map=True, mean_map='map', ini_method='intensity', adaptive_rms_box=True, adaptive_thresh=150, rms_box_bright=(1800,450), group_by_isl=False, group_tol=10.0, output_opts=True, output_all=True, atrous_do=True, atrous_jmax=5, flagging_opts=True, flag_maxsize_fwhm=0.5, advanced_opts=True, blank_limit=None, frequency=restfrq, aperture=True, src_ra_dec=aperture_coords, src_radius_pix=int(apasec/pixscale))
  File "/software/rhel7/lib64/python2.7/site-packages/bdsf/__init__.py", line 253, in process_image
    img.process(**kwargs)
  File "/software/rhel7/lib64/python2.7/site-packages/bdsf/image.py", line 135, in process
    success = interface.process(self, **kwargs)
  File "/software/rhel7/lib64/python2.7/site-packages/bdsf/interface.py", line 62, in process
    _run_op_list(img, op_chain)
  File "/software/rhel7/lib64/python2.7/site-packages/bdsf/__init__.py", line 152, in _run_op_list
    op(img)
  File "/software/rhel7/lib64/python2.7/site-packages/bdsf/islands.py", line 88, in __call__
    img.island_labels = det_img.island_labels
  File "/software/rhel7/lib64/python2.7/site-packages/bdsf/image.py", line 86, in __getattribute__
    return object.__getattribute__(self, name)
AttributeError: 'Image' object has no attribute 'island_labels'

real    76m55.252s
user    169m32.901s
sys 108m1.307s
darafferty commented 3 years ago

The problem should be fixed with commit 3adc43c. Can you update and give it a try?

tikk3r commented 3 years ago

Yep, I tried that commit and now it works like a charm. Thanks!