Skip to content

Commit

Permalink
Merge pull request #157 from HERA-Team/fix_lsts
Browse files Browse the repository at this point in the history
Fix Simulator LST array
  • Loading branch information
r-pascua authored Jul 7, 2021
2 parents e91c6ec + 6f2bee7 commit 2005a45
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
Changelog
=========

v1.0.2 [2021.07.01]
===================

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.
- :func:`~.io.empty_uvdata` now sets the ``phase_type`` attribute to "drift".

v1.0.1 [2021.06.30]
===================

Expand Down
6 changes: 6 additions & 0 deletions hera_sim/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -100,6 +101,11 @@ def empty_uvdata(
complete=True,
**kwargs,
)
# 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)
Expand Down
6 changes: 2 additions & 4 deletions hera_sim/simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions hera_sim/tests/test_simulate_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions hera_sim/tests/test_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ 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,
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)
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)
Expand Down

0 comments on commit 2005a45

Please sign in to comment.