Data Products

A calibration solution consists of 2048 values (4 flattened complex numbers per antenna). Solutions are stored in the calibration database, together with the metadata produced by the solve and the parameters the solve was run with. The database is the only source of solutions: MccsCalibrationStore reads from it to serve GetSolution and GetFittedSolutions.

Database schema

The PostgreSQL database schema spans four tables: a frequency_sweep describes an acquisition, a calibration_job describes one solve against that sweep, and the resulting solutions are written per channel to calibration_per_channel and once per sweep to calibration_per_sweep.

@startuml
' --- Configuration ---
hide circle
skinparam linetype ortho
skinparam packageStyle rectangle

' --- Table: frequency_sweep ---
entity "frequency_sweep" as e01 {
  *sweep_id : SERIAL PRIMARY KEY
  --
  *station_id : SMALLINT
  *channel_start : SMALLINT
  *channel_stop : SMALLINT
  path_to_data : TEXT <<unique>>
  start_time : TIMESTAMPTZ
  nof_samples : INTEGER
  initial_static_delays : FLOAT8[]
}

' --- Table: calibration_job ---
entity "calibration_job" as e02 {
  *id : SERIAL <<generated>>
  --
  *sweep_id : INTEGER <<FK>>
  *initial_mask : FLOAT8[]
  *calibration_parameters : JSON
  *user_friendly_name : TEXT <<unique>>
  preferred : BOOLEAN
}

' --- Table: calibration_per_channel ---
entity "calibration_per_channel" as e04 {
  *id : SERIAL <<generated>>
  --
  *creation_time : TIMESTAMP
  *frequency_channel : SMALLINT <<indexed>>
  *station_id : SMALLINT
  *calibration_path : TEXT
  *acquisition_time : FLOAT8
  calibration_id : TEXT <<unique>>
  preferred : BOOLEAN
  solution : FLOAT8[]
  corrcoeff : FLOAT8[]
  residual_max : FLOAT8[]
  residual_std : FLOAT8[]
  xy_phase : FLOAT8
  n_masked_initial : INTEGER
  n_masked_final : INTEGER
  lst : FLOAT8
  galactic_centre_elevation : FLOAT8
  sun_elevation : FLOAT8
  sun_adjustment_factor : FLOAT8
  masked_antennas : TEXT[]
  job_id : INTEGER <<FK>>
  solution_type : TEXT
}

' --- Table: calibration_per_sweep ---
entity "calibration_per_sweep" as e03 {
  *id : SERIAL <<generated>>
  --
  *job_id : INTEGER <<FK, unique>>
  *phase : FLOAT8[]
  *phase_gradient : FLOAT8[]
  *phase_fit_cost : FLOAT8[]
  *phase_fit_covariance : FLOAT8[][][]
  final_mask : BOOL[]
  mean_amplitude : DOUBLE PRECISION[256]
  amplitude_fit_cost : DOUBLE PRECISION
}

' --- Relationships (Information Engineering notation) ---
' All foreign keys are ON DELETE CASCADE.

e01 "1" -- "0..*" e02
e02 "1" -- "0..*" e04
e02 "1" -- "1" e03

@enduml

calibration_per_channel additionally carries an index on frequency_channel.

The columns are described below.

