Skip to content

Commit

Permalink
hyperbeam 0.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
d3v-null committed Jan 30, 2024
1 parent 53a8ec1 commit 455d3c0
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ indicatif = { version = "0.17.5", features = ["rayon"] }
lazy_static = "1.4.0"
log = "0.4.0"
marlu = { version = "0.10.1", features = ["serde"] }
mwa_hyperbeam = "0.6.0"
mwa_hyperbeam = "0.7.1"
mwalib = "0.16.0"
ndarray = { version = "0.15.4", features = ["rayon"] }
num-complex = "0.4.1"
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ mod gpu {

match env::var("DEBUG").as_deref() {
Ok("false") => (),
_ => gpu_target.flag("-ggdb"),
_ => {hip_target.flag("-ggdb");},
};

hip_target
Expand Down
21 changes: 6 additions & 15 deletions src/beam/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use log::debug;
use marlu::{AzEl, Jones};
use ndarray::prelude::*;

use super::{Beam, BeamError, BeamType, Delays};
use super::{partial_to_full, validate_delays, Beam, BeamError, BeamType, Delays};

#[cfg(any(feature = "cuda", feature = "hip"))]
use super::{BeamGpu, DevicePointer, GpuFloat};
Expand All @@ -33,6 +33,8 @@ impl FEEBeam {
gains: Option<Array2<f64>>,
file: Option<&Path>,
) -> Result<FEEBeam, BeamError> {
validate_delays(&delays, num_tiles)?;

let ideal_delays = delays.get_ideal_delays();
debug!("Ideal dipole delays: {:?}", ideal_delays);

Expand Down Expand Up @@ -350,11 +352,11 @@ impl BeamGpu for FEEBeamGpu {
}

fn get_tile_map(&self) -> *const i32 {
self.hyperbeam_object.get_tile_map()
self.hyperbeam_object.get_device_tile_map()
}

fn get_freq_map(&self) -> *const i32 {
self.hyperbeam_object.get_freq_map()
self.hyperbeam_object.get_device_freq_map()
}

fn get_num_unique_tiles(&self) -> i32 {
Expand All @@ -364,15 +366,4 @@ impl BeamGpu for FEEBeamGpu {
fn get_num_unique_freqs(&self) -> i32 {
self.hyperbeam_object.get_num_unique_freqs()
}
}

/// Assume that the dipole delays for all tiles is the same as the delays for
/// one tile.
fn partial_to_full(delays: Vec<u32>, num_tiles: usize) -> Array2<u32> {
let mut out = Array2::zeros((num_tiles, 16));
let d = Array1::from(delays);
out.outer_iter_mut().for_each(|mut tile_delays| {
tile_delays.assign(&d);
});
out
}
}
55 changes: 36 additions & 19 deletions src/beam/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,25 +415,7 @@ pub fn create_beam_object(
debug!("Setting up a FEE beam object");

// Check that the delays are sensible.
match &dipole_delays {
Delays::Partial(v) => {
if v.len() != 16 || v.iter().any(|&v| v > 32) {
return Err(BeamError::BadDelays);
}
}

Delays::Full(a) => {
if a.len_of(Axis(1)) != 16 || a.iter().any(|&v| v > 32) {
return Err(BeamError::BadDelays);
}
if a.len_of(Axis(0)) != num_tiles {
return Err(BeamError::InconsistentDelays {
num_rows: a.len_of(Axis(0)),
num_tiles,
});
}
}
}
validate_delays(&dipole_delays, num_tiles)?;

// Set up the FEE beam struct from the `MWA_BEAM_FILE` environment
// variable.
Expand All @@ -445,3 +427,38 @@ pub fn create_beam_object(
}
}
}

/// Assume that the dipole delays for all tiles is the same as the delays for
/// one tile.
fn partial_to_full(delays: Vec<u32>, num_tiles: usize) -> Array2<u32> {
let mut out = Array2::zeros((num_tiles, 16));
let d = Array1::from(delays);
out.outer_iter_mut().for_each(|mut tile_delays| {
tile_delays.assign(&d);
});
out
}

fn validate_delays(delays: &Delays, num_tiles: usize) -> Result<(), BeamError> {
match delays {
Delays::Partial(v) => {
if v.len() != 16 || v.iter().any(|&v| v > 32) {
return Err(BeamError::BadDelays);
}
}

Delays::Full(a) => {
if a.len_of(Axis(1)) != 16 || a.iter().any(|&v| v > 32) {
return Err(BeamError::BadDelays);
}
if a.len_of(Axis(0)) != num_tiles {
return Err(BeamError::InconsistentDelays {
num_rows: a.len_of(Axis(0)),
num_tiles,
});
}
}
}

Ok(())
}

0 comments on commit 455d3c0

Please sign in to comment.