Skip to content

Commit

Permalink
add mwa and mwax reading benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
mkolopanis committed Sep 24, 2024
1 parent e24e9f9 commit 13eea2c
Showing 1 changed file with 101 additions and 0 deletions.
101 changes: 101 additions & 0 deletions tests/uvdata/test_mwa_corr_fits.py
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,107 @@ def test_default_corrections(tmp_path):
assert "Applied cable length correction" in uv2.history


@pytest.mark.skipif(not hasbench, reason="benchmark utility not installed")
def test_read_mwa(benchmark, tmp_path):
"""
MWA correlator fits to uvfits loopback test.
Read in MWA correlator files, write out as uvfits, read back in and check
for object equality.
"""
mwa_uv = UVData()
uvfits_uv = UVData()
# we check warnings earlier here we care about performance.
with warnings.catch_warnings():
warnings.simplefilter("ignore")
benchmark(
mwa_uv.read,
filelist[0:2],
correct_cable_len=True,
phase_to_pointing_center=True,
)

testfile = str(tmp_path / "outtest_MWAcorr.uvfits")
mwa_uv.write_uvfits(testfile)
uvfits_uv.read_uvfits(testfile)

# make sure filenames are what we expect
assert set(mwa_uv.filename) == {
"1131733552.metafits",
"1131733552_20151116182537_mini_gpubox01_00.fits",
}
assert uvfits_uv.filename == ["outtest_MWAcorr.uvfits"]
mwa_uv.filename = uvfits_uv.filename
mwa_uv._filename.form = (1,)

for item in ["dut1", "earth_omega", "gst0", "rdate", "timesys"]:
# Check to make sure that the UVFITS-specific paramters are set on the
# UVFITS-based obj, and not on our original object. Then set it to None for the
# UVFITS-based obj.
assert getattr(mwa_uv, item) is None
assert getattr(uvfits_uv, item) is not None
setattr(uvfits_uv, item, None)

uvfits_uv._consolidate_phase_center_catalogs(
reference_catalog=mwa_uv.phase_center_catalog
)
assert mwa_uv == uvfits_uv


@pytest.mark.filterwarnings("ignore:antnums_to_baseline")
@pytest.mark.filterwarnings("ignore:Found antenna numbers > 255 in this data")
@pytest.mark.skipif(not hasbench, reason="benchmark utility not installed")
def test_read_mwax(benchmark, tmp_path):
"""
MWAX correlator fits to uvfits loopback test.
Read in MWAX correlator files, write out as uvfits, read back in and check
for object equality.
"""
# spoof testfile to contain 2 times and 2 freqs
spoof_file = str(tmp_path / "mwax_spoof_ch137_000.fits")
with fits.open(filelist[12]) as mini1:
mini1[1].data = np.repeat(mini1[1].data, 2, axis=1)
mini1[2].data = np.repeat(mini1[2].data, 2, axis=1)
extra_dat = np.copy(mini1[1].data)
extra_samps = np.copy(mini1[2].data)
mini1.append(fits.ImageHDU(extra_dat))
mini1.append(fits.ImageHDU(extra_samps))
mini1[3].header["TIME"] = 1636374472
mini1[4].header["TIME"] = 1636374472
mini1[3].header["MILLITIM"] = 0
mini1[4].header["MILLITIM"] = 0
mini1.writeto(spoof_file)
mwax_uv = UVData()
uvfits_uv = UVData()

# we check warnings earlier here we care about performance.
with warnings.catch_warnings():
warnings.simplefilter("ignore")
benchmark(
mwax_uv.read,
[spoof_file, filelist[11]],
correct_cable_len=True,
phase_to_pointing_center=True,
)
testfile = str(tmp_path / "outtest_MWAXcorr.uvfits")
mwax_uv.write_uvfits(testfile)
uvfits_uv.read_uvfits(testfile)

for item in ["dut1", "earth_omega", "gst0", "rdate", "timesys"]:
# Check to make sure that the UVFITS-specific paramters are set on the
# UVFITS-based obj, and not on our original object. Then set it to None for the
# UVFITS-based obj.
assert getattr(mwax_uv, item) is None
assert getattr(uvfits_uv, item) is not None
setattr(uvfits_uv, item, None)

uvfits_uv._consolidate_phase_center_catalogs(
reference_catalog=mwax_uv.phase_center_catalog, ignore_name=True
)
assert mwax_uv == uvfits_uv


@pytest.mark.skipif(not hasbench, reason="benchmark utility not installed")
def test_corr_fits_select_on_read(benchmark):
mwa_uv = UVData()
Expand Down

2 comments on commit 13eea2c

@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: 13eea2c Previous: e24e9f9 Ratio
tests/utils/test_bls.py::test_bls_to_ant[min=0-len=1] 32950.60703849764 iter/sec (stddev: 0.0000050454620178087835) 126341.09324403049 iter/sec (stddev: 0.00000283536162085795) 3.83

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

@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: 13eea2c Previous: e24e9f9 Ratio
tests/utils/test_bls.py::test_bls_to_ant[min=4259840-len=1000000] 40.465281659069234 iter/sec (stddev: 0.027700154658305515) 81.18231217717381 iter/sec (stddev: 0.0003328855455023551) 2.01
tests/utils/test_bls.py::test_ants_to_bls[min=0-len=10000] 545.6664119999737 iter/sec (stddev: 0.0022979431048648813) 2157.9299585756726 iter/sec (stddev: 0.0001132114981571514) 3.95
tests/utils/test_bls.py::test_ants_to_bls[min=65536-len=1] 5975.8078209931255 iter/sec (stddev: 0.00029878761112567124) 13599.332745375197 iter/sec (stddev: 0.000027933534475555287) 2.28
tests/utils/test_bls.py::test_ants_to_bls[min=4259840-len=1] 5752.426938764758 iter/sec (stddev: 0.002356484821543443) 13687.154782220867 iter/sec (stddev: 0.0000399383740718475) 2.38

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

Please sign in to comment.