Skip to content

Commit d3814a2

Browse files
committed
more test coverage
1 parent ff500c2 commit d3814a2

File tree

2 files changed

+49
-4
lines changed

2 files changed

+49
-4
lines changed

tests/uvbeam/test_mwa_beam.py

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,19 +196,54 @@ def test_mwa_pointing(delay_set, az_val, za_range):
196196
assert np.rad2deg(za_array[max_nn_loc]) < za_range[1]
197197

198198

199-
def test_mwa_fhd_decompose(mwa_beam_1ppd):
199+
@pytest.mark.parametrize(
200+
["approach", "inplace"],
201+
[
202+
("decompose", None),
203+
("separate", True),
204+
("separate", False),
205+
("joint", True),
206+
("joint", False),
207+
],
208+
)
209+
def test_mwa_fhd_decompose(mwa_beam_1ppd, approach, inplace):
200210
mwa_beam = mwa_beam_1ppd
201211
# select to above the horizon
202212
mwa_beam.select(axis2_inds=np.nonzero(mwa_beam.axis2_array <= np.pi / 2))
203213

204214
small_za_ind = np.nonzero(np.isclose(mwa_beam.axis2_array, 2.0 * np.pi / 180))
205215

206-
firesp, fproj = mwa_beam.decompose_feed_iresponse_projection()
207-
216+
if approach == "decompose":
217+
firesp, fproj = mwa_beam.decompose_feed_iresponse_projection()
218+
elif approach == "joint":
219+
rets = mwa_beam.efield_to_feed_projection(
220+
return_feed_iresponse=True, inplace=inplace
221+
)
222+
if inplace:
223+
firesp = rets
224+
fproj = mwa_beam
225+
else:
226+
firesp = rets[1]
227+
fproj = rets[0]
228+
else:
229+
mwa_beam2 = mwa_beam.copy()
230+
ret0 = mwa_beam.efield_to_feed_iresponse(inplace=inplace)
231+
ret1 = mwa_beam2.efield_to_feed_projection(
232+
return_feed_iresponse=False, inplace=inplace
233+
)
234+
if inplace:
235+
firesp = mwa_beam
236+
fproj = mwa_beam2
237+
else:
238+
firesp = ret0
239+
fproj = ret1
240+
241+
# feed I response should have a real component that is positive near zenith
208242
assert np.all(firesp.data_array[0, :, :, small_za_ind].real > 0)
209243

210244
az_array, za_array = np.meshgrid(mwa_beam.axis1_array, mwa_beam.axis2_array)
211245

246+
# MWA fproj is pretty similar to dipole_fproj up to mutual coupling effects
212247
dipole_beam = ShortDipoleBeam()
213248

214249
dipole_fproj = dipole_beam.feed_projection_eval(
@@ -218,7 +253,6 @@ def test_mwa_fhd_decompose(mwa_beam_1ppd):
218253
)
219254
dipole_fproj = dipole_fproj.reshape(2, 2, mwa_beam.Naxes2, mwa_beam.Naxes1)
220255

221-
# MWA fproj is pretty similar to dipole_fproj up to mutual coupling effects
222256
# they are very similar near zenith
223257
fproj_diff = fproj.data_array[:, :, 0] - dipole_fproj
224258

tests/uvbeam/test_uvbeam.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3596,3 +3596,14 @@ def test_plotting_errors(mwa_beam_1ppd):
35963596
"to plot.",
35973597
):
35983598
beam.plot(freq_ind=5.5)
3599+
3600+
3601+
@pytest.mark.parametrize(
3602+
"method", ["decompose_feed_iresponse_projection", "efield_to_feed_iresponse"]
3603+
)
3604+
def test_decompose_errors(cst_power_1freq, cst_efield_2freq_cut_healpix, method):
3605+
with pytest.raises(ValueError, match="beam_type must be efield."):
3606+
getattr(cst_power_1freq, method)()
3607+
3608+
with pytest.raises(ValueError, match="pixel_coordinate_system must be az_za."):
3609+
getattr(cst_efield_2freq_cut_healpix, method)()

0 commit comments

Comments
 (0)