Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9706fbd
add helper function to __init__
dmehring Feb 19, 2026
7e8c35e
test helpers
dmehring Feb 19, 2026
4993521
units, frame now in other attr dicts
dmehring Feb 19, 2026
53a8bb5
no more rest_frequencies in schema,freq coord type update
dmehring Feb 19, 2026
79397dc
test helpers
dmehring Feb 19, 2026
73b3174
incompute rewrite of tests to use truth images
dmehring Feb 19, 2026
721f664
add create_empty_sky_image tests
dmehring Feb 21, 2026
93c6095
rewrite make_empty_aperture_image tests
dmehring Feb 24, 2026
3d2362b
rewrite make_empty_lmuv_image tests
dmehring Feb 24, 2026
5282777
refactor, remove dead code, one last test done
dmehring Feb 25, 2026
104e582
refactor
dmehring Feb 26, 2026
398919d
refactor
dmehring Feb 26, 2026
43d3746
refactor
dmehring Feb 26, 2026
f351d5a
clean up
dmehring Feb 26, 2026
3ebd703
black
dmehring Feb 26, 2026
df8432d
add downloading of truth images
dmehring Mar 6, 2026
0cd118a
respond to copilot review comments
dmehring Mar 6, 2026
9aceaff
more responses to copilot comments
dmehring Mar 6, 2026
72532ad
more responses to copilot comments
dmehring Mar 6, 2026
8ec2c87
more responses to copilot comments
dmehring Mar 6, 2026
29476f6
transitional change, not ready for primetime
dmehring Mar 20, 2026
8b22da9
images that were created otf now downloaded
dmehring Mar 23, 2026
b4c8704
Merge branch 'main' into 536-rewrite-testsunitimagetest_imagepy-to-us…
dmehring Mar 23, 2026
2b3a0dc
Use `np.atleast_1d` for `worldreplace` coordinates and remove the ass…
r-xue Mar 26, 2026
f484e28
Merge pull request #558 from casangi/536-fix-casatools-backend-tests
dmehring Mar 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 0 additions & 57 deletions src/xradio/image/_util/_casacore/xds_from_casacore.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,6 @@ def _add_sky_or_aperture(
xda = xr.DataArray(ary, dims=dimorder).astype(ary.dtype)
with _open_image_ro(img_full_path) as casa_image:
xda.attrs = _casa_image_to_xds_image_attrs(casa_image, history, image_type)
# xds.attrs = attrs
# name = "SKY" if has_sph_dims else "APERTURE"
xda = xda.rename(image_type)
xds[xda.name] = xda
return xds
Expand All @@ -237,14 +235,12 @@ def _get_time_format(value: float, unit: str) -> str:


def _add_time_attrs(xds: xr.Dataset, coord_dict: dict) -> xr.Dataset:
# time_coord = xds['time']
meta = {}
meta["type"] = "time"
meta["scale"] = coord_dict["obsdate"]["refer"]
meta["units"] = [coord_dict["obsdate"]["m0"]["unit"]]
meta["format"] = _get_time_format(xds["time"][0], meta["units"])
xds["time"].attrs = copy.deepcopy(meta)
# xds['time'] = time_coord
return xds


Expand Down Expand Up @@ -321,31 +317,6 @@ def _casa_image_to_xds_attrs(img_full_path: str) -> dict:
attrs["coordinate_system_info"] = coordinate_system_info
return copy.deepcopy(attrs)

# dir_dict = {}

# dir_dict["reference"] = make_skycoord_dict(
# data=[0.0, 0.0], units="rad", frame=ap_system
# )
# if ap_equinox:
# dir_dict["reference"]["attrs"]["equinox"] = ap_equinox
# for i in range(2):
# unit = u.Unit(_get_unit(coord_dir_dict["units"][i]))
# q = coord_dir_dict["crval"][i] * unit
# x = q.to("rad")
# dir_dict["reference"]["data"][i] = float(x.value)
# k = "latpole"
# if k in coord_dir_dict:
# for j in (k, "lonpole"):
# m = "longpole" if j == "lonpole" else j
# dir_dict[j] = make_quantity(
# value=coord_dir_dict[m] * _deg_to_rad, units="rad", dims=["l", "m"]
# )
# for j in ("pc", "projection_parameters", "projection"):
# if j in coord_dir_dict:
# dir_dict[j] = coord_dir_dict[j]
# attrs["direction"] = dir_dict
# return copy.deepcopy(attrs)


def _casa_image_to_xds_coords(
img_full_path: str, verbose: bool, do_sky_coords: bool, image_type: str
Expand Down Expand Up @@ -561,23 +532,6 @@ def _get_dimmap(coords: list, verbose: bool = False) -> dict:
return dimmap


def _get_freq_values(coords: coordinates.coordinatesystem, shape: tuple) -> list:
idx = _get_image_axis_order(coords)[::-1].index("Frequency")
if idx >= 0:
coord_dict = coords.dict()
for k in coord_dict:
if k.startswith("spectral"):
wcs = coord_dict[k]["wcs"]
return _compute_linear_world_values(
naxis=shape[idx],
crval=wcs["crval"],
crpix=wcs["crpix"],
cdelt=wcs["cdelt"],
)
else:
return [1420e6]


def _get_freq_values_attrs(
casa_coords: coordinates.coordinatesystem, shape: tuple
) -> Tuple[List[float], dict]:
Expand All @@ -598,11 +552,7 @@ def _get_freq_values_attrs(
)
attrs["rest_frequency"] = make_quantity(sd["restfreq"], "Hz")
attrs["type"] = "spectral_coord"
attrs["units"] = sd["unit"]
attrs["frame"] = sd["system"]
attrs["wave_units"] = sd["waveUnit"]
# attrs["crval"] = sd["wcs"]["crval"]
# attrs["cdelt"] = sd["wcs"]["cdelt"]

attrs["reference_frequency"] = make_spectral_coord_reference_dict(
value=sd["wcs"]["crval"],
Expand Down Expand Up @@ -1122,11 +1072,6 @@ def _read_image_array(
"""
img_full_path = os.path.expanduser(infile)
with _open_image_ro(img_full_path) as casa_image:
"""
if isinstance(chunks, list):
mychunks = tuple(chunks)
elif isinstance(chunks, dict):
"""
if isinstance(chunks, dict):
mychunks = _get_chunk_list(
chunks,
Expand Down Expand Up @@ -1186,8 +1131,6 @@ def _read_image_array(
rtrc = rtrc + [1 for rr in range(5) if rr >= len(mychunks)]

# expand the actual data shape to the full 5 possible dims
# full_shape = cshape + [1 for rr in range(5) if rr >= len(cshape)]
# full_shape = list(rtrc - rblc)
full_chunks = mychunks[::-1] + tuple([1 for rr in range(5) if rr >= len(mychunks)])
d0slices = []
for d0 in range(rblc[0], rtrc[0], full_chunks[0]):
Expand Down
5 changes: 3 additions & 2 deletions src/xradio/image/_util/_casacore/xds_to_casacore.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,9 @@ def _coord_dict_from_xds(xds: xr.Dataset) -> dict:
coord["worldmap2"] = np.array([3], dtype=np.int32)
# this probbably needs some verification
coord["worldreplace0"] = [0.0, 0.0]
coord["worldreplace1"] = np.array(coord["stokes1"]["crval"])
coord["worldreplace2"] = np.array(coord["spectral2"]["wcs"]["crval"])
coord["worldreplace1"] = np.atleast_1d(coord["stokes1"]["crval"])
coord["worldreplace2"] = np.atleast_1d(coord["spectral2"]["wcs"]["crval"])

return coord


Expand Down
5 changes: 3 additions & 2 deletions src/xradio/image/_util/_fits/xds_from_fits.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ def _add_freq_attrs(xds: xr.Dataset, helpers: dict) -> xr.Dataset:
meta = {}
if helpers["has_freq"]:
meta["rest_frequency"] = make_quantity(helpers["restfreq"], "Hz")
meta["rest_frequencies"] = [meta["rest_frequency"]]
meta["type"] = "frequency"
# it appears this was purged from the schema, not sure why
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment "it appears this was purged from the schema, not sure why" is vague and suggests uncertainty. If the removal of rest_frequencies is intentional to align with the CASA code path (which also doesn't have it), consider replacing this comment with a more definitive explanation. Additionally, note that the image factory in image_factory.py:85 still sets rest_frequencies — you may want to verify if the factory should also be updated for consistency.

Suggested change
# it appears this was purged from the schema, not sure why
# rest_frequencies was removed from the schema; we now expose only
# the scalar rest_frequency here to match the CASA code path and
# current image schema.

Copilot uses AI. Check for mistakes.
# meta["rest_frequencies"] = [meta["rest_frequency"]]
meta["type"] = "spectral_coord"
meta["wave_units"] = "mm"
freq_axis = helpers["freq_axis"]
meta["reference_frequency"] = make_spectral_coord_reference_dict(
Expand Down
9 changes: 9 additions & 0 deletions src/xradio/testing/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from xradio.testing.assertions import (
assert_attrs_dicts_equal,
assert_xarray_datasets_equal,
)

__all__ = [
"assert_attrs_dicts_equal",
"assert_xarray_datasets_equal",
]
Loading
Loading