xradio 1.1.0__tar.gz → 1.1.1__tar.gz
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-1.1.0/src/xradio.egg-info → xradio-1.1.1}/PKG-INFO +2 -1
- {xradio-1.1.0 → xradio-1.1.1}/pyproject.toml +3 -2
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/_utils/_casacore/casacore_from_casatools.py +75 -9
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/image/_util/_casacore/xds_from_casacore.py +43 -45
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/image/_util/_casacore/xds_to_casacore.py +1 -1
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/image/_util/_fits/xds_from_fits.py +1 -1
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/image/_util/casacore.py +56 -15
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/image/_util/common.py +4 -3
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/image/_util/image_factory.py +10 -7
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/_utils/_msv2/_tables/read.py +0 -3
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/testing/measurement_set/__init__.py +2 -2
- {xradio-1.1.0 → xradio-1.1.1/src/xradio.egg-info}/PKG-INFO +2 -1
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio.egg-info/requires.txt +1 -0
- {xradio-1.1.0 → xradio-1.1.1}/LICENSE.txt +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/MANIFEST.in +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/README.md +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/setup.cfg +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/__init__.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/_utils/__init__.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/_utils/_casacore/tables.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/_utils/coord_math.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/_utils/dict_helpers.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/_utils/list_and_array.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/_utils/schema.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/_utils/xarray_helpers.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/_utils/zarr/__init__.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/_utils/zarr/common.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/image/__init__.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/image/_util/__init__.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/image/_util/_casacore/__init__.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/image/_util/_casacore/common.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/image/_util/_zarr/common.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/image/_util/_zarr/xds_from_zarr.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/image/_util/_zarr/xds_to_zarr.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/image/_util/_zarr/zarr_low_level.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/image/_util/zarr.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/image/image.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/image/image_xds.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/image/schema.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/__init__.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/_utils/__init__.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/_utils/_msv2/__init__.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/_utils/_msv2/_tables/read_main_table.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/_utils/_msv2/_tables/table_query.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/_utils/_msv2/conversion.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/_utils/_msv2/create_antenna_xds.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/_utils/_msv2/create_field_and_source_xds.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/_utils/_msv2/msv2_to_msv4_meta.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/_utils/_msv2/msv4_info_dicts.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/_utils/_msv2/msv4_sub_xdss.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/_utils/_msv2/optimised_functions.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/_utils/_msv2/partition_queries.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/_utils/_msv2/subtables.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/_utils/_utils/interpolate.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/_utils/_utils/partition_attrs.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/_utils/_utils/stokes_types.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/_utils/_zarr/encoding.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/convert_msv2_to_processing_set.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/load_processing_set.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/measurement_set_xdt.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/open_processing_set.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/processing_set_xdt.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/schema.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/schema/__init__.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/schema/bases.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/schema/check.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/schema/common.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/schema/dataclass.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/schema/export.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/schema/metamodel.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/schema/typing.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/sphinx/__init__.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/sphinx/schema_table.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/testing/__init__.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/testing/_utils/__template__.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/testing/measurement_set/checker.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/testing/measurement_set/io.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio/testing/measurement_set/msv2_io.py +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio.egg-info/SOURCES.txt +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio.egg-info/dependency_links.txt +0 -0
- {xradio-1.1.0 → xradio-1.1.1}/src/xradio.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xradio
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.1
|
|
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
|
|
@@ -98,6 +98,7 @@ Requires-Dist: sphinx-autosummary-accessors; extra == "docs"
|
|
|
98
98
|
Requires-Dist: sphinx_rtd_theme; extra == "docs"
|
|
99
99
|
Requires-Dist: twine; extra == "docs"
|
|
100
100
|
Requires-Dist: pandoc; extra == "docs"
|
|
101
|
+
Requires-Dist: toolviper; extra == "docs"
|
|
101
102
|
Provides-Extra: all
|
|
102
103
|
Requires-Dist: astropy; extra == "all"
|
|
103
104
|
Requires-Dist: toolviper>=0.0.12; extra == "all"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "xradio"
|
|
3
|
-
version = "v1.1.
|
|
3
|
+
version = "v1.1.1"
|
|
4
4
|
description = " Xarray Radio Astronomy Data IO"
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "Jan-Willem Steeb", email="jsteeb@nrao.edu"},
|
|
@@ -85,7 +85,8 @@ docs = [
|
|
|
85
85
|
'sphinx-autosummary-accessors',
|
|
86
86
|
'sphinx_rtd_theme',
|
|
87
87
|
'twine',
|
|
88
|
-
'pandoc'
|
|
88
|
+
'pandoc',
|
|
89
|
+
'toolviper',
|
|
89
90
|
]
|
|
90
91
|
|
|
91
92
|
all = [
|
|
@@ -29,6 +29,24 @@ except ModuleNotFoundError as exc:
|
|
|
29
29
|
f"{exc}"
|
|
30
30
|
)
|
|
31
31
|
|
|
32
|
+
# Valid casacore ImageInfo enum values
|
|
33
|
+
# Reference: https://casacore.github.io/casacore/classcasacore_1_1ImageInfo.html
|
|
34
|
+
_VALID_IMAGE_TYPES = (
|
|
35
|
+
"Undefined",
|
|
36
|
+
"Intensity",
|
|
37
|
+
"Beam",
|
|
38
|
+
"ColumnDensity",
|
|
39
|
+
"DepolarizationRatio",
|
|
40
|
+
"KineticTemperature",
|
|
41
|
+
"MagneticField",
|
|
42
|
+
"OpticalDepth",
|
|
43
|
+
"RotationMeasure",
|
|
44
|
+
"RotationalTemperature",
|
|
45
|
+
"SpectralIndex",
|
|
46
|
+
"Velocity",
|
|
47
|
+
"VelocityDispersion",
|
|
48
|
+
)
|
|
49
|
+
|
|
32
50
|
import numpy as np
|
|
33
51
|
import toolviper.utils.logger as logger
|
|
34
52
|
|
|
@@ -166,6 +184,32 @@ def wrap_class_methods(cls: type) -> type:
|
|
|
166
184
|
return cls
|
|
167
185
|
|
|
168
186
|
|
|
187
|
+
def _validate_image_type(value: str) -> str:
|
|
188
|
+
"""Validate and normalize an image type string.
|
|
189
|
+
|
|
190
|
+
Parameters
|
|
191
|
+
----------
|
|
192
|
+
value
|
|
193
|
+
The image type string to validate.
|
|
194
|
+
|
|
195
|
+
Returns
|
|
196
|
+
-------
|
|
197
|
+
str
|
|
198
|
+
A valid casacore ImageInfo enum value with proper capitalization.
|
|
199
|
+
Returns 'Intensity' if the input is not a valid type.
|
|
200
|
+
|
|
201
|
+
Notes
|
|
202
|
+
-----
|
|
203
|
+
Validation is case-insensitive. The returned string uses the
|
|
204
|
+
canonical capitalization from the casacore ImageInfo enum.
|
|
205
|
+
"""
|
|
206
|
+
value_lower = value.lower()
|
|
207
|
+
for valid_type in _VALID_IMAGE_TYPES:
|
|
208
|
+
if valid_type.lower() == value_lower:
|
|
209
|
+
return valid_type
|
|
210
|
+
return "Intensity"
|
|
211
|
+
|
|
212
|
+
|
|
169
213
|
@wrap_class_methods
|
|
170
214
|
class table(casatools.table):
|
|
171
215
|
"""A wrapper for the casatools table object.
|
|
@@ -513,7 +557,7 @@ class image(casatools.image):
|
|
|
513
557
|
self,
|
|
514
558
|
imagename,
|
|
515
559
|
axis=0,
|
|
516
|
-
maskname="
|
|
560
|
+
maskname="MASK_0",
|
|
517
561
|
images=(),
|
|
518
562
|
values=None,
|
|
519
563
|
coordsys=None,
|
|
@@ -702,18 +746,36 @@ class image(casatools.image):
|
|
|
702
746
|
def imageinfo(self) -> dict:
|
|
703
747
|
"""Retrieve metadata from the image table.
|
|
704
748
|
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
749
|
+
Accesses the image table and retrieves information stored under the
|
|
750
|
+
'imageinfo' keyword. The 'imagetype' value is validated against
|
|
751
|
+
casacore's ImageInfo enumeration values to mimic python-casacore
|
|
752
|
+
`image.imageinfo()` behavior.
|
|
709
753
|
|
|
710
754
|
Returns
|
|
711
755
|
-------
|
|
712
756
|
dict
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
757
|
+
Image metadata dictionary containing:
|
|
758
|
+
|
|
759
|
+
- **imagetype** : str
|
|
760
|
+
Type of the image, validated against casacore ImageInfo enum.
|
|
761
|
+
Defaults to 'Intensity' if invalid or missing.
|
|
762
|
+
- **objectname** : str
|
|
763
|
+
Name of the observed object.
|
|
764
|
+
|
|
765
|
+
Notes
|
|
766
|
+
-----
|
|
767
|
+
image.info()['imageinfo'] and image.imageinfo() from python-casacore
|
|
768
|
+
always returns "imagetype" in a predefined enum value. When the "imageinfo"
|
|
769
|
+
keyword is missing from the image table, or a non-standard value of "imagetype"
|
|
770
|
+
(e.g. 'sky') was written into that keyword, image.info() will just return
|
|
771
|
+
"Intensity" as the imagetype.
|
|
772
|
+
|
|
773
|
+
Examples
|
|
774
|
+
--------
|
|
775
|
+
>>> img = image('my_image.im')
|
|
776
|
+
>>> info = img.imageinfo()
|
|
777
|
+
>>> info['imagetype']
|
|
778
|
+
'Intensity'
|
|
717
779
|
"""
|
|
718
780
|
with table(self._imagename) as tb:
|
|
719
781
|
if "imageinfo" in tb.keywordnames():
|
|
@@ -721,6 +783,10 @@ class image(casatools.image):
|
|
|
721
783
|
else:
|
|
722
784
|
image_metadata = {"imagetype": "Intensity", "objectname": ""}
|
|
723
785
|
|
|
786
|
+
image_metadata["imagetype"] = _validate_image_type(
|
|
787
|
+
image_metadata.get("imagetype", "Intensity")
|
|
788
|
+
)
|
|
789
|
+
|
|
724
790
|
return image_metadata
|
|
725
791
|
|
|
726
792
|
def datatype(self):
|
|
@@ -217,7 +217,7 @@ def _add_sky_or_aperture(
|
|
|
217
217
|
img_full_path: str,
|
|
218
218
|
has_sph_dims: bool,
|
|
219
219
|
history: bool,
|
|
220
|
-
image_type: str
|
|
220
|
+
image_type: str,
|
|
221
221
|
) -> xr.Dataset:
|
|
222
222
|
xda = xr.DataArray(ary, dims=dimorder).astype(ary.dtype)
|
|
223
223
|
with _open_image_ro(img_full_path) as casa_image:
|
|
@@ -270,8 +270,6 @@ def _casa_image_to_xds_attrs(img_full_path: str) -> dict:
|
|
|
270
270
|
"""
|
|
271
271
|
with _open_image_ro(img_full_path) as casa_image:
|
|
272
272
|
meta_dict = casa_image.info()
|
|
273
|
-
# print("meta_dict:", meta_dict)
|
|
274
|
-
# print("***********")
|
|
275
273
|
coord_dict = copy.deepcopy(meta_dict["coordinates"])
|
|
276
274
|
attrs = {}
|
|
277
275
|
dir_key = None
|
|
@@ -350,14 +348,13 @@ def _casa_image_to_xds_attrs(img_full_path: str) -> dict:
|
|
|
350
348
|
|
|
351
349
|
|
|
352
350
|
def _casa_image_to_xds_coords(
|
|
353
|
-
img_full_path: str, verbose: bool, do_sky_coords: bool
|
|
351
|
+
img_full_path: str, verbose: bool, do_sky_coords: bool, image_type: str
|
|
354
352
|
) -> dict:
|
|
355
353
|
"""
|
|
356
354
|
TODO: complete documentation
|
|
357
355
|
Create an xds without any pixel data from metadata from the specified CASA image
|
|
358
356
|
"""
|
|
359
357
|
attrs = {}
|
|
360
|
-
# casa_image = images.image(img_full_path)
|
|
361
358
|
with _open_image_ro(img_full_path) as casa_image:
|
|
362
359
|
# shape list is the reverse of the actual image shape
|
|
363
360
|
shape = casa_image.shape()[::-1]
|
|
@@ -390,46 +387,47 @@ def _casa_image_to_xds_coords(
|
|
|
390
387
|
coord_dict
|
|
391
388
|
)
|
|
392
389
|
coords["velocity"] = (["frequency"], velocity_vals)
|
|
393
|
-
if
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
390
|
+
if image_type.upper() != "VISIBILITY_NORMALIZATION":
|
|
391
|
+
if len(sphr_dims) > 0:
|
|
392
|
+
crpix = _flatten_list(csys.get_referencepixel())[::-1]
|
|
393
|
+
inc = _flatten_list(csys.get_increment())[::-1]
|
|
394
|
+
unit = _flatten_list(csys.get_unit())[::-1]
|
|
395
|
+
attr_note = _l_m_attr_notes()
|
|
396
|
+
for c in ["l", "m"]:
|
|
397
|
+
idx = dimmap[c]
|
|
398
|
+
delta = ((inc[idx]) * u.Unit(_get_unit(unit[idx]))).to("rad").value
|
|
399
|
+
coords[c] = _compute_linear_world_values(
|
|
400
|
+
naxis=shape[idx], crval=0.0, crpix=crpix[idx], cdelt=delta
|
|
401
|
+
)
|
|
402
|
+
coord_attrs[c] = {
|
|
403
|
+
"note": attr_note[c],
|
|
404
|
+
}
|
|
405
|
+
if do_sky_coords:
|
|
406
|
+
for k in coord_dict.keys():
|
|
407
|
+
if k.startswith("direction"):
|
|
408
|
+
dc = coordinates.directioncoordinate(coord_dict[k])
|
|
409
|
+
break
|
|
410
|
+
crval = _flatten_list(csys.get_referencevalue())[::-1]
|
|
411
|
+
pick = lambda my_list: [my_list[i] for i in sphr_dims]
|
|
412
|
+
my_ret = _compute_world_sph_dims(
|
|
413
|
+
projection=dc.get_projection(),
|
|
414
|
+
shape=pick(shape),
|
|
415
|
+
ctype=diraxes,
|
|
416
|
+
crval=pick(crval),
|
|
417
|
+
crpix=pick(crpix),
|
|
418
|
+
cdelt=pick(inc),
|
|
419
|
+
cunit=pick(unit),
|
|
420
|
+
)
|
|
421
|
+
for i in [0, 1]:
|
|
422
|
+
axis_name = my_ret["axis_name"][i]
|
|
423
|
+
coords[axis_name] = (["l", "m"], my_ret["value"][i])
|
|
424
|
+
coord_attrs[axis_name] = {}
|
|
425
|
+
else:
|
|
426
|
+
# Fourier image
|
|
427
|
+
ret = _get_uv_values_attrs(coord_dict, axis_names, shape)
|
|
428
|
+
for z in ["u", "v"]:
|
|
429
|
+
coords[z], coord_attrs[z] = ret[z]
|
|
430
|
+
coords["beam_params_label"] = ["major", "minor", "pa"]
|
|
433
431
|
attrs["shape"] = shape
|
|
434
432
|
xds = xr.Dataset(coords=coords)
|
|
435
433
|
for c in coord_attrs.keys():
|
|
@@ -177,7 +177,7 @@ def _coord_dict_from_xds(xds: xr.Dataset) -> dict:
|
|
|
177
177
|
if "observer" in xds[sky_ap].attrs:
|
|
178
178
|
coord["observer"] = xds[sky_ap].attrs["observer"]
|
|
179
179
|
obsdate = {}
|
|
180
|
-
obsdate["refer"] = xds.coords["time"].attrs["scale"]
|
|
180
|
+
obsdate["refer"] = xds.coords["time"].attrs["scale"].upper()
|
|
181
181
|
obsdate["type"] = "epoch"
|
|
182
182
|
obsdate["m0"] = {}
|
|
183
183
|
obsdate["m0"]["unit"] = xds.coords["time"].attrs["units"]
|
|
@@ -72,7 +72,7 @@ def _fits_image_to_xds(
|
|
|
72
72
|
xds = _create_coords(helpers, header, do_sky_coords)
|
|
73
73
|
sphr_dims = helpers["sphr_dims"]
|
|
74
74
|
ary = _read_image_array(img_full_path, chunks, helpers, verbose)
|
|
75
|
-
dim_order = _get_xds_dim_order(sphr_dims)
|
|
75
|
+
dim_order = _get_xds_dim_order(sphr_dims, image_type)
|
|
76
76
|
xds = _add_sky_or_aperture(
|
|
77
77
|
xds, ary, dim_order, header, helpers, sphr_dims, image_type
|
|
78
78
|
)
|
|
@@ -10,7 +10,7 @@ from typing import Union
|
|
|
10
10
|
|
|
11
11
|
import xarray as xr
|
|
12
12
|
import re
|
|
13
|
-
|
|
13
|
+
import dask.array as da
|
|
14
14
|
from xradio._utils.schema import get_data_group_keys
|
|
15
15
|
|
|
16
16
|
try:
|
|
@@ -47,25 +47,63 @@ from xradio.image._util._casacore.common import _beam_fit_params, _open_image_ro
|
|
|
47
47
|
warnings.filterwarnings("ignore", category=FutureWarning)
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
def
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
def _squeeze_if_needed(ary: da, image_type: str) -> da:
|
|
51
|
+
if image_type.upper() == "VISIBILITY_NORMALIZATION":
|
|
52
|
+
shape = ary.shape
|
|
53
|
+
if shape[3] != 1 or shape[4] != 1:
|
|
54
|
+
raise ValueError(
|
|
55
|
+
"VISIBILITY_NORMALIZATION casa image must have l and m of length 1. Found "
|
|
56
|
+
+ [shape[3], shape[4]]
|
|
57
|
+
)
|
|
58
|
+
ary = ary.squeeze(axis=(3, 4))
|
|
59
|
+
return ary
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _get_casa_image_metadata(infile: str, do_sky_coords: bool, image_type: str) -> dict:
|
|
53
63
|
image_full_path = os.path.expanduser(infile)
|
|
54
64
|
with _open_image_ro(image_full_path) as casa_image:
|
|
55
65
|
coords = casa_image.coordinates()
|
|
56
66
|
cshape = casa_image.shape()
|
|
57
|
-
ret = _casa_image_to_xds_coords(image_full_path, False, do_sky_coords)
|
|
58
|
-
xds = ret["xds"]
|
|
67
|
+
ret = _casa_image_to_xds_coords(image_full_path, False, do_sky_coords, image_type)
|
|
68
|
+
xds = ret["xds"]
|
|
69
|
+
sphr_dims = ret["sphr_dims"]
|
|
59
70
|
nchan = ret["xds"].sizes["frequency"]
|
|
60
71
|
npol = ret["xds"].sizes["polarization"]
|
|
72
|
+
dimorder = _get_xds_dim_order(ret["sphr_dims"], image_type)
|
|
73
|
+
metadata = {
|
|
74
|
+
"coords": coords,
|
|
75
|
+
"cshape": cshape,
|
|
76
|
+
"image_full_path": image_full_path,
|
|
77
|
+
"nchan": nchan,
|
|
78
|
+
"npol": npol,
|
|
79
|
+
"dimorder": dimorder,
|
|
80
|
+
# "xds_attrs": _casa_image_to_xds_attrs(image_full_path),
|
|
81
|
+
"sphr_dims": sphr_dims,
|
|
82
|
+
"xds": xds,
|
|
83
|
+
}
|
|
84
|
+
return metadata
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def _load_casa_image_block(
|
|
88
|
+
infile: str, block_des: dict, do_sky_coords: bool, image_type: str
|
|
89
|
+
) -> xr.Dataset:
|
|
90
|
+
md = _get_casa_image_metadata(infile, do_sky_coords, image_type)
|
|
91
|
+
coords = md["coords"]
|
|
92
|
+
cshape = md["cshape"]
|
|
93
|
+
dimorder = md["dimorder"]
|
|
94
|
+
sphr_dims = md["sphr_dims"]
|
|
95
|
+
nchan = md["nchan"]
|
|
96
|
+
npol = md["npol"]
|
|
97
|
+
xds = md["xds"].isel(block_des)
|
|
98
|
+
image_full_path = md["image_full_path"]
|
|
61
99
|
starts, shapes, slices = _get_starts_shapes_slices(block_des, coords, cshape)
|
|
62
|
-
dimorder = _get_xds_dim_order(ret["sphr_dims"])
|
|
63
100
|
transpose_list, new_axes = _get_transpose_list(coords)
|
|
64
101
|
block = _get_persistent_block(
|
|
65
102
|
image_full_path, shapes, starts, dimorder, transpose_list, new_axes
|
|
66
103
|
)
|
|
104
|
+
block = _squeeze_if_needed(block, image_type)
|
|
67
105
|
xds = _add_sky_or_aperture(
|
|
68
|
-
xds, block, dimorder, image_full_path,
|
|
106
|
+
xds, block, dimorder, image_full_path, sphr_dims, False, image_type
|
|
69
107
|
)
|
|
70
108
|
mymasks = _get_mask_names(image_full_path)
|
|
71
109
|
for m in mymasks:
|
|
@@ -104,18 +142,21 @@ def _open_casa_image(
|
|
|
104
142
|
history: bool = False,
|
|
105
143
|
image_type: str = "SKY",
|
|
106
144
|
) -> xr.Dataset:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
145
|
+
md = _get_casa_image_metadata(infile, do_sky_coords, image_type)
|
|
146
|
+
xds = md["xds"]
|
|
147
|
+
dimorder = md["dimorder"]
|
|
148
|
+
sphr_dims = md["sphr_dims"]
|
|
149
|
+
img_full_path = md["image_full_path"]
|
|
150
|
+
ary = _read_image_array(img_full_path, chunks, verbose=verbose)
|
|
151
|
+
ary = _squeeze_if_needed(ary, image_type)
|
|
111
152
|
xds = _add_sky_or_aperture(
|
|
112
153
|
xds,
|
|
113
|
-
|
|
154
|
+
ary,
|
|
114
155
|
dimorder,
|
|
115
156
|
img_full_path,
|
|
116
|
-
|
|
157
|
+
sphr_dims,
|
|
117
158
|
history,
|
|
118
|
-
image_type
|
|
159
|
+
image_type,
|
|
119
160
|
)
|
|
120
161
|
if masks:
|
|
121
162
|
mymasks = _get_mask_names(img_full_path)
|
|
@@ -25,10 +25,11 @@ def _aperture_or_sky(xds: xr.Dataset) -> str:
|
|
|
25
25
|
return "SKY" if "SKY" in xds.data_vars or "l" in xds.coords else "APERTURE"
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
def _get_xds_dim_order(has_sph: bool) -> list:
|
|
28
|
+
def _get_xds_dim_order(has_sph: bool, image_type: str) -> list:
|
|
29
29
|
dimorder = ["time", "frequency", "polarization"]
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
if image_type.upper() != "VISIBILITY_NORMALIZATION":
|
|
31
|
+
dir_lin = ["l", "m"] if has_sph else ["u", "v"]
|
|
32
|
+
dimorder.extend(dir_lin)
|
|
32
33
|
return dimorder
|
|
33
34
|
|
|
34
35
|
|
|
@@ -693,14 +693,17 @@ def create_image_xds_from_store(
|
|
|
693
693
|
data_group["beam_fit_params_point_spread_function"] = (
|
|
694
694
|
"BEAM_FIT_PARAMS_" + image_type.upper()
|
|
695
695
|
)
|
|
696
|
+
if (
|
|
697
|
+
"visibility_normalization" not in image_type.lower()
|
|
698
|
+
or len(img_xds.data_vars) > 1
|
|
699
|
+
):
|
|
700
|
+
# if beam_param coord not in image type it is not auto assigned to img_xds
|
|
701
|
+
# but it must be present even if unused
|
|
702
|
+
if "beam_params_label" not in img_xds.dims:
|
|
703
|
+
img_xds.expand_dims(beam_params_label=3)
|
|
696
704
|
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
if "beam_params_label" not in img_xds.dims:
|
|
700
|
-
img_xds.expand_dims(beam_params_label=3)
|
|
701
|
-
|
|
702
|
-
if "beam_params_label" not in img_xds.coords:
|
|
703
|
-
img_xds = _move_beam_param_dim_coord(img_xds)
|
|
705
|
+
if "beam_params_label" not in img_xds.coords:
|
|
706
|
+
img_xds = _move_beam_param_dim_coord(img_xds)
|
|
704
707
|
img_xds.attrs["type"] = "image_dataset"
|
|
705
708
|
img_xds.attrs["data_groups"] = data_groups
|
|
706
709
|
return img_xds
|
|
@@ -93,12 +93,9 @@ def convert_mjd_time(rawtimes: np.ndarray) -> np.ndarray:
|
|
|
93
93
|
np.ndarray
|
|
94
94
|
times converted to pandas reference and datetime type
|
|
95
95
|
"""
|
|
96
|
-
|
|
97
|
-
print("^^^^^^^", rawtimes, MJD_DIF_UNIX, SECS_IN_DAY)
|
|
98
96
|
times_reref = pd.to_datetime(
|
|
99
97
|
(rawtimes - MJD_DIF_UNIX) * SECS_IN_DAY, unit="s"
|
|
100
98
|
).values
|
|
101
|
-
print("^^^^^^^", times_reref)
|
|
102
99
|
|
|
103
100
|
return times_reref
|
|
104
101
|
|
|
@@ -5,8 +5,6 @@ This module provides reusable test utilities for generating test data,
|
|
|
5
5
|
custom assertions, and helper functions for testing xradio functionality.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
import toolviper.utils.logger as _logger
|
|
9
|
-
|
|
10
8
|
__all__ = [
|
|
11
9
|
# Generators
|
|
12
10
|
"gen_test_ms",
|
|
@@ -49,6 +47,8 @@ try:
|
|
|
49
47
|
build_minimal_msv4_xdt,
|
|
50
48
|
)
|
|
51
49
|
except ModuleNotFoundError as exc:
|
|
50
|
+
import toolviper.utils.logger as _logger
|
|
51
|
+
|
|
52
52
|
_logger.warning(
|
|
53
53
|
"Could not import casacore tables to handle MSv2. "
|
|
54
54
|
"Could not import the functions to convert from MSv2 to MSv4. "
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xradio
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.1
|
|
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
|
|
@@ -98,6 +98,7 @@ Requires-Dist: sphinx-autosummary-accessors; extra == "docs"
|
|
|
98
98
|
Requires-Dist: sphinx_rtd_theme; extra == "docs"
|
|
99
99
|
Requires-Dist: twine; extra == "docs"
|
|
100
100
|
Requires-Dist: pandoc; extra == "docs"
|
|
101
|
+
Requires-Dist: toolviper; extra == "docs"
|
|
101
102
|
Provides-Extra: all
|
|
102
103
|
Requires-Dist: astropy; extra == "all"
|
|
103
104
|
Requires-Dist: toolviper>=0.0.12; extra == "all"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/_utils/_msv2/_tables/read_main_table.py
RENAMED
|
File without changes
|
{xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/_utils/_msv2/_tables/table_query.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/_utils/_msv2/create_field_and_source_xds.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{xradio-1.1.0 → xradio-1.1.1}/src/xradio/measurement_set/_utils/_msv2/optimised_functions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|