diff --git a/hera_pspec/data/test_uvp.h5 b/hera_pspec/data/test_uvp.h5 new file mode 100644 index 00000000..984d739f Binary files /dev/null and b/hera_pspec/data/test_uvp.h5 differ diff --git a/hera_pspec/pspecdata.py b/hera_pspec/pspecdata.py index 53392470..2be883f4 100644 --- a/hera_pspec/pspecdata.py +++ b/hera_pspec/pspecdata.py @@ -65,8 +65,9 @@ def __init__(self, dsets=[], wgts=None, dsets_std=None, labels=None, self.spw_range = None self.spw_Nfreqs = None self.spw_Ndlys = None - self.r_params = {} #r_params is a dictionary that stores parameters for - #parametric R matrices. + # r_params is a dictionary that stores parameters for + # parametric R matrices. + self.r_params = {} self.cov_regularization = 0. # set data weighting to identity by default # and taper to none by default @@ -831,11 +832,11 @@ def R(self, key): # Note that we multiply sqrtY inside of the pinv #to apply flagging weights before taking psuedo inverse. self._R[Rkey] = sqrtT.T * np.linalg.pinv(sqrtY.T * \ - dspec.sinc_downweight_mat_inv(nchan = self.spw_Nfreqs, - df = np.median(np.diff(self.freqs)), - filter_centers = r_params['filter_centers'], - filter_widths = r_params['filter_widths'], - filter_factors = r_params['filter_factors'])* sqrtY) * sqrtT + dspec.sinc_downweight_mat_inv(nchan=self.spw_Nfreqs, + df=np.median(np.diff(self.freqs)), + filter_centers=r_params['filter_centers'], + filter_widths=r_params['filter_widths'], + filter_factors=r_params['filter_factors']) * sqrtY) * sqrtT return self._R[Rkey] @@ -2065,7 +2066,7 @@ def pspec(self, bls1, bls2, dsets, pols, n_dlys=None, input_data_weight='identity', norm='I', taper='none', sampling=False, little_h=True, spw_ranges=None, baseline_tol=1.0, store_cov=False, verbose=True, - exact_norm=False, history='', r_params = None): + exact_norm=False, history='', r_params=None): """ Estimate the delay power spectrum from a pair of datasets contained in this object, using the optimal quadratic estimator of arXiv:1502.06016. @@ -2461,8 +2462,8 @@ def pspec(self, bls1, bls2, dsets, pols, n_dlys=None, if not key2 in r_params: raise ValueError("No r_param dictionary supplied" " for baseline %s"%(str(key2))) - self.set_r_param(key1,r_params[key1]) - self.set_r_param(key2,r_params[key2]) + self.set_r_param(key1, r_params[key1]) + self.set_r_param(key2, r_params[key2]) # Build Fisher matrix if input_data_weight == 'identity': diff --git a/hera_pspec/tests/test_uvpspec.py b/hera_pspec/tests/test_uvpspec.py index a5eb5d27..7dd55a93 100644 --- a/hera_pspec/tests/test_uvpspec.py +++ b/hera_pspec/tests/test_uvpspec.py @@ -722,3 +722,10 @@ def test_conj_blpair(): blpair = uvputils._conj_blpair(101102103104, which='both') nt.assert_equal(blpair, 102101104103) nt.assert_raises(ValueError, uvputils._conj_blpair, 102101103104, which='foo') + +def test_compatibility_read(): + # test read in of a static test file dated 8/2019 + uvp = uvpspec.UVPSpec() + uvp.read_hdf5(os.path.join(DATA_PATH, 'test_uvp.h5')) + # assert check does not fail + uvp.check() diff --git a/hera_pspec/uvpspec_utils.py b/hera_pspec/uvpspec_utils.py index a945f836..7f5f668b 100644 --- a/hera_pspec/uvpspec_utils.py +++ b/hera_pspec/uvpspec_utils.py @@ -745,7 +745,7 @@ def _select(uvp, spws=None, bls=None, only_pairs_in_bls=False, blpairs=None, if store_cov: uvp.cov_array = cov - #select r_params based on new bl_array + # select r_params based on new bl_array blp_keys = uvp.get_all_keys() blkeys = [] for blpkey in blp_keys: @@ -756,7 +756,7 @@ def _select(uvp, spws=None, bls=None, only_pairs_in_bls=False, blpairs=None, if not key2 in blkeys: blkeys += [key2,] new_r_params = {} - if not uvp.r_params == '': + if hasattr(uvp, 'r_params') and uvp.r_params != '': r_params = uvp.get_r_params() for rpkey in r_params: if rpkey in blkeys: