diff --git a/CHANGELOG.md b/CHANGELOG.md index ced6d95..298dd93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ Changes in each release are listed below. +## 1.7.0 18-Oct-2024 + +* Update fitsio to 0.21 and fitsio-sys to 0.5 + ## 1.6.0 18-Oct-2024 * Updated ndarray to 0.16 diff --git a/Cargo.toml b/Cargo.toml index 459e55e..cef16fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mwalib" -version = "1.6.0" +version = "1.7.0" homepage = "https://github.com/MWATelescope/mwalib" repository = "https://github.com/MWATelescope/mwalib" readme = "README.md" @@ -29,8 +29,8 @@ python = ["pyo3", "numpy", "ndarray"] [dependencies] chrono = "0.4.38" -fitsio = "~0.20" -fitsio-sys = "~0.4" +fitsio = "~0.21" +fitsio-sys = "~0.5" lazy_static = "~1.5" libc = "~0.2" log = "~0.4" diff --git a/src/coarse_channel/mod.rs b/src/coarse_channel/mod.rs index b5f304c..5d8bc5b 100644 --- a/src/coarse_channel/mod.rs +++ b/src/coarse_channel/mod.rs @@ -105,7 +105,7 @@ impl CoarseChannel { /// /// # Arguments /// - /// `metafits_fptr` - a reference to a metafits FitsFile object. + /// `metafits_fptr` - a reference to a metafits MWAFitsFile object. /// /// `metafits_hdu` - a reference to a metafits primary HDU. /// @@ -118,7 +118,7 @@ impl CoarseChannel { /// The width in Hz of each coarse channel /// pub(crate) fn get_metafits_coarse_channel_info( - metafits_fptr: &mut fitsio::FitsFile, + metafits_fptr: &mut MWAFitsFile, hdu: &fitsio::hdu::FitsHdu, observation_bandwidth_hz: u32, ) -> Result<(Vec, u32), FitsError> { diff --git a/src/correlator_context/mod.rs b/src/correlator_context/mod.rs index 0d92011..80cf173 100644 --- a/src/correlator_context/mod.rs +++ b/src/correlator_context/mod.rs @@ -782,7 +782,7 @@ impl CorrelatorContext { /// /// * `visibility_pols` - the number of pols produced by the correlator (always 4 for MWA) /// - /// * `gpubox_fptr` - FITSFile pointer to an MWA GPUbox file + /// * `gpubox_fptr` - MWAFITSFile pointer to an MWA GPUbox file /// /// # Returns /// @@ -794,7 +794,7 @@ impl CorrelatorContext { metafits_fine_chans_per_coarse: usize, metafits_baselines: usize, visibility_pols: usize, - gpubox_fptr: &mut fitsio::FitsFile, + gpubox_fptr: &mut MWAFitsFile, ) -> Result<(), GpuboxError> { // Get NAXIS1 and NAXIS2 from a gpubox file first image HDU let hdu = fits_open_hdu!(gpubox_fptr, 1)?; diff --git a/src/ffi/mod.rs b/src/ffi/mod.rs index e7a9002..2104bb6 100644 --- a/src/ffi/mod.rs +++ b/src/ffi/mod.rs @@ -1856,25 +1856,22 @@ pub unsafe extern "C" fn mwalib_metafits_metadata_get( // Populate signal chain corrections let mut signal_chain_corrections_vec: Vec = Vec::new(); - match &metafits_context.signal_chain_corrections { - Some(v) => { - for item in v.iter() { - let out_item = { - let metafits_context::SignalChainCorrection { - receiver_type, - whitening_filter, - corrections, - } = item; - ffi::SignalChainCorrection { - receiver_type: *receiver_type, - whitening_filter: *whitening_filter, - corrections: ffi_array_to_boxed_slice(corrections.clone()), - } - }; - signal_chain_corrections_vec.push(out_item); - } + if let Some(v) = &metafits_context.signal_chain_corrections { + for item in v.iter() { + let out_item = { + let metafits_context::SignalChainCorrection { + receiver_type, + whitening_filter, + corrections, + } = item; + ffi::SignalChainCorrection { + receiver_type: *receiver_type, + whitening_filter: *whitening_filter, + corrections: ffi_array_to_boxed_slice(corrections.clone()), + } + }; + signal_chain_corrections_vec.push(out_item); } - None => {} } // Populate the outgoing structure with data from the metafits context diff --git a/src/fits_read/mod.rs b/src/fits_read/mod.rs index cbbd14d..8d84d39 100644 --- a/src/fits_read/mod.rs +++ b/src/fits_read/mod.rs @@ -5,8 +5,8 @@ //! Helper functions for reading FITS files. pub(crate) mod error; +pub use crate::mwa_fits_file::MWAFitsFile; pub use error::FitsError; - use fitsio::{hdu::*, FitsFile}; use log::trace; use std::ffi::*; @@ -293,14 +293,13 @@ pub fn _open_fits>( file: T, source_file: &'static str, source_line: u32, -) -> Result { - match FitsFile::open(file.as_ref()) { +) -> Result { + match FitsFile::open(&file) { Ok(f) => { - trace!( - "_open_fits() filename: '{}'", - file.as_ref().to_str().unwrap().to_string() - ); - Ok(f) + trace!("_open_fits() filename: '{}'", file.as_ref().display()); + + // Create the wrapper/MWAFitsFile + Ok(MWAFitsFile::new(file.as_ref().to_path_buf(), f)) } Err(e) => Err(FitsError::Open { fits_error: e, @@ -316,12 +315,12 @@ pub fn _open_fits>( /// To only be used internally; use the `fits_open_hdu!` macro instead. #[doc(hidden)] pub fn _open_hdu( - fits_fptr: &mut FitsFile, + fits_fptr: &mut MWAFitsFile, hdu_num: usize, source_file: &'static str, source_line: u32, ) -> Result { - match fits_fptr.hdu(hdu_num) { + match fits_fptr.fits_file.hdu(hdu_num) { Ok(f) => { trace!( "_open_hdu() filename: '{}' hdu: {}", @@ -345,12 +344,12 @@ pub fn _open_hdu( /// To only be used internally; use the `fits_open_hdu_by_name!` macro instead. #[doc(hidden)] pub fn _open_hdu_by_name( - fits_fptr: &mut FitsFile, + fits_fptr: &mut MWAFitsFile, hdu_name: &'static str, source_file: &'static str, source_line: u32, ) -> Result { - match fits_fptr.hdu(hdu_name) { + match fits_fptr.fits_file.hdu(hdu_name) { Ok(f) => { trace!( "_open_hdu_by_name() filename: '{}' hdu: {}", @@ -381,13 +380,13 @@ pub fn _open_hdu_by_name( // #[doc(hidden)] pub fn _get_optional_fits_key( - fits_fptr: &mut FitsFile, + fits_fptr: &mut MWAFitsFile, hdu: &FitsHdu, keyword: &str, source_file: &'static str, source_line: u32, ) -> Result, FitsError> { - let unparsed_value: String = match hdu.read_key(fits_fptr, keyword) { + let unparsed_value: String = match hdu.read_key(&mut fits_fptr.fits_file, keyword) { Ok(key_value) => key_value, Err(e) => match &e { fitsio::errors::Error::Fits(fe) => match fe.status { @@ -439,7 +438,7 @@ pub fn _get_optional_fits_key( /// To only be used internally; use the `get_required_fits_key!` macro instead. #[doc(hidden)] pub fn _get_required_fits_key( - fits_fptr: &mut FitsFile, + fits_fptr: &mut MWAFitsFile, hdu: &FitsHdu, keyword: &str, source_file: &'static str, @@ -463,13 +462,13 @@ pub fn _get_required_fits_key( /// To only be used internally; use the `fits_get_col!` macro instead. #[doc(hidden)] pub fn _get_fits_col( - fits_fptr: &mut FitsFile, + fits_fptr: &mut MWAFitsFile, hdu: &FitsHdu, keyword: &str, source_file: &'static str, source_line: u32, ) -> Result, FitsError> { - match hdu.read_col(fits_fptr, keyword) { + match hdu.read_col(&mut fits_fptr.fits_file, keyword) { Ok(c) => { trace!( "_get_fits_col() filename: '{}' hdu: {} keyword: '{}' values: {}", @@ -507,7 +506,7 @@ pub fn _get_fits_col( /// This function calls cfitsio. Anything goes! #[doc(hidden)] pub fn _get_optional_fits_key_long_string( - fits_fptr: &mut fitsio::FitsFile, + fits_fptr: &mut MWAFitsFile, hdu: &FitsHdu, keyword: &str, source_file: &'static str, @@ -520,7 +519,7 @@ pub fn _get_optional_fits_key_long_string( let mut status = 0; let mut long_string_ptr = ptr::null_mut(); fitsio_sys::ffgkls( - fits_fptr.as_raw(), + fits_fptr.fits_file.as_raw(), keyword_ffi.as_ptr(), &mut long_string_ptr, ptr::null_mut(), @@ -567,7 +566,7 @@ pub fn _get_optional_fits_key_long_string( /// macro instead. #[doc(hidden)] pub fn _get_required_fits_key_long_string( - fits_fptr: &mut FitsFile, + fits_fptr: &mut MWAFitsFile, hdu: &FitsHdu, keyword: &str, source_file: &'static str, @@ -591,7 +590,7 @@ pub fn _get_required_fits_key_long_string( /// To only be used internally; use the `get_hdu_image_size!` macro instead. #[doc(hidden)] pub fn _get_hdu_image_size( - fits_fptr: &mut FitsFile, + fits_fptr: &mut MWAFitsFile, hdu: &FitsHdu, source_file: &'static str, source_line: u32, @@ -620,13 +619,13 @@ pub fn _get_hdu_image_size( /// To only be used internally; use the `get_fits_image!` macro instead. #[doc(hidden)] pub fn _get_fits_image( - fits_fptr: &mut FitsFile, + fits_fptr: &mut MWAFitsFile, hdu: &FitsHdu, source_file: &'static str, source_line: u32, ) -> Result { match &hdu.info { - HduInfo::ImageInfo { .. } => match hdu.read_image(fits_fptr) { + HduInfo::ImageInfo { .. } => match hdu.read_image(&mut fits_fptr.fits_file) { Ok(img) => { trace!( "_get_fits_image() filename: '{}' hdu: {}", @@ -655,7 +654,7 @@ pub fn _get_fits_image( /// Direct read of FITS HDU #[doc(hidden)] pub fn _get_fits_float_img_into_buf( - fits_fptr: &mut FitsFile, + fits_fptr: &mut MWAFitsFile, hdu: &FitsHdu, buffer: &mut [f32], source_file: &'static str, @@ -669,7 +668,7 @@ pub fn _get_fits_float_img_into_buf( // Call the underlying cfitsio read function for floats let mut status = 0; fitsio_sys::ffgpv( - fits_fptr.as_raw(), + fits_fptr.fits_file.as_raw(), fitsio_sys::TFLOAT as _, 1, buffer_len, @@ -704,25 +703,25 @@ pub fn _get_fits_float_img_into_buf( } pub fn read_cell_value( - metafits_fptr: &mut fitsio::FitsFile, - metafits_tile_table_hdu: &fitsio::hdu::FitsHdu, + fits_fptr: &mut MWAFitsFile, + fits_tile_table_hdu: &fitsio::hdu::FitsHdu, col_name: &str, row: usize, ) -> Result { - match metafits_tile_table_hdu.read_cell_value(metafits_fptr, col_name, row) { + match fits_tile_table_hdu.read_cell_value(&mut fits_fptr.fits_file, col_name, row) { Ok(c) => { trace!( "read_cell_value() filename: '{}' hdu: {} col_name: '{}' row '{}'", - metafits_fptr.filename.display(), - metafits_tile_table_hdu.number, + fits_fptr.filename.display(), + fits_tile_table_hdu.number, col_name, row ); Ok(c) } Err(_) => Err(FitsError::ReadCell { - fits_filename: metafits_fptr.filename.clone(), - hdu_num: metafits_tile_table_hdu.number + 1, + fits_filename: fits_fptr.filename.clone(), + hdu_num: fits_tile_table_hdu.number + 1, row_num: row, col_name: col_name.to_string(), }), @@ -731,8 +730,8 @@ pub fn read_cell_value( /// Pull out the array-in-a-cell values. T pub fn read_cell_array_u32( - metafits_fptr: &mut fitsio::FitsFile, - metafits_table_hdu: &fitsio::hdu::FitsHdu, + fits_fptr: &mut MWAFitsFile, + fits_table_hdu: &fitsio::hdu::FitsHdu, col_name: &str, row: i64, n_elem: usize, @@ -743,7 +742,7 @@ pub fn read_cell_array_u32( let mut col_num = -1; let keyword = std::ffi::CString::new(col_name).unwrap().into_raw(); fitsio_sys::ffgcno( - metafits_fptr.as_raw(), + fits_fptr.fits_file.as_raw(), 0, keyword, &mut col_num, @@ -752,8 +751,8 @@ pub fn read_cell_array_u32( // Check the status. if status != 0 { return Err(FitsError::CellArray { - fits_filename: metafits_fptr.filename.clone(), - hdu_num: metafits_table_hdu.number, + fits_filename: fits_fptr.filename.clone(), + hdu_num: fits_table_hdu.number, row_num: row, col_name: col_name.to_string(), }); @@ -767,7 +766,7 @@ pub fn read_cell_array_u32( array.shrink_to_fit(); let array_ptr = array.as_mut_ptr(); fitsio_sys::ffgcv( - metafits_fptr.as_raw(), + fits_fptr.fits_file.as_raw(), 31, col_num, row + 1, @@ -787,8 +786,8 @@ pub fn read_cell_array_u32( trace!( "read_cell_array_u32() filename: '{}' hdu: {} col_name: '{}' row '{}'", - metafits_fptr.filename.display(), - metafits_table_hdu.number, + fits_fptr.filename.display(), + fits_table_hdu.number, col_name, row ); @@ -799,15 +798,15 @@ pub fn read_cell_array_u32( println!( "ERROR {} read_cell_array_u32() filename: '{}' hdu: {} col_name: '{}' row '{}'", status, - metafits_fptr.filename.display(), - metafits_table_hdu.number, + fits_fptr.filename.display(), + fits_table_hdu.number, col_name, row ); Err(FitsError::CellArray { - fits_filename: metafits_fptr.filename.clone(), - hdu_num: metafits_table_hdu.number + 1, + fits_filename: fits_fptr.filename.clone(), + hdu_num: fits_table_hdu.number + 1, row_num: row, col_name: col_name.to_string(), }) @@ -820,8 +819,8 @@ pub fn read_cell_array_u32( /// datatype is f32, and that the fits datatype is E (f32), so it is not to be used /// generally! pub fn read_cell_array_f32( - metafits_fptr: &mut fitsio::FitsFile, - metafits_table_hdu: &fitsio::hdu::FitsHdu, + fits_fptr: &mut MWAFitsFile, + fits_table_hdu: &fitsio::hdu::FitsHdu, col_name: &str, row: i64, n_elem: usize, @@ -832,7 +831,7 @@ pub fn read_cell_array_f32( let mut col_num = -1; let keyword = std::ffi::CString::new(col_name).unwrap().into_raw(); fitsio_sys::ffgcno( - metafits_fptr.as_raw(), + fits_fptr.fits_file.as_raw(), 0, keyword, &mut col_num, @@ -841,8 +840,8 @@ pub fn read_cell_array_f32( // Check the status. if status != 0 { return Err(FitsError::CellArray { - fits_filename: metafits_fptr.filename.clone(), - hdu_num: metafits_table_hdu.number, + fits_filename: fits_fptr.filename.clone(), + hdu_num: fits_table_hdu.number, row_num: row, col_name: col_name.to_string(), }); @@ -860,7 +859,7 @@ pub fn read_cell_array_f32( //let nullval_ptr: *mut c_void = &mut null_replace_value as *mut f32 as *mut c_void; fitsio_sys::ffgcv( - metafits_fptr.as_raw(), + fits_fptr.fits_file.as_raw(), 42, col_num, row + 1, @@ -877,8 +876,8 @@ pub fn read_cell_array_f32( 0 => { trace!( "read_cell_array_f32() filename: '{}' hdu: {} col_name: '{}' row '{}'", - metafits_fptr.filename.display(), - metafits_table_hdu.number, + fits_fptr.filename.display(), + fits_table_hdu.number, col_name, row ); @@ -890,15 +889,15 @@ pub fn read_cell_array_f32( println!( "ERROR {} read_cell_array_f32() filename: '{}' hdu: {} col_name: '{}' row '{}'", status, - metafits_fptr.filename.display(), - metafits_table_hdu.number, + fits_fptr.filename.display(), + fits_table_hdu.number, col_name, row ); Err(FitsError::CellArray { - fits_filename: metafits_fptr.filename.clone(), - hdu_num: metafits_table_hdu.number + 1, + fits_filename: fits_fptr.filename.clone(), + hdu_num: fits_table_hdu.number + 1, row_num: row, col_name: col_name.to_string(), }) @@ -911,8 +910,8 @@ pub fn read_cell_array_f32( /// datatype is f64, and that the fits datatype is D (f64), so it is not to be used /// generally! pub fn read_cell_array_f64( - metafits_fptr: &mut fitsio::FitsFile, - metafits_table_hdu: &fitsio::hdu::FitsHdu, + fits_fptr: &mut MWAFitsFile, + fits_table_hdu: &fitsio::hdu::FitsHdu, col_name: &str, row: i64, n_elem: usize, @@ -923,7 +922,7 @@ pub fn read_cell_array_f64( let mut col_num = -1; let keyword = std::ffi::CString::new(col_name).unwrap().into_raw(); fitsio_sys::ffgcno( - metafits_fptr.as_raw(), + fits_fptr.fits_file.as_raw(), 0, keyword, &mut col_num, @@ -932,8 +931,8 @@ pub fn read_cell_array_f64( // Check the status. if status != 0 { return Err(FitsError::CellArray { - fits_filename: metafits_fptr.filename.clone(), - hdu_num: metafits_table_hdu.number, + fits_filename: fits_fptr.filename.clone(), + hdu_num: fits_table_hdu.number, row_num: row, col_name: col_name.to_string(), }); @@ -951,7 +950,7 @@ pub fn read_cell_array_f64( //let nullval_ptr: *mut c_void = &mut null_replace_value as *mut f32 as *mut c_void; fitsio_sys::ffgcv( - metafits_fptr.as_raw(), + fits_fptr.fits_file.as_raw(), 82, col_num, row + 1, @@ -968,8 +967,8 @@ pub fn read_cell_array_f64( 0 => { trace!( "read_cell_array_f64() filename: '{}' hdu: {} col_name: '{}' row '{}'", - metafits_fptr.filename.display(), - metafits_table_hdu.number, + fits_fptr.filename.display(), + fits_table_hdu.number, col_name, row ); @@ -981,15 +980,15 @@ pub fn read_cell_array_f64( println!( "ERROR {} read_cell_array_f64() filename: '{}' hdu: {} col_name: '{}' row '{}'", status, - metafits_fptr.filename.display(), - metafits_table_hdu.number, + fits_fptr.filename.display(), + fits_table_hdu.number, col_name, row ); Err(FitsError::CellArray { - fits_filename: metafits_fptr.filename.clone(), - hdu_num: metafits_table_hdu.number + 1, + fits_filename: fits_fptr.filename.clone(), + hdu_num: fits_table_hdu.number + 1, row_num: row, col_name: col_name.to_string(), }) diff --git a/src/fits_read/test.rs b/src/fits_read/test.rs index 8052349..a174cdb 100644 --- a/src/fits_read/test.rs +++ b/src/fits_read/test.rs @@ -26,7 +26,8 @@ fn test_get_hdu_image_size_image() { }; // Create a new image HDU - fptr.create_image("EXTNAME".to_string(), &image_description) + fptr.fits_file + .create_image("EXTNAME".to_string(), &image_description) .unwrap(); let hdu = fits_open_hdu!(fptr, 1).expect("Couldn't open HDU 1"); @@ -56,7 +57,8 @@ fn test_get_hdu_image_size_non_image() { .unwrap(); let descriptions = [first_description, second_description]; - fptr.create_table("EXTNAME".to_string(), &descriptions) + fptr.fits_file + .create_table("EXTNAME".to_string(), &descriptions) .unwrap(); let hdu = fits_open_hdu!(fptr, 1).expect("Couldn't open HDU 1"); @@ -78,12 +80,15 @@ fn test_get_fits_image_valid_f32() { }; // Create a new image HDU - fptr.create_image("EXTNAME".to_string(), &image_description) + fptr.fits_file + .create_image("EXTNAME".to_string(), &image_description) .unwrap(); let hdu = fits_open_hdu!(fptr, 1).expect("Couldn't open HDU 1"); // Write some data - assert!(hdu.write_image(fptr, &[1.0, 2.0, 3.0]).is_ok()); + assert!(hdu + .write_image(&mut fptr.fits_file, &[1.0, 2.0, 3.0]) + .is_ok()); // Run our test, check dimensions let size_vec = get_hdu_image_size!(fptr, &hdu).unwrap(); @@ -112,12 +117,13 @@ fn test_get_fits_image_valid_i32() { }; // Create a new image HDU - fptr.create_image("EXTNAME".to_string(), &image_description) + fptr.fits_file + .create_image("EXTNAME".to_string(), &image_description) .unwrap(); let hdu = fits_open_hdu!(fptr, 1).expect("Couldn't open HDU 1"); // Write some data - assert!(hdu.write_image(fptr, &[-1, 0, 1]).is_ok()); + assert!(hdu.write_image(&mut fptr.fits_file, &[-1, 0, 1]).is_ok()); // Run our test, check dimensions let size_vec = get_hdu_image_size!(fptr, &hdu).unwrap(); @@ -146,12 +152,15 @@ fn test_get_fits_image_invalid() { }; // Create a new image HDU - fptr.create_image("EXTNAME".to_string(), &image_description) + fptr.fits_file + .create_image("EXTNAME".to_string(), &image_description) .unwrap(); let hdu = fits_open_hdu!(fptr, 1).expect("Couldn't open HDU 1"); // Write some data - assert!(hdu.write_image(fptr, &[-12345678, 0, 12345678]).is_ok()); + assert!(hdu + .write_image(&mut fptr.fits_file, &[-12345678, 0, 12345678]) + .is_ok()); // Run our test, check dimensions let size_vec = get_hdu_image_size!(fptr, &hdu).unwrap(); @@ -194,7 +203,8 @@ fn test_get_fits_image_not_image() { .unwrap(); let descriptions = [first_description, second_description]; - fptr.create_table("EXTNAME".to_string(), &descriptions) + fptr.fits_file + .create_table("EXTNAME".to_string(), &descriptions) .unwrap(); let hdu = fits_open_hdu!(fptr, 1).expect("Couldn't open HDU 1"); @@ -225,22 +235,22 @@ fn test_get_required_fits_key() { assert!(doesnt_exist.is_err()); // Key types must be i64 to get any sort of sanity. - hdu.write_key(fptr, "foo", 10i64) + hdu.write_key(&mut fptr.fits_file, "foo", 10i64) .expect("Couldn't write key 'foo'"); - hdu.write_key(fptr, "bar", -5i64) + hdu.write_key(&mut fptr.fits_file, "bar", -5i64) .expect("Couldn't write key 'bar'"); // Verify that using the normal `fitsio` gives the wrong result, unless // the type is an i64. - let fits_value_i32 = hdu.read_key::(fptr, "FOO"); - let fits_value_i64 = hdu.read_key::(fptr, "FOO"); + let fits_value_i32 = hdu.read_key::(&mut fptr.fits_file, "FOO"); + let fits_value_i64 = hdu.read_key::(&mut fptr.fits_file, "FOO"); assert!(fits_value_i32.is_ok()); assert!(fits_value_i64.is_ok()); assert_eq!(fits_value_i32.unwrap(), 1); assert_eq!(fits_value_i64.unwrap(), 10); // Despite writing to "fits_value", the key is written as "FOO". - let fits_value_i64 = hdu.read_key::(fptr, "FOO"); + let fits_value_i64 = hdu.read_key::(&mut fptr.fits_file, "FOO"); assert!(fits_value_i64.is_ok()); assert_eq!(fits_value_i64.unwrap(), 10); @@ -264,7 +274,7 @@ fn test_get_required_fits_key() { fn test_get_optional_fits_key() { // with_temp_file creates a temp dir and temp file, then removes them once out of scope with_new_temp_fits_file("test_fits_read_key.fits", |fptr| { - let hdu = fptr.hdu(0).expect("Couldn't open HDU 0"); + let hdu = fptr.fits_file.hdu(0).expect("Couldn't open HDU 0"); // Failure to get a key that doesn't exist is OK if we're using the optional variant. let fits_value: Result, _> = get_optional_fits_key!(fptr, &hdu, "foo"); @@ -272,22 +282,22 @@ fn test_get_optional_fits_key() { assert!(fits_value.unwrap().is_none()); // Key types must be i64 to get any sort of sanity. - hdu.write_key(fptr, "foo", 10i64) + hdu.write_key(&mut fptr.fits_file, "foo", 10i64) .expect("Couldn't write key 'foo'"); - hdu.write_key(fptr, "bar", -5i64) + hdu.write_key(&mut fptr.fits_file, "bar", -5i64) .expect("Couldn't write key 'bar'"); // Verify that using the normal `fitsio` gives the wrong result, unless // the type is an i64. - let fits_value_i32 = hdu.read_key::(fptr, "FOO"); - let fits_value_i64 = hdu.read_key::(fptr, "FOO"); + let fits_value_i32 = hdu.read_key::(&mut fptr.fits_file, "FOO"); + let fits_value_i64 = hdu.read_key::(&mut fptr.fits_file, "FOO"); assert!(fits_value_i32.is_ok()); assert!(fits_value_i64.is_ok()); assert_eq!(fits_value_i32.unwrap(), 1); assert_eq!(fits_value_i64.unwrap(), 10); // Despite writing to "foo", the key is written as "FOO". - let fits_value_i64 = hdu.read_key::(fptr, "FOO"); + let fits_value_i64 = hdu.read_key::(&mut fptr.fits_file, "FOO"); assert!(fits_value_i64.is_ok()); assert_eq!(fits_value_i64.unwrap(), 10); @@ -319,7 +329,7 @@ fn test_get_required_fits_key_string() { assert!(does_not_exist.is_err()); // Add a test string - hdu.write_key(fptr, "fits_value", "hello") + hdu.write_key(&mut fptr.fits_file, "fits_value", "hello") .expect("Couldn't write key 'fits_value'"); // Read fits_value back in @@ -334,7 +344,7 @@ fn test_get_required_fits_key_string() { fn test_get_optional_fits_key_string() { // with_temp_file creates a temp dir and temp file, then removes them once out of scope with_new_temp_fits_file("test_fits_read_key_string.fits", |fptr| { - let hdu = fptr.hdu(0).expect("Couldn't open HDU 0"); + let hdu = fptr.fits_file.hdu(0).expect("Couldn't open HDU 0"); // No Failure to get a key that doesn't exist. let does_not_exist: Result, FitsError> = @@ -344,7 +354,7 @@ fn test_get_optional_fits_key_string() { assert!(does_not_exist.unwrap().is_none()); // Add a test string - hdu.write_key(fptr, "fits_value", "hello") + hdu.write_key(&mut fptr.fits_file, "fits_value", "hello") .expect("Couldn't write key 'fits_value'"); // Read fits_value back in @@ -367,7 +377,7 @@ fn test_get_fits_long_string() { // Sadly, rust's `fitsio` library doesn't support writing long strings // with CONTINUE statements. We have to do it for ourselves. unsafe { - let fptr_ffi = fptr.as_raw(); + let fptr_ffi = fptr.fits_file.as_raw(); let keyword_ffi = CString::new("foo").expect("get_fits_long_string: CString::new() failed for 'foo'"); let value_ffi = CString::new(complete_string) @@ -383,19 +393,19 @@ fn test_get_fits_long_string() { ); } - let hdu = fptr.hdu(0).unwrap(); + let hdu = fptr.fits_file.hdu(0).unwrap(); let fits_value_str = get_required_fits_key_long_string!(fptr, &hdu, "FOO"); assert!(fits_value_str.is_ok()); assert_eq!(fits_value_str.unwrap(), complete_string); // Try out the `fitsio` read key. - let hdu = fptr.hdu(0).expect("Couldn't open HDU 0"); - let fitsio_str = hdu.read_key::(fptr, "FOO"); + let hdu = fptr.fits_file.hdu(0).expect("Couldn't open HDU 0"); + let fitsio_str = hdu.read_key::(&mut fptr.fits_file, "FOO"); assert!(fitsio_str.is_ok()); assert_eq!(fitsio_str.unwrap(), first_string); // A repeated read just returns the first string again. - let fitsio_str = hdu.read_key::(fptr, "FOO"); + let fitsio_str = hdu.read_key::(&mut fptr.fits_file, "FOO"); assert!(fitsio_str.is_ok()); assert_eq!(fitsio_str.unwrap(), first_string); }); @@ -411,7 +421,7 @@ fn test_get_required_fits_long_string() { // Sadly, rust's `fitsio` library doesn't support writing long strings // with CONTINUE statements. We have to do it for ourselves. unsafe { - let fptr_ffi = fptr.as_raw(); + let fptr_ffi = fptr.fits_file.as_raw(); let keyword_ffi = CString::new("foo").expect("get_fits_long_string: CString::new() failed for 'foo'"); let value_ffi = CString::new(complete_string) @@ -427,7 +437,7 @@ fn test_get_required_fits_long_string() { ); } - let hdu = fptr.hdu(0).expect("Couldn't open HDU 0"); + let hdu = fptr.fits_file.hdu(0).expect("Couldn't open HDU 0"); // Check for a valid long string let result1 = get_required_fits_key_long_string!(fptr, &hdu, "FOO"); @@ -435,13 +445,13 @@ fn test_get_required_fits_long_string() { assert_eq!(result1.unwrap(), complete_string); // Try out the `fitsio` read key. - let hdu = fptr.hdu(0).expect("Couldn't open HDU 0"); - let fitsio_str = hdu.read_key::(fptr, "FOO"); + let hdu = fptr.fits_file.hdu(0).expect("Couldn't open HDU 0"); + let fitsio_str = hdu.read_key::(&mut fptr.fits_file, "FOO"); assert!(fitsio_str.is_ok()); assert_eq!(fitsio_str.unwrap(), first_string); // A repeated read just returns the first string again. - let fitsio_str = hdu.read_key::(fptr, "FOO"); + let fitsio_str = hdu.read_key::(&mut fptr.fits_file, "FOO"); assert!(fitsio_str.is_ok()); assert_eq!(fitsio_str.unwrap(), first_string); @@ -470,7 +480,7 @@ fn test_get_optional_fits_long_string() { // Sadly, rust's `fitsio` library doesn't support writing long strings // with CONTINUE statements. We have to do it for ourselves. unsafe { - let fptr_ffi = fptr.as_raw(); + let fptr_ffi = fptr.fits_file.as_raw(); let keyword_ffi = CString::new("foo").expect("get_fits_long_string: CString::new() failed for 'foo'"); let value_ffi = CString::new(complete_string) @@ -486,7 +496,7 @@ fn test_get_optional_fits_long_string() { ); } - let hdu = fptr.hdu(0).expect("Couldn't open HDU 0"); + let hdu = fptr.fits_file.hdu(0).expect("Couldn't open HDU 0"); // Read a key that IS there let result1 = get_optional_fits_key_long_string!(fptr, &hdu, "FOO"); @@ -497,12 +507,12 @@ fn test_get_optional_fits_long_string() { assert_eq!(fits_value1_str.unwrap(), complete_string); // Try out the `fitsio` read key. - let fitsio_str = hdu.read_key::(fptr, "FOO"); + let fitsio_str = hdu.read_key::(&mut fptr.fits_file, "FOO"); assert!(fitsio_str.is_ok()); assert_eq!(fitsio_str.unwrap(), first_string); // A repeated read just returns the first string again. - let fitsio_str = hdu.read_key::(fptr, "FOO"); + let fitsio_str = hdu.read_key::(&mut fptr.fits_file, "FOO"); assert!(fitsio_str.is_ok()); assert_eq!(fitsio_str.unwrap(), first_string); @@ -525,7 +535,7 @@ fn test_get_fits_long_string_failure() { // Sadly, rust's `fitsio` library doesn't support writing long strings // with CONTINUE statements. We have to do it for ourselves. unsafe { - let fptr_ffi = fptr.as_raw(); + let fptr_ffi = fptr.fits_file.as_raw(); let keyword_ffi = CString::new("fits_value") .expect("get_fits_long_string: CString::new() failed for 'fits_value'"); let value_ffi = CString::new(complete_string) @@ -541,7 +551,7 @@ fn test_get_fits_long_string_failure() { ); } - let hdu = fptr.hdu(0).unwrap(); + let hdu = fptr.fits_file.hdu(0).unwrap(); let fits_value_str = get_required_fits_key_long_string!(fptr, &hdu, "NOTfits_value"); assert!(fits_value_str.is_err()); }); diff --git a/src/gpubox_files/mod.rs b/src/gpubox_files/mod.rs index 1dc12d3..ba1a5fb 100644 --- a/src/gpubox_files/mod.rs +++ b/src/gpubox_files/mod.rs @@ -11,7 +11,7 @@ use std::collections::HashSet; use std::fmt; use std::path::Path; -use fitsio::{hdu::FitsHdu, FitsFile}; +use fitsio::hdu::FitsHdu; use rayon::prelude::*; use regex::Regex; @@ -248,7 +248,7 @@ pub(crate) fn examine_gpubox_files>( // Check that there are some HDUs (apart from just the primary) // Assuming it does have some, open the first one - let hdu = match fptr.iter().count() { + let hdu = match fptr.fits_file.iter().count() { 1 => { return Err(GpuboxError::NoDataHDUsInGpuboxFile { gpubox_filename: g.filename.clone(), @@ -408,7 +408,7 @@ fn determine_gpubox_batches>( /// /// # Arguments /// -/// * `gpubox_fptr` - A FitsFile reference to this gpubox file. +/// * `gpubox_fptr` - An MWAFitsFile reference to this gpubox file. /// /// * `gpubox_hdu_fptr` - A reference to the HDU we are finding the time of. /// @@ -419,7 +419,7 @@ fn determine_gpubox_batches>( /// /// fn determine_hdu_time( - gpubox_fptr: &mut FitsFile, + gpubox_fptr: &mut MWAFitsFile, gpubox_hdu_fptr: &FitsHdu, ) -> Result { let start_unix_time: u64 = get_required_fits_key!(gpubox_fptr, gpubox_hdu_fptr, "TIME")?; @@ -434,7 +434,7 @@ fn determine_hdu_time( /// /// # Arguments /// -/// * `gpubox_fptr` - A FitsFile reference to this gpubox file. +/// * `gpubox_fptr` - An MWAFitsFile reference to this gpubox file. /// /// * `mwa_version` - enum telling us which correlator version the observation was created by. /// @@ -445,11 +445,11 @@ fn determine_hdu_time( /// /// fn map_unix_times_to_hdus( - gpubox_fptr: &mut FitsFile, + gpubox_fptr: &mut MWAFitsFile, mwa_version: MWAVersion, ) -> Result, FitsError> { let mut map = BTreeMap::new(); - let last_hdu_index = gpubox_fptr.iter().count(); + let last_hdu_index = gpubox_fptr.fits_file.iter().count(); // The new correlator has a "weights" HDU in each alternating HDU. Skip // those. let step_size = if mwa_version == MWAVersion::CorrMWAXv2 { @@ -474,7 +474,7 @@ fn map_unix_times_to_hdus( /// /// # Arguments /// -/// * `gpubox_fptr` - A FitsFile reference to this gpubox file. +/// * `gpubox_fptr` - An MWAFitsFile reference to this gpubox file. /// /// * `gpubox_primary_hdu` - The primary HDU of the gpubox file. /// @@ -489,7 +489,7 @@ fn map_unix_times_to_hdus( /// /// fn validate_gpubox_metadata_mwa_version( - gpubox_fptr: &mut FitsFile, + gpubox_fptr: &mut MWAFitsFile, gpubox_primary_hdu: &FitsHdu, gpubox_filename: &str, mwa_version: MWAVersion, @@ -527,7 +527,7 @@ fn validate_gpubox_metadata_mwa_version( /// /// # Arguments /// -/// * `gpubox_fptr` - A FitsFile reference to this gpubox file. +/// * `gpubox_fptr` - An MWAFitsFile reference to this gpubox file. /// /// * `gpubox_primary_hdu` - The primary HDU of the gpubox file. /// @@ -542,7 +542,7 @@ fn validate_gpubox_metadata_mwa_version( /// /// fn validate_gpubox_metadata_obs_id( - gpubox_fptr: &mut FitsFile, + gpubox_fptr: &mut MWAFitsFile, gpubox_primary_hdu: &FitsHdu, gpubox_filename: &str, metafits_obs_id: u32, @@ -610,7 +610,7 @@ fn create_time_map( } } - // Get the UNIX times from each of the HDUs of this `FitsFile`. + // Get the UNIX times from each of the HDUs of this `MWAFitsFile`. map_unix_times_to_hdus(&mut fptr, mwa_version).map_err(GpuboxError::from) }) .collect::, GpuboxError>>>(); diff --git a/src/gpubox_files/test.rs b/src/gpubox_files/test.rs index 04175c4..559fae3 100644 --- a/src/gpubox_files/test.rs +++ b/src/gpubox_files/test.rs @@ -371,13 +371,13 @@ fn test_no_hdus() { fn test_determine_hdu_time_test1() { // with_temp_file creates a temp dir and temp file, then removes them once out of scope with_new_temp_fits_file("determine_hdu_time_test1.fits", |fptr| { - let hdu = fptr.hdu(0).expect("Couldn't open HDU 0"); + let hdu = fptr.fits_file.hdu(0).expect("Couldn't open HDU 0"); // Write the TIME and MILLITIM keys. Key types must be i64 to get any // sort of sanity. - hdu.write_key(fptr, "TIME", 1_434_494_061) + hdu.write_key(&mut fptr.fits_file, "TIME", 1_434_494_061) .expect("Couldn't write key 'TIME'"); - hdu.write_key(fptr, "MILLITIM", 0) + hdu.write_key(&mut fptr.fits_file, "MILLITIM", 0) .expect("Couldn't write key 'MILLITIM'"); let result = determine_hdu_time(fptr, &hdu); @@ -390,11 +390,11 @@ fn test_determine_hdu_time_test1() { fn test_determine_hdu_time_test2() { // with_temp_file creates a temp dir and temp file, then removes them once out of scope with_new_temp_fits_file("determine_hdu_time_test2.fits", |fptr| { - let hdu = fptr.hdu(0).expect("Couldn't open HDU 0"); + let hdu = fptr.fits_file.hdu(0).expect("Couldn't open HDU 0"); - hdu.write_key(fptr, "TIME", 1_381_844_923) + hdu.write_key(&mut fptr.fits_file, "TIME", 1_381_844_923) .expect("Couldn't write key 'TIME'"); - hdu.write_key(fptr, "MILLITIM", 500) + hdu.write_key(&mut fptr.fits_file, "MILLITIM", 500) .expect("Couldn't write key 'MILLITIM'"); let result = determine_hdu_time(fptr, &hdu); @@ -413,11 +413,11 @@ fn test_determine_hdu_time_test3() { // with_temp_file creates a temp dir and temp file, then removes them once out of scope with_new_temp_fits_file("determine_hdu_time_test3.fits", |fptr| { - let hdu = fptr.hdu(0).expect("Couldn't open HDU 0"); + let hdu = fptr.fits_file.hdu(0).expect("Couldn't open HDU 0"); - hdu.write_key(fptr, "TIME", current) + hdu.write_key(&mut fptr.fits_file, "TIME", current) .expect("Couldn't write key 'TIME'"); - hdu.write_key(fptr, "MILLITIM", 500) + hdu.write_key(&mut fptr.fits_file, "MILLITIM", 500) .expect("Couldn't write key 'MILLITIM'"); let result = determine_hdu_time(fptr, &hdu); @@ -439,11 +439,12 @@ fn test_map_unix_times_to_hdus_test() { }; for (i, (time, millitime)) in times.iter().enumerate() { let hdu = fptr + .fits_file .create_image("EXTNAME".to_string(), &image_description) .expect("Couldn't create image"); - hdu.write_key(fptr, "TIME", *time) + hdu.write_key(&mut fptr.fits_file, "TIME", *time) .expect("Couldn't write key 'TIME'"); - hdu.write_key(fptr, "MILLITIM", *millitime) + hdu.write_key(&mut fptr.fits_file, "MILLITIM", *millitime) .expect("Couldn't write key 'MILLITIM'"); expected.insert(time * 1000 + millitime, i + 1); @@ -552,7 +553,7 @@ fn test_determine_common_times_test_one_timestep() { fn test_validate_gpubox_metadata_mwa_version() { // with_temp_file creates a temp dir and temp file, then removes them once out of scope with_new_temp_fits_file("test_validate_gpubox_metadata_mwa_version.fits", |fptr| { - let hdu = fptr.hdu(0).expect("Couldn't open HDU 0"); + let hdu = fptr.fits_file.hdu(0).expect("Couldn't open HDU 0"); // This should succeed- LegacyOld should NOT have CORR_VER key assert!(validate_gpubox_metadata_mwa_version( @@ -582,7 +583,7 @@ fn test_validate_gpubox_metadata_mwa_version() { .is_err()); // Now put in a corr version - hdu.write_key(fptr, "CORR_VER", 2) + hdu.write_key(&mut fptr.fits_file, "CORR_VER", 2) .expect("Couldn't write key 'CORR_VER'"); // This should succeed- V2 should have CORR_VER key @@ -616,12 +617,12 @@ fn test_validate_gpubox_metadata_mwa_version() { // with_temp_file creates a temp dir and temp file, then removes them once out of scope // This section tests CORR_VER where it is != 2 with_new_temp_fits_file("test_validate_gpubox_metadata_mwa_version.fits", |fptr| { - let hdu = fptr.hdu(0).expect("Couldn't open HDU 0"); + let hdu = fptr.fits_file.hdu(0).expect("Couldn't open HDU 0"); // This should not succeed- CORR_VER key if it exists should be 2 // CORR_VER did not exist in OldLegacy or Legacy correlator // Now put in a corr version - hdu.write_key(fptr, "CORR_VER", 1) + hdu.write_key(&mut fptr.fits_file, "CORR_VER", 1) .expect("Couldn't write key 'CORR_VER'"); assert!(validate_gpubox_metadata_mwa_version( @@ -638,7 +639,7 @@ fn test_validate_gpubox_metadata_mwa_version() { fn test_validate_gpubox_metadata_obsid() { // with_temp_file creates a temp dir and temp file, then removes them once out of scope with_new_temp_fits_file("test_validate_gpubox_metadata_mwa_version.fits", |fptr| { - let hdu = fptr.hdu(0).expect("Couldn't open HDU 0"); + let hdu = fptr.fits_file.hdu(0).expect("Couldn't open HDU 0"); // OBSID is not there, this should be an error assert!(validate_gpubox_metadata_obs_id( @@ -650,7 +651,7 @@ fn test_validate_gpubox_metadata_obsid() { .is_err()); // Now add the key - hdu.write_key(fptr, "OBSID", 1_234_567_890) + hdu.write_key(&mut fptr.fits_file, "OBSID", 1_234_567_890) .expect("Couldn't write key 'OBSID'"); // OBSID is there, but does not match metafits- this should be an error diff --git a/src/lib.rs b/src/lib.rs index eaa87c6..a3ef883 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,6 +17,7 @@ mod fits_read; mod gpubox_files; mod metafits_context; mod misc; +mod mwa_fits_file; mod rfinput; mod timestep; mod voltage_context; diff --git a/src/metafits_context/mod.rs b/src/metafits_context/mod.rs index fce15ca..795fe60 100644 --- a/src/metafits_context/mod.rs +++ b/src/metafits_context/mod.rs @@ -1126,7 +1126,7 @@ impl MetafitsContext { /// /// # Arguments /// - /// * `metafits_fptr` - reference to the FitsFile representing the metafits file. + /// * `metafits_fptr` - reference to the MWAFitsFile representing the metafits file. /// /// * `sig_chain_hdu` - The FitsHdu containing valid signal chain corrections data. /// @@ -1135,7 +1135,7 @@ impl MetafitsContext { /// * Result containing a vector of signal chain corrections read from the sig_chain_hdu HDU. /// fn populate_signal_chain_corrections( - metafits_fptr: &mut fitsio::FitsFile, + metafits_fptr: &mut MWAFitsFile, sig_chain_hdu: &fitsio::hdu::FitsHdu, ) -> Result, FitsError> { // Find out how many rows there are in the table diff --git a/src/misc/test.rs b/src/misc/test.rs index b6c2891..c2073ed 100644 --- a/src/misc/test.rs +++ b/src/misc/test.rs @@ -9,6 +9,7 @@ use core::f32; #[cfg(test)] use super::*; use crate::antenna::*; +use crate::fits_read::*; use crate::rfinput::*; use float_cmp::*; @@ -27,7 +28,7 @@ use float_cmp::*; #[cfg(test)] pub fn with_new_temp_fits_file(filename: &str, callback: F) where - F: for<'a> Fn(&'a mut fitsio::FitsFile), + F: for<'a> Fn(&'a mut MWAFitsFile), { let tdir = tempdir::TempDir::new("fitsio-").unwrap(); let tdir_path = tdir.path(); @@ -35,11 +36,13 @@ where let filename_str = filename.to_str().expect("cannot create string filename"); - let mut fptr = fitsio::FitsFile::create(filename_str) + let fptr = fitsio::FitsFile::create(filename_str) .open() .expect("Couldn't open tempfile"); - callback(&mut fptr); + let mut mwa_fits_file = MWAFitsFile::new(filename_str.into(), fptr); + + callback(&mut mwa_fits_file); } #[test] diff --git a/src/mwa_fits_file/mod.rs b/src/mwa_fits_file/mod.rs new file mode 100644 index 0000000..0e597fc --- /dev/null +++ b/src/mwa_fits_file/mod.rs @@ -0,0 +1,47 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +//! Encapsulating filename and FitsFile + +// This struct encapsulates the fitsio::FitsFile struct and adds back +// the 'filename' property that was removed in v0.21.0 of the fitsio crate +// +use fitsio::FitsFile; +use std::path::PathBuf; + +#[cfg(test)] +mod test; + +pub struct MWAFitsFile { + /// FitsFile struct + pub fits_file: FitsFile, + + /// Filename (filename, including + /// the full or relative path to the file) + pub filename: PathBuf, +} + +impl MWAFitsFile { + /// Creates an encapsulating struct to hold a FitsFile object and + /// it's filename. Filename was removed from fitsio in 0.21, so + /// this is a way to retain that property since we use it in error + /// messages and debug. + /// + /// # Arguments + /// + /// * `filename` - filename of FITS file as a path or string. + /// + /// * `fits_file` - an already created fitsio::FitsFile struct + /// + /// # Returns + /// + /// * A populated MWAFits object + /// + pub fn new(filename: PathBuf, fits_file: FitsFile) -> Self { + MWAFitsFile { + fits_file, + filename, + } + } +} diff --git a/src/mwa_fits_file/test.rs b/src/mwa_fits_file/test.rs new file mode 100644 index 0000000..fd6a42c --- /dev/null +++ b/src/mwa_fits_file/test.rs @@ -0,0 +1,38 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +//! Unit tests for the mwa_fits_file module +#[cfg(test)] +use fitsio::FitsFile; + +#[test] +fn test_mwa_fits_file_new() { + use super::MWAFitsFile; + + let metafits_filename = "test_files/1101503312_1_timestep/1101503312.metafits"; + + let fptr = FitsFile::open(metafits_filename).expect("Could not open fits file!"); + + let mut mwa_fits_file = MWAFitsFile::new(metafits_filename.into(), fptr); + + // Check it works! + assert_eq!( + mwa_fits_file.filename.display().to_string(), + metafits_filename + ); + + // Open a hdu + let hdu = mwa_fits_file + .fits_file + .hdu(0) + .expect("Could not open PRIMARY HDU"); + + // Read the obs_id from the fits file + let obs_id = hdu + .read_key::(&mut mwa_fits_file.fits_file, "GPSTIME") + .expect("Cannot read key"); + + // Ensure it is what is expected + assert_eq!(obs_id, 1101503312); +} diff --git a/src/rfinput/mod.rs b/src/rfinput/mod.rs index 996971c..64d96e4 100644 --- a/src/rfinput/mod.rs +++ b/src/rfinput/mod.rs @@ -368,7 +368,7 @@ impl Rfinput { /// /// # Arguments /// - /// * `metafits_fptr` - reference to the FitsFile representing the metafits file. + /// * `metafits_fptr` - reference to the MWAFitsFile representing the metafits file. /// /// * `metafits_tile_table_hdu` - reference to the HDU containing the TILEDATA table. /// @@ -382,7 +382,7 @@ impl Rfinput { /// * An Result containing a populated vector of RFInputMetafitsTableRow structss or an Error /// fn read_metafits_tiledata_values( - metafits_fptr: &mut fitsio::FitsFile, + metafits_fptr: &mut MWAFitsFile, metafits_tile_table_hdu: &fitsio::hdu::FitsHdu, row: usize, num_coarse_chans: usize, @@ -496,7 +496,7 @@ impl Rfinput { /// /// # Arguments /// - /// * `metafits_fptr` - reference to the FitsFile representing the metafits file. + /// * `metafits_fptr` - reference to the MWAFitsFile representing the metafits file. /// /// * `metafits_calibdata_table_hdu` - reference to the HDU containing the CALIBDATA table. /// @@ -510,7 +510,7 @@ impl Rfinput { /// * An Result containing a populated vector of RFInputMetafitsTableRow structss or an Error /// fn read_metafits_calibdata_values( - metafits_fptr: &mut fitsio::FitsFile, + metafits_fptr: &mut MWAFitsFile, metafits_calibdata_table_hdu: &Option, row: usize, num_coarse_chans: usize, @@ -567,7 +567,7 @@ impl Rfinput { /// /// * `num_inputs` - number of rf_inputs to read from the metafits TILEDATA bintable. /// - /// * `metafits_fptr` - reference to the FitsFile representing the metafits file. + /// * `metafits_fptr` - reference to the MWAFitsFile representing the metafits file. /// /// * `metafits_tile_table_hdu` - reference to the HDU containing the TILEDATA table. /// @@ -581,7 +581,7 @@ impl Rfinput { /// pub(crate) fn populate_rf_inputs( num_inputs: usize, - metafits_fptr: &mut fitsio::FitsFile, + metafits_fptr: &mut MWAFitsFile, metafits_tile_table_hdu: fitsio::hdu::FitsHdu, coax_v_factor: f64, num_coarse_chans: usize, diff --git a/src/rfinput/test.rs b/src/rfinput/test.rs index 549f65e..cd1ecaa 100644 --- a/src/rfinput/test.rs +++ b/src/rfinput/test.rs @@ -113,6 +113,7 @@ fn test_read_metafits_tiledata_values_from_invalid_metafits() { let descriptions = [first_description, second_description]; metafits_fptr + .fits_file .create_table("TILEDATA".to_string(), &descriptions) .unwrap(); @@ -177,10 +178,12 @@ fn test_read_metafits_calibdata_values_from_invalid_metafits() { let descriptions = [first_description, second_description]; metafits_fptr + .fits_file .create_table("TILEDATA".to_string(), &descriptions) .unwrap(); metafits_fptr + .fits_file .create_table("CALIBDATA".to_string(), &descriptions) .unwrap();