caracal-pipeline / caracal

Containerized Automated Radio Astronomy Calibration (CARACal) pipeline
GNU General Public License v2.0
28 stars 6 forks source link

cube_path referenced before assignment error #1535

Closed kyraluthien closed 10 months ago

kyraluthien commented 10 months ago

Good day. We're using caracal to process MeerKAT HI data. We have eight sessions, which have been processed individually without an error. However, when we tried to process them together to make a single cube with the line worker, it throws an error that cube_path referenced before assigment. Here is an extract from the logfile at output/logs-20230831-094501/log-caracal.txt:

2023-08-31 14:28:22 CARACal INFO: Preparing final cubes.
2023-08-31 14:28:22 CARACal ERROR: local variable 'cube_path' referenced before assignment [UnboundLocalError]
2023-08-31 14:28:22 CARACal INFO:   More information can be found in the logfile at output/logs-20230831-094501/log-caracal.txt
2023-08-31 14:28:22 CARACal INFO:   You are running version 1.0.6
2023-08-31 14:28:22 CARACal ERROR: Traceback (most recent call last):
2023-08-31 14:28:22 CARACal ERROR:   File "/idia/projects/uct-mega-hi/m31/MKT/caracal/caracal_venv/lib/python3.8/site-packages/caracal/main.py", line 187, in __run
2023-08-31 14:28:22 CARACal ERROR:     pipeline.run_workers()
2023-08-31 14:28:22 CARACal ERROR:   File "/idia/projects/uct-mega-hi/m31/MKT/caracal/caracal_venv/lib/python3.8/site-packages/caracal/workers/worker_administrator.py", line 441, in run_workers
2023-08-31 14:28:22 CARACal ERROR:     worker.worker(self, recipe, config)
2023-08-31 14:28:22 CARACal ERROR:   File "/idia/projects/uct-mega-hi/m31/MKT/caracal/caracal_venv/lib/python3.8/site-packages/caracal/workers/line_worker.py", line 1117, in worker
2023-08-31 14:28:22 CARACal ERROR:     cube_path, pipeline.prefix, field, line_name, j, ss)
2023-08-31 14:28:22 CARACal ERROR: UnboundLocalError: local variable 'cube_path' referenced before assignment
2023-08-31 14:28:22 CARACal INFO: exiting with error code 1

Here is the line worker as written in the .yml file:

line:
  enable: true 
  restfreq: '1.420405752GHz'
  label_in: corr #!!!
  rewind_flags:
    enable: false
  subtractmodelcol:
    enable: false # !! default true
  mstransform:
    enable: true
    doppler:
      enable: true
      telescope: meerkat
      changrid: 250, 1421.0MHz, 6.400kHz ## nchan is an integer, and chan0 and chanw must include units #
    uvlin:
      enable: true
      fitorder: 3
  make_cube:
    enable: true # 
    use_mstransform: true
    npix: [256] # 110' in size
    cell: 20 # <= 1/3 beam # 2 V1 # V1a 
    weight: 'briggs'
    robust: 1.5 # 0.5 v0 # 0 V1a
    taper: 60 # V1d   
    niter: 1
    wscl_sofia_niter: 0
    wscl_auto_mask: 3 # 10 # 5 Julia #V0 # V1a
    wscl_auto_thr: 1.5 # 0.5 *rms #V0 # V1a
  remove_stokes_axis:
    enable: true # V1d
  pb_cube:
    enable: false # true # V1d
    apply_pb: false # 
    pb_type: mauch
  freq_to_vel:
    enable: true #true # false  
  sofia:
    enable: false

The error is thrown by line 1117 in the line_worker.py file, which tries to use cube_path: image

Tracing this further up in the line_worker.py file, we think that the cube_path isn't being created. image

We did find a workaround, where changing wscl_sofia_niter: 0 to wscl_sofia_niter: 1 yields the desired output and seems to circumvent the issue. However, I've posted here to log the issue in any case.

paoloserra commented 10 months ago

Thanks for the feedback, and glad to hear that setting wscl_sofia_niter: 1 solves your problem!

Setting that parameter to 0 should actually not be allowed. The docs reads: A value of 1 means that WSClean is only executed once and SoFiA is not used. So 1 should be the lowest allowed value.

We will fix that.