Generating a Solution

MccsStationCalibrator.GenerateCalibrationSolution performs a single frequency sweep: it configures the station, records a correlation matrix for each channel in the requested range, solves each one, and stores the results against a single calibration job. It is a long running command, and the sweep is complete when it reports COMPLETED.

A calibration job is what ties the results of one sweep together. A single solve of one acquisition, holding the parameters the solve was run with, the antennas masked before it began, and its unique name, with every per-channel solution and the sweep’s phase fit stored against it. It is the unit operations works with, since it is a job, not an individual solution, that is marked preferred and so put into service. See Storing a Solution.

The command takes a JSON argument. Every parameter is optional: the channel range defaults to 64-448, and the solver parameters default to a gsm sky model over the whole station. See Solving for a Gain for the solver parameters and their effect.

See sequence diagram for an overview of the internals:

@startuml
participant TangoUser as User
participant "Scheduler thread" as Scheduler
participant MccsStationCalibrator as Calibrator
participant MccsCalibrationStore as Store
participant "Calibration Database" as DB
participant MccsStation as Station
participant SpsStation
participant MccsTile
participant MccsDaq
participant StationCalibrationSolverDevice as Solver
participant "DAQ Volume Mount" as DataVolume
participant "EEP Volume Mount" as EEPVolume
hnote over Calibrator: isLoopRunning = False
alt operator request
User -> Calibrator: GenerateCalibrationSolution()
else scheduled run
Scheduler -> Calibrator: cron tick (entry parameters)
end
activate Calibrator
hnote over Calibrator: IN_PROGRESS
== Register the job ==
Calibrator -> Store: CheckCalibrationId(user_friendly_name)
Store --> Calibrator: in_use
note over Calibrator: REJECTED if the calibration id is already in use
Calibrator -> Store: StoreFrequencySweep(station_id, channel_start, channel_stop)
Store -> DB: insert frequency_sweep
Store --> Calibrator: sweep_id
Calibrator -> Store: StoreCalibrationJob(sweep_id, calibration_parameters, user_friendly_name)
Store -> DB: insert calibration_job
Store --> Calibrator: job_id
== Acquire correlation data ==
Calibrator -> Station: ConfigureStationForCalibration(daq_config)
activate Station
Station -> SpsStation: ConfigureStationForCalibration()
SpsStation -> MccsDaq: Configure()
SpsStation -> MccsDaq: Start()
deactivate Station
Calibrator -> Station: AcquireDataForCalibration(first_channel, last_channel, daq_mode)
Station -> SpsStation: AcquireDataForCalibration()
loop tiles
SpsStation -> MccsTile: SetLmcDownload()
SpsStation -> MccsTile: SendDataSamples()
end
== Solve and store each channel ==
loop frequency channels
MccsDaq -> DataVolume: dump_hdf5(correlation_matrix)
MccsDaq --> SpsStation: dataReceivedResult
SpsStation --> Station: dataReceivedResult
Station --> Calibrator: dataReceivedResult(data_path)
note over Calibrator: skipped if the channel is in ChannelsToIgnore
Calibrator -> Solver: Solve(data_path, solution_path, station_config_path)
activate Solver
Solver -> DataVolume: read correlation_matrix
Solver -> EEPVolume: read embedded element patterns
Solver --> Calibrator: gain_solution, metadata
deactivate Solver
Calibrator -> Store: StoreSolution(job_id, solution, metadata)
Store -> DB: insert calibration_per_channel
end
Calibrator -> Store: UpdateFrequencySweep(sweep_id, path_to_data)
note over Calibrator: driven by the acquisition callback,\nso it can arrive during the loop above
Store -> DB: update frequency_sweep
== Fit the sweep ==
Calibrator -> Calibrator: fit_gains(channels, phases)
Calibrator -> Store: StorePhaseFitParams(job_id, phase, phase_gradient, phase_fit_cost)
Store -> DB: insert calibration_per_sweep
hnote over Calibrator: COMPLETED
deactivate Calibrator
@enduml

To run sweeps repeatedly without issuing the command each time, see Scheduling.