xradio 0.0.47__py3-none-any.whl → 0.0.49__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/__init__.py +1 -0
- xradio/_utils/dict_helpers.py +69 -2
- xradio/_utils/list_and_array.py +3 -1
- xradio/_utils/schema.py +3 -1
- xradio/image/_util/__init__.py +0 -3
- xradio/image/_util/_casacore/common.py +0 -13
- xradio/image/_util/_casacore/xds_from_casacore.py +102 -97
- xradio/image/_util/_casacore/xds_to_casacore.py +36 -24
- xradio/image/_util/_fits/xds_from_fits.py +81 -36
- xradio/image/_util/_zarr/zarr_low_level.py +3 -3
- xradio/image/_util/casacore.py +7 -5
- xradio/image/_util/common.py +13 -26
- xradio/image/_util/image_factory.py +143 -191
- xradio/image/image.py +10 -59
- xradio/measurement_set/__init__.py +11 -6
- xradio/measurement_set/_utils/_msv2/_tables/read.py +187 -46
- xradio/measurement_set/_utils/_msv2/_tables/table_query.py +22 -0
- xradio/measurement_set/_utils/_msv2/conversion.py +347 -299
- xradio/measurement_set/_utils/_msv2/create_field_and_source_xds.py +233 -150
- xradio/measurement_set/_utils/_msv2/descr.py +1 -1
- xradio/measurement_set/_utils/_msv2/msv4_info_dicts.py +20 -13
- xradio/measurement_set/_utils/_msv2/msv4_sub_xdss.py +21 -22
- xradio/measurement_set/convert_msv2_to_processing_set.py +46 -6
- xradio/measurement_set/load_processing_set.py +100 -52
- xradio/measurement_set/measurement_set_xdt.py +197 -0
- xradio/measurement_set/open_processing_set.py +122 -86
- xradio/measurement_set/processing_set_xdt.py +1552 -0
- xradio/measurement_set/schema.py +375 -197
- xradio/schema/bases.py +5 -1
- xradio/schema/check.py +97 -5
- xradio/sphinx/schema_table.py +12 -0
- {xradio-0.0.47.dist-info → xradio-0.0.49.dist-info}/METADATA +4 -4
- {xradio-0.0.47.dist-info → xradio-0.0.49.dist-info}/RECORD +36 -36
- {xradio-0.0.47.dist-info → xradio-0.0.49.dist-info}/WHEEL +1 -1
- xradio/measurement_set/measurement_set_xds.py +0 -117
- xradio/measurement_set/processing_set.py +0 -777
- {xradio-0.0.47.dist-info → xradio-0.0.49.dist-info/licenses}/LICENSE.txt +0 -0
- {xradio-0.0.47.dist-info → xradio-0.0.49.dist-info}/top_level.txt +0 -0
xradio/schema/bases.py
CHANGED
|
@@ -397,11 +397,15 @@ def xarray_dataset_schema(cls):
|
|
|
397
397
|
cls = dataclasses.dataclass(cls, init=True, repr=False, eq=False, frozen=True)
|
|
398
398
|
|
|
399
399
|
# Make schema
|
|
400
|
-
|
|
400
|
+
schema = dataclass.xarray_dataclass_to_dataset_schema(cls)
|
|
401
|
+
cls.__xradio_dataset_schema = schema
|
|
401
402
|
|
|
402
403
|
# Replace __new__
|
|
403
404
|
cls.__new__ = _dataset_new
|
|
404
405
|
|
|
406
|
+
# Register type
|
|
407
|
+
check.register_dataset_type(schema)
|
|
408
|
+
|
|
405
409
|
return cls
|
|
406
410
|
|
|
407
411
|
|
xradio/schema/check.py
CHANGED
|
@@ -2,6 +2,7 @@ import dataclasses
|
|
|
2
2
|
import typing
|
|
3
3
|
import inspect
|
|
4
4
|
import functools
|
|
5
|
+
import warnings
|
|
5
6
|
|
|
6
7
|
import xarray
|
|
7
8
|
import numpy
|
|
@@ -173,7 +174,9 @@ def check_array(
|
|
|
173
174
|
|
|
174
175
|
|
|
175
176
|
def check_dataset(
|
|
176
|
-
dataset: xarray.Dataset,
|
|
177
|
+
dataset: xarray.Dataset,
|
|
178
|
+
schema: typing.Union[type, metamodel.DatasetSchema],
|
|
179
|
+
allow_superflous_dims: typing.Set[str] = frozenset(),
|
|
177
180
|
) -> SchemaIssues:
|
|
178
181
|
"""
|
|
179
182
|
Check whether an xarray DataArray conforms to a schema
|
|
@@ -196,7 +199,12 @@ def check_dataset(
|
|
|
196
199
|
)
|
|
197
200
|
|
|
198
201
|
# Check dimensions. Order does not matter on datasets
|
|
199
|
-
issues = check_dimensions(
|
|
202
|
+
issues = check_dimensions(
|
|
203
|
+
dataset.dims,
|
|
204
|
+
schema.dimensions,
|
|
205
|
+
check_order=False,
|
|
206
|
+
allow_superflous=allow_superflous_dims,
|
|
207
|
+
)
|
|
200
208
|
|
|
201
209
|
# Check attributes
|
|
202
210
|
issues += check_attributes(dataset.attrs, schema.attributes)
|
|
@@ -211,7 +219,10 @@ def check_dataset(
|
|
|
211
219
|
|
|
212
220
|
|
|
213
221
|
def check_dimensions(
|
|
214
|
-
dims: [str],
|
|
222
|
+
dims: [str],
|
|
223
|
+
expected: [[str]],
|
|
224
|
+
check_order: bool = True,
|
|
225
|
+
allow_superflous: typing.Set[str] = frozenset(),
|
|
215
226
|
) -> SchemaIssues:
|
|
216
227
|
"""
|
|
217
228
|
Check whether a dimension list conforms to a schema
|
|
@@ -230,7 +241,7 @@ def check_dimensions(
|
|
|
230
241
|
exp_dims_set = set(exp_dims)
|
|
231
242
|
|
|
232
243
|
# No match? Continue, but take note of best match
|
|
233
|
-
if exp_dims_set != dims_set:
|
|
244
|
+
if exp_dims_set - allow_superflous != dims_set - allow_superflous:
|
|
234
245
|
diff = len(dims_set.symmetric_difference(exp_dims_set))
|
|
235
246
|
if best is None or diff < best_diff:
|
|
236
247
|
best = exp_dims_set
|
|
@@ -253,7 +264,7 @@ def check_dimensions(
|
|
|
253
264
|
)
|
|
254
265
|
|
|
255
266
|
# Dimensionality not supported - try to give a helpful suggestion
|
|
256
|
-
hint_remove = [f"'{hint}'" for hint in dims_set - best]
|
|
267
|
+
hint_remove = [f"'{hint}'" for hint in (dims_set - best) - allow_superflous]
|
|
257
268
|
hint_add = [f"'{hint}'" for hint in best - dims_set]
|
|
258
269
|
if hint_remove and hint_add:
|
|
259
270
|
message = f"Unexpected coordinates, replace {','.join(hint_remove)} by {','.join(hint_add)}?"
|
|
@@ -560,6 +571,87 @@ def _check_value_union(val, ann):
|
|
|
560
571
|
return args_issues
|
|
561
572
|
|
|
562
573
|
|
|
574
|
+
_DATASET_TYPES = {}
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
def register_dataset_type(schema: metamodel.DatasetSchema):
|
|
578
|
+
"""
|
|
579
|
+
Registers the given schema for usage with :py:meth:`check_datatree`
|
|
580
|
+
|
|
581
|
+
This looks for a ``type`` attribute in the dataset schema, which
|
|
582
|
+
must have a :py:class:`typing.Literal` type annotation specifying
|
|
583
|
+
the type name of the dataset
|
|
584
|
+
|
|
585
|
+
:param schema: Schema to register
|
|
586
|
+
"""
|
|
587
|
+
|
|
588
|
+
# Find type attribute
|
|
589
|
+
for attr in schema.attributes:
|
|
590
|
+
if attr.name != "type":
|
|
591
|
+
continue
|
|
592
|
+
|
|
593
|
+
# Type should be a kind of literal
|
|
594
|
+
if typing.get_origin(attr.typ) is not typing.Literal:
|
|
595
|
+
warnings.warn(
|
|
596
|
+
f"In dataset schema {schema.schema_name}:"
|
|
597
|
+
'Attribute "type" should be a literal!'
|
|
598
|
+
)
|
|
599
|
+
continue
|
|
600
|
+
|
|
601
|
+
# Register type names
|
|
602
|
+
for typ in typing.get_args(attr.typ):
|
|
603
|
+
_DATASET_TYPES[typ] = schema
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
def check_datatree(
|
|
607
|
+
datatree: xarray.DataTree,
|
|
608
|
+
):
|
|
609
|
+
"""
|
|
610
|
+
Check datatree for schema conformance
|
|
611
|
+
|
|
612
|
+
This is the case if all nodes containing data
|
|
613
|
+
|
|
614
|
+
This looks for a ``type`` attribute in the dataset schema, which
|
|
615
|
+
must have a :py:class:`typing.Literal` type annotation specifying
|
|
616
|
+
the type name of the dataset
|
|
617
|
+
|
|
618
|
+
:param schema: Schema to register
|
|
619
|
+
"""
|
|
620
|
+
|
|
621
|
+
# Loop through all groups in datatree
|
|
622
|
+
issues = SchemaIssues()
|
|
623
|
+
for xds_name in datatree.groups:
|
|
624
|
+
|
|
625
|
+
# Ignore any leaf without data
|
|
626
|
+
node = datatree[xds_name]
|
|
627
|
+
if not node.has_data:
|
|
628
|
+
continue
|
|
629
|
+
|
|
630
|
+
# Look up schema
|
|
631
|
+
schema = _DATASET_TYPES.get(node.attrs.get("type"))
|
|
632
|
+
if schema is None:
|
|
633
|
+
issues.add(
|
|
634
|
+
SchemaIssue(
|
|
635
|
+
[("", xds_name)],
|
|
636
|
+
message="Unknown dataset type!",
|
|
637
|
+
found=typ,
|
|
638
|
+
expected=list(schemas.keys()),
|
|
639
|
+
)
|
|
640
|
+
)
|
|
641
|
+
continue
|
|
642
|
+
|
|
643
|
+
# Determine dimensions inherited from parent
|
|
644
|
+
# (they might show up as "superflous" for the child schema)
|
|
645
|
+
parent_dims = frozenset()
|
|
646
|
+
if node.parent is not None:
|
|
647
|
+
parent_dims = set(node.parent.dims)
|
|
648
|
+
|
|
649
|
+
# Check schema
|
|
650
|
+
issues += check_dataset(node.dataset, schema, parent_dims).at_path("", xds_name)
|
|
651
|
+
|
|
652
|
+
return issues
|
|
653
|
+
|
|
654
|
+
|
|
563
655
|
def schema_checked(fn, check_parameters: bool = True, check_return: bool = True):
|
|
564
656
|
"""
|
|
565
657
|
Function decorator to check parameters and return value for
|
xradio/sphinx/schema_table.py
CHANGED
|
@@ -212,6 +212,18 @@ def format_attr_model_text(state, attr) -> StringList:
|
|
|
212
212
|
state.nested_parse(vl, 0, line)
|
|
213
213
|
return line
|
|
214
214
|
|
|
215
|
+
if typing.get_origin(attr.typ) == typing.Union:
|
|
216
|
+
vl = StringList()
|
|
217
|
+
type_args = typing.get_args(attr.typ)
|
|
218
|
+
options = []
|
|
219
|
+
for i, arg in enumerate(type_args):
|
|
220
|
+
vl.append(f":py:class:`~{arg.__module__}.{arg.__name__}`", "")
|
|
221
|
+
if i + 1 < len(type_args):
|
|
222
|
+
vl.append(" or ", "")
|
|
223
|
+
with switch_source_input(state, vl):
|
|
224
|
+
state.nested_parse(vl, 0, line)
|
|
225
|
+
return line
|
|
226
|
+
|
|
215
227
|
# Derived type, e.g. list of types?
|
|
216
228
|
if typing.get_origin(attr.typ) == list and all(
|
|
217
229
|
[isinstance(arg, type) for arg in type_args]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: xradio
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.49
|
|
4
4
|
Summary: Xarray Radio Astronomy Data IO
|
|
5
5
|
Author-email: Jan-Willem Steeb <jsteeb@nrao.edu>
|
|
6
6
|
License: BSD 3-Clause License
|
|
@@ -37,7 +37,7 @@ License: BSD 3-Clause License
|
|
|
37
37
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
38
38
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
39
39
|
|
|
40
|
-
Requires-Python: <3.
|
|
40
|
+
Requires-Python: <3.14,>=3.11
|
|
41
41
|
Description-Content-Type: text/markdown
|
|
42
42
|
License-File: LICENSE.txt
|
|
43
43
|
Requires-Dist: astropy
|
|
@@ -55,7 +55,6 @@ Requires-Dist: xarray
|
|
|
55
55
|
Requires-Dist: zarr<3,>=2
|
|
56
56
|
Requires-Dist: pyarrow
|
|
57
57
|
Requires-Dist: python_casacore>=3.6.1; sys_platform != "darwin"
|
|
58
|
-
Requires-Dist: typing_extensions; python_version < "3.10"
|
|
59
58
|
Requires-Dist: typeguard
|
|
60
59
|
Provides-Extra: interactive
|
|
61
60
|
Requires-Dist: matplotlib; extra == "interactive"
|
|
@@ -74,6 +73,7 @@ Requires-Dist: sphinx-autosummary-accessors; extra == "docs"
|
|
|
74
73
|
Requires-Dist: sphinx_rtd_theme; extra == "docs"
|
|
75
74
|
Requires-Dist: twine; extra == "docs"
|
|
76
75
|
Requires-Dist: pandoc; extra == "docs"
|
|
76
|
+
Dynamic: license-file
|
|
77
77
|
|
|
78
78
|
# xradio
|
|
79
79
|
Xarray Radio Astronomy Data IO is still in development.
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
xradio/__init__.py,sha256=
|
|
1
|
+
xradio/__init__.py,sha256=82picDsKDBYZRlIpp5JjWsBEf_daXgiLVM7zq6rY_6Q,383
|
|
2
2
|
xradio/_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
xradio/_utils/coord_math.py,sha256=n4Td6jcEX4vM49Xseuwrg6USylTGsySS6CND93DEG_8,3587
|
|
4
|
-
xradio/_utils/dict_helpers.py,sha256=
|
|
5
|
-
xradio/_utils/list_and_array.py,sha256=
|
|
6
|
-
xradio/_utils/schema.py,sha256=
|
|
4
|
+
xradio/_utils/dict_helpers.py,sha256=rUiZhicKu0rptWwXpEwo1fHdAf7hCF4yyoXpRoDrjcU,2162
|
|
5
|
+
xradio/_utils/list_and_array.py,sha256=fW0LDSXlPrSQguSUcZM5oy2Zw-KQVqq9vmmLS8jhc70,4340
|
|
6
|
+
xradio/_utils/schema.py,sha256=XJwJNCenkgK0tjxJmMO_F-8VDqHiutDX2K1iP9kBgIA,7472
|
|
7
7
|
xradio/_utils/_casacore/tables.py,sha256=aq6E_4RRAHdTBCwMKrVil1cWhFU2O980DNH9IlRKXLw,1280
|
|
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=
|
|
12
|
-
xradio/image/_util/__init__.py,sha256=
|
|
13
|
-
xradio/image/_util/casacore.py,sha256=
|
|
14
|
-
xradio/image/_util/common.py,sha256=
|
|
11
|
+
xradio/image/image.py,sha256=j2Rhya35RRR5NIq1kYzXHbYvKlhtKLhD28sZq_2AtPo,14042
|
|
12
|
+
xradio/image/_util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
+
xradio/image/_util/casacore.py,sha256=3gF720wtbU0_L6ZWZlKTvBTHFKWNdTgI4_uCwVYwnWE,4353
|
|
14
|
+
xradio/image/_util/common.py,sha256=y2QJXTHowvjqwNPG5a-cOzl0WneH7c8c9jAVSKQeK2w,8429
|
|
15
15
|
xradio/image/_util/fits.py,sha256=gyGm06fuCKqVGK7uv-ObvQNfFawUDsIOa_nQyklM3Aw,329
|
|
16
|
-
xradio/image/_util/image_factory.py,sha256=
|
|
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
|
-
xradio/image/_util/_casacore/common.py,sha256=
|
|
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=
|
|
19
|
+
xradio/image/_util/_casacore/common.py,sha256=Z7Jl3AU7jVcgjNtCnvL7CCXJQAxXeEtowXBmSShuAv4,1329
|
|
20
|
+
xradio/image/_util/_casacore/xds_from_casacore.py,sha256=-y-VluzdvdnoK3swCDgA0UFhhajCRoPD6eY9e8c42F8,42462
|
|
21
|
+
xradio/image/_util/_casacore/xds_to_casacore.py,sha256=Oh1Uve0y7R54VOqchm8JAxrmx4n1oHEvae7zJrVHMFg,16054
|
|
22
|
+
xradio/image/_util/_fits/xds_from_fits.py,sha256=vadDxBvLYJudlUwLQcR7cX23hRIDMJZUHP0adKwh1WU,29853
|
|
23
23
|
xradio/image/_util/_zarr/common.py,sha256=apMX_bF4Hr3pFGjnDFpp36KgmhTYAPBZquNkjBHrsXk,307
|
|
24
24
|
xradio/image/_util/_zarr/xds_from_zarr.py,sha256=4b6KHmAcnrhBbCi-Z7e3Lm6l6wziJL1zaNIohmPAYDk,3601
|
|
25
25
|
xradio/image/_util/_zarr/xds_to_zarr.py,sha256=wogXbwX8n3Sl9PHoc3_Y_LBowQsQ-94HZQFZ5NcxUZA,1624
|
|
26
|
-
xradio/image/_util/_zarr/zarr_low_level.py,sha256=
|
|
27
|
-
xradio/measurement_set/__init__.py,sha256=
|
|
28
|
-
xradio/measurement_set/convert_msv2_to_processing_set.py,sha256=
|
|
29
|
-
xradio/measurement_set/load_processing_set.py,sha256=
|
|
30
|
-
xradio/measurement_set/
|
|
31
|
-
xradio/measurement_set/open_processing_set.py,sha256=
|
|
32
|
-
xradio/measurement_set/
|
|
33
|
-
xradio/measurement_set/schema.py,sha256=
|
|
26
|
+
xradio/image/_util/_zarr/zarr_low_level.py,sha256=xnYm6EmVbmLxMlOSXH32SABfQBLHfr2H9ch9gYwFNXs,13338
|
|
27
|
+
xradio/measurement_set/__init__.py,sha256=Vrr1Py50TvbzeZ_VMCswYNz0Wcccbf-iJDj4ArlfcJ0,870
|
|
28
|
+
xradio/measurement_set/convert_msv2_to_processing_set.py,sha256=uLZjXplVPXa0XnNa-Fty85k_-fsw6ZC98Hfiwd1WF-U,9704
|
|
29
|
+
xradio/measurement_set/load_processing_set.py,sha256=8EPApyGy0Tmzu6Seeby7dKxvtxtAFA585kK50DYVHas,8164
|
|
30
|
+
xradio/measurement_set/measurement_set_xdt.py,sha256=t9CKwgZlnogE6KoGQSVDwHel9FzYiOlA0ldoRyt5jZo,7636
|
|
31
|
+
xradio/measurement_set/open_processing_set.py,sha256=kMODJmXT2KU12L6Y2NdTV8shvLGb5PgLIOqJgMCzlHI,5308
|
|
32
|
+
xradio/measurement_set/processing_set_xdt.py,sha256=fIsfhhnBg5uq7KU0dDRJpyP12jpHo6f4ppbRJTqUAAc,59342
|
|
33
|
+
xradio/measurement_set/schema.py,sha256=ppH-iibynbCw3kp_Ms_scpCanJNKnBHYdXC4GMwbLAU,85646
|
|
34
34
|
xradio/measurement_set/_utils/__init__.py,sha256=XE-h1yMfr6tVD6gdUwXO1CVq5SQ6kD_oj-e5TFwslds,97
|
|
35
35
|
xradio/measurement_set/_utils/msv2.py,sha256=7hnZMFoQ-s1g0ATjEupLvtdqQCdroPv-Rl5OwjqXjh8,4430
|
|
36
36
|
xradio/measurement_set/_utils/zarr.py,sha256=ehXlu0Xh_UZ5Xm2RnHCxESsRZ26c3DQAO5rqMK5MwTk,3947
|
|
37
37
|
xradio/measurement_set/_utils/_msv2/chunks.py,sha256=JTPk3il6fk570BjWZMoOAtsbvnLmqPcBv9EPY6A2yOs,2964
|
|
38
|
-
xradio/measurement_set/_utils/_msv2/conversion.py,sha256=
|
|
38
|
+
xradio/measurement_set/_utils/_msv2/conversion.py,sha256=KH6DQ9HKeAaIkXBjDNKKnUuQI7xp647ucLqu9m_TsFE,52931
|
|
39
39
|
xradio/measurement_set/_utils/_msv2/create_antenna_xds.py,sha256=qLUDxbkJBOaD7EaVx7ufiU0CL5f8VVxK-923-j4XpXc,17758
|
|
40
|
-
xradio/measurement_set/_utils/_msv2/create_field_and_source_xds.py,sha256=
|
|
41
|
-
xradio/measurement_set/_utils/_msv2/descr.py,sha256=
|
|
40
|
+
xradio/measurement_set/_utils/_msv2/create_field_and_source_xds.py,sha256=iyR5LzCupA6ZJmIOjIylwCQRI1EU4JEofBL7sbDWzwA,37069
|
|
41
|
+
xradio/measurement_set/_utils/_msv2/descr.py,sha256=PGY39PYQj0K4th5RUv0jOWszcHlZDt6VQRTOuntCeYI,5213
|
|
42
42
|
xradio/measurement_set/_utils/_msv2/msv2_msv3.py,sha256=9AKs2HWly7Ivv_Cjr11dIPGmm33_rtSBoGF9wN5ZwEQ,116
|
|
43
43
|
xradio/measurement_set/_utils/_msv2/msv2_to_msv4_meta.py,sha256=gk9gU7g2Lk7dmaiLW8qecOEt574pRtGsCHnUnHXM3D0,1614
|
|
44
|
-
xradio/measurement_set/_utils/_msv2/msv4_info_dicts.py,sha256=
|
|
45
|
-
xradio/measurement_set/_utils/_msv2/msv4_sub_xdss.py,sha256=
|
|
44
|
+
xradio/measurement_set/_utils/_msv2/msv4_info_dicts.py,sha256=5-T-C5wPAPHIUY1eQXvfdLQxPPuTy6UJIZhLlMyfMqA,7213
|
|
45
|
+
xradio/measurement_set/_utils/_msv2/msv4_sub_xdss.py,sha256=Y_YjSOvH5A1Ij2x5lAC7FAL6C0mEbWvbGRPYpBIay7w,21958
|
|
46
46
|
xradio/measurement_set/_utils/_msv2/optimised_functions.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
47
47
|
xradio/measurement_set/_utils/_msv2/partition_queries.py,sha256=6toOYRE6lay78r24kgUgQHOngQLuIGqQKcBTZcCk4lE,14709
|
|
48
48
|
xradio/measurement_set/_utils/_msv2/partitions.py,sha256=_KhRq8bSx2QxuWp9K57fLoLxcU6kvJ35e6wvJ-THbwc,12979
|
|
49
49
|
xradio/measurement_set/_utils/_msv2/subtables.py,sha256=_mpOOtHexqhiqEKt7S4LVqImJoNMJKSY18vNVw83r_U,3945
|
|
50
50
|
xradio/measurement_set/_utils/_msv2/_tables/load.py,sha256=IR3fdKlq8rgH4bHmB1JTtB5gSGuITIvErJEVjUA8rWM,1799
|
|
51
51
|
xradio/measurement_set/_utils/_msv2/_tables/load_main_table.py,sha256=IOGHMyemLbc6kJZC81LE6l0gVdgXuIFmDty2pxb5rr0,14806
|
|
52
|
-
xradio/measurement_set/_utils/_msv2/_tables/read.py,sha256=
|
|
52
|
+
xradio/measurement_set/_utils/_msv2/_tables/read.py,sha256=31GvjuaH_FjoaL-ffbN3m3KxGGQdFBCoCp8yACPg4pc,46983
|
|
53
53
|
xradio/measurement_set/_utils/_msv2/_tables/read_main_table.py,sha256=8AbNt-AxrhPK3EPRa7xqJXffxzIgfVsv1BDfoVJEXLU,26056
|
|
54
54
|
xradio/measurement_set/_utils/_msv2/_tables/read_subtables.py,sha256=JM6pGUQtjQR881u9VqakmbJjppEFq-EVKnEZ14JqnAw,12438
|
|
55
|
-
xradio/measurement_set/_utils/_msv2/_tables/table_query.py,sha256=
|
|
55
|
+
xradio/measurement_set/_utils/_msv2/_tables/table_query.py,sha256=9fNIpYLOHvomsFqZ42NTr_EYiIcVCvMrlKFI0qa4erE,1217
|
|
56
56
|
xradio/measurement_set/_utils/_msv2/_tables/write.py,sha256=43XQ-tHhbhex0eUTRknNpPEEOnNR-w1lGCox9WZ9NHE,9540
|
|
57
57
|
xradio/measurement_set/_utils/_msv2/_tables/write_exp_api.py,sha256=GDEll8nMwkQGc6vosu4UddFL5_ld7WurRgF9hYFTRmU,15511
|
|
58
58
|
xradio/measurement_set/_utils/_utils/cds.py,sha256=OpvKowSheIthUbcPEv2AoKmxlEt3DqJZS5C1AYh5z10,1179
|
|
@@ -63,15 +63,15 @@ xradio/measurement_set/_utils/_zarr/encoding.py,sha256=GENIlThV6a9CUCL6gIGlu9c6N
|
|
|
63
63
|
xradio/measurement_set/_utils/_zarr/read.py,sha256=O9DiwD2Gn8WiatQ-Q6WGGSwjsXwFktG4f81lM-mgcSg,7596
|
|
64
64
|
xradio/measurement_set/_utils/_zarr/write.py,sha256=k5IfqtI44Dm4KBDiKFGhL5hN7kwNOulvVHmeP5Mi7N4,10043
|
|
65
65
|
xradio/schema/__init__.py,sha256=EzEMnOtN8G_wdjo8QBRKfq5MrYgfr_nt1pfunlI6i6Q,733
|
|
66
|
-
xradio/schema/bases.py,sha256=
|
|
67
|
-
xradio/schema/check.py,sha256=
|
|
66
|
+
xradio/schema/bases.py,sha256=dk24pFhugCe5RjaR41xxP38FxVVsIC9bdmBdsarwFvk,17162
|
|
67
|
+
xradio/schema/check.py,sha256=nIvGpXWkKei5cS14PvbYL29R6_YnrI1NjOPQHkUFOZY,21857
|
|
68
68
|
xradio/schema/dataclass.py,sha256=w6FbFtmGnAX4SYwYar7v8-YFf6j40G7g_jvIfVCuxjc,14087
|
|
69
69
|
xradio/schema/metamodel.py,sha256=WjtW7pAVzcjLRWifRH3sQoOiN6TV810hARpOIz1M_gw,3845
|
|
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
|
-
xradio/sphinx/schema_table.py,sha256=
|
|
73
|
-
xradio-0.0.
|
|
74
|
-
xradio-0.0.
|
|
75
|
-
xradio-0.0.
|
|
76
|
-
xradio-0.0.
|
|
77
|
-
xradio-0.0.
|
|
72
|
+
xradio/sphinx/schema_table.py,sha256=uq33habbAbReqnEG6ASKSd4UOMZGUzA3qoTX45rq84U,12373
|
|
73
|
+
xradio-0.0.49.dist-info/licenses/LICENSE.txt,sha256=9CYIJt7riOXo9AD0eXBZviLxo_HebD-2JJI8oiWtzfg,1807
|
|
74
|
+
xradio-0.0.49.dist-info/METADATA,sha256=-rwVHT0ItsA4EO7VmVQ0gmCmVrUpgOvufSxEhcIPfbc,4441
|
|
75
|
+
xradio-0.0.49.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
76
|
+
xradio-0.0.49.dist-info/top_level.txt,sha256=dQu27fGBZJ2Yk-gW5XeD-dZ76Xa4Xcvk60Vz-dwXp7k,7
|
|
77
|
+
xradio-0.0.49.dist-info/RECORD,,
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import pandas as pd
|
|
2
|
-
from xradio._utils.list_and_array import to_list
|
|
3
|
-
import xarray as xr
|
|
4
|
-
import numbers
|
|
5
|
-
import os
|
|
6
|
-
from collections.abc import Mapping, Iterable
|
|
7
|
-
from typing import Any, Union
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class MeasurementSetXds(xr.Dataset):
|
|
11
|
-
__slots__ = ()
|
|
12
|
-
|
|
13
|
-
def __init__(self, xds):
|
|
14
|
-
super().__init__(xds.data_vars, xds.coords, xds.attrs)
|
|
15
|
-
|
|
16
|
-
def to_store(self, store, **kwargs):
|
|
17
|
-
"""
|
|
18
|
-
Write the MeasurementSetXds to a Zarr store.
|
|
19
|
-
Does not write to cloud storage yet.
|
|
20
|
-
|
|
21
|
-
Args:
|
|
22
|
-
store (str): The path to the Zarr store.
|
|
23
|
-
**kwargs: Additional keyword arguments to be passed to `xarray.Dataset.to_zarr`. See https://docs.xarray.dev/en/latest/generated/xarray.Dataset.to_zarr.html for more information.
|
|
24
|
-
|
|
25
|
-
Returns:
|
|
26
|
-
None
|
|
27
|
-
"""
|
|
28
|
-
|
|
29
|
-
copy_cor_xds = self.copy() # No deep copy
|
|
30
|
-
|
|
31
|
-
# Remove field_and_source_xds from all correlated_data (VISIBILITY/SPECTRUM) data variables
|
|
32
|
-
# and save them as separate zarr files.
|
|
33
|
-
for data_group_name, data_group in self.attrs["data_groups"].items():
|
|
34
|
-
del copy_cor_xds[data_group["correlated_data"]].attrs[
|
|
35
|
-
"field_and_source_xds"
|
|
36
|
-
]
|
|
37
|
-
|
|
38
|
-
# print("data_group_name", data_group_name)
|
|
39
|
-
xr.Dataset.to_zarr(
|
|
40
|
-
self[data_group["correlated_data"]].attrs["field_and_source_xds"],
|
|
41
|
-
os.path.join(store, "field_and_source_xds_" + data_group_name),
|
|
42
|
-
**kwargs,
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
# Remove xds attributes from copy_cor_xds and save xds attributes as separate zarr files.
|
|
46
|
-
for attrs_name in self.attrs:
|
|
47
|
-
if "xds" in attrs_name:
|
|
48
|
-
del copy_cor_xds.attrs[attrs_name]
|
|
49
|
-
xr.Dataset.to_zarr(
|
|
50
|
-
self.attrs[attrs_name], os.path.join(store, attrs_name), **kwargs
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
# Save copy_cor_xds as zarr file.
|
|
54
|
-
xr.Dataset.to_zarr(
|
|
55
|
-
copy_cor_xds, os.path.join(store, "correlated_xds"), **kwargs
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
def sel(
|
|
59
|
-
self,
|
|
60
|
-
indexers: Union[Mapping[Any, Any], None] = None,
|
|
61
|
-
method: Union[str, None] = None,
|
|
62
|
-
tolerance: Union[int, float, Iterable[Union[int, float]], None] = None,
|
|
63
|
-
drop: bool = False,
|
|
64
|
-
**indexers_kwargs: Any,
|
|
65
|
-
):
|
|
66
|
-
"""
|
|
67
|
-
Select data along dimension(s) by label. Overrides `xarray.Dataset.sel <https://xarray.pydata.org/en/stable/generated/xarray.Dataset.sel.html>`__ so that a data group can be selected by name by using the `data_group_name` parameter.
|
|
68
|
-
For more information on data groups see `Data Groups <https://xradio.readthedocs.io/en/latest/measurement_set_overview.html#Data-Groups>`__ section. See `xarray.Dataset.sel <https://xarray.pydata.org/en/stable/generated/xarray.Dataset.sel.html>`__ for parameter descriptions.
|
|
69
|
-
|
|
70
|
-
Returns:
|
|
71
|
-
MeasurementSetXds
|
|
72
|
-
|
|
73
|
-
Examples
|
|
74
|
-
--------
|
|
75
|
-
>>> # Select data group 'corrected' and polarization 'XX'.
|
|
76
|
-
>>> selected_ms_xds = ms_xds.sel(data_group_name='corrected', polarization='XX')
|
|
77
|
-
|
|
78
|
-
>>> # Select data group 'corrected' and polarization 'XX' using a dict.
|
|
79
|
-
>>> selected_ms_xds = ms_xds.sel({'data_group_name':'corrected', 'polarization':'XX')
|
|
80
|
-
"""
|
|
81
|
-
|
|
82
|
-
if "data_group_name" in indexers_kwargs:
|
|
83
|
-
data_group_name = indexers_kwargs["data_group_name"]
|
|
84
|
-
del indexers_kwargs["data_group_name"]
|
|
85
|
-
elif (indexers is not None) and ("data_group_name" in indexers):
|
|
86
|
-
data_group_name = indexers["data_group_name"]
|
|
87
|
-
del indexers["data_group_name"]
|
|
88
|
-
else:
|
|
89
|
-
data_group_name = None
|
|
90
|
-
|
|
91
|
-
if data_group_name is not None:
|
|
92
|
-
sel_data_group_set = set(
|
|
93
|
-
self.attrs["data_groups"][data_group_name].values()
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
data_variables_to_drop = []
|
|
97
|
-
for dg in self.attrs["data_groups"].values():
|
|
98
|
-
temp_set = set(dg.values()) - sel_data_group_set
|
|
99
|
-
data_variables_to_drop.extend(list(temp_set))
|
|
100
|
-
|
|
101
|
-
data_variables_to_drop = list(set(data_variables_to_drop))
|
|
102
|
-
|
|
103
|
-
sel_ms_xds = MeasurementSetXds(
|
|
104
|
-
super()
|
|
105
|
-
.sel(indexers, method, tolerance, drop, **indexers_kwargs)
|
|
106
|
-
.drop_vars(data_variables_to_drop)
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
sel_ms_xds.attrs["data_groups"] = {
|
|
110
|
-
data_group_name: self.attrs["data_groups"][data_group_name]
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return sel_ms_xds
|
|
114
|
-
else:
|
|
115
|
-
return MeasurementSetXds(
|
|
116
|
-
super().sel(indexers, method, tolerance, drop, **indexers_kwargs)
|
|
117
|
-
)
|