Skip to content

Commit

Permalink
Added support for MWAX_BUFFER mode, fixed some lints in convert/mod.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
gsleap committed Apr 27, 2023
1 parent 2155c19 commit c5e5d6f
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 46 deletions.
98 changes: 61 additions & 37 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# Change Log

Changes in each release are listed below.
## 0.16.0 08-Dec-2022 (Pre-release)

## 0.16.1 27-Apr-2023

* MWAX Voltage Buffer mode `MWAX_BUFFER` is now supported.

## 0.16.0 08-Dec-2022

* FFI/C: `MetafitsMetadata`->`ra_phase_center_deg` is now NaN not 0 when missing from metafits file.
* FFI/C: `MetafitsMetadata`->`dec_phase_center_deg` is now NaN not 0 when missing from metafits file.
* `MetafitsContext::grid_name` defaults to 'NOGRID' when key is missing from metafits file.
Expand All @@ -14,19 +20,22 @@ Changes in each release are listed below.
* Update dependencies.
* Fixed a bunch of clippy lints.

## 0.15.1 09-Aug-2022 (Pre-release)
## 0.15.1 09-Aug-2022

* mwalib now requires Rust version 1.57 or newer
* Speed up conversion of legacy -> MWAX visibility ordering
* Expose all mwalib error types

## 0.15.0 23-Jun-2022 (Pre-release)
## 0.15.0 23-Jun-2022

* Provide DUT1 in the metafits context
* API tweaks surrounding generic types
* Things should be slightly more flexible than before
* Clippy lints and update cbindgen
* Rename mwa_rust_core -> Marlu

## 0.14.0 13-Apr-2022 (Pre-release)
## 0.14.0 13-Apr-2022

* Specify minimum-required dependency versions.
* Clean up fits long-string functions.
* Stop borrowing generic types.
Expand All @@ -39,77 +48,92 @@ Changes in each release are listed below.
* Lighten code to get channel frequencies.
* Changed metafits_context `cable_delays_applied` from bool to an enum `CableDelaysApplied`.

## 0.13.1 13-Apr-2022 (Pre-release)
## 0.13.1 13-Apr-2022

* Fixed calculation of number of baselines for cases where num_antennas is odd.

## 0.13.0 04-Feb-2022 (Pre-release)
## 0.13.0 04-Feb-2022

* rfinput->digital_gains are now f64 and are divided by 64 (the value in the metafits is 64x larger to allow more flexible gains settings)
* Modernised examples using clap 3.0 and reduced dependencies

## 0.12.2 17-Jan-2022 (Pre-release)
## 0.12.2 17-Jan-2022

* `get_optional_fits_key` now handles the CFITSIO return code of 204 (when there no value for the key) and correctly returns None instead of an error
* The `digital_gains array` in `rf_input` is now sized based on the `num_metafits_coarse_chans` rather than hardcoded to be 24
* `VoltageContext`'s voltage batches and voltage time map are now (library) public like the equivalent attributes in `CorrelatorContext`
* Updated code coverage github action as it had stopped working

## 0.12.1 29-Nov-2021 (Pre-release)
## 0.12.1 29-Nov-2021

* Fixed issue and covered with tests the case where mwalib would panic when creating `CorrelatorContext` with only gpubox file(s) from the second or higher batch (e.g. 001,002...).

## 0.12.0 12-Nov-2021 (Pre-release)
## 0.12.0 12-Nov-2021

* Added calibrator and calibrator_source to `metafits_context`
* Reverted efa8ca41edccbe15079642b26ed5049a8656e3a9 (behaviour of coarse_chan.gpubox_number for VoltageContext LegacyVCS use-case)

## 0.11.0 28-Oct-2021 (Pre-release)
## 0.11.0 28-Oct-2021

