Skip to content

Commit

Permalink
Fix a bug with beam freq selects using freq buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
bhazelton committed Jan 16, 2025
1 parent d8253e9 commit 51f9ddb
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ string/object mode switch.
- Setting the `select.bls` property in the obsparams file now selects baselines _before_
creating the UVData object, rather than down-selecting afterwards, saving memory and time.

### Fixed
- A bug when specifying a frequency buffer for beam frequency selects in telescope
config files.

## [1.3.1] - 2024-07-18

### Added
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
beam_paths:
0: !UVBeam
filename: HERA_NicCST.beamfits
path_variable: pyuvsim.data.DATA_PATH
1: !AnalyticBeam
class: UniformBeam
2: !AnalyticBeam
class: GaussianBeam
sigma: 0.02
3: !AnalyticBeam
class: AiryBeam
diameter: 14.6
telescope_location: (-30.721527777777847, 21.428305555555557, 1073.0000000046566)
telescope_name: Triangle
select:
freq_buffer: 1000000.0 # Restrict beam to read frequencies within 1MHz of sim freqs.
23 changes: 23 additions & 0 deletions src/pyuvsim/data/test_config/obsparam_diffuse_sky_freqbuf_tel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
filing:
outdir: '.'
outfile_name: 'sim_results.uvfits'
freq:
Nfreqs: 1
bandwidth: 800000.0
start_freq: 100000000.0
sources:
catalog: 'mock'
time: 2457458.1738949567
mock_arrangement: 'diffuse'
diffuse_model: 'monopole'
map_nside: 128
telescope:
telescope_config_name: '28m_triangle_10time_10chan_freqbuff.yaml'
array_layout: 'triangle_bl_layout.csv'
time:
Ntimes: 1
integration_time: 11.0
start_time: 2457458.1738949567
ordering:
conjugation_convention: ant1<ant2
blt_order: [time, baseline]
11 changes: 6 additions & 5 deletions src/pyuvsim/simsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,17 +1109,18 @@ def _construct_beam_list(
)

select = telconfig.pop("select", {})
freq_buffer = select.pop("freq_buffer", None)
if (
freq_range is not None
and "freq_range" not in select
and "freq_buffer" not in select
and freq_buffer is None
):
select["freq_range"] = freq_range
if "freq_buffer" in select and "freq_range" not in select:
freq_arr_val = freq_array.to("Hz").value
if freq_buffer is not None and "freq_range" not in select:
freq_arr_val = freq_array
freq_range = (
freq_arr_val.min() - select["freq_buffer"],
freq_arr_val.max() + select["freq_buffer"],
freq_arr_val.min() - freq_buffer,
freq_arr_val.max() + freq_buffer,
)
select["freq_range"] = freq_range

Expand Down
12 changes: 10 additions & 2 deletions tests/test_simsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1831,7 +1831,7 @@ def test_beamlist_init_freqrange(sel_type):
}

Nfreqs = 10
freqs = np.linspace(120, 145, Nfreqs) * 1e6 * units.Hz
freqs = np.linspace(120, 145, Nfreqs) * 1e6

freq_range = [117e6, 148e6]
if sel_type == "freq_range":
Expand Down Expand Up @@ -2057,7 +2057,7 @@ def test_skymodeldata_attr_bases(inds, cat_with_some_pols):
assert smd_copy.stokes_I.base is smd.stokes_I.base


def test_simsetup_with_freq_buffer():
def test_simsetup_with_obsparam_freq_buffer():
fl = os.path.join(SIM_DATA_PATH, "test_config", "obsparam_diffuse_sky_freqbuf.yaml")

with check_warnings(
Expand All @@ -2069,3 +2069,11 @@ def test_simsetup_with_freq_buffer():
_, beams, _ = simsetup.initialize_uvdata_from_params(fl, return_beams=True)

assert beams[0].beam.freq_array.max() < 101e6


def test_simsetup_with_freq_buffer():
fl = os.path.join(SIM_DATA_PATH, "test_config", "obsparam_diffuse_sky_freqbuf_tel.yaml")

_, beams, _ = simsetup.initialize_uvdata_from_params(fl, return_beams=True)

assert beams[0].beam.freq_array.max() < 101e6

0 comments on commit 51f9ddb

Please sign in to comment.