Skip to content

Commit

Permalink
changed "pseudo_stokes" to just "stokes" across the repo
Browse files Browse the repository at this point in the history
  • Loading branch information
nkern committed Apr 27, 2018
1 parent 6c36370 commit 3aa945a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 40 deletions.
1 change: 0 additions & 1 deletion hera_pspec/noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def calc_scalar(self, freqs, stokes, num_steps=5000, little_h=True):
self.stokes : str, stokes polarization used to calculate self.scalar
"""
# parse stokes
if stokes == 'I': stokes = 'pseudo_I'
self.scalar = self.beam.compute_pspec_scalar(freqs.min(), freqs.max(), len(freqs), num_steps=num_steps,
stokes=stokes, little_h=little_h, noise_scalar=True)
self.subband = freqs
Expand Down
58 changes: 29 additions & 29 deletions hera_pspec/pspecbeam.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ def __init__(self, cosmo=None):
else:
self.cosmo = conversions.Cosmo_Conversions()

def compute_pspec_scalar(self, lower_freq, upper_freq, num_freqs, num_steps=5000, stokes='pseudo_I',
def compute_pspec_scalar(self, lower_freq, upper_freq, num_freqs, num_steps=5000, stokes='I',
taper='none', little_h=True, noise_scalar=False):
"""
Computes the scalar function to convert a power spectrum estimate
in "telescope units" to cosmological units
See arxiv:1304.4991 and HERA memo #27 for details.
Currently, only the "pseudo Stokes I", "XX" and "YY" beam are supported.
Currently, only the Stokes "I", "XX" and "YY" beam are supported.
See Equations 4 and 5 of Moore et al. (2017) ApJ 836, 154
or arxiv:1502.05072 for details.
Expand All @@ -133,9 +133,9 @@ def compute_pspec_scalar(self, lower_freq, upper_freq, num_freqs, num_steps=5000
stokes: str, optional
Which Stokes parameter's to compute the beam scalar for.
'pseudo_I', 'pseudo_Q', 'pseudo_U', 'pseudo_V', 'XX', 'YY', 'XY', 'YX', although
currently only 'pseudo_I' and linear dipole pol (e.g. 'XX') are implemented.
Default: 'pseudo_I'
'I', 'Q', 'U', 'V', 'XX', 'YY', 'XY', 'YX', although
currently only 'I' and linear dipole pol (e.g. 'XX') are implemented.
Default: 'I'
taper : str, optional
Whether a tapering function (e.g. Blackman-Harris) is being
Expand Down Expand Up @@ -171,7 +171,7 @@ def compute_pspec_scalar(self, lower_freq, upper_freq, num_freqs, num_steps=5000

return scalar

def Jy_to_mK(self, freqs, stokes='pseudo_I'):
def Jy_to_mK(self, freqs, stokes='I'):
"""
Return the multiplicative factor, M [mK / Jy], to convert a visibility from Jy -> mK,
Expand All @@ -188,9 +188,9 @@ def Jy_to_mK(self, freqs, stokes='pseudo_I'):
stokes: str, optional
Which Stokes parameter's to compute the beam scalar for.
'pseudo_I', 'pseudo_Q', 'pseudo_U', 'pseudo_V', 'XX', 'YY', 'XY', 'YX', although
currently only 'pseudo_I' and linear dipole pol (e.g. 'XX') are implemented.
Default: 'pseudo_I'
'I', 'Q', 'U', 'V', 'XX', 'YY', 'XY', 'YX', although
currently only 'I' and linear dipole pol (e.g. 'XX') are implemented.
Default: 'I'
Returns
-------
Expand Down Expand Up @@ -233,7 +233,7 @@ def __init__(self, fwhm, beam_freqs, cosmo=None):
else:
self.cosmo = conversions.Cosmo_Conversions()

def power_beam_int(self, stokes='pseudo_I'):
def power_beam_int(self, stokes='I'):
"""
Computes the integral of the beam over solid angle to give
a beam area (in sr). Uses analytic formula that the answer
Expand All @@ -242,25 +242,25 @@ def power_beam_int(self, stokes='pseudo_I'):
Trivially this returns an array (i.e., a function of frequency),
but the results are frequency independent.
Currently, only the "pseudo Stokes I", "XX" and "YY" beam are supported.
Currently, only the Stokes "I", "XX" and "YY" beam are supported.
See Equations 4 and 5 of Moore et al. (2017) ApJ 836, 154
or arxiv:1502.05072 for details.
Parameters
----------
stokes: str, optional
Which Stokes parameter's to compute the beam scalar for.
'pseudo_I', 'pseudo_Q', 'pseudo_U', 'pseudo_V', 'XX', 'YY', 'XY', 'YX', although
currently only 'pseudo_I' and linear dipole pol (e.g. 'XX') are implemented.
Default: 'pseudo_I'
'I', 'Q', 'U', 'V', 'XX', 'YY', 'XY', 'YX', although
currently only 'I' and linear dipole pol (e.g. 'XX') are implemented.
Default: 'I'
Returns
-------
primary beam area: float, array-like
"""
return np.ones_like(self.beam_freqs) * 2. * np.pi * self.fwhm**2 / (8. * np.log(2.))

def power_beam_sq_int(self, stokes='pseudo_I'):
def power_beam_sq_int(self, stokes='I'):
"""
Computes the integral of the beam**2 over solid angle to give
a beam area (in str). Uses analytic formula that the answer
Expand All @@ -269,17 +269,17 @@ def power_beam_sq_int(self, stokes='pseudo_I'):
Trivially this returns an array (i.e., a function of frequency),
but the results are frequency independent.
Currently, only the "pseudo Stokes I", "XX" and "YY" beam are supported.
Currently, only the Stokes "I", "XX" and "YY" beam are supported.
See Equations 4 and 5 of Moore et al. (2017) ApJ 836, 154
or arxiv:1502.05072 for details.
Parameters
----------
stokes: str, optional
Which Stokes parameter's to compute the beam scalar for.
'pseudo_I', 'pseudo_Q', 'pseudo_U', 'pseudo_V', 'XX', 'YY', 'XY', 'YX', although
currently only 'pseudo_I' and linear dipole pol (e.g. 'XX') are implemented.
Default: 'pseudo_I'
'I', 'Q', 'U', 'V', 'XX', 'YY', 'XY', 'YX', although
currently only 'I' and linear dipole pol (e.g. 'XX') are implemented.
Default: 'I'
Returns
-------
Expand Down Expand Up @@ -310,23 +310,23 @@ def __init__(self, beam_fname, cosmo=None):
else:
self.cosmo = conversions.Cosmo_Conversions()

def power_beam_int(self, stokes='pseudo_I'):
def power_beam_int(self, stokes='I'):
"""
Computes the integral of the beam over solid angle to give
a beam area (in str) as a function of frequency. Uses function
in pyuvdata.
Currently, only the "pseudo Stokes I", "XX" and "YY" beam are supported.
Currently, only the Stokes "I", "XX" and "YY" beam are supported.
See Equations 4 and 5 of Moore et al. (2017) ApJ 836, 154
or arxiv:1502.05072 for details.
Parameters
----------
stokes: str, optional
Which Stokes parameter's to compute the beam scalar for.
'pseudo_I', 'pseudo_Q', 'pseudo_U', 'pseudo_V', 'XX', 'YY', 'XY', 'YX', although
currently only 'pseudo_I' and linear dipole pol (e.g. 'XX') are implemented.
Default: 'pseudo_I'
'I', 'Q', 'U', 'V', 'XX', 'YY', 'XY', 'YX', although
currently only 'I' and linear dipole pol (e.g. 'XX') are implemented.
Default: 'I'
Returns
-------
Expand All @@ -337,23 +337,23 @@ def power_beam_int(self, stokes='pseudo_I'):
else:
raise NotImplementedError("Outdated version of pyuvdata.")

def power_beam_sq_int(self, stokes='pseudo_I'):
def power_beam_sq_int(self, stokes='I'):
"""
Computes the integral of the beam**2 over solid angle to give
a beam**2 area (in str) as a function of frequency. Uses function
in pyuvdata.
Currently, only the "pseudo Stokes I", "XX" and "YY" beam are supported.
Currently, only the Stokes "I", "XX" and "YY" beam are supported.
See Equations 4 and 5 of Moore et al. (2017) ApJ 836, 154
or arxiv:1502.05072 for details.
Parameters
----------
stokes: str, optional
Which Stokes parameter's to compute the beam scalar for.
'pseudo_I', 'pseudo_Q', 'pseudo_U', 'pseudo_V', 'XX', 'YY', 'XY', 'YX', although
currently only 'pseudo_I' and linear dipole pol (e.g. 'XX') are implemented.
Default: 'pseudo_I'
'I', 'Q', 'U', 'V', 'XX', 'YY', 'XY', 'YX', although
currently only 'I' and linear dipole pol (e.g. 'XX') are implemented.
Default: 'I'
Returns
-------
Expand Down
2 changes: 1 addition & 1 deletion hera_pspec/pspecdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ def delays(self):
return utils.get_delays(self.freqs[self.spw_range[0]:self.spw_range[1]]) * 1e9 # convert to ns


def scalar(self, stokes='pseudo_I', taper='none', little_h=True, num_steps=2000, beam=None):
def scalar(self, stokes='I', taper='none', little_h=True, num_steps=2000, beam=None):
"""
Computes the scalar function to convert a power spectrum estimate
in "telescope units" to cosmological units, using self.spw_range to set spectral window.
Expand Down
4 changes: 2 additions & 2 deletions hera_pspec/tests/test_noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def test_add(self):

def test_scalar(self):
freqs = np.linspace(150e6, 160e6, 100, endpoint=False)
self.sense.calc_scalar(freqs, 'pseudo_I', num_steps=5000, little_h=True)
self.sense.calc_scalar(freqs, 'I', num_steps=5000, little_h=True)
nt.assert_true(np.isclose(freqs, self.sense.subband).all())
nt.assert_true(self.sense.stokes, 'I')

def test_calc_P_N(self):
# calculate scalar
freqs = np.linspace(150e6, 160e6, 100, endpoint=False)
self.sense.calc_scalar(freqs, 'pseudo_I', num_steps=5000, little_h=True)
self.sense.calc_scalar(freqs, 'I', num_steps=5000, little_h=True)
# basic execution
k = np.linspace(0, 3, 10)
Tsys = 500.0
Expand Down
8 changes: 4 additions & 4 deletions hera_pspec/tests/test_pspecbeam.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_UVbeam(self):
lower_freq = 120.*10**6
upper_freq = 128.*10**6
num_freqs = 20
scalar = self.bm.compute_pspec_scalar(lower_freq, upper_freq, num_freqs, stokes='pseudo_I', num_steps=2000)
scalar = self.bm.compute_pspec_scalar(lower_freq, upper_freq, num_freqs, stokes='I', num_steps=2000)

# Check that user-defined cosmology can be specified
bm = pspecbeam.PSpecBeamUV(self.beamfile,
Expand Down Expand Up @@ -72,7 +72,7 @@ def test_UVbeam(self):
self.assertAlmostEqual(scalar/567871703.75268996, 1.0, delta=1e-4)

# convergence of integral
scalar_large_Nsteps = self.bm.compute_pspec_scalar(lower_freq, upper_freq, num_freqs, stokes='pseudo_I', num_steps=10000)
scalar_large_Nsteps = self.bm.compute_pspec_scalar(lower_freq, upper_freq, num_freqs, stokes='I', num_steps=10000)
self.assertAlmostEqual(scalar / scalar_large_Nsteps, 1.0, delta=1e-5)

# test taper execution
Expand All @@ -93,7 +93,7 @@ def test_UVbeam(self):
nt.assert_raises(TypeError, self.bm.Jy_to_mK, np.array([1]))

# test noise scalar
sclr = self.bm.compute_pspec_scalar(lower_freq, upper_freq, num_freqs, stokes='pseudo_I', num_steps=2000, noise_scalar=True)
sclr = self.bm.compute_pspec_scalar(lower_freq, upper_freq, num_freqs, stokes='I', num_steps=2000, noise_scalar=True)
nt.assert_almost_equal(sclr, 70.983962969086235)


Expand All @@ -103,7 +103,7 @@ def test_Gaussbeam(self):
lower_freq = 120.*10**6
upper_freq = 128.*10**6
num_freqs = 20
scalar = self.gauss.compute_pspec_scalar(lower_freq, upper_freq, num_freqs, stokes='pseudo_I', num_steps=2000)
scalar = self.gauss.compute_pspec_scalar(lower_freq, upper_freq, num_freqs, stokes='I', num_steps=2000)

# Check that user-defined cosmology can be specified
bgauss = pspecbeam.PSpecBeamGauss(0.8,
Expand Down
5 changes: 2 additions & 3 deletions hera_pspec/uvpspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -962,9 +962,8 @@ def generate_noise_spectra(self, spw, pol, Tsys, blpairs=None,
# get frequency band
freqs = self.freq_array[self.spw_to_indices(spw)]

# calculate scalar, hard-coded to pseudo_I because that is currently all that pyuvdata supports
# near-future pyuvdata PR will extend support for extra polarizations
self.sensitivity.calc_scalar(freqs, 'pseudo_I', num_steps=num_steps, little_h=little_h)
# calculate scalar
self.sensitivity.calc_scalar(freqs, pol, num_steps=num_steps, little_h=little_h)

# Get k vectors
if form == 'DelSq':
Expand Down

0 comments on commit 3aa945a

Please sign in to comment.