Skip to content

Commit

Permalink
Provide the newly-available metafits DUT1.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjordan committed Jun 16, 2022
1 parent dd52fdf commit 38a5fe8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Changes in each release are listed below.

## Unreleased
* Provide DUT1 in the metafits context.
* API tweaks surrounding generic types.
* Things should be slightly more flexible than before.

Expand Down
19 changes: 12 additions & 7 deletions src/ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,9 @@ pub struct MetafitsMetadata {
pub sched_end_gps_time_ms: u64,
/// Scheduled duration of observation
pub sched_duration_ms: u64,
/// DUT1 (i.e. UTC-UT1). The UTC of the obsid is used to determine this
/// value. Calculated by astropy. Made optional for compatibility.
pub dut1: f64,
/// Seconds of bad data after observation starts
pub quack_time_duration_ms: u64,
/// OBSID+QUACKTIM as Unix timestamp (first good timestep)
Expand Down Expand Up @@ -1662,6 +1665,7 @@ pub unsafe extern "C" fn mwalib_metafits_metadata_get(
sched_start_mjd,
sched_end_mjd,
sched_duration_ms,
dut1,
ra_tile_pointing_degrees,
dec_tile_pointing_degrees,
ra_phase_center_degrees,
Expand Down Expand Up @@ -1709,18 +1713,18 @@ pub unsafe extern "C" fn mwalib_metafits_metadata_get(
num_rf_inputs,
rf_inputs: _, // This is populated seperately
num_ant_pols,
num_baselines,
baselines: _, // This is populated seperately
num_visibility_pols,
metafits_timesteps: _, // This is populated seperately
num_metafits_timesteps,
metafits_fine_chan_freqs_hz,
num_metafits_fine_chan_freqs,
metafits_coarse_chans: _, // This is populated seperately
metafits_timesteps: _, // This is populated seperately
num_metafits_coarse_chans,
metafits_coarse_chans: _, // This is populated seperately
num_metafits_fine_chan_freqs,
metafits_fine_chan_freqs_hz,
obs_bandwidth_hz,
coarse_chan_width_hz,
centre_freq_hz,
num_baselines,
baselines: _, // This is populated seperately
num_visibility_pols,
metafits_filename,
} = metafits_context;
MetafitsMetadata {
Expand Down Expand Up @@ -1778,6 +1782,7 @@ pub unsafe extern "C" fn mwalib_metafits_metadata_get(
sched_start_gps_time_ms: *sched_start_gps_time_ms,
sched_end_gps_time_ms: *sched_end_gps_time_ms,
sched_duration_ms: *sched_duration_ms,
dut1: dut1.unwrap_or(0.0),
quack_time_duration_ms: *quack_time_duration_ms,
good_time_unix_ms: *good_time_unix_ms,
good_time_gps_ms: *good_time_gps_ms,
Expand Down
12 changes: 9 additions & 3 deletions src/metafits_context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ pub struct MetafitsContext {
pub sched_end_mjd: f64,
/// Scheduled duration of observation
pub sched_duration_ms: u64,
/// DUT1 (i.e. UTC-UT1). The UTC of the obsid is used to determine this
/// value. Calculated by astropy. Made optional for compatibility.
pub dut1: Option<f64>,
/// RA tile pointing
pub ra_tile_pointing_degrees: f64,
/// DEC tile pointing
Expand Down Expand Up @@ -666,6 +669,8 @@ impl MetafitsContext {
ex * 1000
};

let dut1: Option<f64> = get_optional_fits_key!(&mut metafits_fptr, &metafits_hdu, "DUT1")?;

let num_metafits_timesteps: usize = 0;
let metafits_timesteps: Vec<TimeStep> = Vec::new();

Expand Down Expand Up @@ -836,6 +841,7 @@ impl MetafitsContext {
sched_start_mjd: scheduled_start_mjd,
sched_end_mjd: scheduled_end_mjd,
sched_duration_ms: scheduled_duration_ms,
dut1,
ra_tile_pointing_degrees,
dec_tile_pointing_degrees,
ra_phase_center_degrees,
Expand Down Expand Up @@ -883,19 +889,19 @@ impl MetafitsContext {
num_rf_inputs,
rf_inputs,
num_ant_pols: num_antenna_pols,
num_metafits_timesteps,
metafits_timesteps,
num_metafits_coarse_chans,
metafits_coarse_chans,
num_metafits_fine_chan_freqs,
metafits_fine_chan_freqs_hz: metafits_fine_chan_freqs,
num_metafits_timesteps,
metafits_timesteps,
obs_bandwidth_hz: metafits_observation_bandwidth_hz,
coarse_chan_width_hz: metafits_coarse_chan_width_hz,
centre_freq_hz,
metafits_filename,
num_baselines,
baselines,
num_visibility_pols,
metafits_filename,
})
}

Expand Down

0 comments on commit 38a5fe8

Please sign in to comment.