tables:
  - table: calibration_per_channel
    columns:
      - name: id
        type: integer
        description: Primary key identifier for each row.

      - name: creation_time
        type: timestamp without time zone
        description: Time the record was stored in the database.

      - name: frequency_channel
        type: smallint
        description: Frequency channel identifier.

      - name: station_id
        type: smallint
        description: ID of the station associated with the solution.

      - name: preferred
        type: boolean
        description: Whether this row is marked as the preferred solution.

      - name: calibration_path
        type: text
        description: Path to the calibration/correlation matrix file.

      - name: calibration_id
        type: text
        description: Unique calibration id.

      - name: acquisition_time
        type: double precision
        units: s (Unix epoch seconds, UTC)
        description: >
          Time the data was acquired (floating-point format).

      - name: solution
        type: ARRAY
        units: dimensionless (complex gain)
        description: >
          The solution dataset. Ordered by TPM index:
          ``tpm_id * 16 + (adc_channel // 2)`` for 8 values per TPM.

      - name: corrcoeff
        type: ARRAY
        units: dimensionless (-1 to 1)
        description: Pearson correlation coefficients per polarisation.

      - name: residual_max
        type: ARRAY
        units: K
        description: >
          Maximum absolute residual visibility deviation (per polarisation).
          Must be of length 4.

      - name: residual_std
        type: ARRAY
        units: K
        description: >
          Standard deviation of residual visibilities (per polarisation).
          Must be of length 4.

      - name: xy_phase
        type: double precision
        units: deg
        description: Estimated XY-phase error.

      - name: n_masked_initial
        type: integer
        units: antennas (count)
        description: Number of masked antennas at the start.

      - name: n_masked_final
        type: integer
        units: antennas (count)
        description: Number of masked antennas after calibration.

      - name: lst
        type: double precision
        units: deg
        description: Local apparent sidereal time at the station.

      - name: galactic_centre_elevation
        type: double precision
        units: deg
        description: Elevation of the Galactic Centre.

      - name: sun_elevation
        type: double precision
        units: deg
        description: Elevation of the Sun.

      - name: sun_adjustment_factor
        type: double precision
        units: dimensionless
        description: Adjustment factor related to solar influence.

      - name: masked_antennas
        type: ARRAY
        description: Antenna masked as bad. This is currently eep indexed. Length must be between 0 and 256 (inclusive).

      - name: job_id
        type: integer
        description: The id of the job, this is a foreign key to calibration_job(id) cascading.

      - name: solution_type
        type: text
        description: text representing the solution type.
  - table: calibration_job
    columns:
      - name: id
        type: integer
        description: Primary key identifier for each row.

      - name: sweep_id
        type: integer
        description: The sweep this job was run against, this is a foreign key to frequency_sweep(sweep_id) cascading.

      - name: initial_mask
        type: ARRAY
        description: Antennas masked from the spshw subsystem.

      - name: calibration_parameters
        type: json
        description: The parameters the calibration job was run with.

      - name: user_friendly_name
        type: text
        description: A friendly name to identify this job. It can be something simple and autogenerated like "<stationid>_<date>_<time>".

      - name: preferred
        type: boolean
        description: Whether this is the default calibration solution to use if one isn't chosen.
  - table: frequency_sweep
    columns:
      - name: sweep_id
        type: integer
        description: Primary key identifing the sweep.

      - name: station_id
        type: smallint
        description: The id of station this sweep is related to.

      - name: channel_start
        type: smallint
        description: The starting channel

      - name: channel_stop
        type: smallint
        description: The final channel

      - name: path_to_data
        type: text
        description: path to data products.

      - name: start_time
        type: timestamp with time zone
        description: Time sweep starts.

      - name: nof_samples
        type: integer
        units: samples (count)
        description: Number of samples.

      - name: initial_static_delays
        type: ARRAY
        units: ns
        description: Static delays currently applied when sweep executed.
  - table: calibration_per_sweep
    columns:
      - name: id
        type: integer
        description: Primary key identifying a calibration_per_sweep entry

      - name: job_id
        type: integer
        description: foreign key 1 to 1 representing the calibration_job this calibration_per_sweep belongs to.

      - name: final_mask
        type: ARRAY
        description: Masked antennas while generating this calibration_per_sweep solution. Boolean per antenna.

      - name: mean_amplitude
        type: ARRAY
        units: dimensionless (gain amplitude)
        description: A single amplitude across the band per antenna

      - name: phase
        type: ARRAY
        units: rad
        description: the phase offset at 0Hz per antenna per Jones element

      - name: phase_gradient
        type: ARRAY
        units: us (microseconds, as a delay)
        description: the slope of the phase gradients per antenna per Jones element

      - name: amplitude_fit_cost
        type: double precision
        units: dimensionless
        description: Sum of squares scaled based on the number of points for amplitude.

      - name: phase_fit_cost
        type: ARRAY
        units: rad^2
        description: Sum of squares scaled based on the number of points for phase per antenna per Jones element.

      - name: phase_fit_covariance
        type: ARRAY
        units: "[[rad^2, rad us], [rad us, us^2]]"
        description: >
          the covariance on the phase fit per antenna per Jones element. The 2x2
          matrix is over the fitted (phase, phase_gradient) parameters.