Skip to content

Commit

Permalink
Tidy up the formatting of dipole-gains.
Browse files Browse the repository at this point in the history
This command used to be confusing in that it used the 0-128 index of a
tile in what looked like the tile name. No longer -- the index and tile
name are now both printed.

Also allow verbosity to passed in, in case the user wants to see
something wrong with their metafits file.
  • Loading branch information
cjordan committed Oct 20, 2022
1 parent 3d54ffb commit bf297fd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Versioning](https://semver.org/spec/v2.0.0.html).
- Bugs were fixed surrounding the reading of RTS solutions.

### Changed
- The output of `dipole-gains` is now less confusing.
- When applying solutions, if a baseline/tile doesn't have an appropriate
solution available, the output Jones matrix is all zeros. This is to avoid
confusion on whether the Jones matrix has been calibrated but is just flagged
Expand Down
9 changes: 7 additions & 2 deletions src/bin/hyperdrive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ https://mwatelescope.github.io/mwa_hyperdrive/user/solutions_apply/intro.html"#)
DipoleGains {
#[clap(flatten)]
args: mwa_hyperdrive::DipoleGainsArgs,

/// The verbosity of the program. The default is to print high-level
/// information.
#[clap(short, long, parse(from_occurrences))]
verbosity: u8,
},
}

Expand All @@ -222,7 +227,7 @@ fn cli() -> Result<(), HyperdriveError> {
Args::SrclistConvert { verbosity, .. } => (verbosity, "srclist-convert"),
Args::SrclistShift { verbosity, .. } => (verbosity, "srclist-shift"),
Args::SrclistVerify { verbosity, .. } => (verbosity, "srclist-verify"),
Args::DipoleGains { .. } => (&0, "dipole-gains"),
Args::DipoleGains { verbosity, .. } => (verbosity, "dipole-gains"),
};
setup_logging(*verbosity).expect("Failed to initialise logging.");

Expand Down Expand Up @@ -278,7 +283,7 @@ fn cli() -> Result<(), HyperdriveError> {
Args::SrclistVerify { args, .. } => args.run()?,

// Misc. utilities.
Args::DipoleGains { args } => args.run().unwrap(),
Args::DipoleGains { args, .. } => args.run()?,
}

info!("hyperdrive {} complete.", sub_command);
Expand Down
17 changes: 8 additions & 9 deletions src/cli/dipole_gains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,24 @@ impl DipoleGainsArgs {
.iter()
.all(|&g| g.is_finite() && (g - 1.0).abs() < f64::EPSILON)
{
all_unity.push(i);
all_unity.push((i, &meta.antennas[i].tile_name));
} else {
non_unity.push((i, tile_gains));
non_unity.push((i, &meta.antennas[i].tile_name, tile_gains));
}
}

if all_unity.len() == meta.num_ants {
info!("All dipoles on all tiles have a gain of 1.0!");
} else {
info!(
"Tiles with all dipoles alive ({}): {:?}",
all_unity.len(),
all_unity
);
info!("Tiles with all dipoles alive ({}):", all_unity.len());
for (tile_num, tile_name) in all_unity {
info!(" {:>3}: {:>8}", tile_num, tile_name);
}
info!("Other tiles:");
let mut bad_x = Vec::with_capacity(16);
let mut bad_y = Vec::with_capacity(16);
let mut bad_string = String::new();
for (tile_num, tile_gains) in non_unity {
for (tile_num, tile_name, tile_gains) in non_unity {
let tile_gains = tile_gains.as_slice().unwrap();
tile_gains[..16].iter().enumerate().for_each(|(i, &g)| {
if (g - 1.0).abs() > f64::EPSILON {
Expand All @@ -59,7 +58,7 @@ impl DipoleGainsArgs {
bad_y.push(i);
}
});
bad_string.push_str(&format!(" Tile {:>3}: ", tile_num));
bad_string.push_str(&format!(" {:>3}: {:>8}: ", tile_num, tile_name));
if !bad_x.is_empty() {
bad_string.push_str(&format!("X {:?}", &bad_x));
}
Expand Down
6 changes: 6 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,9 @@ impl From<DiCalArgsError> for HyperdriveError {
}
}
}

impl From<mwalib::MwalibError> for HyperdriveError {
fn from(e: mwalib::MwalibError) -> Self {
Self::Mwalib(e.to_string())
}
}

0 comments on commit bf297fd

Please sign in to comment.