* Added new metafits key RAWSCALE to metafits context
* Made gridnum and global_analogue_attenuation_db optional (since they are not in every historical metafits)
* For Legacy VCS, coarse channel.gpuboxnumber now matches the values used by the Legacy Correlator (instead of receiver channel number)
* Added back constants recently removed as they were needed by FFI users: MWALIB_MWA_LATITUDE_RADIANS, MWALIB_MWA_LONGITUDE_RADIANS, MWALIB_MWA_ALTITUDE_METRES, MWALIB_SPEED_OF_LIGHT_IN_VACUUM_M_PER_S. The constants are prefixed with "MWALIB_" to ensure no clashes with mwa_rust_core constants
* Fixed missing nul terminators on returned strings in mwalib FFI functions

## 0.10.0 20-Aug-2021 (Pre-release)
## 0.10.0 20-Aug-2021

* 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.4 19-Aug-2021

## 0.9.3 10-Aug-2021

## 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.

## 0.9.2 09-Aug-2021 (Pre-release)
## 0.9.2 09-Aug-2021

* 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)
## 0.9.1 09-Aug-2021

* 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().

## 0.9.0 09-Aug-2021 (Pre-release)
## 0.9.0 09-Aug-2021

* Added mwa_version <Option<MWAVersion>> to MetafitsContext struct.
* When working only with a MetafitsContext, a None can be passed in lieu of an MWAVersion, and mwalib will attempt to determine the correct MWAVersion based on the MODE keyword from the metafits file.
* Added method get_expected_volt_filename() function to MetafitsContext.
* Added digital_gains, dipole_gains and dipole_delays to FFI rfinput struct.
* Added num_receivers, num_delays to MetafitsContext / metafits_metadata struct in FFI.
* Metafits metadata sched_start_utc and sched_end_utc are now typed as time_t and represent the Unix timestamp (which can be used by various time.h functions).

## 0.8.7 03-Aug-2021 (Pre-release)
## 0.8.7 03-Aug-2021

* Updated some dependencies in Cargo.toml.
* Renamed metafits_context.metafits_fine_chan_freqs by adding _hz suffix to be consistent with other naming of attributes with units.

## 0.8.6 02-Aug-2021 (Pre-release)
## 0.8.6 02-Aug-2021

* Fixed bug where the metafits.num_metafits_fine_chan_freqs was not being set correctly.

## 0.8.5 02-Aug-2021 (Pre-release)
## 0.8.5 02-Aug-2021

* Added helper function get_fine_chan_freqs_hz_array to correlator context and voltage context.
* Added metafits_context.num_metafits_fine_chan_freqs & metafits_context.metafits_fine_chan_freqs, providing a vector of sky frequencies for all fine channels.
* Added metafits_context.volt_fine_chan_width_hz & metafits_context.num_volt_fine_chans_per_coarse to describe the voltage fine channel configuration.
* Added the above new functions and attributes to equivalent structs in FFI.
* Added more badges to github README.

## 0.8.4 15-Jul-2021 (Pre-release)
## 0.8.4 15-Jul-2021

* mwalib legacy autocorrelations (where ant1==ant2) are now conjugated with respect to previous versions.

## 0.8.3 01-Jul-2021 (Pre-release)
## 0.8.3 01-Jul-2021

* Refactor of FFI: collapsing, antennas, baselines, coarse channels, rf inputs and timesteps into attributes of the MetafitsMetadata, CorrelatorMetadata and Voltage Metadata structs.
* Refactor of FFI: Added common, common good and provided timesteps/coarse channels to CorrelatorMetadata and VoltageMetadata structs.
Expand All @@ -119,18 +143,18 @@ Changes in each release are listed below.
* Updated VoltageContext display to be consistent with CorrelatorContext.
* Fixed bugs when reading metafits files which have new MWAX GEODEL, CALIBDEL and CABLEDEL keys.

## 0.8.2 09-Jun-2021 (Pre-release)
## 0.8.2 09-Jun-2021

* Added common, common good and provided timesteps/coarse channels for VoltageContext.
* Voltage timesteps and coarse channel vectors now represent the superset of metafits and provided data.
* Due to the above, the read methods now may return a NoDataForTimeStepCoarseChannel error if the timestep/coarse channel combination does not have a file available to read data from.

