Skip to content

Commit

Permalink
fix: updates to Bryna's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-murray committed Nov 13, 2024
1 parent 5b378e6 commit 304c63d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ All notable changes to this project will be documented in this file.
## [Unreleased]

### Added
- New convenience methods on `BeamInterface` to simplify the handling of analytic vs UVBeam objects.
- Added support for partial read for MWA correlator FITS files.
- Added `antenna_names`, `time_range`, `lsts` and `lst_range` parameters to
`UVFlag.select` to match UVData and UVCal select methods.
- New convenience methods on `BeamInterface` to simplify the handling of analytic vs
UVBeam objects.

### Changed
- Made it possible to *not* return the `interp_basis_vector` array from beam
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ select = [
]
ignore = [
"N806", # non-lowercase variable (we use N* for axes lengths)
"N802", # non-lowercase function name (we use N* for axes lengths)
"B028", # no-explicit-stacklevel for warnings
"SIM108", # prefer ternary opperators. I find them difficult to read.
"D203", # one-blank-line-before-class. we use two.
Expand Down
28 changes: 22 additions & 6 deletions src/pyuvdata/beam_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __post_init__(self, include_cross_pols: bool):
if isinstance(self.beam, UVBeam):
if self.beam_type is None or self.beam_type == self.beam.beam_type:
self.beam_type = self.beam.beam_type
elif self.beam_type == "power" and self.beam.beam_type != "power":
elif self.beam_type == "power":
warnings.warn(
"Input beam is an efield UVBeam but beam_type is specified as "
"'power'. Converting efield beam to power."
Expand All @@ -94,7 +94,7 @@ def __post_init__(self, include_cross_pols: bool):
self.beam_type = "efield"

@property
def Npols(self):
def Npols(self): # noqa N802
"""The number of polarizations in the beam."""
return self.beam.Npols or len(self.polarization_array)

Expand All @@ -109,7 +109,7 @@ def feed_array(self):
return self.beam.feed_array

@property
def Nfeeds(self):
def Nfeeds(self): # noqa N802
"""The number of feeds defined on the beam."""
return self.beam.Nfeeds or len(self.feed_array)

Expand All @@ -118,7 +118,7 @@ def clone(self, **kw):
return replace(self, **kw)

def as_power_beam(
self, include_cross_pols: bool = True, allow_beam_mutation: bool = False
self, include_cross_pols: bool | None = None, allow_beam_mutation: bool = False
):
"""Return a new interface instance that is in the power-beam mode.
Expand All @@ -129,13 +129,30 @@ def as_power_beam(
Parameters
----------
include_cross_pols : bool, optional
Whether to include cross-pols in the power beam.
Whether to include cross-pols in the power beam. By default, this is True
for E-field beams, and takes the same value as the existing beam if the
existing beam is already a power beam.
allow_beam_mutation : bool, optional
Whether to allow the underlying beam to be updated in-place.
"""
if self.beam_type == "power":
if include_cross_pols is None:
# By default, keep the value of include_cross_pols the same.
include_cross_pols = self.Npols > 2

if self.Npols > 1 and (
(include_cross_pols and self.Npols != 4)
or (not include_cross_pols and self.Npols != 4)
):
warnings.warn(

Check warning on line 147 in src/pyuvdata/beam_interface.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/beam_interface.py#L147

Added line #L147 was not covered by tests
"as_power_beam does not modify cross pols when the beam is"
"already in power mode!"
)
return self

if include_cross_pols is None:
include_cross_pols = True

Check warning on line 154 in src/pyuvdata/beam_interface.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/beam_interface.py#L154

Added line #L154 was not covered by tests

beam = self.beam if allow_beam_mutation else copy.deepcopy(self.beam)

# We cannot simply use .clone() here, because we need to be able to pass
Expand Down Expand Up @@ -176,7 +193,6 @@ def with_feeds(self, feeds, *, maintain_ordering: bool = True):
use_pols = [
p for p in self.beam.polarization_array if p in possible_pol_ints
]
print("use_pols: ", use_pols)
else:
use_pols = [
p for p in possible_pol_ints if p in self.beam.polarization_array
Expand Down

1 comment on commit 304c63d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 304c63d Previous: 72dd3bc Ratio
tests/uvdata/test_mwa_corr_fits.py::test_van_vleck[cheby=True] 4.438941417745471 iter/sec (stddev: 0.08279880633802884) 10.115029583093587 iter/sec (stddev: 0.010289479599246814) 2.28

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.