From 3a7566be9519fdea6822b3f696bbc90af5652494 Mon Sep 17 00:00:00 2001 From: Greg Sleap Date: Wed, 11 Aug 2021 16:48:44 +0800 Subject: [PATCH] When using a stand-alone MetafitsContext, the rf_inputs are now correctly sorted for the VCSLegacyRecombined case. --- CHANGELOG.md | 3 +++ Cargo.toml | 2 +- src/metafits_context/mod.rs | 8 ++++++++ src/metafits_context/test.rs | 27 +++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec0432d..154c226 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ Changes in each release are listed below. +## 0.9.2 09-Aug-2021 (Pre-release) +* When using a stand-alone MetafitsContext, the rf_inputs are now correctly sorted for the VCSLegacyRecombined case. + ## 0.9.1 09-Aug-2021 (Pre-release) * Added alternative version of mwalib_metafits_context_new (mwalib_metafits_context_new2) to FFI interface which does not require an MWAVersion and will determine it via the MODE keyword. * Fixed errors, ommissions in comment/documentation for FFI function mwalib_metafits_get_expected_volt_filename(). diff --git a/Cargo.toml b/Cargo.toml index fd8d60a..75e6d8a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mwalib" -version = "0.9.1" +version = "0.9.2" homepage = "https://github.com/MWATelescope/mwalib" repository = "https://github.com/MWATelescope/mwalib" readme = "README.md" diff --git a/src/metafits_context/mod.rs b/src/metafits_context/mod.rs index e6d3784..1d4b8bb 100644 --- a/src/metafits_context/mod.rs +++ b/src/metafits_context/mod.rs @@ -436,6 +436,14 @@ impl MetafitsContext { m => m, }; + // The rf inputs should be sorted depending on the Version + match new_context.mwa_version.unwrap() { + MWAVersion::VCSLegacyRecombined => { + new_context.rf_inputs.sort_by_key(|k| k.vcs_order); + } + _ => {} + } + // Update the voltage fine channel size now that we know which mwaversion we are using if new_context.mwa_version == Some(MWAVersion::VCSMWAXv2) { // MWAX VCS- the data is unchannelised so coarse chan width == fine chan width diff --git a/src/metafits_context/test.rs b/src/metafits_context/test.rs index 1354691..26a0742 100644 --- a/src/metafits_context/test.rs +++ b/src/metafits_context/test.rs @@ -244,6 +244,33 @@ fn test_metafits_context_new_vcsmwax2_valid() { assert_eq!(context.num_volt_fine_chans_per_coarse, 1); } +#[test] +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"; + + // + // Read the observation using mwalib + // + // Open a context and load in a test metafits + let context = MetafitsContext::new(&metafits_filename, Some(MWAVersion::VCSLegacyRecombined)) + .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"); +} + #[test] fn test_populate_expected_timesteps() { // Note the timesteps returned are fully tested in the timesteps tests, so this is checking the metafits_context calling of that code