Skip to content

Commit

Permalink
updated validate_datasets to include match of exact time and freq bins
Browse files Browse the repository at this point in the history
in pspecdata.dsets, else print a warning
  • Loading branch information
nkern committed Mar 20, 2018
1 parent c105e67 commit 63379eb
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions hera_pspec/pspecdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class PSpecData(object):

def __init__(self, dsets=[], wgts=[], beam=None):
def __init__(self, dsets=[], wgts=[], beam=None, warn=True):
"""
Object to store multiple sets of UVData visibilities and perform
operations such as power spectrum estimation on them.
Expand All @@ -23,7 +23,11 @@ def __init__(self, dsets=[], wgts=[], beam=None):
beam : PspecBeam object, optional
PspecBeam object containing information about the primary beam
Default: None.
warn : boolean, optional
If True, print warnings raised by PSpecData object.
"""
self.warn = warn
self.clear_cov_cache() # Covariance matrix cache
self.dsets = []; self.wgts = []
self.Nfreqs = None
Expand All @@ -38,6 +42,7 @@ def __init__(self, dsets=[], wgts=[], beam=None):
# Store a primary beam
self.primary_beam = beam


def add(self, dsets, wgts):
"""
Add a dataset to the collection in this PSpecData object.
Expand Down Expand Up @@ -105,6 +110,19 @@ def validate_datasets(self):
if np.unique(Ntimes).size > 1:
raise ValueError("all dsets must have the same Ntimes")

# raise warnings if times don't match
if self.warn:
lst_diffs = np.array(map(lambda dset: np.unique(self.dsets[0].lst_array) - np.unique(dset.lst_array), self.dsets[1:]))
if np.max(np.abs(lst_diffs)) > 0.001:
print("Warning: taking power spectra between LST bins misaligned by more than 15 seconds")

# raise warning if frequencies don't match
if self.warn:
freq_diffs = np.array(map(lambda dset: np.unique(self.dsets[0].freq_array) - np.unique(dset.freq_array), self.dsets[1:]))
if np.max(np.abs(lst_diffs)) > 0.1e6:
print("Warning: taking power spectra between frequency bins misaligned by more than 0.1 MHz")


def clear_cov_cache(self, keys=None):
"""
Clear stored covariance data (or some subset of it).
Expand Down Expand Up @@ -482,7 +500,7 @@ def get_MW(self, G, mode='I'):
\hat{p} = M \hat{q}
<\hat{p}> = W p
W = M G,
g
where p is the true band power and G is the response matrix (defined above
in get_G) of unnormalized bandpowers to normed bandpowers. The G matrix
is the Fisher matrix when R = C^-1
Expand Down

0 comments on commit 63379eb

Please sign in to comment.