Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnboundLocalError when running DDF.py - 0 Jones-directions #46

Open
kendak333 opened this issue Sep 8, 2023 · 4 comments
Open

UnboundLocalError when running DDF.py - 0 Jones-directions #46

kendak333 opened this issue Sep 8, 2023 · 4 comments

Comments

@kendak333
Copy link

I'm trying to do some 3GC processing for a MeerKAT field and am coming across an issue when running DDF.py, which appears to be a problem with the output generated from MakeModel.py.

The command being run:
DDF.py ddf_imgDI_clustered.parset --Output-Clobber true

The parset file (in .txt form): ddf_imgDI_clustered.txt

The error:

- 11:12:39 - ClassStokes                  [0.2/0.2 8.9/8.9 0.0Gb] Correlations stored in Measurement set (and gridded) is labeled as ['XX', 'XY', 'YX', 'YY']
 - 11:12:39 - ClassStokes                  [0.2/0.2 8.9/8.9 0.0Gb] Stokes parameters required in FITS cube: ['I']
 - 11:12:39 - ClassFacetMachineTessel      [0.2/0.2 8.9/8.9 0.0Gb] Taking facet directions from Nodes catalog: /scratch/knowles/merghers/t1/out-1/continuum/image_3/J0438-5419_ddfsrcs.reg.ClusterCat.npy
 - 11:12:39 - ClassFacetMachineTessel      [0.2/0.2 8.9/8.9 0.0Gb]   There are 0 Jones-directions
 - 11:12:39 - ClassFacetMachineTessel      [0.2/0.2 8.9/8.9 0.0Gb] Saving Nodes catalog in ddf_DI_clustered.NodesCat.npy (Nfacets:0)
DDFacet has encountered an unexpected error. Dropping you into pdb for a post-mortem.
(This is because you're running with --Debug-Pdb set to 'auto' and --Log-Boring is off.)
Traceback (most recent call last):
  File "/home/knowles/venv-ddfkms/bin/DDF.py", line 461, in <module>
    main(OP, messages)
  File "/home/knowles/venv-ddfkms/bin/DDF.py", line 287, in main
    Imager.Init()
  File "/home/knowles/venv-ddfkms/lib/python3.8/site-packages/DDFacet/Imager/ClassDeconvMachine.py", line 313, in Init
    self.CreateFacetMachines()
  File "/home/knowles/venv-ddfkms/lib/python3.8/site-packages/DDFacet/Imager/ClassDeconvMachine.py", line 352, in CreateFacetMachines
    self.FacetMachine.appendMainField(ImageName="%s.image"%self.BaseName,**MainFacetOptions)
  File "/home/knowles/venv-ddfkms/lib/python3.8/site-packages/DDFacet/Imager/ClassFacetMachine.py", line 301, in appendMainField
    self.setFacetsLocs()
  File "/home/knowles/venv-ddfkms/lib/python3.8/site-packages/DDFacet/Imager/ClassFacetMachineTessel.py", line 334, in setFacetsLocs
    for iFacet, polygon0 in zip(range(len(LPolygon)), LPolygon):
UnboundLocalError: local variable 'LPolygon' referenced before assignment

The J0438-5419_ddfsrcs.reg.ClusterCat.npy file is generated via:

MakeModel.py --ds9PreClusterFile <ds9 region file> --NCluster=0 --BaseImageName <relevant 2GC image>

No errors are generated, other than the warning about Astropy read_ds9 depreciation. The region file looks like the following (I manually replaced the ellipse entries from CARTA with circle ones, but got the same issue):

# Region file format: DS9 CARTA 3.0.0
global color=green dashlist=8 3 width=1 font="helvetica 10 normal roman" select=1 highlite=1 dash=0 fixed=0 edit=1 move=1 delete=1 include=1 source=1
fk5
circle(69.147725970, -54.608262553, 34.7293") # color=#2EE6D6 width=2
circle(68.290231347, -53.727704663, 55.7437") # color=#2EE6D6 width=2
circle(69.416763670, -53.909809815, 51.7000") # color=#2EE6D6 width=2
circle(70.523180227, -54.248390134, 24.2000") # color=#2EE6D6 width=2
circle(69.949181960, -54.676278227, 28.6000") # color=#2EE6D6 width=2

I tried running MakeModel.py with --Ncluster=5 (same number as regions in the file) and got a different error (lack of DicoModel).
I'm not sure where I'm going wrong or whether this is a bug - having checked with colleagues, others are experiencing this issue for certain fields but not for others.

@ktrehaeven
Copy link

Hi. Also experiencing this issue.

@cyriltasse
Copy link
Collaborator

can you do an np.load("J0438-5419_ddfsrcs.reg.ClusterCat.npy") and see if anything intersting is in there?

@kendak333
Copy link
Author

It's indeed empty:

Out[2]: 
array([],
      dtype=[('Name', 'S200'), ('ra', '<f8'), ('dec', '<f8'), ('SumI', '<f8'), ('Cluster', '<i8')])

I wondered if it was something the the ds9 file - after changing the header from # Region file format: DS9 CARTA 3.0.0 to # Region file format: DS9 version 4.1 (from my current install of ds9) and removing the # color=#2EE6D6 width=2 from the end of each region line I get a non-empty *ClusterCat.npy (see below). I still got an empty array if I leave in the # color=#2EE6D6 width=2 and only change the header.

Out[2]: 
array([(b'0', 1.20685554, -0.95309401, 1., 0),
       (b'1', 1.19188941, -0.93772537, 1., 1),
       (b'2', 1.21155107, -0.94090366, 1., 2),
       (b'3', 1.23086166, -0.94681305, 1., 3),
       (b'4', 1.22084355, -0.95428109, 1., 4)],
      dtype=[('Name', 'S200'), ('ra', '<f8'), ('dec', '<f8'), ('SumI', '<f8'), ('Cluster', '<i8')])

So looks like the issue is in the MakeModel.py if the region file is created in CARTA rather than in ds9.

@cyriltasse
Copy link
Collaborator

ok cool! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants