xradio 1.1.1__tar.gz → 1.1.12a0__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.1/src/xradio.egg-info → xradio-1.1.12a0}/PKG-INFO +1 -2
- {xradio-1.1.1 → xradio-1.1.12a0}/pyproject.toml +2 -3
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/_utils/_casacore/casacore_from_casatools.py +9 -75
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/_utils/zarr/common.py +1 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/image/_util/_casacore/xds_from_casacore.py +51 -48
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/image/_util/_casacore/xds_to_casacore.py +1 -1
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/image/_util/_fits/xds_from_fits.py +1 -1
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/image/_util/_zarr/common.py +1 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/image/_util/casacore.py +16 -56
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/image/_util/common.py +3 -4
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/image/_util/image_factory.py +8 -20
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/_msv2/_tables/read.py +3 -4
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/_msv2/create_field_and_source_xds.py +0 -1
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/_utils/interpolate.py +0 -5
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/_utils/partition_attrs.py +1 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/schema/common.py +1 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/testing/measurement_set/__init__.py +2 -2
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/testing/measurement_set/msv2_io.py +1 -0
- {xradio-1.1.1 → xradio-1.1.12a0/src/xradio.egg-info}/PKG-INFO +1 -2
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio.egg-info/requires.txt +0 -1
- {xradio-1.1.1 → xradio-1.1.12a0}/LICENSE.txt +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/MANIFEST.in +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/README.md +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/setup.cfg +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/__init__.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/_utils/__init__.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/_utils/_casacore/tables.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/_utils/coord_math.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/_utils/dict_helpers.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/_utils/list_and_array.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/_utils/schema.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/_utils/xarray_helpers.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/_utils/zarr/__init__.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/image/__init__.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/image/_util/__init__.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/image/_util/_casacore/__init__.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/image/_util/_casacore/common.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/image/_util/_zarr/xds_from_zarr.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/image/_util/_zarr/xds_to_zarr.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/image/_util/_zarr/zarr_low_level.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/image/_util/zarr.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/image/image.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/image/image_xds.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/image/schema.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/__init__.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/__init__.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/_msv2/__init__.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/_msv2/_tables/read_main_table.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/_msv2/_tables/table_query.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/_msv2/conversion.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/_msv2/create_antenna_xds.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/_msv2/msv2_to_msv4_meta.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/_msv2/msv4_info_dicts.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/_msv2/msv4_sub_xdss.py +1 -1
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/_msv2/optimised_functions.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/_msv2/partition_queries.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/_msv2/subtables.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/_utils/stokes_types.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/_zarr/encoding.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/convert_msv2_to_processing_set.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/load_processing_set.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/measurement_set_xdt.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/open_processing_set.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/processing_set_xdt.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/schema.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/schema/__init__.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/schema/bases.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/schema/check.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/schema/dataclass.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/schema/export.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/schema/metamodel.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/schema/typing.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/sphinx/__init__.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/sphinx/schema_table.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/testing/__init__.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/testing/_utils/__template__.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/testing/measurement_set/checker.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/testing/measurement_set/io.py +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio.egg-info/SOURCES.txt +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/src/xradio.egg-info/dependency_links.txt +0 -0
- {xradio-1.1.1 → xradio-1.1.12a0}/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.12a0
|
|
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,7 +98,6 @@ 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"
|
|
102
101
|
Provides-Extra: all
|
|
103
102
|
Requires-Dist: astropy; extra == "all"
|
|
104
103
|
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.12-alpha"
|
|
4
4
|
description = " Xarray Radio Astronomy Data IO"
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "Jan-Willem Steeb", email="jsteeb@nrao.edu"},
|
|
@@ -85,8 +85,7 @@ docs = [
|
|
|
85
85
|
'sphinx-autosummary-accessors',
|
|
86
86
|
'sphinx_rtd_theme',
|
|
87
87
|
'twine',
|
|
88
|
-
'pandoc'
|
|
89
|
-
'toolviper',
|
|
88
|
+
'pandoc'
|
|
90
89
|
]
|
|
91
90
|
|
|
92
91
|
all = [
|
|
@@ -29,24 +29,6 @@ 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
|
-
|
|
50
32
|
import numpy as np
|
|
51
33
|
import toolviper.utils.logger as logger
|
|
52
34
|
|
|
@@ -184,32 +166,6 @@ def wrap_class_methods(cls: type) -> type:
|
|
|
184
166
|
return cls
|
|
185
167
|
|
|
186
168
|
|
|
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
|
-
|
|
213
169
|
@wrap_class_methods
|
|
214
170
|
class table(casatools.table):
|
|
215
171
|
"""A wrapper for the casatools table object.
|
|
@@ -557,7 +513,7 @@ class image(casatools.image):
|
|
|
557
513
|
self,
|
|
558
514
|
imagename,
|
|
559
515
|
axis=0,
|
|
560
|
-
maskname="
|
|
516
|
+
maskname="mask_0",
|
|
561
517
|
images=(),
|
|
562
518
|
values=None,
|
|
563
519
|
coordsys=None,
|
|
@@ -746,36 +702,18 @@ class image(casatools.image):
|
|
|
746
702
|
def imageinfo(self) -> dict:
|
|
747
703
|
"""Retrieve metadata from the image table.
|
|
748
704
|
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
705
|
+
This method accesses the image table associated with the image name
|
|
706
|
+
and attempts to retrieve information stored under the 'imageinfo'
|
|
707
|
+
keyword. If the 'imageinfo' keyword is not found in the table,
|
|
708
|
+
a default dictionary containing basic information is returned.
|
|
753
709
|
|
|
754
710
|
Returns
|
|
755
711
|
-------
|
|
756
712
|
dict
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
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'
|
|
713
|
+
A dictionary containing image metadata. This is either the
|
|
714
|
+
value associated with the 'imageinfo' keyword in the table,
|
|
715
|
+
or a default dictionary {'imagetype': 'Intensity',
|
|
716
|
+
'objectname': ''} if the keyword is absent.
|
|
779
717
|
"""
|
|
780
718
|
with table(self._imagename) as tb:
|
|
781
719
|
if "imageinfo" in tb.keywordnames():
|
|
@@ -783,10 +721,6 @@ class image(casatools.image):
|
|
|
783
721
|
else:
|
|
784
722
|
image_metadata = {"imagetype": "Intensity", "objectname": ""}
|
|
785
723
|
|
|
786
|
-
image_metadata["imagetype"] = _validate_image_type(
|
|
787
|
-
image_metadata.get("imagetype", "Intensity")
|
|
788
|
-
)
|
|
789
|
-
|
|
790
724
|
return image_metadata
|
|
791
725
|
|
|
792
726
|
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 = "SKY",
|
|
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,6 +270,8 @@ 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("***********")
|
|
273
275
|
coord_dict = copy.deepcopy(meta_dict["coordinates"])
|
|
274
276
|
attrs = {}
|
|
275
277
|
dir_key = None
|
|
@@ -348,13 +350,14 @@ def _casa_image_to_xds_attrs(img_full_path: str) -> dict:
|
|
|
348
350
|
|
|
349
351
|
|
|
350
352
|
def _casa_image_to_xds_coords(
|
|
351
|
-
img_full_path: str, verbose: bool, do_sky_coords: bool
|
|
353
|
+
img_full_path: str, verbose: bool, do_sky_coords: bool
|
|
352
354
|
) -> dict:
|
|
353
355
|
"""
|
|
354
356
|
TODO: complete documentation
|
|
355
357
|
Create an xds without any pixel data from metadata from the specified CASA image
|
|
356
358
|
"""
|
|
357
359
|
attrs = {}
|
|
360
|
+
# casa_image = images.image(img_full_path)
|
|
358
361
|
with _open_image_ro(img_full_path) as casa_image:
|
|
359
362
|
# shape list is the reverse of the actual image shape
|
|
360
363
|
shape = casa_image.shape()[::-1]
|
|
@@ -378,56 +381,57 @@ def _casa_image_to_xds_coords(
|
|
|
378
381
|
attrs["sphr_dims"] = sphr_dims
|
|
379
382
|
coords = {}
|
|
380
383
|
coord_attrs = {}
|
|
381
|
-
coords["time"], coord_attrs["time"] = _get_time_values_attrs(coord_dict)
|
|
382
|
-
coords["frequency"], coord_attrs["frequency"] = _get_freq_values_attrs(
|
|
383
|
-
|
|
384
|
+
(coords["time"], coord_attrs["time"]) = _get_time_values_attrs(coord_dict)
|
|
385
|
+
(coords["frequency"], coord_attrs["frequency"]) = _get_freq_values_attrs(
|
|
386
|
+
csys, shape
|
|
387
|
+
)
|
|
388
|
+
(velocity_vals, coord_attrs["velocity"]) = _get_velocity_values_attrs(
|
|
384
389
|
coord_dict, coords["frequency"]
|
|
385
390
|
)
|
|
386
|
-
coords["polarization"], coord_attrs["polarization"] = _get_pol_values_attrs(
|
|
391
|
+
(coords["polarization"], coord_attrs["polarization"]) = _get_pol_values_attrs(
|
|
387
392
|
coord_dict
|
|
388
393
|
)
|
|
389
394
|
coords["velocity"] = (["frequency"], velocity_vals)
|
|
390
|
-
if
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
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
|
-
coords["beam_params_label"] = ["major", "minor", "pa"]
|
|
395
|
+
if len(sphr_dims) > 0:
|
|
396
|
+
crpix = _flatten_list(csys.get_referencepixel())[::-1]
|
|
397
|
+
inc = _flatten_list(csys.get_increment())[::-1]
|
|
398
|
+
unit = _flatten_list(csys.get_unit())[::-1]
|
|
399
|
+
attr_note = _l_m_attr_notes()
|
|
400
|
+
for c in ["l", "m"]:
|
|
401
|
+
idx = dimmap[c]
|
|
402
|
+
delta = ((inc[idx]) * u.Unit(_get_unit(unit[idx]))).to("rad").value
|
|
403
|
+
coords[c] = _compute_linear_world_values(
|
|
404
|
+
naxis=shape[idx], crval=0.0, crpix=crpix[idx], cdelt=delta
|
|
405
|
+
)
|
|
406
|
+
coord_attrs[c] = {
|
|
407
|
+
"note": attr_note[c],
|
|
408
|
+
}
|
|
409
|
+
if do_sky_coords:
|
|
410
|
+
for k in coord_dict.keys():
|
|
411
|
+
if k.startswith("direction"):
|
|
412
|
+
dc = coordinates.directioncoordinate(coord_dict[k])
|
|
413
|
+
break
|
|
414
|
+
crval = _flatten_list(csys.get_referencevalue())[::-1]
|
|
415
|
+
pick = lambda my_list: [my_list[i] for i in sphr_dims]
|
|
416
|
+
my_ret = _compute_world_sph_dims(
|
|
417
|
+
projection=dc.get_projection(),
|
|
418
|
+
shape=pick(shape),
|
|
419
|
+
ctype=diraxes,
|
|
420
|
+
crval=pick(crval),
|
|
421
|
+
crpix=pick(crpix),
|
|
422
|
+
cdelt=pick(inc),
|
|
423
|
+
cunit=pick(unit),
|
|
424
|
+
)
|
|
425
|
+
for i in [0, 1]:
|
|
426
|
+
axis_name = my_ret["axis_name"][i]
|
|
427
|
+
coords[axis_name] = (["l", "m"], my_ret["value"][i])
|
|
428
|
+
coord_attrs[axis_name] = {}
|
|
429
|
+
else:
|
|
430
|
+
# Fourier image
|
|
431
|
+
ret = _get_uv_values_attrs(coord_dict, axis_names, shape)
|
|
432
|
+
for z in ["u", "v"]:
|
|
433
|
+
coords[z], coord_attrs[z] = ret[z]
|
|
434
|
+
coords["beam_params_label"] = ["major", "minor", "pa"]
|
|
431
435
|
attrs["shape"] = shape
|
|
432
436
|
xds = xr.Dataset(coords=coords)
|
|
433
437
|
for c in coord_attrs.keys():
|
|
@@ -681,7 +685,6 @@ def _get_persistent_block(
|
|
|
681
685
|
block = _read_image_chunk(infile, shapes, starts)
|
|
682
686
|
block = np.expand_dims(block, new_axes)
|
|
683
687
|
block = block.transpose(transpose_list)
|
|
684
|
-
block = da.from_array(block, chunks=block.shape)
|
|
685
688
|
block = xr.DataArray(block, dims=dimorder)
|
|
686
689
|
return block
|
|
687
690
|
|
|
@@ -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"]
|
|
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)
|
|
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
|
+
|
|
14
14
|
from xradio._utils.schema import get_data_group_keys
|
|
15
15
|
|
|
16
16
|
try:
|
|
@@ -47,63 +47,25 @@ 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
|
-
|
|
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:
|
|
50
|
+
def _load_casa_image_block(
|
|
51
|
+
infile: str, block_des: dict, do_sky_coords, image_type: str
|
|
52
|
+
) -> xr.Dataset:
|
|
63
53
|
image_full_path = os.path.expanduser(infile)
|
|
64
54
|
with _open_image_ro(image_full_path) as casa_image:
|
|
65
55
|
coords = casa_image.coordinates()
|
|
66
56
|
cshape = casa_image.shape()
|
|
67
|
-
ret = _casa_image_to_xds_coords(image_full_path, False, do_sky_coords
|
|
68
|
-
xds = ret["xds"]
|
|
69
|
-
sphr_dims = ret["sphr_dims"]
|
|
57
|
+
ret = _casa_image_to_xds_coords(image_full_path, False, do_sky_coords)
|
|
58
|
+
xds = ret["xds"].isel(block_des)
|
|
70
59
|
nchan = ret["xds"].sizes["frequency"]
|
|
71
60
|
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"]
|
|
99
61
|
starts, shapes, slices = _get_starts_shapes_slices(block_des, coords, cshape)
|
|
62
|
+
dimorder = _get_xds_dim_order(ret["sphr_dims"])
|
|
100
63
|
transpose_list, new_axes = _get_transpose_list(coords)
|
|
101
64
|
block = _get_persistent_block(
|
|
102
65
|
image_full_path, shapes, starts, dimorder, transpose_list, new_axes
|
|
103
66
|
)
|
|
104
|
-
block = _squeeze_if_needed(block, image_type)
|
|
105
67
|
xds = _add_sky_or_aperture(
|
|
106
|
-
xds, block, dimorder, image_full_path, sphr_dims, False, image_type
|
|
68
|
+
xds, block, dimorder, image_full_path, ret["sphr_dims"], False, image_type
|
|
107
69
|
)
|
|
108
70
|
mymasks = _get_mask_names(image_full_path)
|
|
109
71
|
for m in mymasks:
|
|
@@ -142,21 +104,18 @@ def _open_casa_image(
|
|
|
142
104
|
history: bool = False,
|
|
143
105
|
image_type: str = "SKY",
|
|
144
106
|
) -> xr.Dataset:
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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)
|
|
107
|
+
img_full_path = os.path.expanduser(infile)
|
|
108
|
+
ret = _casa_image_to_xds_coords(img_full_path, verbose, do_sky_coords)
|
|
109
|
+
xds = ret["xds"]
|
|
110
|
+
dimorder = _get_xds_dim_order(ret["sphr_dims"])
|
|
152
111
|
xds = _add_sky_or_aperture(
|
|
153
112
|
xds,
|
|
154
|
-
|
|
113
|
+
_read_image_array(img_full_path, chunks, verbose=verbose),
|
|
155
114
|
dimorder,
|
|
156
115
|
img_full_path,
|
|
157
|
-
sphr_dims,
|
|
116
|
+
ret["sphr_dims"],
|
|
158
117
|
history,
|
|
159
|
-
image_type,
|
|
118
|
+
image_type=image_type,
|
|
160
119
|
)
|
|
161
120
|
if masks:
|
|
162
121
|
mymasks = _get_mask_names(img_full_path)
|
|
@@ -243,6 +202,7 @@ def _xds_to_multiple_casa_images(xds: xr.Dataset, image_store_name: str) -> None
|
|
|
243
202
|
]
|
|
244
203
|
|
|
245
204
|
if "flag" in xds.attrs["data_groups"][data_group]:
|
|
205
|
+
print("******* found flag")
|
|
246
206
|
mask_sky_name = xds.attrs["data_groups"][data_group]["flag"]
|
|
247
207
|
image_to_write_xds["MASK_0"] = xds[mask_sky_name]
|
|
248
208
|
image_to_write_xds["SKY"].attrs["flag"] = "MASK_0"
|
|
@@ -25,11 +25,10 @@ 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
|
|
28
|
+
def _get_xds_dim_order(has_sph: bool) -> list:
|
|
29
29
|
dimorder = ["time", "frequency", "polarization"]
|
|
30
|
-
if
|
|
31
|
-
|
|
32
|
-
dimorder.extend(dir_lin)
|
|
30
|
+
dir_lin = ["l", "m"] if has_sph else ["u", "v"]
|
|
31
|
+
dimorder.extend(dir_lin)
|
|
33
32
|
return dimorder
|
|
34
33
|
|
|
35
34
|
|
|
@@ -337,16 +337,7 @@ def detect_store_type(store):
|
|
|
337
337
|
raise ValueError("Unknown directory structure." + str(store))
|
|
338
338
|
else:
|
|
339
339
|
logger.error("Path does not exist.")
|
|
340
|
-
raise ValueError(
|
|
341
|
-
"Path does not exist. The current path: "
|
|
342
|
-
+ str(os.system("pwd"))
|
|
343
|
-
+ " .The current casa directory: "
|
|
344
|
-
+ str(os.system("ls 3c286_Band6_5chans_lsrk_robust_0.5_niter_99_casa"))
|
|
345
|
-
+ ". The current fits directory: "
|
|
346
|
-
+ str(os.system("ls 3c286_Band6_5chans_lsrk_robust_0.5_niter_99_fits"))
|
|
347
|
-
+ " The given store "
|
|
348
|
-
+ str(store)
|
|
349
|
-
)
|
|
340
|
+
raise ValueError("Path does not exist." + str(store))
|
|
350
341
|
else:
|
|
351
342
|
store_type = "zarr"
|
|
352
343
|
|
|
@@ -693,17 +684,14 @@ def create_image_xds_from_store(
|
|
|
693
684
|
data_group["beam_fit_params_point_spread_function"] = (
|
|
694
685
|
"BEAM_FIT_PARAMS_" + image_type.upper()
|
|
695
686
|
)
|
|
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)
|
|
704
687
|
|
|
705
|
-
|
|
706
|
-
|
|
688
|
+
# if beam_param coord not in image type it is not auto assigned to img_xds
|
|
689
|
+
# but it must be present even if unused
|
|
690
|
+
if "beam_params_label" not in img_xds.dims:
|
|
691
|
+
img_xds.expand_dims(beam_params_label=3)
|
|
692
|
+
|
|
693
|
+
if "beam_params_label" not in img_xds.coords:
|
|
694
|
+
img_xds = _move_beam_param_dim_coord(img_xds)
|
|
707
695
|
img_xds.attrs["type"] = "image_dataset"
|
|
708
696
|
img_xds.attrs["data_groups"] = data_groups
|
|
709
697
|
return img_xds
|
|
@@ -160,7 +160,7 @@ def make_taql_where_between_min_max(
|
|
|
160
160
|
if min_max_range is None:
|
|
161
161
|
taql = None
|
|
162
162
|
else:
|
|
163
|
-
min_val, max_val = min_max_range
|
|
163
|
+
(min_val, max_val) = min_max_range
|
|
164
164
|
taql = f"where {colname} >= {min_val} AND {colname} <= {max_val}"
|
|
165
165
|
|
|
166
166
|
return taql
|
|
@@ -226,7 +226,7 @@ def find_projected_min_max_array(
|
|
|
226
226
|
"""Does the min/max checks and search for find_projected_min_max_table()"""
|
|
227
227
|
|
|
228
228
|
sorted_array = np.sort(array)
|
|
229
|
-
range_min, range_max = min_max
|
|
229
|
+
(range_min, range_max) = min_max
|
|
230
230
|
if len(sorted_array) < 2:
|
|
231
231
|
tol = np.finfo(sorted_array.dtype).eps * 4
|
|
232
232
|
else:
|
|
@@ -891,8 +891,7 @@ def raw_col_data_to_coords_vars(
|
|
|
891
891
|
|
|
892
892
|
if col in timecols:
|
|
893
893
|
if col == "MJD":
|
|
894
|
-
|
|
895
|
-
data = convert_mjd_time(data).astype("datetime64[ns]").view("int64") / 1e9
|
|
894
|
+
data = convert_mjd_time(data).astype("float64") / 1e9
|
|
896
895
|
else:
|
|
897
896
|
try:
|
|
898
897
|
data = convert_casacore_time(data, False)
|
|
@@ -285,7 +285,6 @@ def extract_ephemeris_info(
|
|
|
285
285
|
# Metadata has to be fixed manually. Alternatively, issues like
|
|
286
286
|
# UNIT/QuantumUnits issue could be handled in convert_generic_xds_to_xradio_schema,
|
|
287
287
|
# but for now preferring not to pollute that function.
|
|
288
|
-
|
|
289
288
|
time_ephemeris_dim = ["time_ephemeris"]
|
|
290
289
|
to_new_data_variables = {
|
|
291
290
|
# mandatory: SOURCE_RADIAL_VELOCITY
|
|
@@ -41,10 +41,6 @@ def interpolate_to_time(
|
|
|
41
41
|
method = "linear"
|
|
42
42
|
else:
|
|
43
43
|
method = "nearest"
|
|
44
|
-
|
|
45
|
-
# print("xds before interp:",xds.NORTH_POLE_ANGULAR_DISTANCE.values, xds[time_name].values)
|
|
46
|
-
# print("interp_time data:",interp_time,interp_time.data)
|
|
47
|
-
# print("method:",method)
|
|
48
44
|
xds = xds.interp(
|
|
49
45
|
{time_name: interp_time.data}, method=method, assume_sorted=True
|
|
50
46
|
)
|
|
@@ -60,6 +56,5 @@ def interpolate_to_time(
|
|
|
60
56
|
f"{message_prefix}: interpolating the time coordinate "
|
|
61
57
|
f"from {points_before} to {points_after} points"
|
|
62
58
|
)
|
|
63
|
-
# print("xds after interp:",xds.NORTH_POLE_ANGULAR_DISTANCE.values, xds[time_name].values)
|
|
64
59
|
|
|
65
60
|
return xds
|
|
@@ -5,6 +5,8 @@ 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
|
+
|
|
8
10
|
__all__ = [
|
|
9
11
|
# Generators
|
|
10
12
|
"gen_test_ms",
|
|
@@ -47,8 +49,6 @@ try:
|
|
|
47
49
|
build_minimal_msv4_xdt,
|
|
48
50
|
)
|
|
49
51
|
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. "
|
|
@@ -19,6 +19,7 @@ from casacore.tables import default_ms, default_ms_subtable
|
|
|
19
19
|
from casacore.tables.tableutil import makedminfo, maketabdesc
|
|
20
20
|
from casacore.tables.msutil import complete_ms_desc, makearrcoldesc, required_ms_desc
|
|
21
21
|
|
|
22
|
+
|
|
22
23
|
# 2 observations, 2 fields, 2 states
|
|
23
24
|
# 2 SPWs, 4 polarizations
|
|
24
25
|
default_ms_descr = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xradio
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.12a0
|
|
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,7 +98,6 @@ 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"
|
|
102
101
|
Provides-Extra: all
|
|
103
102
|
Requires-Dist: astropy; extra == "all"
|
|
104
103
|
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
|
{xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/_msv2/_tables/read_main_table.py
RENAMED
|
File without changes
|
{xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/_msv2/_tables/table_query.py
RENAMED
|
File without changes
|
|
File without changes
|
{xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/_msv2/create_antenna_xds.py
RENAMED
|
File without changes
|
{xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/_msv2/msv2_to_msv4_meta.py
RENAMED
|
File without changes
|
|
File without changes
|
|
@@ -27,6 +27,7 @@ from xradio.measurement_set._utils._msv2._tables.read import (
|
|
|
27
27
|
table_has_column,
|
|
28
28
|
)
|
|
29
29
|
|
|
30
|
+
|
|
30
31
|
standard_time_coord_attrs = make_time_measure_attrs(time_format="unix")
|
|
31
32
|
|
|
32
33
|
|
|
@@ -80,7 +81,6 @@ def rename_and_interpolate_to_time(
|
|
|
80
81
|
)
|
|
81
82
|
|
|
82
83
|
# rename the time_* axis to time.
|
|
83
|
-
|
|
84
84
|
time_coord = {"time": (time_initial_name, interp_time.data)}
|
|
85
85
|
renamed_time_xds = interpolated_xds.assign_coords(time_coord)
|
|
86
86
|
renamed_time_xds.coords["time"].attrs.update(standard_time_coord_attrs)
|
{xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/_msv2/optimised_functions.py
RENAMED
|
File without changes
|
{xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/_utils/_msv2/partition_queries.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{xradio-1.1.1 → xradio-1.1.12a0}/src/xradio/measurement_set/convert_msv2_to_processing_set.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
|