Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
All notable changes to this project will be documented in this file.

## [Unreleased]
### Changed
- When reading MWAX correlator files , `remove_coarse_band` now defaults to
`False` if DERIPPLE is on. Otherwise it defaults to `True`.
- If the user has set `remove_coarse_band=True` when DERIPPLE is on, a warning is
raised, and no pfb shape is removed.

### Added
- A NotImplementedError to `mwa_corr_fits.py` that is thrown when trying to read
Expand Down
25 changes: 24 additions & 1 deletion src/pyuvdata/uvdata/mwa_corr_fits.py
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,7 @@ def read_mwa_corr_fits(
keep_all_metadata=True,
use_aoflagger_flags=None,
remove_dig_gains=True,
remove_coarse_band=True,
remove_coarse_band=None,
correct_cable_len=True,
correct_van_vleck=False,
cheby_approx=True,
Expand Down Expand Up @@ -1745,6 +1745,29 @@ def read_mwa_corr_fits(
if key not in self.extra_keywords:
self.extra_keywords[key] = value

if remove_coarse_band is None:
if (
"DERIPPLE" in self.extra_keywords
and self.extra_keywords["DERIPPLE"] == 1
):
remove_coarse_band = False
else:
remove_coarse_band = True
elif (
remove_coarse_band is True
and "DERIPPLE" in self.extra_keywords
and self.extra_keywords["DERIPPLE"] == 1
):
# turn off pfb correction if it was corrected in the correlator
warnings.warn(
"No coarse band shape will be removed from this data "
"because DERIPPLE is on.",
stacklevel=2,
)
remove_coarse_band = False
else:
pass

# set parameters from other parameters
self.telescope.Nants = len(self.telescope.antenna_numbers)
self.Nants_data = len(self.telescope.antenna_numbers)
Expand Down
40 changes: 40 additions & 0 deletions tests/uvdata/test_mwa_corr_fits.py
Original file line number Diff line number Diff line change
Expand Up @@ -1711,3 +1711,43 @@ def test_fringe_stopping_error(tmp_path):
NotImplementedError, match="This data has had fringe stopping applied. "
):
UVData.from_file([test_metafits, fetch_data("mwax_2021_raw_gpubox")])


@pytest.mark.filterwarnings("ignore:some coarse channel files were not submitted")
@pytest.mark.filterwarnings("ignore:Fixing auto-correlations to be be real-only")
def test_deripple_on_warns_and_passes(tmp_path):
test_metafits = str(tmp_path / "1131733552_dr.metafits")
with fits.open(fetch_data("mwax_2021_metafits")) as meta:
meta[0].header["DERIPPLE"] = 1
meta.writeto(test_metafits)
with pytest.warns(UserWarning, match="No coarse band shape will be removed"):
uvd = UVData.from_file(
[test_metafits, fetch_data("mwax_2021_raw_gpubox")], remove_coarse_band=True
)
assert "Divided out pfb coarse channel bandpass" not in uvd.history


@pytest.mark.filterwarnings("ignore:some coarse channel files were not submitted")
@pytest.mark.filterwarnings("ignore:Fixing auto-correlations to be be real-only")
def test_deripple_remove_coarse_band_none(tmp_path):
test_metafits = str(tmp_path / "1131733551_dr.metafits")
with fits.open(fetch_data("mwax_2021_metafits")) as meta:
meta[0].header["DERIPPLE"] = 1
meta.writeto(test_metafits)
uvd = UVData.from_file(
[test_metafits, fetch_data("mwax_2021_raw_gpubox")], remove_coarse_band=None
)
assert "Divided out pfb coarse channel bandpass" not in uvd.history


@pytest.mark.filterwarnings("ignore:some coarse channel files were not submitted")
@pytest.mark.filterwarnings("ignore:Fixing auto-correlations to be be real-only")
def test_deripple_off_does_nothing(tmp_path):
test_metafits = str(tmp_path / "1131733550_dr.metafits")
with fits.open(fetch_data("mwax_2021_metafits")) as meta:
meta[0].header["DERIPPLE"] = 0
meta.writeto(test_metafits)
uvd = UVData.from_file(
[test_metafits, fetch_data("mwax_2021_raw_gpubox")], remove_coarse_band=True
)
assert "Divided out pfb coarse channel bandpass" in uvd.history
Loading