xradio 0.0.53__py3-none-any.whl → 0.0.55__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- xradio/image/_util/_casacore/xds_from_casacore.py +36 -69
- xradio/image/_util/_casacore/xds_to_casacore.py +4 -2
- xradio/image/_util/_fits/xds_from_fits.py +1 -1
- xradio/image/_util/casacore.py +16 -11
- xradio/image/image.py +1 -1
- {xradio-0.0.53.dist-info → xradio-0.0.55.dist-info}/METADATA +1 -1
- {xradio-0.0.53.dist-info → xradio-0.0.55.dist-info}/RECORD +10 -10
- {xradio-0.0.53.dist-info → xradio-0.0.55.dist-info}/WHEEL +1 -1
- {xradio-0.0.53.dist-info → xradio-0.0.55.dist-info}/licenses/LICENSE.txt +0 -0
- {xradio-0.0.53.dist-info → xradio-0.0.55.dist-info}/top_level.txt +0 -0
|
@@ -54,30 +54,6 @@ def _add_lin_attrs(xds, coord_dict, dir_axes):
|
|
|
54
54
|
return xds
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
def _add_freq_attrs(xds, coord_dict):
|
|
58
|
-
freq_coord = xds["frequency"]
|
|
59
|
-
meta = {}
|
|
60
|
-
for k in coord_dict:
|
|
61
|
-
if k.startswith("spectral"):
|
|
62
|
-
sd = coord_dict[k]
|
|
63
|
-
meta["rest_frequency"] = make_quantity(sd["restfreq"], "Hz")
|
|
64
|
-
meta["type"] = "frequency"
|
|
65
|
-
# meta["units"] = sd["unit"]
|
|
66
|
-
# meta["frame"] = sd["system"]
|
|
67
|
-
meta["wave_unit"] = sd["waveUnit"]
|
|
68
|
-
# meta["crval"] = sd["wcs"]["crval"]
|
|
69
|
-
# meta["cdelt"] = sd["wcs"]["cdelt"]
|
|
70
|
-
meta["reference_value"] = make_frequency_reference_dict(
|
|
71
|
-
value=sd["wcs"]["crval"],
|
|
72
|
-
units=sd["unit"],
|
|
73
|
-
observer=sd["system"],
|
|
74
|
-
)
|
|
75
|
-
if not meta:
|
|
76
|
-
# this is the default frequency information CASA creates
|
|
77
|
-
meta = _default_freq_info()
|
|
78
|
-
freq_coord.attrs = meta
|
|
79
|
-
|
|
80
|
-
|
|
81
57
|
def _add_mask(
|
|
82
58
|
xds: xr.Dataset, name: str, ary: Union[np.ndarray, da.array], dimorder: list
|
|
83
59
|
) -> xr.Dataset:
|
|
@@ -553,7 +529,7 @@ def _get_freq_values_attrs(
|
|
|
553
529
|
# attrs["type"] = "frequency"
|
|
554
530
|
# attrs["units"] = sd["unit"]
|
|
555
531
|
# attrs["frame"] = sd["system"]
|
|
556
|
-
attrs["wave_unit"] = sd["waveUnit"]
|
|
532
|
+
attrs["wave_unit"] = [sd["waveUnit"]]
|
|
557
533
|
# attrs["crval"] = sd["wcs"]["crval"]
|
|
558
534
|
# attrs["cdelt"] = sd["wcs"]["cdelt"]
|
|
559
535
|
|
|
@@ -623,36 +599,6 @@ def _get_mask_names(infile: str) -> list:
|
|
|
623
599
|
return mymasks
|
|
624
600
|
|
|
625
601
|
|
|
626
|
-
def _get_beam(imageinfo: dict, nchan: int, npol: int) -> Union[np.ndarray, None]:
|
|
627
|
-
"""Returns None if the image has no beam(s)"""
|
|
628
|
-
x = ["perplanebeams", "restoringbeam"]
|
|
629
|
-
r = None
|
|
630
|
-
for z in x:
|
|
631
|
-
if z in imageinfo:
|
|
632
|
-
r = z
|
|
633
|
-
break
|
|
634
|
-
if r is None:
|
|
635
|
-
return None
|
|
636
|
-
beam = imageinfo[r]
|
|
637
|
-
beam_array = np.zeros([1, nchan, npol, 3])
|
|
638
|
-
if r == "perplanebeams":
|
|
639
|
-
for c in range(nchan):
|
|
640
|
-
for p in range(npol):
|
|
641
|
-
k = nchan * p + c
|
|
642
|
-
b = _casacore_q_to_xradio_q(beam["*" + str(k)])
|
|
643
|
-
beam_dict = _convert_beam_to_rad(b)
|
|
644
|
-
beam_array[0][c][p][0] = beam_dict["major"]["data"]
|
|
645
|
-
beam_array[0][c][p][1] = beam_dict["minor"]["data"]
|
|
646
|
-
beam_array[0][c][p][2] = beam_dict["pa"]["data"]
|
|
647
|
-
elif r == "restoringbeam":
|
|
648
|
-
b = _casacore_q_to_xradio_q(beam)
|
|
649
|
-
beam_dict = _convert_beam_to_rad(b)
|
|
650
|
-
beam_array[0, :, :, 0] = beam_dict["major"]["data"]
|
|
651
|
-
beam_array[0, :, :, 1] = beam_dict["minor"]["data"]
|
|
652
|
-
beam_array[0, :, :, 2] = beam_dict["pa"]["data"]
|
|
653
|
-
return beam_array
|
|
654
|
-
|
|
655
|
-
|
|
656
602
|
def _get_persistent_block(
|
|
657
603
|
infile: str,
|
|
658
604
|
shapes: tuple,
|
|
@@ -858,25 +804,46 @@ def _get_velocity_values_attrs(
|
|
|
858
804
|
)
|
|
859
805
|
|
|
860
806
|
|
|
861
|
-
def
|
|
862
|
-
|
|
807
|
+
def _get_beam(
|
|
808
|
+
img_full_path: str, nchan: int, npol: int, as_dask_array: bool
|
|
863
809
|
) -> Union[xr.DataArray, None]:
|
|
864
810
|
# the image may have multiple beams
|
|
865
811
|
with _open_image_ro(img_full_path) as casa_image:
|
|
866
812
|
imageinfo = casa_image.info()["imageinfo"]
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
xdb = xdb.rename("BEAM")
|
|
875
|
-
xdb = xdb.assign_coords(beam_param=["major", "minor", "pa"])
|
|
876
|
-
xdb.attrs["units"] = "rad"
|
|
877
|
-
return xdb
|
|
878
|
-
else:
|
|
813
|
+
x = ["perplanebeams", "restoringbeam"]
|
|
814
|
+
r = None
|
|
815
|
+
for z in x:
|
|
816
|
+
if z in imageinfo:
|
|
817
|
+
r = z
|
|
818
|
+
break
|
|
819
|
+
if r is None:
|
|
879
820
|
return None
|
|
821
|
+
beam = imageinfo[r]
|
|
822
|
+
beam_array = np.zeros([1, nchan, npol, 3])
|
|
823
|
+
if r == "perplanebeams":
|
|
824
|
+
for c in range(nchan):
|
|
825
|
+
for p in range(npol):
|
|
826
|
+
k = nchan * p + c
|
|
827
|
+
b = _casacore_q_to_xradio_q(beam["*" + str(k)])
|
|
828
|
+
beam_dict = _convert_beam_to_rad(b)
|
|
829
|
+
beam_array[0][c][p][0] = beam_dict["major"]["data"]
|
|
830
|
+
beam_array[0][c][p][1] = beam_dict["minor"]["data"]
|
|
831
|
+
beam_array[0][c][p][2] = beam_dict["pa"]["data"]
|
|
832
|
+
elif r == "restoringbeam":
|
|
833
|
+
b = _casacore_q_to_xradio_q(beam)
|
|
834
|
+
beam_dict = _convert_beam_to_rad(b)
|
|
835
|
+
beam_array[0, :, :, 0] = beam_dict["major"]["data"]
|
|
836
|
+
beam_array[0, :, :, 1] = beam_dict["minor"]["data"]
|
|
837
|
+
beam_array[0, :, :, 2] = beam_dict["pa"]["data"]
|
|
838
|
+
if as_dask_array:
|
|
839
|
+
beam_array = da.array(beam_array)
|
|
840
|
+
xdb = xr.DataArray(
|
|
841
|
+
beam_array, dims=["time", "frequency", "polarization", "beam_param"]
|
|
842
|
+
)
|
|
843
|
+
xdb = xdb.rename("BEAM")
|
|
844
|
+
xdb = xdb.assign_coords(beam_param=["major", "minor", "pa"])
|
|
845
|
+
xdb.attrs["units"] = "rad"
|
|
846
|
+
return xdb
|
|
880
847
|
|
|
881
848
|
|
|
882
849
|
###########################################################################
|
|
@@ -88,9 +88,11 @@ def _compute_spectral_dict(xds: xr.Dataset) -> dict:
|
|
|
88
88
|
spec["unit"] = u if isinstance(u, str) else u[0]
|
|
89
89
|
spec["velType"] = _doppler_types.index(xds.velocity.attrs["doppler_type"])
|
|
90
90
|
u = xds.velocity.attrs["units"]
|
|
91
|
-
spec["velUnit"] = u if isinstance(u, str) else u[0]
|
|
92
91
|
spec["version"] = 2
|
|
93
|
-
|
|
92
|
+
# vel unit is a list[str] in the xds but needs to be a str in the casa image
|
|
93
|
+
spec["velUnit"] = xds.velocity.attrs["units"][0]
|
|
94
|
+
# wave unit is a list[str] in the xds but needs to be a str in the casa image
|
|
95
|
+
spec["waveUnit"] = xds.frequency.attrs["wave_unit"][0]
|
|
94
96
|
wcs = {}
|
|
95
97
|
wcs["ctype"] = "FREQ"
|
|
96
98
|
wcs["pc"] = 1.0
|
|
@@ -83,7 +83,7 @@ def _add_freq_attrs(xds: xr.Dataset, helpers: dict) -> xr.Dataset:
|
|
|
83
83
|
meta["rest_frequency"] = make_quantity(helpers["restfreq"], "Hz")
|
|
84
84
|
meta["rest_frequencies"] = [meta["rest_frequency"]]
|
|
85
85
|
meta["type"] = "frequency"
|
|
86
|
-
meta["wave_unit"] = "mm"
|
|
86
|
+
meta["wave_unit"] = ["mm"]
|
|
87
87
|
freq_axis = helpers["freq_axis"]
|
|
88
88
|
meta["reference_value"] = make_frequency_reference_dict(
|
|
89
89
|
helpers["crval"][freq_axis], ["Hz"], helpers["specsys"]
|
xradio/image/_util/casacore.py
CHANGED
|
@@ -21,7 +21,7 @@ from ._casacore.xds_from_casacore import (
|
|
|
21
21
|
_get_persistent_block,
|
|
22
22
|
_get_starts_shapes_slices,
|
|
23
23
|
_get_transpose_list,
|
|
24
|
-
|
|
24
|
+
_get_beam,
|
|
25
25
|
_read_image_array,
|
|
26
26
|
)
|
|
27
27
|
from ._casacore.xds_to_casacore import (
|
|
@@ -42,6 +42,8 @@ def _load_casa_image_block(infile: str, block_des: dict, do_sky_coords) -> xr.Da
|
|
|
42
42
|
cshape = casa_image.shape()
|
|
43
43
|
ret = _casa_image_to_xds_coords(image_full_path, False, do_sky_coords)
|
|
44
44
|
xds = ret["xds"].isel(block_des)
|
|
45
|
+
nchan = ret["xds"].dims["frequency"]
|
|
46
|
+
npol = ret["xds"].dims["polarization"]
|
|
45
47
|
starts, shapes, slices = _get_starts_shapes_slices(block_des, coords, cshape)
|
|
46
48
|
dimorder = _get_xds_dim_order(ret["sphr_dims"])
|
|
47
49
|
transpose_list, new_axes = _get_transpose_list(coords)
|
|
@@ -60,13 +62,14 @@ def _load_casa_image_block(infile: str, block_des: dict, do_sky_coords) -> xr.Da
|
|
|
60
62
|
# data vars are all caps by convention
|
|
61
63
|
xds = _add_mask(xds, m.upper(), block, dimorder)
|
|
62
64
|
xds.attrs = _casa_image_to_xds_attrs(image_full_path)
|
|
63
|
-
|
|
64
|
-
if
|
|
65
|
-
selectors = {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
beam = _get_beam(image_full_path, nchan, npol, False)
|
|
66
|
+
if beam is not None:
|
|
67
|
+
selectors = {
|
|
68
|
+
k: block_des[k]
|
|
69
|
+
for k in ("time", "frequency", "polarization")
|
|
70
|
+
if k in block_des
|
|
71
|
+
}
|
|
72
|
+
xds["BEAM"] = beam.isel(selectors)
|
|
70
73
|
return xds
|
|
71
74
|
|
|
72
75
|
|
|
@@ -97,9 +100,11 @@ def _read_casa_image(
|
|
|
97
100
|
# data var names are all caps by convention
|
|
98
101
|
xds = _add_mask(xds, m.upper(), ary, dimorder)
|
|
99
102
|
xds.attrs = _casa_image_to_xds_attrs(img_full_path)
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
+
beam = _get_beam(
|
|
104
|
+
img_full_path, xds.dims["frequency"], xds.dims["polarization"], True
|
|
105
|
+
)
|
|
106
|
+
if beam is not None:
|
|
107
|
+
xds["BEAM"] = beam
|
|
103
108
|
# xds = _add_coord_attrs(xds, ret["icoords"], ret["dir_axes"])
|
|
104
109
|
xds = _dask_arrayize_dv(xds)
|
|
105
110
|
return xds
|
xradio/image/image.py
CHANGED
|
@@ -159,7 +159,7 @@ def load_image(infile: str, block_des: dict = {}, do_sky_coords=True) -> xr.Data
|
|
|
159
159
|
do_casa = False
|
|
160
160
|
if do_casa:
|
|
161
161
|
# comment next line when done debugging
|
|
162
|
-
# return _load_casa_image_block(infile,
|
|
162
|
+
# return _load_casa_image_block(infile, selection, do_sky_coords)
|
|
163
163
|
try:
|
|
164
164
|
return _load_casa_image_block(infile, selection, do_sky_coords)
|
|
165
165
|
except Exception as e:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xradio
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.55
|
|
4
4
|
Summary: Xarray Radio Astronomy Data IO
|
|
5
5
|
Author-email: Jan-Willem Steeb <jsteeb@nrao.edu>, Federico Montesino Pouzols <pouzols@eso.edu>, Dave Mehringer <dmehring@nrao.edu>, Peter Wortmann <peter.wortmann@skao.int>
|
|
6
6
|
License: BSD 3-Clause License
|
|
@@ -8,18 +8,18 @@ xradio/_utils/_casacore/tables.py,sha256=aq6E_4RRAHdTBCwMKrVil1cWhFU2O980DNH9IlR
|
|
|
8
8
|
xradio/_utils/zarr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
9
|
xradio/_utils/zarr/common.py,sha256=egj3Zma0BUK0msOBDozMa-62rHrcxrjCNE5XkkZUq70,5332
|
|
10
10
|
xradio/image/__init__.py,sha256=HAD0GfopIbhdxOYckyW6S9US_dSWmZrwIl3FHUzZwrE,435
|
|
11
|
-
xradio/image/image.py,sha256=
|
|
11
|
+
xradio/image/image.py,sha256=bPgjJoQaur10XEnK7nw66YG68tRKFmdXFlER7GjWh64,14579
|
|
12
12
|
xradio/image/_util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
-
xradio/image/_util/casacore.py,sha256=
|
|
13
|
+
xradio/image/_util/casacore.py,sha256=vhmPz5tCUXTN46oQLuTxkdHTxI_9qR_RfHUEeqPn9SU,4511
|
|
14
14
|
xradio/image/_util/common.py,sha256=y2QJXTHowvjqwNPG5a-cOzl0WneH7c8c9jAVSKQeK2w,8429
|
|
15
15
|
xradio/image/_util/fits.py,sha256=gyGm06fuCKqVGK7uv-ObvQNfFawUDsIOa_nQyklM3Aw,329
|
|
16
16
|
xradio/image/_util/image_factory.py,sha256=Mm0ZDraD0WoNpGqy98EneFr1PxgfyNZNQwquIH2t0nc,8610
|
|
17
17
|
xradio/image/_util/zarr.py,sha256=lhQqVRC1GEWClG3zRbuDr2IlQBfXeDqaLUJIN-MVMxA,1652
|
|
18
18
|
xradio/image/_util/_casacore/__init__.py,sha256=OlsiRE40o1jSbBI4khgQQzgfDYbAlOMKIhO4UFlbGhg,41
|
|
19
19
|
xradio/image/_util/_casacore/common.py,sha256=Z7Jl3AU7jVcgjNtCnvL7CCXJQAxXeEtowXBmSShuAv4,1329
|
|
20
|
-
xradio/image/_util/_casacore/xds_from_casacore.py,sha256=
|
|
21
|
-
xradio/image/_util/_casacore/xds_to_casacore.py,sha256=
|
|
22
|
-
xradio/image/_util/_fits/xds_from_fits.py,sha256=
|
|
20
|
+
xradio/image/_util/_casacore/xds_from_casacore.py,sha256=uc2jQRAjKIOMh6OO8qIJs7vrNC_J6jI3bObRdL_4fP4,42865
|
|
21
|
+
xradio/image/_util/_casacore/xds_to_casacore.py,sha256=snHCcbZQZtv329KNMd-RjYXG3pfNQeJQbOWKduY1uQc,17085
|
|
22
|
+
xradio/image/_util/_fits/xds_from_fits.py,sha256=n2tAIOK5GoIKzYBqfwCjZULFYSz2x74aeVkCo0vmOL4,29191
|
|
23
23
|
xradio/image/_util/_zarr/common.py,sha256=ltlj3uFa-uv8lXlDtV79QnfNmfm0tyhXN5FDAjZtjzg,308
|
|
24
24
|
xradio/image/_util/_zarr/xds_from_zarr.py,sha256=KMsfaSSm9kyVoztS6pUzGNxMZzQnCxkk0kDv2GxW5Kw,4451
|
|
25
25
|
xradio/image/_util/_zarr/xds_to_zarr.py,sha256=nsDvDD-kuMuMF2dDlj0jTxSW4mdR-jjIsvXHi5uIERU,2373
|
|
@@ -70,8 +70,8 @@ xradio/schema/metamodel.py,sha256=WjtW7pAVzcjLRWifRH3sQoOiN6TV810hARpOIz1M_gw,38
|
|
|
70
70
|
xradio/schema/typing.py,sha256=8-o6fZd99kJ4FVdgBYRTIRJ-wDqpcUNXzCTfJvl3TIw,10439
|
|
71
71
|
xradio/sphinx/__init__.py,sha256=VGY-7Ty3q67qpnBee0-znbiJ-Iy0F93UO--IpjEdHXc,380
|
|
72
72
|
xradio/sphinx/schema_table.py,sha256=uq33habbAbReqnEG6ASKSd4UOMZGUzA3qoTX45rq84U,12373
|
|
73
|
-
xradio-0.0.
|
|
74
|
-
xradio-0.0.
|
|
75
|
-
xradio-0.0.
|
|
76
|
-
xradio-0.0.
|
|
77
|
-
xradio-0.0.
|
|
73
|
+
xradio-0.0.55.dist-info/licenses/LICENSE.txt,sha256=9CYIJt7riOXo9AD0eXBZviLxo_HebD-2JJI8oiWtzfg,1807
|
|
74
|
+
xradio-0.0.55.dist-info/METADATA,sha256=iF5gDBadJWPQKJFcBEJpMUev97YRCCi1nArYtLDgWHw,5574
|
|
75
|
+
xradio-0.0.55.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
|
|
76
|
+
xradio-0.0.55.dist-info/top_level.txt,sha256=dQu27fGBZJ2Yk-gW5XeD-dZ76Xa4Xcvk60Vz-dwXp7k,7
|
|
77
|
+
xradio-0.0.55.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|