## 0.8.1 09-Jun-2021 (Pre-release)
## 0.8.1 09-Jun-2021

* Modified logic of common and good correlator timesteps/coarse channels to mean common to all provided coarse channels.
* Added provided_coarse_chans which is a vector of all of the provided gpubox files coarse channels.

## 0.8.0 08-Jun-2021 (Pre-release)
## 0.8.0 08-Jun-2021

* Removed VisibilityPol struct, replaced with VisPol enum to simplify.
* Renamed CorrelatorVersion enum to MWAVersion. This now incorporates Correlator version (OldLegacy, Legacy and MWAXv2, as well as VCSRecombined and MWAXVCS).
Expand All @@ -146,28 +170,28 @@ Changes in each release are listed below.
* Added common timesteps and coarse channels which represent the timesteps and channels common the most max set of coarse channels provided.
* Added common good timesteps and coarse channels which is the same as common, except only timesteps after the quack time are used to determine them.

## 0.7.1 15-May-2021 (Pre-release)
## 0.7.1 15-May-2021

* Implemented _into_buffer variant of read_by_baseline and read_by_frequency so you can allocate your own vector and pass the whole thing or a slice to be filled with the relevant data.
* The implementation of the ffi read_by_baseline and read_by_freqeuency now use this method, thus reducing an unneeded allocation and copy.
* Added built crate to allow rust callers to query the mwalib build environment (including the mwalib version number).
* Exposed major, minor and patch version of mwalib to ffi callers.
* Pinned rust nightly build in coverage CI to prevent a missing crate error (temporarily?)

## 0.7.0 30-Apr-2021 (Pre-release)
## 0.7.0 30-Apr-2021

* Added support for reading voltage data by file or gps second.
* Added FFI support for reading voltage data by file or gps second.
* Removed num_samples_per_timestep from VoltageContext. Added more useful struct members describing the data shape precisely.
* Removed unneeded muts from correlator and voltage contexts.
* Minor cleanup of rust examples.

## 0.6.3 28-Mar-2021 (Pre-release)
## 0.6.3 28-Mar-2021

* Refactored github actions for a more complete CI workflow with automated releases.
* Updated README and install instructions and fixed many markdown issues.

## 0.6.2 25-Mar-2021 (Pre-release)
## 0.6.2 25-Mar-2021

* Modified MWA Legacy read code to produce cotter-compatible visibilities:
* mwalib differs from cotter: cotter produces 0+0j for XY on auto's, mwalib provides the values.
Expand All @@ -178,19 +202,19 @@ Changes in each release are listed below.
* Updated CI pipeline: bumped install of cfitsio to v3.49.
* Made error handling code a little lighter.

## 0.6.1 08-Mar-2021 (Pre-release)
## 0.6.1 08-Mar-2021

* Fixed za (zenith angle) calculation.
* Added more comprehensive testing for some coarse_channel methods.
* Addressed many clippy lints.

## 0.6.0 05-Mar-2021 (Pre-release)
## 0.6.0 05-Mar-2021

* Minor updates to enable packaging and deployment to crates.io.
* Fixed visibility of library structs and functions.
* Moved coax_v_factor, mwa_lat_radians, mwa_long_radians and mwa_alt_meters out of metafits_metadata and are now just library constants.

## 0.5.1 04-Mar-2021 (Pre-release)
## 0.5.1 04-Mar-2021

* Major refactoring- this will break compatibility with previous mwalib versions.
* mwalibContext top level object now split into:
Expand All @@ -204,11 +228,11 @@ Changes in each release are listed below.
* Many long named members renamed to use shorter or abbreviated names.
* NOTE: VoltageContext does not have data reading functions in this release (however, metadata is supported). This will be added in an upcoming release.

## 0.4.4 08-Jan-2021 (Pre-release)
## 0.4.4 08-Jan-2021

* Added receiver_number and receiver_slot_number to rfinput struct.

