caracal-pipeline / caracal

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

CARACal ERROR: KeyError: 'GainDiagAmp' #1510

Closed SavannahStanbury closed 1 year ago

SavannahStanbury commented 1 year ago

I am trying to run phase selfcal followed by an amptidue selfcal by setting the following parameter: gain_matrix_type: ['GainDiagPhase', 'GainDiagPhase', 'GainDiagPhase', 'GainDiagPhase', 'GainDiagAmp']

However, I get this error:

2023-05-09 15:11:24 CARACal ERROR: 'GainDiagAmp' [KeyError] 2023-05-09 15:11:24 CARACal INFO: More information can be found in the logfile at output/logs-20230509-151117/log-caracal.txt 2023-05-09 15:11:24 CARACal INFO: You are running version 1.0.6-2-gd0b9d985 2023-05-09 15:11:24 CARACal ERROR: Traceback (most recent call last): 2023-05-09 15:11:24 CARACal ERROR: File "/home/stanbury/Software/caracal/caracal/main.py", line 187, in __run 2023-05-09 15:11:24 CARACal ERROR: pipeline.run_workers() 2023-05-09 15:11:24 CARACal ERROR: File "/home/stanbury/Software/caracal/caracal/workers/worker_administrator.py", line 441, in run_workers 2023-05-09 15:11:24 CARACal ERROR: worker.worker(self, recipe, config) 2023-05-09 15:11:24 CARACal ERROR: File "/home/stanbury/Software/caracal/caracal/workers/selfcal_worker.py", line 2155, in worker 2023-05-09 15:11:24 CARACal ERROR: get_dir_path(image_path, pipeline), mslist, field) 2023-05-09 15:11:24 CARACal ERROR: File "/home/stanbury/Software/caracal/caracal/workers/selfcal_worker.py", line 1369, in calibrate_cubical 2023-05-09 15:11:24 CARACal ERROR: "g-type": CUBICAL_MT[matrix_type], 2023-05-09 15:11:24 CARACal ERROR: KeyError: 'GainDiagAmp' 2023-05-09 15:11:24 CARACal INFO: exiting with error code 1

The run completes successfully when I change the gain matrix type to: gain_matrix_type: ['GainDiagPhase', 'GainDiagPhase', 'GainDiagPhase', 'GainDiagPhase', 'GainDiag']

So I am not sure what the KeyError is for GainDiagAmp - any help would be appreciated, please!

KshitijT commented 1 year ago

It's definitely a bug, from what I can see. While that option is listed in the schema, I am not sure if cubical supports such a mode. @o-smirnov , @JSKenyon could you please advise?

JSKenyon commented 1 year ago

CubiCal doesn't have an amplitude only solver - the functionality is provided by an update restriction. You would need to set type=complex-2x2 or type=complex-diag with update-type=amp-diag. I don't know how these things are set up in CaraCal though.

PeterKamphuis commented 1 year ago

Looks to me that the GainDiagAmp entry has been erroneously removed from the CUBICAL_MT dictionary to do exactly what JSKenyon just mentioned. See https://github.com/caracal-pipeline/caracal/blob/29cd2a18905e7c6924f4aac1d9a6943ee37c87b5/caracal/workers/selfcal_worker.py#L1329

o-smirnov commented 1 year ago

Yeah it should be a tiny fix -- if you just add this

"GainDiagAmp": 'complex-2x2',

to the mapping at line 41, it should work. The code @PeterKamphuis references should then set the update type correctly as per @JSKenyon's suggestion.

I guess the bug has been there forever, just that nobody's tried GainDiagAmp before. It's quite the exotic mode -- when we talk about amplitude selfcal, we usually mean amplitude and phase, for which you would just use GainDiag. Amplitude-only would be for a weird scenario where you have separate phase and amplitude corrections.

PeterKamphuis commented 1 year ago

@o-smirnov If I remember correctly it is implemented to be able to self calibrate the amplitude and the phases on different timescales. I just don't understand why it is not in the dictionary. Might have been an ctrl-x ctrl-s on my behalf. I make code disappear that way sometimes.