Skip to content

Commit

Permalink
Add the FREQCENT key.
Browse files Browse the repository at this point in the history
Also sort the order of the struct members going into a new mwalibContext.
  • Loading branch information
cjordan committed Sep 17, 2020
1 parent 7d7f383 commit d07aff8
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ pub struct mwalibContext {
pub observation_bandwidth_hz: u32,
/// Bandwidth of each coarse channel
pub coarse_channel_width_hz: u32,
/// The value of the FREQCENT key in the metafits file, but in Hz.
pub metafits_centre_freq_hz: u32,
/// Number of fine channels in each coarse channel
pub num_fine_channels_per_coarse: usize,
/// Filename of the metafits we were given
Expand Down Expand Up @@ -374,6 +376,13 @@ impl mwalibContext {
(fc * 1000.).round() as _
};

// Fine-channel resolution. The FINECHAN value in the metafits is in units
// of kHz - make it Hz.
let metafits_centre_freq_hz: u32 = {
let cf: f64 = get_required_fits_key!(&mut metafits_fptr, &metafits_hdu, "FREQCENT")?;
(cf * 1e6).round() as _
};

// Determine the number of fine channels per coarse channel.
let num_fine_channels_per_coarse =
(coarse_channel_width_hz / fine_channel_width_hz) as usize;
Expand Down Expand Up @@ -497,16 +506,15 @@ impl mwalibContext {
rf_inputs.sort_by_key(|k| k.subfile_order);

Ok(mwalibContext {
coax_v_factor,
mwa_latitude_radians,
mwa_longitude_radians,
mwa_altitude_metres,
corr_version: gpubox_info.corr_format,
coax_v_factor,
obsid,
scheduled_start_unix_time_milliseconds,
scheduled_end_unix_time_milliseconds,
scheduled_start_gpstime_milliseconds,
scheduled_end_gpstime_milliseconds,
scheduled_start_unix_time_milliseconds,
scheduled_end_unix_time_milliseconds,
scheduled_start_utc,
scheduled_end_utc,
scheduled_start_mjd,
Expand All @@ -524,17 +532,18 @@ impl mwalibContext {
jupiter_distance_degrees,
lst_degrees,
hour_angle_string,
receivers,
delays,
grid_name,
grid_number,
creator,
project_id,
observation_name,
mode,
receivers,
delays,
global_analogue_attenuation_db,
quack_time_duration_milliseconds,
good_time_unix_milliseconds,
corr_version: gpubox_info.corr_format,
start_unix_time_milliseconds,
end_unix_time_milliseconds,
duration_milliseconds,
Expand All @@ -546,26 +555,27 @@ impl mwalibContext {
baselines,
num_rf_inputs,
rf_inputs,
integration_time_milliseconds,
num_antenna_pols,
num_visibility_pols,
visibility_pols,
num_fine_channels_per_coarse,
num_coarse_channels,
coarse_channels,
coarse_channel_width_hz,
integration_time_milliseconds,
fine_channel_width_hz,
observation_bandwidth_hz,
coarse_channel_width_hz,
metafits_centre_freq_hz,
num_fine_channels_per_coarse,
metafits_filename: metafits
.as_ref()
.to_str()
.expect("Metafits filename is not UTF-8 compliant")
.to_string(),
gpubox_batches: gpubox_info.batches,
gpubox_time_map: gpubox_info.time_map,
num_gpubox_files: gpuboxes.len(),
num_timestep_coarse_channel_bytes: gpubox_info.hdu_size * 4,
num_timestep_coarse_channel_floats: gpubox_info.hdu_size,
num_gpubox_files: gpuboxes.len(),
legacy_conversion_table,
})
}
Expand Down Expand Up @@ -928,6 +938,7 @@ impl fmt::Display for mwalibContext {
observation bandwidth: {obw} MHz,
num coarse channels, {n_coarse},
coarse channels: {coarse:?},
metafits FREQCENT key: {freqcent} MHz,
Correlator Mode:
Mode: {mode},
Expand Down Expand Up @@ -1008,6 +1019,7 @@ impl fmt::Display for mwalibContext {
obw = self.observation_bandwidth_hz as f64 / 1e6,
n_coarse = self.num_coarse_channels,
coarse = self.coarse_channels,
freqcent = self.metafits_centre_freq_hz as f64 / 1e6,
mode = self.mode,
fcw = self.fine_channel_width_hz as f64 / 1e3,
int_time = self.integration_time_milliseconds as f64 / 1e3,
Expand Down

0 comments on commit d07aff8

Please sign in to comment.