## 0.4.3 09-Nov-2020 (Pre-release)
## 0.4.3 09-Nov-2020

* Expose the fitsio and fitsio-sys crates used: This allows callers to use whatever version of fitsio and fitsio-sys that is used by mwalib, in turn ensuring that other dependent libraries aren't using different versions of these crates. And, along with the other change to this crate, means that statically-linking cfitsio from other crates is simpler.
* The `infer_static` function introduced to build.rs is a workaround for pkg-config-rs being too restrictive when static linking (rust-lang/pkg-config-rs#102). Basically, if we decide to statically link, we emit a message to cargo, and it'll work. Hopefully this hack can be removed in the future when pkg-config-rs is a little more liberal.
Expand All @@ -223,17 +247,17 @@ Changes in each release are listed below.
* Overhaul the error handling in mwalib, and change the API traits.
* Fixed cargo tarpaulin decorators to use new format.

## 0.3.2 25-Jun-2020 (Pre-release)
## 0.3.2 25-Jun-2020

* libmwalib.so now has statically linked libcfitsio library as cfitsio's ABI keeps changing making linking difficult for users.

## 0.3.1 08-Jun-2020 (Pre-release)
## 0.3.1 08-Jun-2020

* Bugfix: Fixed panic when all 24 coarse channels are using receiver channel numbers >128.
* Added more inline documentation for mwalib.h.
* Improved the output, by making it more complete, when displaying the contents of the context object.

## 0.3.0 14-May-2020 (Pre-release)
## 0.3.0 14-May-2020

* Added baseline array.
* Added visibility pol(arisations) array.
Expand All @@ -242,6 +266,6 @@ Changes in each release are listed below.
* Added extra validation to ensure NAXIS1 and NAXIS2 across all gpubox files match expected values from metafits.
* Metadata reading from gpubox files is now done in parallel.

## 0.2.0 20-Mar-2020 (Pre-release)
## 0.2.0 20-Mar-2020

* Initial pre-release.
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.16.0"
version = "0.16.1"
homepage = "https://github.com/MWATelescope/mwalib"
repository = "https://github.com/MWATelescope/mwalib"
readme = "README.md"
Expand Down
14 changes: 7 additions & 7 deletions src/convert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,17 @@ fn generate_full_matrix(mwax_order: Vec<usize>) -> Vec<i32> {
row1st = mwax_order[fine_pfb_reorder(row_order)];
row2nd = mwax_order[fine_pfb_reorder(row_order + 1)];

full_matrix[((row1st << 8) | col_a)] = source_legacy_ndx; // Top left complex number in the 2x2 correlation square
full_matrix[(row1st << 8) | col_a] = source_legacy_ndx; // Top left complex number in the 2x2 correlation square
source_legacy_ndx += 1;
// Unless it's one of the 128 redundant outputs from the old correlator
if col_order != row_order {
full_matrix[((row2nd << 8) | col_a)] = source_legacy_ndx; // Bottom left
full_matrix[(row2nd << 8) | col_a] = source_legacy_ndx; // Bottom left
}
source_legacy_ndx += 1; // NB the source index *isn't* incremented during the 'if'
full_matrix[((row1st << 8) | col_b)] = source_legacy_ndx; // Here is the Top right.
full_matrix[(row1st << 8) | col_b] = source_legacy_ndx; // Here is the Top right.
source_legacy_ndx += 1;

full_matrix[((row2nd << 8) | col_b)] = source_legacy_ndx; // Bottom Right complex number in the 2x2.
full_matrix[(row2nd << 8) | col_b] = source_legacy_ndx; // Bottom Right complex number in the 2x2.
source_legacy_ndx += 1;
}
}
Expand All @@ -199,10 +199,10 @@ fn generate_full_matrix(mwax_order: Vec<usize>) -> Vec<i32> {
// Now we want to fill in the pointers to conjugates where we don't have the value itself
for col_order in 0..256 {
// Go through every cell by row and column
if full_matrix[(row_order << 8 | col_order)] == -1 {
if full_matrix[row_order << 8 | col_order] == -1 {
// If the entry is currently empty (represented by -1)
full_matrix[(row_order << 8 | col_order)] =
-(full_matrix[(col_order << 8 | row_order)]); // copy the result from the inverse and negate it
full_matrix[row_order << 8 | col_order] =
-(full_matrix[col_order << 8 | row_order]); // copy the result from the inverse and negate it
}
// Useful debug
// print!("{},", full_matrix[row_order << 8 | col_order]);
Expand Down
5 changes: 4 additions & 1 deletion src/metafits_context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ pub enum MWAMode {
Voltage_Buffer = 24,
Mwax_Correlator = 30,
Mwax_Vcs = 31,
Mwax_Buffer = 32,
}

/// Implements fmt::Display for MWAMode enum
Expand Down Expand Up @@ -270,6 +271,7 @@ impl fmt::Display for MWAMode {
MWAMode::Voltage_Buffer => "VOLTAGE_BUFFER",
MWAMode::Mwax_Correlator => "MWAX_CORRELATOR",
MWAMode::Mwax_Vcs => "MWAX_VCS",
MWAMode::Mwax_Buffer => "MWAX_BUFFER",
}
)
}
Expand Down Expand Up @@ -301,6 +303,7 @@ impl std::str::FromStr for MWAMode {
"VOLTAGE_BUFFER" => Ok(MWAMode::Voltage_Buffer),
"MWAX_CORRELATOR" => Ok(MWAMode::Mwax_Correlator),
"MWAX_VCS" => Ok(MWAMode::Mwax_Vcs),
"MWAX_BUFFER" => Ok(MWAMode::Mwax_Buffer),
_ => Err(()),
}
}
Expand Down Expand Up @@ -490,7 +493,7 @@ impl MetafitsContext {
Some(MWAVersion::VCSLegacyRecombined)
}
MWAMode::Mwax_Correlator => Some(MWAVersion::CorrMWAXv2),
MWAMode::Mwax_Vcs => Some(MWAVersion::VCSMWAXv2),
MWAMode::Mwax_Vcs | MWAMode::Mwax_Buffer => Some(MWAVersion::VCSMWAXv2),
_ => {
return Err(MwalibError::Metafits(
MetafitsError::UnableToDetermineMWAVersionFromMode(new_context.mode),
Expand Down
3 changes: 3 additions & 0 deletions src/metafits_context/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ fn test_mode_enum() {
let voltage_buffer = MWAMode::Voltage_Buffer;
let mwax_correlator = MWAMode::Mwax_Correlator;
let mwax_vcs = MWAMode::Mwax_Vcs;
let mwax_buffer = MWAMode::Mwax_Buffer;

assert_eq!(format!("{}", no_capture), "NO_CAPTURE");
assert_eq!(format!("{}", burst_vsib), "BURST_VSIB");
Expand All @@ -634,6 +635,7 @@ fn test_mode_enum() {
assert_eq!(format!("{}", voltage_buffer), "VOLTAGE_BUFFER");
assert_eq!(format!("{}", mwax_correlator), "MWAX_CORRELATOR");
assert_eq!(format!("{}", mwax_vcs), "MWAX_VCS");
assert_eq!(format!("{}", mwax_buffer), "MWAX_BUFFER");

assert!(MWAMode::from_str("NO_CAPTURE").is_ok());
assert!(MWAMode::from_str("BURST_VSIB").is_ok());
Expand All @@ -656,5 +658,6 @@ fn test_mode_enum() {
assert!(MWAMode::from_str("VOLTAGE_BUFFER").is_ok());
assert!(MWAMode::from_str("MWAX_CORRELATOR").is_ok());
assert!(MWAMode::from_str("MWAX_VCS").is_ok());
assert!(MWAMode::from_str("MWAX_BUFFER").is_ok());
assert!(MWAMode::from_str("something invalid").is_err());
}

0 comments on commit c5e5d6f

Please sign in to comment.