-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pspecbeam.PSpecBeamUV updates for efield beam #143
Changes from all commits
66c5cff
5dca1ec
9d594dc
08c114a
13bd781
f3e8ab1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -358,30 +358,49 @@ def power_beam_sq_int(self, pol='pI'): | |
|
||
class PSpecBeamUV(PSpecBeamBase): | ||
|
||
def __init__(self, beam_fname, cosmo=None): | ||
def __init__(self, uvbeam, cosmo=None): | ||
""" | ||
Object to store the primary beam for a pspec observation. | ||
This is subclassed from PSpecBeamBase to take in a pyuvdata | ||
UVBeam object. | ||
UVBeam filepath or object. | ||
|
||
Note: If one wants to use this object for linear dipole | ||
polarizations (e.g. XX, XY, YX, YY) then one can feed | ||
uvbeam as a dipole power beam or an efield beam. If, however, | ||
one wants to use this for pseudo-Stokes polarizations | ||
(e.g. pI, pQ, pU, pV), one must feed uvbeam as a pstokes | ||
power beam. See pyuvdata.UVBeam for details on forming | ||
pstokes power beams from an efield beam. | ||
|
||
Parameters | ||
---------- | ||
beam_fname: str | ||
Path to a pyuvdata UVBeam file. | ||
uvbeam: str or UVBeam object | ||
Path to a pyuvdata UVBeam file or a UVBeam object. | ||
|
||
cosmo : conversions.Cosmo_Conversions object, optional | ||
Cosmology object. Uses the default cosmology object if not | ||
specified. Default: None. | ||
""" | ||
self.primary_beam = UVBeam() | ||
self.primary_beam.read_beamfits(beam_fname) | ||
# setup uvbeam object | ||
if isinstance(uvbeam, str): | ||
uvb = UVBeam() | ||
uvb.read_beamfits(uvbeam) | ||
else: | ||
uvb = uvbeam | ||
|
||
self.beam_freqs = self.primary_beam.freq_array[0] | ||
# get frequencies and set cosmology | ||
self.beam_freqs = uvb.freq_array[0] | ||
if cosmo is not None: | ||
self.cosmo = cosmo | ||
else: | ||
self.cosmo = conversions.Cosmo_Conversions() | ||
|
||
# setup primary power beam | ||
self.primary_beam = uvb | ||
if uvb.beam_type == 'efield': | ||
self.primary_beam.efield_to_power(inplace=True) | ||
self.primary_beam.peak_normalize() | ||
|
||
def power_beam_int(self, pol='pI'): | ||
""" | ||
Computes the integral of the beam over solid angle to give | ||
|
@@ -404,7 +423,7 @@ def power_beam_int(self, pol='pI'): | |
Scalar integral over beam solid angle. | ||
""" | ||
if hasattr(self.primary_beam, 'get_beam_area'): | ||
return self.primary_beam.get_beam_area(pol) | ||
return np.real(self.primary_beam.get_beam_area(pol)) | ||
else: | ||
raise NotImplementedError("Outdated version of pyuvdata.") | ||
|
||
|
@@ -429,7 +448,7 @@ def power_beam_sq_int(self, pol='pI'): | |
primary_beam_area: float, array-like | ||
""" | ||
if hasattr(self.primary_beam, 'get_beam_area'): | ||
return self.primary_beam.get_beam_sq_area(pol) | ||
return np.real(self.primary_beam.get_beam_sq_area(pol)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this function be returning complex numbers to begin with? Or is there a bug in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's what I was asking @bhazelton, and I never got a response, but I think I came to the conclusion that in principle it can be complex (e.g. when asking for |
||
else: | ||
raise NotImplementedError("Outdated version of pyuvdata.") | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
efield_to_power is called for linear polarizations, for pseudo-stokes you need to use the function efield_to_pstokes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is done assuming one only wants linear dipole polarization. This function is (purposely) not trying to be smart and will not convert the efield to pstokes. To
pspecbeam
for pstokes parameters, one needs to feed a pstokes power beam. (see the unit tests added where I test for exactly this case). I'll make a comment specifying this in the docstring!