Skip to content

Commit

Permalink
Merge pull request #84 from MWATelescope/fits_filename
Browse files Browse the repository at this point in the history
remove MWAFitsFile, use FitsFile.file_path()
  • Loading branch information
gsleap authored Nov 8, 2024
2 parents dded90b + 11846f4 commit 0367add
Show file tree
Hide file tree
Showing 15 changed files with 183 additions and 298 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Changes in each release are listed below.

## next

* Update to fitsio 0.21.6 - provides FitsFile.file_path() method.

## 1.7.1 23-Oct-2024

* Release to fix issue generating Rust docs.
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ python = ["anyhow", "env_logger", "ndarray", "numpy", "pyo3", "pyo3-stub-gen", "

[dependencies]
chrono = "0.4.38"
fitsio = "~0.21"
fitsio = "0.21.6"
fitsio-sys = "~0.5"
lazy_static = "~1.5"
libc = "~0.2"
Expand Down Expand Up @@ -95,4 +95,4 @@ required-features = ["examples"]

[[example]]
name = "mwalib-sum-first-fine-channel-gpubox-hdus"
required-features = ["examples"]
required-features = ["examples"]
21 changes: 11 additions & 10 deletions src/coarse_channel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::voltage_files::VoltageFileTimeMap;
pub mod error;
use crate::*;
use error::CoarseChannelError;
use fitsio::{hdu::FitsHdu, FitsFile};
use std::fmt;

#[cfg(feature = "python")]
Expand Down Expand Up @@ -109,10 +110,10 @@ impl CoarseChannel {
///
/// # Arguments
///
/// `metafits_fptr` - a reference to a metafits MWAFitsFile object.
/// `metafits_fptr` - a reference to a metafits FitsFile object.
///
/// `metafits_hdu` - a reference to a metafits primary HDU.
///
///
/// `observation_bandwidth_hz` - total bandwidth in Hz of the entire observation. If there are 24 x 1.28 MHz channels
/// this would be 30.72 MHz (30,720,000 Hz)
///
Expand All @@ -122,8 +123,8 @@ impl CoarseChannel {
/// The width in Hz of each coarse channel
///
pub(crate) fn get_metafits_coarse_channel_info(
metafits_fptr: &mut MWAFitsFile,
hdu: &fitsio::hdu::FitsHdu,
metafits_fptr: &mut FitsFile,
hdu: &FitsHdu,
observation_bandwidth_hz: u32,
) -> Result<(Vec<usize>, u32), FitsError> {
// The coarse-channels string uses the FITS "CONTINUE" keywords. The
Expand All @@ -147,7 +148,7 @@ impl CoarseChannel {
/// * if `voltage_time_map` is supplied, then the coarse channels represent actual coarse channels supplied for a VoltageContext.
/// * if neither `gpubox_time_map` nor `voltage_time_map` is supplied, then the coarse channels represent the expected coarse channels supplied for a MetafitsContext.
///
/// # Arguments
/// # Arguments
///
/// `mwa_version` - enum representing the version of the correlator this observation was created with.
///
Expand All @@ -162,7 +163,7 @@ impl CoarseChannel {
/// # Returns
///
/// * A tuple containing: A vector of CoarseChannel structs (limited to those are supplied by the client and are valid, unless neither `gpubox_time_map` nor
/// `voltage_time_map` are provided, and the it is based on the metafits),
/// `voltage_time_map` are provided, and the it is based on the metafits),
/// The width in Hz of each coarse channel
///
pub(crate) fn populate_coarse_channels(
Expand Down Expand Up @@ -313,11 +314,11 @@ impl CoarseChannel {
/// This creates a populated vector of indices from the passed in `all_coarse_chans' slice of CoarseChannels based on the
/// coarse_chan_identifiers vector of coarse channel identifers we pass in.
///
/// # Arguments
/// # Arguments
///
/// * `all_coarse_chans` - Reference to a slice containing all the coarse channels
/// * `all_coarse_chans` - Reference to a slice containing all the coarse channels
///
/// * `coarse_chan_identifiers` - Vector or coarse channel identifiers we want to find the indices for.
/// * `coarse_chan_identifiers` - Vector or coarse channel identifiers we want to find the indices for.
///
/// # Returns
///
Expand Down Expand Up @@ -345,7 +346,7 @@ impl CoarseChannel {
/// Calculate the centre frequency of each fine channel of the provided coarse channels.
///
///
/// # Arguments
/// # Arguments
///
/// * `mwa_version` - The version of the MWA is in use.
///
Expand Down
13 changes: 7 additions & 6 deletions src/correlator_context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

//! The main interface to MWA data.
use fitsio::FitsFile;
use std::collections::BTreeMap;
use std::fmt;
use std::path::Path;
Expand Down Expand Up @@ -121,7 +122,7 @@ pub struct CorrelatorContext {
/// number, batch number and HDU index are everything needed to find the
/// correct HDU out of all gpubox files.
pub gpubox_time_map: BTreeMap<u64, BTreeMap<usize, (usize, usize)>>,
/// A conversion table to optimise reading of legacy MWA HDUs
/// A conversion table to optimise reading of legacy MWA HDUs
pub(crate) legacy_conversion_table: Vec<LegacyConversionBaseline>,
}

Expand All @@ -141,7 +142,7 @@ impl CorrelatorContext {
///
/// * Result containing a populated CorrelatorContext object if Ok.
///
///
///
pub fn new<P: AsRef<Path>, P2: AsRef<Path>>(
metafits_filename: P,
gpubox_filenames: &[P2],
Expand Down Expand Up @@ -798,7 +799,7 @@ impl CorrelatorContext {
metafits_fine_chans_per_coarse: usize,
metafits_baselines: usize,
visibility_pols: usize,
gpubox_fptr: &mut MWAFitsFile,
gpubox_fptr: &mut FitsFile,
) -> Result<(), GpuboxError> {
// Get NAXIS1 and NAXIS2 from a gpubox file first image HDU
let hdu = fits_open_hdu!(gpubox_fptr, 1)?;
Expand Down Expand Up @@ -926,7 +927,7 @@ impl fmt::Display for CorrelatorContext {
r#"CorrelatorContext (
Metafits Context: {metafits_context}
MWA version: {corr_ver},
num timesteps: {n_timesteps},
timesteps: {timesteps:?},
num coarse channels, {n_coarse},
Expand All @@ -942,8 +943,8 @@ impl fmt::Display for CorrelatorContext {
Common GPS start time: {common_start_gps},
Common GPS end time: {common_end_gps},
Common duration: {common_duration} s,
Common bandwidth: {common_bw} MHz,
Common bandwidth: {common_bw} MHz,
Common/Good timestep indices: {num_common_good_timesteps}: {common_good_ts:?},
Common/Good coarse chan indices: {num_common_good_coarse_chans}: {common_good_chans:?},
Common/Good UNIX start time: {common_good_start_unix},
Expand Down
Loading

0 comments on commit 0367add

Please sign in to comment.