diff --git a/CHANGELOG.md b/CHANGELOG.md index 85c14b1..bec9fb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ Changes in each release are listed below. +## 0.10.0 20-Aug-2021 (Pre-release) +* Fixed bug where the `num_metafits_fine_chan_freqs` and `metafits_fine_chan_freqs_hz` were not being populated correctly for a stand-alone `MetafitsContext` usecase. +* Fixed attribute name `metafits_fine_chan_freqs` to `metafits_fine_chan_freqs_hz` in FFI `MetafitsMetadata`to be consistent with the rest of the library. +* Removed constants `SPEED_OF_LIGHT_IN_VACUUM_M_PER_S`, `MWA_LATITUDE_RADIANS`, `MWA_LONGITUDE_RADIANS`, `MWA_ALTITUDE_METRES` as these are now provided by the [mwa_rust_core](https://github.com/MWATelescope/mwa_rust_core) repo. +* Simplified the dependency rules for `regex` and `rayon` crates. + +## 0.9.4 19-Aug-2021 (Pre-release) + ## 0.9.3 10-Aug-2021 (Pre-release) * Antenna rf_input_x and rf_input_y are now correctly indexed/sorted for the VCSLegacyRecombined case. diff --git a/src/coarse_channel/mod.rs b/src/coarse_channel/mod.rs index 193b75f..825aec1 100644 --- a/src/coarse_channel/mod.rs +++ b/src/coarse_channel/mod.rs @@ -380,7 +380,7 @@ impl CoarseChannel { }; // Return a vector of f64s which are the fine channel centre frequencies for all the fine channels in [coarse_channels] - coarse_channels + let return_vec: Vec = coarse_channels .iter() .flat_map(|coarse_chan| { (0..num_fine_chans_per_coarse).map(move |fine_chan_idx| { @@ -389,7 +389,9 @@ impl CoarseChannel { + offset_hz }) }) - .collect() + .collect(); + + return_vec } } diff --git a/src/metafits_context/mod.rs b/src/metafits_context/mod.rs index 7af87d7..ab405a8 100644 --- a/src/metafits_context/mod.rs +++ b/src/metafits_context/mod.rs @@ -475,6 +475,7 @@ impl MetafitsContext { } }, ); + new_context.num_metafits_fine_chan_freqs = new_context.metafits_fine_chan_freqs_hz.len(); // Populate the timesteps new_context.populate_expected_timesteps(new_context.mwa_version.unwrap())?; @@ -708,9 +709,9 @@ impl MetafitsContext { Vec::with_capacity(metafits_coarse_chan_vec.len()); let num_metafits_coarse_chans: usize = 0; - // Populate fine channel frequencies- we know enough to do this now - let num_metafits_fine_chan_freqs: usize = metafits_coarse_chan_vec.len(); - let metafits_fine_chan_freqs: Vec = Vec::with_capacity(num_metafits_fine_chan_freqs); + // Placeholder values- we work these out once we know the mwa_version + let num_metafits_fine_chan_freqs: usize = 0; + let metafits_fine_chan_freqs: Vec = Vec::new(); // Fine-channel resolution. The FINECHAN value in the metafits is in units // of kHz - make it Hz. diff --git a/src/metafits_context/test.rs b/src/metafits_context/test.rs index 9d27bf8..9502478 100644 --- a/src/metafits_context/test.rs +++ b/src/metafits_context/test.rs @@ -22,7 +22,7 @@ fn test_metafits_context_new_invalid() { } #[test] -fn test_metafits_context_new_vcslegacy_valid() { +fn test_metafits_context_new_vcs_legacy_valid() { // Open the test mwa v 1 metafits file let metafits_filename = "test_files/1101503312_1_timestep/1101503312.metafits"; @@ -33,23 +33,25 @@ fn test_metafits_context_new_vcslegacy_valid() { let context = MetafitsContext::new(&metafits_filename, Some(MWAVersion::VCSLegacyRecombined)) .expect("Failed to create MetafitsContext"); - // Test the properties of the context object match what we expect - - // obsid: 1101503312, - assert_eq!(context.obs_id, 1_101_503_312); - - assert_eq!(context.volt_fine_chan_width_hz, 10_000); - assert_eq!(context.num_volt_fine_chans_per_coarse, 128); + // rf_inputs: [Tile104Y, ..., Tile055X], + assert_eq!(context.num_rf_inputs, 256); + assert_eq!(context.rf_inputs[0].pol, Pol::Y); + assert_eq!(context.rf_inputs[0].tile_name, "Tile104"); + assert_eq!(context.rf_inputs[255].pol, Pol::X); + assert_eq!(context.rf_inputs[255].tile_name, "Tile055"); - for i in 0..128 { - if context.antennas[i].tile_id == 154 { - assert_eq!(context.antennas[i].rfinput_y.vcs_order, 1); - } + // Test the properties of the context object match what we expect + // antennas: [Tile011, Tile012, ... Tile167, Tile168], + // NOTE: since in Legacy VCS the VCS order may look like Tile104Y, Tile103Y, Tile102Y, Tile104X, ... + // so the order of antennas makes no sense, since 104 needs to be first AND further down the list!, so we leave it in the MWAX order. + assert_eq!(context.antennas[0].tile_name, "Tile011"); + assert_eq!(context.antennas[127].tile_name, "Tile168"); - if context.antennas[i].tile_id == 104 { - assert_eq!(context.antennas[i].rfinput_y.vcs_order, 0); - } - } + assert_eq!(context.metafits_fine_chan_freqs_hz.len(), 3072); + assert_eq!( + context.metafits_fine_chan_freqs_hz.len(), + context.num_metafits_fine_chan_freqs + ); } #[test] @@ -231,10 +233,21 @@ fn test_metafits_context_new_corrlegacy_valid() { assert_eq!(VisPol::XY.to_string(), "XY"); assert_eq!(VisPol::YX.to_string(), "YX"); assert_eq!(VisPol::YY.to_string(), "YY"); + + // Check correlator mode + assert_eq!(context.corr_fine_chan_width_hz, 10_000); + assert_eq!(context.corr_int_time_ms, 2_000); + + // Check metafits fine chan freqs + assert_eq!(context.metafits_fine_chan_freqs_hz.len(), 3072); + assert_eq!( + context.metafits_fine_chan_freqs_hz.len(), + context.num_metafits_fine_chan_freqs + ); } #[test] -fn test_metafits_context_new_vcsmwax2_valid() { +fn test_metafits_context_new_corrmwaxv2_valid() { // Open the test mwa v 1 metafits file let metafits_filename = "test_files/1101503312_1_timestep/1101503312.metafits"; @@ -242,7 +255,7 @@ fn test_metafits_context_new_vcsmwax2_valid() { // Read the observation using mwalib // // Open a context and load in a test metafits - let context = MetafitsContext::new(&metafits_filename, Some(MWAVersion::VCSMWAXv2)) + let context = MetafitsContext::new(&metafits_filename, Some(MWAVersion::CorrMWAXv2)) .expect("Failed to create MetafitsContext"); // Test the properties of the context object match what we expect @@ -250,12 +263,15 @@ fn test_metafits_context_new_vcsmwax2_valid() { // obsid: 1101503312, assert_eq!(context.obs_id, 1_101_503_312); - assert_eq!(context.volt_fine_chan_width_hz, 1_280_000); - assert_eq!(context.num_volt_fine_chans_per_coarse, 1); + assert_eq!(context.metafits_fine_chan_freqs_hz.len(), 3072); + assert_eq!( + context.metafits_fine_chan_freqs_hz.len(), + context.num_metafits_fine_chan_freqs + ); } #[test] -fn test_metafits_context_new_vcs_legacy_valid() { +fn test_metafits_context_new_vcsmwax2_valid() { // Open the test mwa v 1 metafits file let metafits_filename = "test_files/1101503312_1_timestep/1101503312.metafits"; @@ -263,22 +279,22 @@ fn test_metafits_context_new_vcs_legacy_valid() { // Read the observation using mwalib // // Open a context and load in a test metafits - let context = MetafitsContext::new(&metafits_filename, Some(MWAVersion::VCSLegacyRecombined)) + let context = MetafitsContext::new(&metafits_filename, Some(MWAVersion::VCSMWAXv2)) .expect("Failed to create MetafitsContext"); - // rf_inputs: [Tile104Y, ..., Tile055X], - assert_eq!(context.num_rf_inputs, 256); - assert_eq!(context.rf_inputs[0].pol, Pol::Y); - assert_eq!(context.rf_inputs[0].tile_name, "Tile104"); - assert_eq!(context.rf_inputs[255].pol, Pol::X); - assert_eq!(context.rf_inputs[255].tile_name, "Tile055"); - // Test the properties of the context object match what we expect - // antennas: [Tile011, Tile012, ... Tile167, Tile168], - // NOTE: since in Legacy VCS the VCS order may look like Tile104Y, Tile103Y, Tile102Y, Tile104X, ... - // so the order of antennas makes no sense, since 104 needs to be first AND further down the list!, so we leave it in the MWAX order. - assert_eq!(context.antennas[0].tile_name, "Tile011"); - assert_eq!(context.antennas[127].tile_name, "Tile168"); + + // obsid: 1101503312, + assert_eq!(context.obs_id, 1_101_503_312); + + assert_eq!(context.volt_fine_chan_width_hz, 1_280_000); + assert_eq!(context.num_volt_fine_chans_per_coarse, 1); + + assert_eq!(context.metafits_fine_chan_freqs_hz.len(), 24); + assert_eq!( + context.metafits_fine_chan_freqs_hz.len(), + context.num_metafits_fine_chan_freqs + ); } #[test]