RadioAstronomySoftwareGroup / pyuvsim

A ultra-high precision package for simulating radio interferometers in python on compute clusters.
https://pyuvsim.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
43 stars 7 forks source link

Ordering of UVData matters #370

Closed steven-murray closed 2 years ago

steven-murray commented 2 years ago

There seems to be an issue when the ordering of the input UVData is not "time". I came across this in testing for the hera_sim wrapper. The TLDR is that if you reorder the UVData object to anything but "time", then put it into pyuvsim, then reorder back to time, the resulting data array doesn't look right (eg. looking at data for non-redundant baselines gives the same visibilities, which can't be true).

I'll put a not-quite-minimal failing example below, copied from the hera_sim tests. Note that we run this test over all our wrappers (eg. VisCPU and Healvis) and it passes for them.


@pytest.fixture(scope="function")
def uvdata_linear():
    defaults.set("h1c")
    return io.empty_uvdata(
        Nfreqs=1,
        integration_time=sday.to("s") / NTIMES,
        Ntimes=NTIMES,
        array_layout={0: (0, 0, 0), 1: (10, 0, 0), 2: (20, 0, 0), 3: (0, 10, 0)},
        start_time=2456658.5,
        conjugation="ant1<ant2",
        polarization_array=["xx", "yy", "xy", "yx"],
    )

def test_ordering(uvdata_linear, simulator, order, conj):

    uvdata_linear.reorder_blts(order=order, conj_convention=conj)

    sky_model = make_point_sky(
        uvdata_linear,
        ra=np.linspace(0, 2 * np.pi, 8) * rad,
        dec=uvdata_linear.telescope_location_lat_lon_alt[0] * np.ones(8) * rad,
        align=False,
    )

    out_uv = pyuvsim.uvsim.run_uvdata_uvsim(
            input_uv=uvdata_linear,
            beam_list=<beamlist>,
            beam_dict=beam_dict,
            catalog=pyuvsim.simsetup.SkyModelData(sky_model),
     )
    uvdata_linear.data_array = out_uv.data_array

    uvdata_linear.reorder_blts(order="time", conj_convention="ant1<ant2")

    # THIS FAILS
    assert not np.allclose(
        uvdata_linear.get_data((0, 1)), uvdata_linear.get_data((0,3))
    )