ska-sa / katsdpcal

MeerKAT calibration pipeline
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

SPR1-3025: Integrate reference pointing with cal pipeline #72

Closed Tasmiyah27 closed 1 month ago

Tasmiyah27 commented 1 month ago

The following changes integrate the new reference pointing functionality with the cal pipeline. 2 New functions added to reduction.py, the first get_offsets calculates the (x,y) offset co-ordinates of each pointing offset, this is necessary because only the pos_actual_scan_azim/elev of the antennas are known and can be found in telstate. Using katpoint.sphere to plane we can calculate the offset co-ordinates (in degrees) from their known azimuth and elevation, note only the reference antenna is used to do this.

The second function is flush_pipeline, which is essencially a secondary pipeline calibration, when incoming data is pushed through the pipeline, once a 'pointingcal' tag is detected, the B solutions will be calculated and once all of them are present in telstate, await pipeline event is triggered and B solutions will be passed to flush_pipeline where they are used along with other information such as atmospheric conditions to calculate beam solutions from the fitting routines in katsdpcalproc.pointing: get_offset_gains and beam_fit. Beam solutions are then saved (as an array of shape (num_chunks, len(pols), len(ants), 5) where 5 corresponds to center, width and height of the beam) in telstate as a CalSolution product 'product_EPOINT{N}' along with its uncertainties 'product_EPOINT_SNR{N}' which are needed to calculate the offsets via calc_pointing_offsets on the CaptureSession side. Here N corresponds to the server/node number.

product_EPOINT and product_EPOINT_SNR were added to pipelineprocs.py parameters which allows us to save beam solutions to telstate under their correct product names. Similarly in control.py, CalSolutionStore 'B_POINTING' was added to existing solution stores which are passed into pipeline in reduction.py, this is the solution store in which B solutions (gains) of the pointing observation will be stored.

Finally, test_refrence_pointing_capturewas added to test_control, this tests that the mechanics of the reference pointing functionality works by creating a target with a pointing cal tag then faking a track, track, slew for each of 8 pointing offsets followed by an await_pipeline activity. This time, we have the offset (x,y) co-ordinates which we will use to calculate the pos_actual_scan_azim/elev using katpoint.plane_to _sphere 4 times per dump. Antenna gains and delays are created using random number generator and these are used to create visibilities. SPEAD heaps are then created and sent. We then assert whether the expected cal products went into telstate as well as checking their shape and dtypes. While this checks the mechanics of reference pointing, it does not however test the actual values of the solutions. This is something we should add in the future where gains are not random and have some frequency dependence.

ludwigschwardt commented 1 month ago

Hi @Tasmiyah27, do you have more updates for me to review?

Tasmiyah27 commented 1 month ago

Will do @KimMcAlpine comments in the next round of commits, @ludwigschwardt I've added some questions under some of your previous comments for clarification, hopefully I made the correct changes