Skip to content

Commit

Permalink
When using a stand-alone MetafitsContext, the rf_inputs are now corre…
Browse files Browse the repository at this point in the history
…ctly sorted for the VCSLegacyRecombined case.
  • Loading branch information
gsleap committed Aug 11, 2021
1 parent 973fbf1 commit 3a7566b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
8 changes: 8 additions & 0 deletions src/metafits_context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions src/metafits_context/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3a7566b

Please sign in to comment.