xradio 0.0.56__py3-none-any.whl → 0.0.59__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 +2 -2
- xradio/_utils/_casacore/casacore_from_casatools.py +12 -2
- xradio/_utils/_casacore/tables.py +1 -0
- xradio/_utils/coord_math.py +22 -23
- xradio/_utils/dict_helpers.py +76 -11
- xradio/_utils/schema.py +5 -2
- xradio/_utils/zarr/common.py +1 -73
- xradio/image/_util/_casacore/xds_from_casacore.py +49 -33
- xradio/image/_util/_casacore/xds_to_casacore.py +41 -14
- xradio/image/_util/_fits/xds_from_fits.py +146 -35
- xradio/image/_util/casacore.py +4 -3
- xradio/image/_util/common.py +4 -4
- xradio/image/_util/image_factory.py +8 -8
- xradio/image/image.py +45 -5
- xradio/measurement_set/__init__.py +19 -9
- xradio/measurement_set/_utils/__init__.py +1 -3
- xradio/measurement_set/_utils/_msv2/__init__.py +0 -0
- xradio/measurement_set/_utils/_msv2/_tables/read.py +17 -76
- xradio/measurement_set/_utils/_msv2/_tables/read_main_table.py +2 -685
- xradio/measurement_set/_utils/_msv2/conversion.py +174 -156
- xradio/measurement_set/_utils/_msv2/create_antenna_xds.py +9 -16
- xradio/measurement_set/_utils/_msv2/create_field_and_source_xds.py +128 -222
- xradio/measurement_set/_utils/_msv2/msv2_to_msv4_meta.py +1 -2
- xradio/measurement_set/_utils/_msv2/msv4_info_dicts.py +8 -7
- xradio/measurement_set/_utils/_msv2/msv4_sub_xdss.py +31 -74
- xradio/measurement_set/_utils/_msv2/partition_queries.py +1 -261
- xradio/measurement_set/_utils/_msv2/subtables.py +0 -107
- xradio/measurement_set/_utils/_utils/interpolate.py +60 -0
- xradio/measurement_set/_utils/_zarr/encoding.py +2 -7
- xradio/measurement_set/convert_msv2_to_processing_set.py +0 -2
- xradio/measurement_set/load_processing_set.py +2 -2
- xradio/measurement_set/measurement_set_xdt.py +20 -16
- xradio/measurement_set/open_processing_set.py +1 -3
- xradio/measurement_set/processing_set_xdt.py +54 -841
- xradio/measurement_set/schema.py +122 -132
- xradio/schema/check.py +95 -101
- xradio/schema/dataclass.py +159 -22
- xradio/schema/export.py +99 -0
- xradio/schema/metamodel.py +51 -16
- xradio/schema/typing.py +5 -5
- xradio/sphinx/schema_table.py +41 -77
- {xradio-0.0.56.dist-info → xradio-0.0.59.dist-info}/METADATA +20 -5
- xradio-0.0.59.dist-info/RECORD +65 -0
- {xradio-0.0.56.dist-info → xradio-0.0.59.dist-info}/WHEEL +1 -1
- xradio/image/_util/fits.py +0 -13
- xradio/measurement_set/_utils/_msv2/_tables/load.py +0 -66
- xradio/measurement_set/_utils/_msv2/_tables/load_main_table.py +0 -490
- xradio/measurement_set/_utils/_msv2/_tables/read_subtables.py +0 -398
- xradio/measurement_set/_utils/_msv2/_tables/write.py +0 -323
- xradio/measurement_set/_utils/_msv2/_tables/write_exp_api.py +0 -388
- xradio/measurement_set/_utils/_msv2/chunks.py +0 -115
- xradio/measurement_set/_utils/_msv2/descr.py +0 -165
- xradio/measurement_set/_utils/_msv2/msv2_msv3.py +0 -7
- xradio/measurement_set/_utils/_msv2/partitions.py +0 -392
- xradio/measurement_set/_utils/_utils/cds.py +0 -40
- xradio/measurement_set/_utils/_utils/xds_helper.py +0 -404
- xradio/measurement_set/_utils/_zarr/read.py +0 -263
- xradio/measurement_set/_utils/_zarr/write.py +0 -329
- xradio/measurement_set/_utils/msv2.py +0 -106
- xradio/measurement_set/_utils/zarr.py +0 -133
- xradio-0.0.56.dist-info/RECORD +0 -78
- {xradio-0.0.56.dist-info → xradio-0.0.59.dist-info}/licenses/LICENSE.txt +0 -0
- {xradio-0.0.56.dist-info → xradio-0.0.59.dist-info}/top_level.txt +0 -0
|
@@ -4,11 +4,6 @@ def add_encoding(xds, compressor, chunks=None):
|
|
|
4
4
|
|
|
5
5
|
chunks = {**dict(xds.sizes), **chunks} # Add missing sizes if presents.
|
|
6
6
|
|
|
7
|
-
encoding = {}
|
|
8
7
|
for da_name in list(xds.data_vars):
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
xds[da_name].encoding = {"compressor": compressor, "chunks": da_chunks}
|
|
12
|
-
# print(xds[da_name].encoding)
|
|
13
|
-
else:
|
|
14
|
-
xds[da_name].encoding = {"compressor": compressor}
|
|
8
|
+
da_chunks = [chunks[dim_name] for dim_name in xds[da_name].sizes]
|
|
9
|
+
xds[da_name].encoding = {"compressor": compressor, "chunks": da_chunks}
|
|
@@ -168,7 +168,7 @@ class ProcessingSetIterator:
|
|
|
168
168
|
def __next__(self):
|
|
169
169
|
try:
|
|
170
170
|
sub_xds_name = next(self.xds_name_iter)
|
|
171
|
-
except Exception
|
|
171
|
+
except Exception:
|
|
172
172
|
raise StopIteration
|
|
173
173
|
|
|
174
174
|
if self.input_data is None:
|
|
@@ -181,7 +181,7 @@ class ProcessingSetIterator:
|
|
|
181
181
|
drop_variables=self.drop_variables,
|
|
182
182
|
load_sub_datasets=self.load_sub_datasets,
|
|
183
183
|
)
|
|
184
|
-
sub_xdt = ps_xdt
|
|
184
|
+
sub_xdt = ps_xdt[sub_xds_name] # Access by name instead of index
|
|
185
185
|
else:
|
|
186
186
|
sub_xdt = self.input_data[sub_xds_name] # In memory
|
|
187
187
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import pandas as pd
|
|
2
|
-
from xradio._utils.list_and_array import to_list
|
|
3
|
-
import xarray as xr
|
|
4
|
-
import numpy as np
|
|
5
|
-
import numbers
|
|
6
|
-
import os
|
|
7
1
|
from collections.abc import Mapping, Iterable
|
|
2
|
+
import datetime
|
|
8
3
|
from typing import Any, Union
|
|
9
4
|
|
|
5
|
+
import numpy as np
|
|
6
|
+
import xarray as xr
|
|
7
|
+
|
|
8
|
+
from xradio._utils.list_and_array import to_list
|
|
9
|
+
|
|
10
10
|
MS_DATASET_TYPES = {"visibility", "spectrum", "radiometer"}
|
|
11
11
|
|
|
12
12
|
|
|
@@ -102,7 +102,7 @@ class MeasurementSetXdt:
|
|
|
102
102
|
data_variables_to_drop = []
|
|
103
103
|
field_and_source_to_drop = []
|
|
104
104
|
for dg_name, dg in self._xdt.attrs["data_groups"].items():
|
|
105
|
-
print(f"Data group: {dg_name}", dg)
|
|
105
|
+
# print(f"Data group: {dg_name}", dg)
|
|
106
106
|
f_and_s = dg["field_and_source"]
|
|
107
107
|
dg_copy = dg.copy()
|
|
108
108
|
dg_copy.pop("date", None)
|
|
@@ -118,8 +118,8 @@ class MeasurementSetXdt:
|
|
|
118
118
|
|
|
119
119
|
sel_ms_xdt = self._xdt
|
|
120
120
|
|
|
121
|
-
print("Data variables to drop: ", data_variables_to_drop)
|
|
122
|
-
print("Field and source to drop: ", field_and_source_to_drop)
|
|
121
|
+
# print("Data variables to drop: ", data_variables_to_drop)
|
|
122
|
+
# print("Field and source to drop: ", field_and_source_to_drop)
|
|
123
123
|
|
|
124
124
|
sel_corr_xds = self._xdt.ds.sel(
|
|
125
125
|
indexers, method, tolerance, drop, **indexers_kwargs
|
|
@@ -152,7 +152,7 @@ class MeasurementSetXdt:
|
|
|
152
152
|
raise InvalidAccessorLocation(f"{self._xdt.path} is not a MSv4 node.")
|
|
153
153
|
|
|
154
154
|
if data_group_name is None:
|
|
155
|
-
if "base" in self._xdt.attrs["data_groups"]
|
|
155
|
+
if "base" in self._xdt.attrs["data_groups"]:
|
|
156
156
|
data_group_name = "base"
|
|
157
157
|
else:
|
|
158
158
|
data_group_name = list(self._xdt.attrs["data_groups"].keys())[0]
|
|
@@ -189,7 +189,7 @@ class MeasurementSetXdt:
|
|
|
189
189
|
)
|
|
190
190
|
|
|
191
191
|
if data_group_name is None:
|
|
192
|
-
if "base" in self._xdt.attrs["data_groups"]
|
|
192
|
+
if "base" in self._xdt.attrs["data_groups"]:
|
|
193
193
|
data_group_name = "base"
|
|
194
194
|
else:
|
|
195
195
|
data_group_name = list(self._xdt.attrs["data_groups"].keys())[0]
|
|
@@ -205,6 +205,9 @@ class MeasurementSetXdt:
|
|
|
205
205
|
|
|
206
206
|
partition_info = {
|
|
207
207
|
"spectral_window_name": self._xdt.frequency.attrs["spectral_window_name"],
|
|
208
|
+
"spectral_window_intent": self._xdt.frequency.attrs[
|
|
209
|
+
"spectral_window_intent"
|
|
210
|
+
],
|
|
208
211
|
"field_name": to_list(np.unique(field_and_source_xds.field_name.values)),
|
|
209
212
|
"polarization_setup": to_list(self._xdt.polarization.values),
|
|
210
213
|
"scan_name": to_list(np.unique(self._xdt.scan_name.values)),
|
|
@@ -228,7 +231,8 @@ class MeasurementSetXdt:
|
|
|
228
231
|
description: str = None,
|
|
229
232
|
data_group_dv_shared_with: str = None,
|
|
230
233
|
) -> xr.DataTree:
|
|
231
|
-
"""
|
|
234
|
+
"""Adds a data group to the MSv4 DataTree, grouping the given data, weight, flag, etc. variables
|
|
235
|
+
and field_and_source_xds.
|
|
232
236
|
|
|
233
237
|
Parameters
|
|
234
238
|
----------
|
|
@@ -254,7 +258,7 @@ class MeasurementSetXdt:
|
|
|
254
258
|
Returns
|
|
255
259
|
-------
|
|
256
260
|
xr.DataTree
|
|
257
|
-
|
|
261
|
+
MSv4 DataTree with the new group added
|
|
258
262
|
"""
|
|
259
263
|
|
|
260
264
|
if data_group_dv_shared_with is None:
|
|
@@ -293,14 +297,14 @@ class MeasurementSetXdt:
|
|
|
293
297
|
), f"Data variable {uvw} not found in dataset."
|
|
294
298
|
|
|
295
299
|
if field_and_source_xds is None:
|
|
296
|
-
field_and_source_xds = default_data_group["
|
|
300
|
+
field_and_source_xds = default_data_group["field_and_source"]
|
|
297
301
|
new_data_group["field_and_source"] = field_and_source_xds
|
|
298
302
|
assert (
|
|
299
303
|
field_and_source_xds in self._xdt.children
|
|
300
304
|
), f"Data variable {field_and_source_xds} not found in dataset."
|
|
301
305
|
|
|
302
306
|
if date_time is None:
|
|
303
|
-
date_time = datetime.now().isoformat()
|
|
307
|
+
date_time = datetime.datetime.now(datetime.timezone.utc).isoformat()
|
|
304
308
|
new_data_group["date"] = date_time
|
|
305
309
|
|
|
306
310
|
if description is None:
|
|
@@ -312,7 +316,7 @@ class MeasurementSetXdt:
|
|
|
312
316
|
return self._xdt
|
|
313
317
|
|
|
314
318
|
def _get_default_data_group_name(self):
|
|
315
|
-
if "base" in self._xdt.attrs["data_groups"]
|
|
319
|
+
if "base" in self._xdt.attrs["data_groups"]:
|
|
316
320
|
data_group_name = "base"
|
|
317
321
|
else:
|
|
318
322
|
data_group_name = list(self._xdt.attrs["data_groups"].keys())[0]
|