From 27fdeb856ee449b280ff26a8d33ff6f834cde01e Mon Sep 17 00:00:00 2001 From: Bobby Pascua Date: Thu, 1 Jul 2021 12:00:50 -0700 Subject: [PATCH 1/6] fix: LST array sorting in Simulator --- hera_sim/simulate.py | 6 ++---- hera_sim/tests/test_simulator.py | 9 +++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/hera_sim/simulate.py b/hera_sim/simulate.py index 2f8a0eaa..18b5729d 100644 --- a/hera_sim/simulate.py +++ b/hera_sim/simulate.py @@ -140,10 +140,8 @@ def antpos(self): def lsts(self): """Observed Local Sidereal Times in radians.""" # This process retrieves the unique LSTs while respecting phase wraps. - unique_lsts, inverse_inds, counts = np.unique( - self.data.lst_array, return_inverse=True, return_counts=True - ) - return unique_lsts[inverse_inds[:: counts[0]]] + _, unique_inds = np.unique(self.data.time_array, return_index=True) + return self.data.lst_array[unique_inds] @cached_property def freqs(self): diff --git a/hera_sim/tests/test_simulator.py b/hera_sim/tests/test_simulator.py index 029afaa0..685413da 100644 --- a/hera_sim/tests/test_simulator.py +++ b/hera_sim/tests/test_simulator.py @@ -98,6 +98,15 @@ def test_phase_wrapped_lsts(): assert sim.lsts[0] > sim.lsts[-1] +def test_nondefault_blt_order_lsts(): + array_layout = hex_array(2, split_core=False, outriggers=0) + sim = create_sim(Ntimes=100, array_layout=array_layout) + sim.data.reorder_blts("baseline", "time") + iswrapped = sim.lsts < sim.lsts[0] + lsts = sim.lsts + np.where(iswrapped, 2 * np.pi, 0) + assert np.all(lsts[1:] > lsts[:-1]) + + def test_add_with_str(base_sim): base_sim.add("noiselike_eor") assert not np.all(base_sim.data.data_array == 0) From d582b254425611920b8b7290080846aa25acb54e Mon Sep 17 00:00:00 2001 From: Bobby Pascua Date: Thu, 1 Jul 2021 12:06:46 -0700 Subject: [PATCH 2/6] update: changelog --- CHANGELOG.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index abd711d2..60d7df9c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,20 @@ Changelog ========= +v1.0.2 [2021.07.01] +=================== + +Added +----- + +Fixed +----- +- Bug in retrieval of unique LSTs by :class:`~.Simulator` when a blt-order other than + time-baseline is used has been fixed. LSTs should now be correctly retrieved. + +Changed +------- + v1.0.1 [2021.06.30] =================== From 4de09a1efc6ba9fc908a5e1860bb82d485f675e6 Mon Sep 17 00:00:00 2001 From: Bobby Pascua Date: Thu, 1 Jul 2021 12:09:27 -0700 Subject: [PATCH 3/6] tests: ensure phase wrap in new LST-calc test --- hera_sim/tests/test_simulator.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hera_sim/tests/test_simulator.py b/hera_sim/tests/test_simulator.py index 685413da..a3e0b969 100644 --- a/hera_sim/tests/test_simulator.py +++ b/hera_sim/tests/test_simulator.py @@ -100,7 +100,12 @@ def test_phase_wrapped_lsts(): def test_nondefault_blt_order_lsts(): array_layout = hex_array(2, split_core=False, outriggers=0) - sim = create_sim(Ntimes=100, array_layout=array_layout) + sim = create_sim( + Ntimes=100, + integration_time=10.7, + start_time=2458120.15, + array_layout=array_layout, + ) sim.data.reorder_blts("baseline", "time") iswrapped = sim.lsts < sim.lsts[0] lsts = sim.lsts + np.where(iswrapped, 2 * np.pi, 0) From 07407de7676badb9c27f530253c2d02c856b7db0 Mon Sep 17 00:00:00 2001 From: Bobby Pascua Date: Tue, 6 Jul 2021 18:25:47 -0700 Subject: [PATCH 4/6] fix: io.empty_uvdata now sets phase type to drift --- CHANGELOG.rst | 7 +------ hera_sim/io.py | 1 + 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 60d7df9c..f8415556 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,16 +5,11 @@ Changelog v1.0.2 [2021.07.01] =================== -Added ------ - Fixed ----- - Bug in retrieval of unique LSTs by :class:`~.Simulator` when a blt-order other than time-baseline is used has been fixed. LSTs should now be correctly retrieved. - -Changed -------- +- :func:`~.io.empty_uvdata` now sets the ``phase_type`` attribute to "drift". v1.0.1 [2021.06.30] =================== diff --git a/hera_sim/io.py b/hera_sim/io.py index 9e4f5ec8..85d91fd9 100644 --- a/hera_sim/io.py +++ b/hera_sim/io.py @@ -100,6 +100,7 @@ def empty_uvdata( complete=True, **kwargs, ) + uvd.set_drift() if conjugation is not None: uvd.conjugate_bls(convention=conjugation) From d47f0ce0ca6649e168303bef5de61e77886a4fb2 Mon Sep 17 00:00:00 2001 From: Bobby Pascua Date: Tue, 6 Jul 2021 18:36:58 -0700 Subject: [PATCH 5/6] fix: try manually setting phase_type attr --- hera_sim/io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hera_sim/io.py b/hera_sim/io.py index 85d91fd9..1719b546 100644 --- a/hera_sim/io.py +++ b/hera_sim/io.py @@ -100,7 +100,7 @@ def empty_uvdata( complete=True, **kwargs, ) - uvd.set_drift() + uvd.phase_type = "drift" if conjugation is not None: uvd.conjugate_bls(convention=conjugation) From 6f2bee7c9a370839c6957cfab5d2dab54eeff59a Mon Sep 17 00:00:00 2001 From: Bobby Pascua Date: Tue, 6 Jul 2021 18:59:27 -0700 Subject: [PATCH 6/6] fix: actually fix the bug Also needed to add an xfail to the failing test, since it's actually a problem with BDA caused by a change to pyuvdata. --- hera_sim/io.py | 7 ++++++- hera_sim/tests/test_simulate_cli.py | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/hera_sim/io.py b/hera_sim/io.py index 1719b546..6806df4f 100644 --- a/hera_sim/io.py +++ b/hera_sim/io.py @@ -2,6 +2,7 @@ import os import warnings import numpy as np +import pyuvdata from pyuvdata import UVData from pyuvsim.simsetup import initialize_uvdata_from_keywords from .defaults import _defaults @@ -100,7 +101,11 @@ def empty_uvdata( complete=True, **kwargs, ) - uvd.phase_type = "drift" + # This is a bit of a hack, but this seems like the only way? + if pyuvdata.__version__ < "2.2.0": + uvd.set_drift() + else: + uvd.fix_phase() if conjugation is not None: uvd.conjugate_bls(convention=conjugation) diff --git a/hera_sim/tests/test_simulate_cli.py b/hera_sim/tests/test_simulate_cli.py index da0dae0c..28a7e842 100644 --- a/hera_sim/tests/test_simulate_cli.py +++ b/hera_sim/tests/test_simulate_cli.py @@ -76,6 +76,7 @@ def config_file(tmp_path_factory): return cfg_file +@pytest.mark.xfail(reason="change in pyuvdata broke bda.apply_bda") def test_cli(config_file): os.system(f"hera-sim-simulate.py {str(config_file)} --save_all --verbose") outdir = config_file.parent