diff --git a/Cargo.lock b/Cargo.lock index 2fa5521..eb7f3c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -99,6 +99,15 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +[[package]] +name = "autotools" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef941527c41b0fc0dd48511a8154cd5fc7e29200a0ff8b7203c5d777dbc795cf" +dependencies = [ + "cc", +] + [[package]] name = "backtrace" version = "0.3.74" @@ -116,7 +125,7 @@ dependencies = [ [[package]] name = "birli" -version = "0.15.1" +version = "0.16.0" dependencies = [ "aoflagger_sys", "approx", @@ -659,9 +668,9 @@ dependencies = [ [[package]] name = "fitsio" -version = "0.20.0" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3c31e99e291587ab50840bdf7e647187355978e93fdfc4c9f0d76b8e53e345d" +checksum = "0cdb3dff2b25ec4e296f3289f7242054e174921ddffdf4772ee715d0c668c629" dependencies = [ "fitsio-sys", "libc", @@ -669,11 +678,11 @@ dependencies = [ [[package]] name = "fitsio-sys" -version = "0.4.0" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3189ae01f4bcdb8e6b90ec9efe5575a1b12c3e63298bde9fc45694fcc488a595" +checksum = "6f4465f848d35a6e1b41ba0370d8bb1d61774bdfd1549f45222c79b2e46229d4" dependencies = [ - "libc", + "autotools", "pkg-config", ] @@ -923,9 +932,9 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "lexical" @@ -1070,9 +1079,8 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "marlu" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "207d8571a6c2fe51ba60e79bc8f840ae7bb0678168d25d61eb56fabebfd9764d" +version = "0.15.0" +source = "git+https://github.com/MWATelescope/Marlu?branch=mwalib-1.7.1#1b41d88946a29e20b1d982767399b70ad1f8e719" dependencies = [ "approx", "built", @@ -1122,9 +1130,9 @@ dependencies = [ [[package]] name = "mwalib" -version = "1.5.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "268aa01c4343e7250273fd839912fe807df701975a586d488a865238ed16471a" +checksum = "13aadce2f2589bf4d1c11f167c60ec42b9b8e36311cb83e01e76d999c17f2547" dependencies = [ "built", "cbindgen", diff --git a/Cargo.toml b/Cargo.toml index 5581a31..8b4b5db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "birli" description = "A preprocessing pipeline for the Murchison Widefield Array" -version = "0.15.1" +version = "0.16.0" readme = "README.md" homepage = "https://github.com/MWATelescope/Birli" repository = "https://github.com/MWATelescope/Birli" @@ -41,9 +41,9 @@ cfg-if = "1.0.0" derive_builder = "0.11.1" indicatif = { version = "0.17.0", features = ["rayon"] } itertools = "0.10.0" -lazy_static = "1.4.0" +lazy_static = "~1.5" log = "0.4.0" -marlu = "0.14.0" +marlu = "0.15.0" # don't forget dev-dependencies! regex = "1.4.0" thiserror = "1.0.0" @@ -64,7 +64,7 @@ csv = "1.1" float-cmp = "0.9" glob = "0.3" lexical = "6.0" -marlu = { version = "0.14.0", features = ["approx"] } +marlu = { version = "0.15.0", features = ["approx"] } ndarray = { version = "0.16.0", features = ["approx"] } tempfile = "3.3" @@ -91,6 +91,6 @@ opt-level = 3 [patch.crates-io] # marlu = { path = "../Marlu" } -# marlu = { git = "https://github.com/MWATelescope/Marlu", branch = "birli-150" } +marlu = { git = "https://github.com/MWATelescope/Marlu", branch = "mwalib-1.7.1" } # mwalib = { path = "../mwalib" } # mwalib = { git = "https://github.com/MWATelescope/mwalib", branch = "digital_gains_plus" } diff --git a/Makefile.toml b/Makefile.toml index a7ccb3c..ac54495 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -161,6 +161,7 @@ install_crate = "rustfmt" [tasks.clippy] command = "cargo" +# cargo clippy --all-targets --all-features -- -D warnings args = ["clippy", "--all-targets", "--all-features", "--", "-D", "warnings"] install_crate = "clippy" diff --git a/README.md b/README.md index e1fbe1a..1cec2b9 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ cargo test ### Dependencies Experiencing segfaults? I can guarantee it's because of one of the C library dependencies. -Make sure you have the right versions of all the libraries. These are specified in [Prerequisites](#Prerequisites). +Make sure you have the right versions of all the libraries. These are specified in [Prerequisites](#prerequisites). Get library versions on linux with: diff --git a/src/cli.rs b/src/cli.rs index 57c9399..59ba257 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -13,8 +13,8 @@ use indicatif::{ProgressDrawTarget, ProgressStyle}; use itertools::{izip, Itertools}; use log::{debug, info, trace, warn}; use mwalib::{ - built_info::PKG_VERSION as MWALIB_PKG_VERSION, fitsio_sys::CFITSIO_VERSION, CableDelaysApplied, - CorrelatorContext, GeometricDelaysApplied, MWAVersion, + built_info::PKG_VERSION as MWALIB_PKG_VERSION, CableDelaysApplied, CorrelatorContext, + GeometricDelaysApplied, MWAVersion, }; use prettytable::{format as prettyformat, row, table}; @@ -98,7 +98,6 @@ pub fn fmt_build_info(f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { writeln!(f, "libraries:")?; writeln!(f, "- marlu v{MARLU_PKG_VERSION}")?; writeln!(f, "- mwalib v{MWALIB_PKG_VERSION}")?; - writeln!(f, "- cfitsio (bindings) v{CFITSIO_VERSION}")?; cfg_if! { if #[cfg(feature = "aoflagger")] { diff --git a/src/io/mod.rs b/src/io/mod.rs index 1d757df..9235962 100644 --- a/src/io/mod.rs +++ b/src/io/mod.rs @@ -858,12 +858,12 @@ mod tests_aoflagger { unsafe { // ffggpe = fits_read_grppar_flt fitsio_sys::ffggpe( - fptr.as_raw(), /* I - FITS file pointer */ - 1 + *row_idx as i64, /* I - group to read (1 = 1st group) */ - 1, /* I - first vector element to read (1 = 1st) */ - pcount as i64, /* I - number of values to read */ + fptr.fits_file.as_raw(), /* I - FITS file pointer */ + 1 + *row_idx as i64, /* I - group to read (1 = 1st group) */ + 1, /* I - first vector element to read (1 = 1st) */ + pcount as i64, /* I - number of values to read */ obs_group_params.as_mut_ptr(), /* O - array of values that are returned */ - &mut status, /* IO - error status */ + &mut status, /* IO - error status */ ); } fits_check_status(status).unwrap(); @@ -885,14 +885,14 @@ mod tests_aoflagger { unsafe { // ffgpve = fits_read_img_flt fitsio_sys::ffgpve( - fptr.as_raw(), /* I - FITS file pointer */ - 1 + *row_idx as i64, /* I - group to read (1 = 1st group) */ - 1, /* I - first vector element to read (1 = 1st) */ - obs_vis.len() as i64, /* I - number of values to read */ - 0.0, /* I - value for undefined pixels */ - obs_vis.as_mut_ptr(), /* O - array of values that are returned */ - &mut 0, /* O - set to 1 if any values are null; else 0 */ - &mut status, /* IO - error status */ + fptr.fits_file.as_raw(), /* I - FITS file pointer */ + 1 + *row_idx as i64, /* I - group to read (1 = 1st group) */ + 1, /* I - first vector element to read (1 = 1st) */ + obs_vis.len() as i64, /* I - number of values to read */ + 0.0, /* I - value for undefined pixels */ + obs_vis.as_mut_ptr(), /* O - array of values that are returned */ + &mut 0, /* O - set to 1 if any values are null; else 0 */ + &mut status, /* IO - error status */ ); }; fits_check_status(status).unwrap(); diff --git a/src/io/mwaf.rs b/src/io/mwaf.rs index 5d6b366..1c91c58 100644 --- a/src/io/mwaf.rs +++ b/src/io/mwaf.rs @@ -30,6 +30,8 @@ use super::error::{ IOError::{FitsIO, FitsOpen, InvalidFlagFilenameTemplate}, }; +use marlu::mwalib::MWAFitsFile; + /// flag metadata which for a particular flag file in the set. pub(crate) struct FlagFileHeader { /// The `VERSION` key from the primary hdu @@ -226,8 +228,11 @@ impl FlagFileSet { std::fs::remove_file(&gpubox.filename)?; } - match FitsFile::create(&gpubox.filename).open() { - Ok(mut fptr) => Self::write_primary_hdu(&mut fptr, &header, Some(gpubox.id)), + match FitsFile::create(&gpubox.filename.clone()).open() { + Ok(fptr_) => { + let mut fptr = MWAFitsFile::new(gpubox.filename.clone(), fptr_); + Self::write_primary_hdu(&mut fptr, &header, Some(gpubox.id)) + } Err(fits_error) => Err(FitsOpen { fits_error, fits_filename: gpubox.filename.clone(), @@ -258,7 +263,7 @@ impl FlagFileSet { } fn write_primary_hdu( - fptr: &mut FitsFile, + fptr: &mut MWAFitsFile, header: &FlagFileHeader, gpubox_id: Option, ) -> Result<(), IOError> { @@ -283,27 +288,27 @@ impl FlagFileSet { unsafe { // ffplsw = fits_write_key_longwarn fitsio_sys::ffplsw( - fptr.as_raw(), /* I - FITS file pointer */ - &mut status, /* IO - error status */ + fptr.fits_file.as_raw(), /* I - FITS file pointer */ + &mut status, /* IO - error status */ ); fitsio::errors::check_status(status)?; } - hdu.write_key(fptr, "VERSION", version.as_str())?; - hdu.write_key(fptr, "OBSID", *obs_id)?; + hdu.write_key(&mut fptr.fits_file, "VERSION", version.as_str())?; + hdu.write_key(&mut fptr.fits_file, "OBSID", *obs_id)?; // For some silly reason, writing `gps_start` as a float truncates; // writing a string works fine. - hdu.write_key(fptr, "GPSSTART", gps_start.to_string())?; - hdu.write_key(fptr, "NCHANS", *num_channels)?; - hdu.write_key(fptr, "NANTENNA", *num_ants)?; - hdu.write_key(fptr, "NSCANS", *num_timesteps)?; - hdu.write_key(fptr, "NPOLS", *num_pols as u32)?; + hdu.write_key(&mut fptr.fits_file, "GPSSTART", gps_start.to_string())?; + hdu.write_key(&mut fptr.fits_file, "NCHANS", *num_channels)?; + hdu.write_key(&mut fptr.fits_file, "NANTENNA", *num_ants)?; + hdu.write_key(&mut fptr.fits_file, "NSCANS", *num_timesteps)?; + hdu.write_key(&mut fptr.fits_file, "NPOLS", *num_pols as u32)?; if let Some(gpubox_id) = gpubox_id { - hdu.write_key(fptr, "GPUBOXNO", gpubox_id as u32)?; + hdu.write_key(&mut fptr.fits_file, "GPUBOXNO", gpubox_id as u32)?; } - hdu.write_key(fptr, "SOFTWARE", software.as_str())?; + hdu.write_key(&mut fptr.fits_file, "SOFTWARE", software.as_str())?; if let Some(aoflagger_version) = aoflagger_version { - hdu.write_key(fptr, "AO_VER", aoflagger_version.as_str())?; + hdu.write_key(&mut fptr.fits_file, "AO_VER", aoflagger_version.as_str())?; } if let Some(aoflagger_strategy) = aoflagger_strategy.as_deref() { // Write AO_STRAT as a long string. @@ -313,11 +318,11 @@ impl FlagFileSet { unsafe { // ffpkls = fits_write_key_longstr fitsio_sys::ffpkls( - fptr.as_raw(), /* I - FITS file pointer */ - key_name.as_ptr(), /* I - name of keyword to write */ - value.as_ptr(), /* I - keyword value */ - comment.as_ptr(), /* I - keyword comment */ - &mut status, /* IO - error status */ + fptr.fits_file.as_raw(), /* I - FITS file pointer */ + key_name.as_ptr(), /* I - name of keyword to write */ + value.as_ptr(), /* I - keyword value */ + comment.as_ptr(), /* I - keyword comment */ + &mut status, /* IO - error status */ ); fitsio::errors::check_status(status)?; } @@ -332,11 +337,11 @@ impl FlagFileSet { unsafe { // ffpkls = fits_write_key_longstr fitsio_sys::ffpkls( - fptr.as_raw(), /* I - FITS file pointer */ - key_name.as_ptr(), /* I - name of keyword to write */ - value.as_ptr(), /* I - keyword value */ - comment.as_ptr(), /* I - keyword comment */ - &mut status, /* IO - error status */ + fptr.fits_file.as_raw(), /* I - FITS file pointer */ + key_name.as_ptr(), /* I - name of keyword to write */ + value.as_ptr(), /* I - keyword value */ + comment.as_ptr(), /* I - keyword comment */ + &mut status, /* IO - error status */ ); fitsio::errors::check_status(status)?; } @@ -426,14 +431,14 @@ impl FlagFileSet { channel_flag_counts: &mut [u64], baseline_flag_counts: &mut [u64], ) -> Result<(), IOError> { - let mut fptr = FitsFile::edit(filename)?; + let mut fptr = MWAFitsFile::new(filename.into(), FitsFile::edit(filename)?); // If the FLAGS HDU doesn't exist, create it. - let mut row_idx = if fptr.hdu("FLAGS").is_err() { + let mut row_idx = if fptr.fits_file.hdu("FLAGS").is_err() { let col = ColumnDescription::new("FLAGS") .with_type(ColumnDataType::Bit) .that_repeats(num_fine_chans_per_coarse) .create()?; - fptr.create_table("FLAGS", &[col])?; + fptr.fits_file.create_table("FLAGS", &[col])?; // Start the row index from 0. 0 } else { @@ -464,7 +469,7 @@ impl FlagFileSet { unsafe { fitsio_sys::ffpclx( - fptr.as_raw(), + fptr.fits_file.as_raw(), 1, 1 + row_idx as i64, 1, @@ -623,7 +628,7 @@ impl FlagFileSet { } #[cfg(test)] - fn read_header(fptr: &mut FitsFile) -> Result<(FlagFileHeader, Option), ReadMwafError> { + fn read_header(fptr: &mut MWAFitsFile) -> Result<(FlagFileHeader, Option), ReadMwafError> { use mwalib::{_get_optional_fits_key, get_optional_fits_key}; let hdu0 = fits_open_hdu!(fptr, 0)?; @@ -679,8 +684,9 @@ impl FlagFileSet { .map_err(|e| e.to_string())?; let mut header = None; for gpubox in &gpuboxes { - match FitsFile::open(&gpubox.filename) { - Ok(mut fptr) => { + match FitsFile::open(gpubox.filename.clone()) { + Ok(fptr_) => { + let mut fptr = MWAFitsFile::new(gpubox.filename.clone(), fptr_); if header.is_none() { header = Some(Self::read_header(&mut fptr).map_err(|e| e.to_string())?.0); } @@ -725,8 +731,9 @@ impl FlagFileSet { let mut date = None; for gpubox in &gpuboxes { - match FitsFile::open(&gpubox.filename) { - Ok(mut fptr) => { + match FitsFile::open(gpubox.filename.clone()) { + Ok(fptr_) => { + let mut fptr = MWAFitsFile::new(gpubox.filename.clone(), fptr_); let hdu0 = fits_open_hdu!(&mut fptr, 0).unwrap(); let version = get_required_fits_key!(&mut fptr, &hdu0, "VERSION").unwrap(); let obs_id = get_required_fits_key!(&mut fptr, &hdu0, "GPSTIME").unwrap(); @@ -794,7 +801,7 @@ impl FlagFileSet { #[cfg(test)] pub(crate) fn read_flags(&self) -> Result, IOError> { let gpubox = &self.gpuboxes[0]; - let mut fptr = FitsFile::open(&gpubox.filename)?; + let mut fptr = MWAFitsFile::new(gpubox.filename.clone(), FitsFile::open(&gpubox.filename)?); let hdu = fits_open_hdu!(&mut fptr, 0)?; let num_timesteps = get_required_fits_key!(&mut fptr, &hdu, "NSCANS")?; let num_channels_per_mwaf: usize = get_required_fits_key!(&mut fptr, &hdu, "NCHANS")?; @@ -815,7 +822,8 @@ impl FlagFileSet { let mut row_flags = Array1::zeros(num_channels_per_mwaf); for (i_gpubox, gpubox) in self.gpuboxes.iter().enumerate() { - let mut fptr = FitsFile::open(&gpubox.filename)?; + let mut fptr = + MWAFitsFile::new(gpubox.filename.clone(), FitsFile::open(&gpubox.filename)?); fits_open_hdu!(&mut fptr, 1)?; let mut status = 0; // cfitsio won't allow you to read everything in at once. So we read @@ -823,7 +831,7 @@ impl FlagFileSet { for i_row in 0..num_rows { unsafe { fitsio_sys::ffgcx( - fptr.as_raw(), + fptr.fits_file.as_raw(), 1, 1 + i_row as i64, 1, @@ -857,7 +865,7 @@ impl FlagFileSet { use itertools::izip; let gpubox = &self.gpuboxes[0]; - let mut fptr = FitsFile::open(&gpubox.filename)?; + let mut fptr = MWAFitsFile::new(gpubox.filename.clone(), FitsFile::open(&gpubox.filename)?); let hdu = fits_open_hdu!(&mut fptr, 2)?; let num_rows: usize = get_required_fits_key!(&mut fptr, &hdu, "NAXIS2")?; let total_num_channels = num_rows * self.gpuboxes.len(); @@ -872,12 +880,13 @@ impl FlagFileSet { out_count.chunks_mut(num_rows), out_occ.chunks_mut(num_rows), ) { - let mut fptr = FitsFile::open(&gpubox.filename)?; + let mut fptr = + MWAFitsFile::new(gpubox.filename.clone(), FitsFile::open(&gpubox.filename)?); let hdu = fits_open_hdu!(&mut fptr, 2)?; - let tmp_count: Vec = hdu.read_col(&mut fptr, "Count").unwrap(); + let tmp_count: Vec = hdu.read_col(&mut fptr.fits_file, "Count").unwrap(); assert_eq!(tmp_count.len(), out_count.len()); out_count.copy_from_slice(&tmp_count); - let tmp_occ: Vec = hdu.read_col(&mut fptr, "Occupancy").unwrap(); + let tmp_occ: Vec = hdu.read_col(&mut fptr.fits_file, "Occupancy").unwrap(); assert_eq!(tmp_occ.len(), out_occ.len()); out_occ.copy_from_slice(&tmp_occ); } @@ -891,21 +900,22 @@ impl FlagFileSet { &self, ) -> Result<(Vec<(u32, u32)>, Array2, Array2), IOError> { use itertools::izip; + use marlu::mwalib::MWAFitsFile; let gpubox = &self.gpuboxes[0]; - let mut fptr = FitsFile::open(&gpubox.filename)?; + let mut fptr = MWAFitsFile::new(gpubox.filename.clone(), FitsFile::open(&gpubox.filename)?); let hdu = fits_open_hdu!(&mut fptr, 3)?; let num_rows: usize = get_required_fits_key!(&mut fptr, &hdu, "NAXIS2")?; - let ant1s: Vec = hdu.read_col(&mut fptr, "Antenna1").unwrap(); - let ant2s: Vec = hdu.read_col(&mut fptr, "Antenna2").unwrap(); + let ant1s: Vec = hdu.read_col(&mut fptr.fits_file, "Antenna1").unwrap(); + let ant2s: Vec = hdu.read_col(&mut fptr.fits_file, "Antenna2").unwrap(); let ant_pairs = izip!(ant1s.into_iter(), ant2s.into_iter()).collect::>(); let num_coarse_chans = self.gpuboxes.len(); let total_num_baselines = num_rows * num_coarse_chans; let mut out_count = vec![0_u32; total_num_baselines]; let mut out_occ = vec![0.; total_num_baselines]; - drop(fptr); + drop(fptr.fits_file); drop(hdu); for (gpubox, out_count, out_occ) in izip!( @@ -913,12 +923,13 @@ impl FlagFileSet { out_count.chunks_mut(num_rows), out_occ.chunks_mut(num_rows), ) { - let mut fptr = FitsFile::open(&gpubox.filename)?; + let mut fptr = + MWAFitsFile::new(gpubox.filename.clone(), FitsFile::open(&gpubox.filename)?); let hdu = fits_open_hdu!(&mut fptr, 3)?; - let tmp_count: Vec = hdu.read_col(&mut fptr, "Count").unwrap(); + let tmp_count: Vec = hdu.read_col(&mut fptr.fits_file, "Count").unwrap(); assert_eq!(tmp_count.len(), out_count.len()); out_count.copy_from_slice(&tmp_count); - let tmp_occ: Vec = hdu.read_col(&mut fptr, "Occupancy").unwrap(); + let tmp_occ: Vec = hdu.read_col(&mut fptr.fits_file, "Occupancy").unwrap(); assert_eq!(tmp_occ.len(), out_occ.len()); out_occ.copy_from_slice(&tmp_occ); } @@ -959,6 +970,7 @@ mod tests { get_required_fits_key, }, }; + use mwalib::MWAFitsFile; use std::fs::File; use std::path::Path; use tempfile::tempdir; @@ -1115,8 +1127,11 @@ mod tests { .unwrap(); for gpubox in gpuboxes { - let mut fptr = FitsFile::open(gpubox.filename).unwrap(); - let hdu0 = fptr.primary_hdu().unwrap(); + let mut fptr = MWAFitsFile::new( + gpubox.filename.clone(), + FitsFile::open(gpubox.filename).unwrap(), + ); + let hdu0 = fptr.fits_file.primary_hdu().unwrap(); let version: String = get_required_fits_key!(&mut fptr, &hdu0, "VERSION").unwrap(); let obs_id: Option = get_optional_fits_key!(&mut fptr, &hdu0, "OBSID").unwrap(); @@ -1150,24 +1165,13 @@ mod tests { assert_eq!(bytes_per_row, 16); assert_eq!(num_rows, 16512); // Test the other keys cotter writes but we no longer write. - let gpstime: f64 = fptr - .primary_hdu() - .unwrap() - .read_key(&mut fptr, "GPSTIME") - .unwrap(); + let hdu0 = &mut fptr.fits_file.primary_hdu().unwrap(); + let gpstime: f64 = hdu0.read_key(&mut fptr.fits_file, "GPSTIME").unwrap(); assert!((gpstime - 1247842824.0).abs() < f64::EPSILON); - let cotver: String = fptr - .primary_hdu() - .unwrap() - .read_key(&mut fptr, "COTVER") - .unwrap(); + let cotver: String = hdu0.read_key(&mut fptr.fits_file, "COTVER").unwrap(); assert_eq!(cotver, "4.5"); - let cotdate: String = fptr - .primary_hdu() - .unwrap() - .read_key(&mut fptr, "COTVDATE") - .unwrap(); + let cotdate: String = hdu0.read_key(&mut fptr.fits_file, "COTVDATE").unwrap(); assert_eq!(cotdate, "2020-08-10"); } } @@ -1219,7 +1223,8 @@ mod tests { { for (&gpubox_id, path) in &gpubox_paths { - let mut fptr = FitsFile::create(path).open().unwrap(); + let mut fptr = + MWAFitsFile::new(path.clone(), FitsFile::create(path).open().unwrap()); let header = FlagFileHeader { version: "2.0".to_string(), obs_id: context.metafits_context.obs_id, @@ -1240,8 +1245,9 @@ mod tests { } for (&gpubox_id, path) in &gpubox_paths { - let mut flag_fptr = FitsFile::open(path).unwrap(); - let hdu = flag_fptr.primary_hdu().unwrap(); + let mut flag_fptr = + MWAFitsFile::new(path.clone(), FitsFile::open(path.clone()).unwrap()); + let hdu = flag_fptr.fits_file.primary_hdu().unwrap(); let obsid: i32 = get_required_fits_key!(&mut flag_fptr, &hdu, "OBSID").unwrap(); assert_eq!(obsid, context.metafits_context.obs_id as i32); diff --git a/src/test_common.rs b/src/test_common.rs index 823de93..67c2af5 100644 --- a/src/test_common.rs +++ b/src/test_common.rs @@ -268,12 +268,12 @@ pub fn compare_uvfits_with_csv( unsafe { // ffggpe = fits_read_grppar_flt fitsio_sys::ffggpd( - fptr.as_raw(), /* I - FITS file pointer */ - 1 + row_idx as i64, /* I - group to read (1 = 1st group) */ - 1, /* I - first vector element to read (1 = 1st) */ - pcount as i64, /* I - number of values to read */ + fptr.fits_file.as_raw(), /* I - FITS file pointer */ + 1 + row_idx as i64, /* I - group to read (1 = 1st group) */ + 1, /* I - first vector element to read (1 = 1st) */ + pcount as i64, /* I - number of values to read */ obs_group_params.as_mut_ptr(), /* O - array of values that are returned */ - &mut status, /* IO - error status */ + &mut status, /* IO - error status */ ); } fits_check_status(status).unwrap(); @@ -315,14 +315,14 @@ pub fn compare_uvfits_with_csv( unsafe { // ffgpve = fits_read_img_flt fitsio_sys::ffgpve( - fptr.as_raw(), /* I - FITS file pointer */ - 1 + row_idx as i64, /* I - group to read (1 = 1st group) */ - 1, /* I - first vector element to read (1 = 1st) */ - obs_vis.len() as i64, /* I - number of values to read */ - 0.0, /* I - value for undefined pixels */ - obs_vis.as_mut_ptr(), /* O - array of values that are returned */ - &mut 0, /* O - set to 1 if any values are null; else 0 */ - &mut status, /* IO - error status */ + fptr.fits_file.as_raw(), /* I - FITS file pointer */ + 1 + row_idx as i64, /* I - group to read (1 = 1st group) */ + 1, /* I - first vector element to read (1 = 1st) */ + obs_vis.len() as i64, /* I - number of values to read */ + 0.0, /* I - value for undefined pixels */ + obs_vis.as_mut_ptr(), /* O - array of values that are returned */ + &mut 0, /* O - set to 1 if any values are null; else 0 */ + &mut status, /* IO - error status */ ); }; fits_check_status(status).unwrap();