Skip to content

Commit

Permalink
Merge 184d604 into 78c5fe8
Browse files Browse the repository at this point in the history
  • Loading branch information
philbull committed Apr 17, 2019
2 parents 78c5fe8 + 184d604 commit 6e277a3
Show file tree
Hide file tree
Showing 7 changed files with 312 additions and 362 deletions.
19 changes: 9 additions & 10 deletions docs/pspec.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ The following example shows how to load ``UVData`` objects into a ``PSpecData``
uvd1.read_miriad(datafile1)
uvd2.read_miriad(datafile2)
# Create a new PSpecData object. When 'wgts' is None, the flags from the
# UVData objects are used as weights
ds = hp.PSpecData(dsets=[uvd1, uvd2], wgts=[None, None], beam=beam)
# Create a new PSpecData object
ds = hp.PSpecData(dsets=[uvd1, uvd2], beam=beam)
# bls1 and bls2 are lists of tuples specifying baselines (antenna pairs)
# Here, we specify three baseline-pairs, i.e. bls1[0] x bls2[0],
Expand All @@ -34,7 +33,7 @@ The following example shows how to load ``UVData`` objects into a ``PSpecData``
# dataset 1 (and i goes from 0..2). This is done for two spectral windows
# (freq. channel indexes between 300-400 and 600-721), with unity weights
# and a Blackman-Harris taper in each spectral window
uvp = ds.pspec(bls1, bls2, dsets=(0, 1), spw_ranges=[(300, 400), (600,721)],
uvp = ds.pspec(bls1, bls2, dsets=(0, 1), spw_ranges=[(300, 400), (600, 721)],
input_data_weight='identity', norm='I', taper='blackman-harris',
verbose=True)
Expand All @@ -48,11 +47,11 @@ To get power spectra from the ``UVPSpec`` object that was returned by ``pspec``:

.. code-block:: python
# Key specifying desired spectral window, baseline-pair, and polarization
# Key specifying desired spectral window, baseline-pair, and polarization pair
spw = 1
pol = 'xx'
polpair = ('xx', 'xx')
blpair =((24, 25), (37, 38))
key = (spw, blpair, pol)
key = (spw, blpair, polpair)
# Get delay bins and power spectrum
dlys = uvp.get_dlys(spw)
Expand Down Expand Up @@ -102,15 +101,15 @@ The most frequently-used methods from ``PSpecData`` are listed below. See :any:`

The :meth:`~hera_pspec.PSpecData.pspec` method outputs power spectra as a single ``UVPSpec`` object, which also contains metadata and various methods for accessing the data, input/output etc.

To access the power spectra, use the :meth:`~hera_pspec.UVPSpec.get_data` method, which takes a key of the form: ``(spw, blpair, pol)``. For example:
To access the power spectra, use the :meth:`~hera_pspec.UVPSpec.get_data` method, which takes a key of the form: ``(spw, blpair, polpair)``. For example:

.. code-block:: python
# Key specifying desired spectral window, baseline-pair, and polarization
spw = 1
pol = 'xx'
polpair = ('xx', 'xx')
blpair =((24, 25), (37, 38))
key = (spw, blpair, pol)
key = (spw, blpair, polpair)
# Get delay bins and power spectrum
dlys = uvp.get_dlys(spw)
Expand Down
104 changes: 50 additions & 54 deletions examples/Bootstrap_example.ipynb

Large diffs are not rendered by default.

37 changes: 12 additions & 25 deletions examples/Forming_PseudoStokes_Vis.ipynb

Large diffs are not rendered by default.

337 changes: 161 additions & 176 deletions examples/PS_estimation_example.ipynb

Large diffs are not rendered by default.

63 changes: 21 additions & 42 deletions examples/PSpecBeam_tutorial.ipynb

Large diffs are not rendered by default.

99 changes: 51 additions & 48 deletions examples/Plotting_examples.ipynb

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions hera_pspec/pspecdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def dset_idx(self, dset):
return self.labels.index(dset)
else:
raise KeyError("dset '%s' not found." % dset)
elif isinstance(dset, int):
elif isinstance(dset, (int, np.integer)):
return dset
else:
raise TypeError("dset must be either an int or string")
Expand Down Expand Up @@ -412,7 +412,8 @@ def parse_blkey(self, key):
# put pol into bl key if it exists
if len(key) > 0:
pol = key[0]
assert isinstance(pol, (str, int, np.int, np.int32)), "pol must be fed as a str or int"
assert isinstance(pol, (str, int, np.integer)), \
"pol must be fed as a str or int"
bl += (key[0],)

return dset_idx, bl
Expand Down Expand Up @@ -455,7 +456,7 @@ def dx(self, key):
dx : array_like
Array of std data from the requested UVData dataset and baseline.
"""
assert isinstance(key,tuple)
assert isinstance(key, tuple)
dset,bl = self.parse_blkey(key)
spw = slice(self.spw_range[0], self.spw_range[1])

Expand Down Expand Up @@ -808,7 +809,7 @@ def set_spw(self, spw_range):
"""
assert isinstance(spw_range, tuple), \
"spw_range must be fed as a len-2 integer tuple"
assert isinstance(spw_range[0], (int, np.int)), \
assert isinstance(spw_range[0], (int, np.integer)), \
"spw_range must be fed as len-2 integer tuple"
self.spw_range = spw_range
self.spw_Nfreqs = spw_range[1] - spw_range[0]
Expand Down Expand Up @@ -1663,7 +1664,7 @@ def scalar(self, polpair, little_h=True, num_steps=2000, beam=None,
in h^-3 Mpc^3 or Mpc^3.
"""
# make sure polarizations are the same
if isinstance(polpair, int):
if isinstance(polpair, (int, np.integer)):
polpair = uvputils.polpair_int2tuple(polpair)
if isinstance(polpair, str):
polpair = (polpair, polpair)
Expand Down Expand Up @@ -1976,8 +1977,8 @@ def pspec(self, bls1, bls2, dsets, pols, n_dlys=None,
assert isinstance(dsets, (list, tuple)), \
"dsets must be fed as length-2 tuple of integers"
assert len(dsets) == 2, "len(dsets) must be 2"
assert isinstance(dsets[0], (int, np.int)) \
and isinstance(dsets[1], (int, np.int)), \
assert isinstance(dsets[0], (int, np.integer)) \
and isinstance(dsets[1], (int, np.integer)), \
"dsets must contain integer indices"
dset1 = self.dsets[self.dset_idx(dsets[0])]
dset2 = self.dsets[self.dset_idx(dsets[1])]
Expand Down

0 comments on commit 6e277a3

Please sign in to comment.