Skip to content

Commit

Permalink
Added metafits fine channel freqs, metafits volt fine chan width, fix…
Browse files Browse the repository at this point in the history
…ed clippy lints
  • Loading branch information
gsleap committed Aug 2, 2021
1 parent f7e71eb commit d2a93f7
Show file tree
Hide file tree
Showing 15 changed files with 433 additions and 179 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Changes in each release are listed below.

## 0.8.5 02-Aug-2021 (Pre-release)
* 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 attributes to equivalent metafits_context struct in FFI.
* Added more badges to github README.

## 0.8.4 15-Jul-2021 (Pre-release)
* mwalib legacy autocorrelations (where ant1==ant2) are now conjugated with respect to previous versions.

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.8.4"
version = "0.8.5"
homepage = "https://github.com/MWATelescope/mwalib"
repository = "https://github.com/MWATelescope/mwalib"
readme = "README.md"
Expand Down
50 changes: 24 additions & 26 deletions src/coarse_channel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ impl CoarseChannel {
_ => match voltage_time_map {
Some(v) => {
if let Some((_, channel_map)) = v.iter().next() {
if channel_map.contains_key(&rec_chan_number) {
if channel_map.contains_key(rec_chan_number) {
coarse_chans.push(CoarseChannel::new(
correlator_chan_number,
*rec_chan_number,
Expand Down Expand Up @@ -264,7 +264,7 @@ impl CoarseChannel {
match gpubox_time_map {
Some(g) => {
if let Some((_, channel_map)) = g.iter().next() {
if channel_map.contains_key(&rec_chan_number) {
if channel_map.contains_key(rec_chan_number) {
coarse_chans.push(CoarseChannel::new(
correlator_chan_number,
*rec_chan_number,
Expand All @@ -277,7 +277,7 @@ impl CoarseChannel {
_ => match voltage_time_map {
Some(v) => {
if let Some((_, channel_map)) = v.iter().next() {
if channel_map.contains_key(&rec_chan_number) {
if channel_map.contains_key(rec_chan_number) {
coarse_chans.push(CoarseChannel::new(
correlator_chan_number,
*rec_chan_number,
Expand Down Expand Up @@ -337,16 +337,14 @@ impl CoarseChannel {
coarse_chan_indices
}

/// Calculate the centre frequency of first fine channel of coarse channel.
/// Calculate the centre frequency of each fine channel of this coarse channel.
///
///
/// # Arguments
///
/// * `mwa_version` - The version of the MWA is in use.
///
/// * `coarse_chan_width_hz` - Width in Hz of the coarse channel.
///
/// * `coarse_chan_centre_hz` - Center in sky frequency of this coarse channel.
/// * `coarse_channels` - Vector of populated Coarse Channels.
///
/// * `fine_chan_width_hz` - Fine channel width in Hz.
///
Expand All @@ -356,23 +354,21 @@ impl CoarseChannel {
///
/// * The centre frequency of the first fine channel of the coarse channel.
///
pub fn get_first_fine_chan_centre_hz(
pub fn get_fine_chan_centres_array_hz(
mwa_version: MWAVersion,
coarse_chan_width_hz: u32,
coarse_chan_centre_hz: u32,
fine_chan_width_hz: u64,
coarse_channels: &[CoarseChannel],
fine_chan_width_hz: u32,
num_fine_chans_per_coarse: usize,
) -> f64 {
) -> Vec<f64> {
// Firstly calculate the offset
// For Legacy MWA, the offset is only needed if the fine channel width is 20 or 40kHz.
let offset_hz = match mwa_version {
MWAVersion::CorrLegacy
| MWAVersion::CorrOldLegacy
| MWAVersion::VCSLegacyRecombined => match num_fine_chans_per_coarse {
128 => 0.0, // 10 kHz
64 => 5_000.0, // 20 kHz
32 => 15_000.0, // 40 Khz
_ => 0.0,
64 => 5_000.0, // 20 kHz corr mode needs a 5 kHz offset applied
32 => 15_000.0, // 40 kHz corr mode needs a 15 kHz offset applied
_ => 0.0, // other modes (10kHz) does not need any offset applied
},
MWAVersion::CorrMWAXv2 | MWAVersion::VCSMWAXv2 => 0.0,
};
Expand All @@ -383,16 +379,18 @@ impl CoarseChannel {
false => 0.5, // Odd
};

// Now calculate the first fine chan centre hz:
//
// = coarse_chan_centre - (coarse_chan_width/2) // This gets you to the start edge Hz of the coarse channel
// + (odd_even_adjustment * fine_chan_width) // This moves us into the centre of that fine channel
let first_fine_chan_center_hz: f64 = coarse_chan_centre_hz as f64
- (coarse_chan_width_hz as f64 / 2.0)
+ (odd_even_adjustment * fine_chan_width_hz as f64);

// Apply the offset (if required)
first_fine_chan_center_hz + offset_hz
// Return a vector of f64s which are the fine channel centre frequencies for all the fine channels in [coarse_channels]
coarse_channels
.iter()
.flat_map(|coarse_chan| {
let chan_start_hz = coarse_chan.chan_start_hz;
(0..num_fine_chans_per_coarse).map(move |fine_chan_idx| {
chan_start_hz as f64
+ ((fine_chan_idx as f64 + odd_even_adjustment) * fine_chan_width_hz as f64)
+ offset_hz
})
})
.collect()
}
}

Expand Down
Loading

0 comments on commit d2a93f7

Please sign in to comment.