diff --git a/src/io/mod.rs b/src/io/mod.rs index e568394..ec502ff 100644 --- a/src/io/mod.rs +++ b/src/io/mod.rs @@ -18,14 +18,10 @@ use log::{trace, warn}; use crate::{ marlu::{ constants::MWA_LAT_RAD, - fitsio, hifitime::Duration, io::{ms::MeasurementSetWriter, uvfits::UvfitsWriter, VisWrite}, mwalib, - mwalib::{ - CorrelatorContext, MwalibError, _get_optional_fits_key, _open_hdu, fits_open_hdu, - get_optional_fits_key, - }, + mwalib::{CorrelatorContext, MwalibError}, rayon::prelude::*, Jones, LatLngHeight, MwaObsContext, ObsContext, RADec, SelectionError, VisContext, VisSelection, ENH, @@ -56,59 +52,13 @@ pub struct IOContext { } impl IOContext { - // get the scale factor for the raw files - // will be deprecated after is resolved - fn get_raw_scale_factor(&self) -> f32 { - let mut meta_fptr = fitsio::FitsFile::open(&self.metafits_in).unwrap(); - let hdu0 = fits_open_hdu!(&mut meta_fptr, 1).unwrap(); - let mut scale_factor: Option = - get_optional_fits_key!(&mut meta_fptr, &hdu0, "RAWSCALE").unwrap(); - let gpstime: Option = - get_optional_fits_key!(&mut meta_fptr, &hdu0, "GPSTIME").unwrap(); - for raw_path in &self.gpufits_in { - let mut fptr = fitsio::FitsFile::open(raw_path).unwrap(); - let hdu1 = fits_open_hdu!(&mut fptr, 1).unwrap(); - for key in ["SCALEFAC", "BSCALE"] { - let this_scale_factor: Option = - get_optional_fits_key!(&mut fptr, &hdu1, key).unwrap(); - match (scale_factor, this_scale_factor) { - (Some(sf), Some(this_sf)) => { - assert!( - ((sf - this_sf).abs() < f32::EPSILON), - "Different scale factors found in raw files: {} and {}", - sf, - this_sf - ); - } - (None, Some(this_sf)) => { - scale_factor = Some(this_sf); - } - _ => {} - } - } - } - match (scale_factor, gpstime) { - (Some(sf), _) => sf, - // according to pyuvdata "correlator did a divide by 4 before october 2014" - // https://github.com/RadioAstronomySoftwareGroup/pyuvdata/blob/05ee100af2e4e11c9d291c9eafc937578ef01763/src/pyuvdata/uvdata/mwa_corr_fits.py#L1464 - (None, Some(t)) if t < 1096160568 => 0.25, - _ => { - warn!("No scale factor found in metafits or gpufits files, defaulting to 1.0"); - 1.0 - } - } - } - /// Get the `mwalib::CorrelatorContext` from metafits and gpufits /// /// # Errors /// /// see `mwalib::CorrelatorContext::new` pub fn get_corr_ctx(&self) -> Result { - CorrelatorContext::new(&self.metafits_in, &self.gpufits_in).map(|mut corr_ctx| { - corr_ctx.metafits_context.corr_raw_scale_factor = self.get_raw_scale_factor(); - corr_ctx - }) + CorrelatorContext::new(&self.metafits_in, &self.gpufits_in) } // TODO: pub fn validate_params(&self), checks permissions diff --git a/src/van_vleck.rs b/src/van_vleck.rs index 92fe173..b7bfbd4 100644 --- a/src/van_vleck.rs +++ b/src/van_vleck.rs @@ -191,7 +191,7 @@ pub fn correct_van_vleck( nsamples: n2samples, }); } - let sample_scale = n2samples as f64 * corr_ctx.metafits_context.corr_raw_scale_factor as f64; + let sample_scale = n2samples as f64 * corr_ctx.bscale as f64; // ant_pair indices which are unflagged autocorrelations, list of corresponding antenna indices let (unflagged_auto_mask, unflagged_autos): (Vec<_>, Vec<_>) = ant_pairs