xradio 0.0.41__py3-none-any.whl → 0.0.43__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/_utils/coord_math.py +100 -0
- xradio/_utils/list_and_array.py +49 -4
- xradio/_utils/schema.py +36 -16
- xradio/image/_util/_casacore/xds_from_casacore.py +5 -5
- xradio/image/_util/_casacore/xds_to_casacore.py +12 -11
- xradio/image/_util/_fits/xds_from_fits.py +18 -17
- xradio/image/_util/_zarr/zarr_low_level.py +29 -12
- xradio/image/_util/common.py +1 -1
- xradio/image/_util/image_factory.py +1 -1
- xradio/{correlated_data → measurement_set}/__init__.py +7 -4
- xradio/measurement_set/_utils/__init__.py +5 -0
- xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/_tables/load_main_table.py +1 -1
- xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/_tables/read.py +1 -1
- xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/conversion.py +115 -37
- xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/create_antenna_xds.py +62 -37
- xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/create_field_and_source_xds.py +117 -25
- xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/msv4_sub_xdss.py +47 -13
- xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/partition_queries.py +4 -0
- xradio/{correlated_data → measurement_set}/_utils/_utils/xds_helper.py +1 -1
- xradio/{correlated_data/_utils/ms.py → measurement_set/_utils/msv2.py} +4 -4
- xradio/{correlated_data → measurement_set}/convert_msv2_to_processing_set.py +7 -2
- xradio/{correlated_data → measurement_set}/load_processing_set.py +5 -5
- xradio/measurement_set/measurement_set_xds.py +110 -0
- xradio/{correlated_data → measurement_set}/open_processing_set.py +9 -16
- xradio/measurement_set/processing_set.py +777 -0
- xradio/{correlated_data → measurement_set}/schema.py +1110 -586
- xradio/schema/check.py +42 -22
- xradio/schema/dataclass.py +56 -6
- xradio/sphinx/__init__.py +12 -0
- xradio/sphinx/schema_table.py +351 -0
- {xradio-0.0.41.dist-info → xradio-0.0.43.dist-info}/METADATA +9 -6
- xradio-0.0.43.dist-info/RECORD +76 -0
- {xradio-0.0.41.dist-info → xradio-0.0.43.dist-info}/WHEEL +1 -1
- xradio/_utils/common.py +0 -101
- xradio/correlated_data/_utils/__init__.py +0 -5
- xradio/correlated_data/correlated_xds.py +0 -13
- xradio/correlated_data/processing_set.py +0 -301
- xradio/correlated_data/test__processing_set.py +0 -74
- xradio-0.0.41.dist-info/RECORD +0 -75
- /xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/_tables/load.py +0 -0
- /xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/_tables/read_main_table.py +0 -0
- /xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/_tables/read_subtables.py +0 -0
- /xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/_tables/table_query.py +0 -0
- /xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/_tables/write.py +0 -0
- /xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/_tables/write_exp_api.py +0 -0
- /xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/chunks.py +0 -0
- /xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/descr.py +0 -0
- /xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/msv2_msv3.py +0 -0
- /xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/msv2_to_msv4_meta.py +0 -0
- /xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/msv4_info_dicts.py +0 -0
- /xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/optimised_functions.py +0 -0
- /xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/partitions.py +0 -0
- /xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/subtables.py +0 -0
- /xradio/{correlated_data → measurement_set}/_utils/_utils/cds.py +0 -0
- /xradio/{correlated_data → measurement_set}/_utils/_utils/partition_attrs.py +0 -0
- /xradio/{correlated_data → measurement_set}/_utils/_utils/stokes_types.py +0 -0
- /xradio/{correlated_data → measurement_set}/_utils/_zarr/encoding.py +0 -0
- /xradio/{correlated_data → measurement_set}/_utils/_zarr/read.py +0 -0
- /xradio/{correlated_data → measurement_set}/_utils/_zarr/write.py +0 -0
- /xradio/{correlated_data → measurement_set}/_utils/zarr.py +0 -0
- {xradio-0.0.41.dist-info → xradio-0.0.43.dist-info}/LICENSE.txt +0 -0
- {xradio-0.0.41.dist-info → xradio-0.0.43.dist-info}/top_level.txt +0 -0
xradio/_utils/common.py
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import numpy as np
|
|
2
|
-
|
|
3
|
-
_deg_to_rad = np.pi / 180
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def cast_to_str(x):
|
|
7
|
-
if isinstance(x, list):
|
|
8
|
-
return x[0]
|
|
9
|
-
else:
|
|
10
|
-
return x
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def get_pad_value(col_dtype: np.dtype) -> object:
|
|
14
|
-
"""
|
|
15
|
-
Produce a padding/missing/nan value appropriate for a casacore data column
|
|
16
|
-
(for when we need to pad data vars coming from columns with rows of
|
|
17
|
-
variable size array values)
|
|
18
|
-
|
|
19
|
-
Parameters
|
|
20
|
-
----------
|
|
21
|
-
col_dtype : dtype
|
|
22
|
-
dtype of data being loaded from a table column
|
|
23
|
-
|
|
24
|
-
Returns
|
|
25
|
-
-------
|
|
26
|
-
object
|
|
27
|
-
pad value ("missing" / "fill") for the type given
|
|
28
|
-
"""
|
|
29
|
-
# Fill values for missing/NaN data in integer variables, based on usual
|
|
30
|
-
# numpy fill values. See https://github.com/numpy/numpy/issues/21166,
|
|
31
|
-
# https://github.com/casangi/xradio/issues/219, https://github.com/casangi/xradio/pull/177
|
|
32
|
-
fill_value_int32 = np.int32(-2147483648)
|
|
33
|
-
fill_value_int64 = np.int64(-9223372036854775808)
|
|
34
|
-
|
|
35
|
-
if col_dtype == np.int32:
|
|
36
|
-
return fill_value_int32
|
|
37
|
-
elif col_dtype == np.int64 or col_dtype == "int":
|
|
38
|
-
return fill_value_int64
|
|
39
|
-
elif np.issubdtype(col_dtype, np.floating):
|
|
40
|
-
return np.nan
|
|
41
|
-
elif np.issubdtype(col_dtype, np.complexfloating):
|
|
42
|
-
return complex(np.nan, np.nan)
|
|
43
|
-
elif np.issubdtype(col_dtype, np.bool_):
|
|
44
|
-
return False
|
|
45
|
-
elif np.issubdtype(col_dtype, str):
|
|
46
|
-
return ""
|
|
47
|
-
else:
|
|
48
|
-
raise RuntimeError(
|
|
49
|
-
"Padding / missing value not defined for the type requested: "
|
|
50
|
-
f"{col_dtype} (of type: {type(col_dtype)})"
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def convert_to_si_units(xds):
|
|
55
|
-
for data_var in xds.data_vars:
|
|
56
|
-
if "units" in xds[data_var].attrs:
|
|
57
|
-
for u_i, u in enumerate(xds[data_var].attrs["units"]):
|
|
58
|
-
if u == "km":
|
|
59
|
-
xds[data_var][..., u_i] = xds[data_var][..., u_i] * 1e3
|
|
60
|
-
xds[data_var].attrs["units"][u_i] = "m"
|
|
61
|
-
if u == "km/s":
|
|
62
|
-
xds[data_var][..., u_i] = xds[data_var][..., u_i] * 1e3
|
|
63
|
-
xds[data_var].attrs["units"][u_i] = "m/s"
|
|
64
|
-
if u == "deg":
|
|
65
|
-
xds[data_var][..., u_i] = xds[data_var][..., u_i] * np.pi / 180
|
|
66
|
-
xds[data_var].attrs["units"][u_i] = "rad"
|
|
67
|
-
if u == "Au" or u == "AU":
|
|
68
|
-
xds[data_var][..., u_i] = xds[data_var][..., u_i] * 149597870700
|
|
69
|
-
xds[data_var].attrs["units"][u_i] = "m"
|
|
70
|
-
if u == "Au/d" or u == "AU/d":
|
|
71
|
-
xds[data_var][..., u_i] = (
|
|
72
|
-
xds[data_var][..., u_i] * 149597870700 / 86400
|
|
73
|
-
)
|
|
74
|
-
xds[data_var].attrs["units"][u_i] = "m/s"
|
|
75
|
-
if u == "arcsec":
|
|
76
|
-
xds[data_var][..., u_i] = xds[data_var][..., u_i] * np.pi / 648000
|
|
77
|
-
xds[data_var].attrs["units"][u_i] = "rad"
|
|
78
|
-
return xds
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
def add_position_offsets(dv_1, dv_2):
|
|
82
|
-
# Fun with angles: We are adding angles together. We need to make sure that the results are between -pi and pi.
|
|
83
|
-
new_pos = dv_1 + dv_2
|
|
84
|
-
|
|
85
|
-
while np.any(new_pos[:, 0] > np.pi) or np.any(new_pos[:, 0] < -np.pi):
|
|
86
|
-
new_pos[:, 0] = np.where(
|
|
87
|
-
new_pos[:, 0] > np.pi, new_pos[:, 0] - 2 * np.pi, new_pos[:, 0]
|
|
88
|
-
)
|
|
89
|
-
new_pos[:, 0] = np.where(
|
|
90
|
-
new_pos[:, 0] < -np.pi, new_pos[:, 0] + 2 * np.pi, new_pos[:, 0]
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
while np.any(new_pos[:, 1] > np.pi / 2) or np.any(new_pos[:, 1] < -np.pi / 2):
|
|
94
|
-
new_pos[:, 1] = np.where(
|
|
95
|
-
new_pos[:, 1] > np.pi / 2, new_pos[:, 1] - np.pi, new_pos[:, 1]
|
|
96
|
-
)
|
|
97
|
-
new_pos[:, 1] = np.where(
|
|
98
|
-
new_pos[:, 1] < -np.pi / 2, new_pos[:, 1] + np.pi, new_pos[:, 1]
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
return new_pos
|
|
@@ -1,13 +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
|
-
|
|
6
|
-
|
|
7
|
-
class CorrelatedXds(xr.Dataset):
|
|
8
|
-
|
|
9
|
-
def __init__(self, *args, **kwargs):
|
|
10
|
-
super().__init__(*args, **kwargs)
|
|
11
|
-
|
|
12
|
-
def to_zarr():
|
|
13
|
-
pass
|
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
import pandas as pd
|
|
2
|
-
from xradio._utils.list_and_array import to_list
|
|
3
|
-
import numbers
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class ProcessingSet(dict):
|
|
7
|
-
"""
|
|
8
|
-
A dictionary subclass representing a Processing Set (PS) that is a set of Measurement Sets v4 (MS).
|
|
9
|
-
|
|
10
|
-
This class extends the built-in `dict` class and provides additional methods for manipulating and selecting subsets of the Processing Set.
|
|
11
|
-
|
|
12
|
-
Attributes:
|
|
13
|
-
meta (dict): A dictionary containing metadata information about the Processing Set.
|
|
14
|
-
|
|
15
|
-
Methods:
|
|
16
|
-
summary(data_group="base"): Returns a summary of the Processing Set as a Pandas table.
|
|
17
|
-
get_ps_max_dims(): Returns the maximum dimension of all the MSs in the Processing Set.
|
|
18
|
-
get_ps_freq_axis(): Combines the frequency axis of all MSs.
|
|
19
|
-
sel(query:str=None, **kwargs): Selects a subset of the Processing Set based on column names and values or a Pandas query.
|
|
20
|
-
ms_sel(**kwargs): Selects a subset of the Processing Set by applying the `sel` method to each individual MS.
|
|
21
|
-
ms_isel(**kwargs): Selects a subset of the Processing Set by applying the `isel` method to each individual MS.
|
|
22
|
-
"""
|
|
23
|
-
|
|
24
|
-
def __init__(self, *args, **kwargs):
|
|
25
|
-
super().__init__(*args, **kwargs)
|
|
26
|
-
self.meta = {"summary": {}}
|
|
27
|
-
|
|
28
|
-
def summary(self, data_group="base"):
|
|
29
|
-
"""
|
|
30
|
-
Returns a summary of the Processing Set as a Pandas table.
|
|
31
|
-
|
|
32
|
-
Args:
|
|
33
|
-
data_group (str): The data group to summarize. Default is "base".
|
|
34
|
-
|
|
35
|
-
Returns:
|
|
36
|
-
pandas.DataFrame: A DataFrame containing the summary information.
|
|
37
|
-
"""
|
|
38
|
-
if data_group in self.meta["summary"]:
|
|
39
|
-
return self.meta["summary"][data_group]
|
|
40
|
-
else:
|
|
41
|
-
self.meta["summary"][data_group] = self._summary(data_group).sort_values(
|
|
42
|
-
by=["name"], ascending=True
|
|
43
|
-
)
|
|
44
|
-
return self.meta["summary"][data_group]
|
|
45
|
-
|
|
46
|
-
def get_ps_max_dims(self):
|
|
47
|
-
"""
|
|
48
|
-
Returns the maximum dimension of all the MSs in the Processing Set.
|
|
49
|
-
|
|
50
|
-
For example, if the Processing Set contains two MSs with dimensions (50, 20, 30) and (10, 30, 40), the maximum dimensions will be (50, 30, 40).
|
|
51
|
-
|
|
52
|
-
Returns:
|
|
53
|
-
dict: A dictionary containing the maximum dimensions of the Processing Set.
|
|
54
|
-
"""
|
|
55
|
-
if "max_dims" in self.meta:
|
|
56
|
-
return self.meta["max_dims"]
|
|
57
|
-
else:
|
|
58
|
-
self.meta["max_dims"] = self._get_ps_max_dims()
|
|
59
|
-
return self.meta["max_dims"]
|
|
60
|
-
|
|
61
|
-
def get_ps_freq_axis(self):
|
|
62
|
-
"""
|
|
63
|
-
Combines the frequency axis of all MSs.
|
|
64
|
-
|
|
65
|
-
Returns:
|
|
66
|
-
xarray.DataArray: The frequency axis of the Processing Set.
|
|
67
|
-
"""
|
|
68
|
-
if "freq_axis" in self.meta:
|
|
69
|
-
return self.meta["freq_axis"]
|
|
70
|
-
else:
|
|
71
|
-
self.meta["freq_axis"] = self._get_ps_freq_axis()
|
|
72
|
-
return self.meta["freq_axis"]
|
|
73
|
-
|
|
74
|
-
def _summary(self, data_group="base"):
|
|
75
|
-
summary_data = {
|
|
76
|
-
"name": [],
|
|
77
|
-
"intents": [],
|
|
78
|
-
"shape": [],
|
|
79
|
-
"polarization": [],
|
|
80
|
-
"scan_number": [],
|
|
81
|
-
"spw_name": [],
|
|
82
|
-
# "field_id": [],
|
|
83
|
-
"field_name": [],
|
|
84
|
-
# "source_id": [],
|
|
85
|
-
"source_name": [],
|
|
86
|
-
# "num_lines": [],
|
|
87
|
-
"line_name": [],
|
|
88
|
-
"field_coords": [],
|
|
89
|
-
"start_frequency": [],
|
|
90
|
-
"end_frequency": [],
|
|
91
|
-
}
|
|
92
|
-
from astropy.coordinates import SkyCoord
|
|
93
|
-
import astropy.units as u
|
|
94
|
-
|
|
95
|
-
for key, value in self.items():
|
|
96
|
-
summary_data["name"].append(key)
|
|
97
|
-
summary_data["intents"].append(value.attrs["partition_info"]["intents"])
|
|
98
|
-
summary_data["spw_name"].append(
|
|
99
|
-
value.attrs["partition_info"]["spectral_window_name"]
|
|
100
|
-
)
|
|
101
|
-
summary_data["polarization"].append(value.polarization.values)
|
|
102
|
-
summary_data["scan_number"].append(
|
|
103
|
-
value.attrs["partition_info"]["scan_number"]
|
|
104
|
-
)
|
|
105
|
-
data_name = value.attrs["data_groups"][data_group]["correlated_data"]
|
|
106
|
-
|
|
107
|
-
if "VISIBILITY" in data_name:
|
|
108
|
-
center_name = "FIELD_PHASE_CENTER"
|
|
109
|
-
|
|
110
|
-
if "SPECTRUM" in data_name:
|
|
111
|
-
center_name = "FIELD_REFERENCE_CENTER"
|
|
112
|
-
|
|
113
|
-
summary_data["shape"].append(value[data_name].shape)
|
|
114
|
-
|
|
115
|
-
# summary_data["field_id"].append(value.attrs["partition_info"]["field_id"])
|
|
116
|
-
# summary_data["source_id"].append(value.attrs["partition_info"]["source_id"])
|
|
117
|
-
|
|
118
|
-
summary_data["field_name"].append(
|
|
119
|
-
value.attrs["partition_info"]["field_name"]
|
|
120
|
-
)
|
|
121
|
-
summary_data["source_name"].append(
|
|
122
|
-
value.attrs["partition_info"]["source_name"]
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
summary_data["line_name"].append(value.attrs["partition_info"]["line_name"])
|
|
126
|
-
|
|
127
|
-
# summary_data["num_lines"].append(value.attrs["partition_info"]["num_lines"])
|
|
128
|
-
summary_data["start_frequency"].append(
|
|
129
|
-
to_list(value["frequency"].values)[0]
|
|
130
|
-
)
|
|
131
|
-
summary_data["end_frequency"].append(to_list(value["frequency"].values)[-1])
|
|
132
|
-
|
|
133
|
-
if value[data_name].attrs["field_and_source_xds"].is_ephemeris:
|
|
134
|
-
summary_data["field_coords"].append("Ephemeris")
|
|
135
|
-
elif (
|
|
136
|
-
"time"
|
|
137
|
-
in value[data_name].attrs["field_and_source_xds"][center_name].coords
|
|
138
|
-
):
|
|
139
|
-
summary_data["field_coords"].append("Multi-Phase-Center")
|
|
140
|
-
else:
|
|
141
|
-
ra_dec_rad = (
|
|
142
|
-
value[data_name].attrs["field_and_source_xds"][center_name].values
|
|
143
|
-
)
|
|
144
|
-
frame = (
|
|
145
|
-
value[data_name]
|
|
146
|
-
.attrs["field_and_source_xds"][center_name]
|
|
147
|
-
.attrs["frame"]
|
|
148
|
-
.lower()
|
|
149
|
-
)
|
|
150
|
-
|
|
151
|
-
coord = SkyCoord(
|
|
152
|
-
ra=ra_dec_rad[0] * u.rad, dec=ra_dec_rad[1] * u.rad, frame=frame
|
|
153
|
-
)
|
|
154
|
-
|
|
155
|
-
summary_data["field_coords"].append(
|
|
156
|
-
[
|
|
157
|
-
frame,
|
|
158
|
-
coord.ra.to_string(unit=u.hour, precision=2),
|
|
159
|
-
coord.dec.to_string(unit=u.deg, precision=2),
|
|
160
|
-
]
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
summary_df = pd.DataFrame(summary_data)
|
|
164
|
-
return summary_df
|
|
165
|
-
|
|
166
|
-
def _get_ps_freq_axis(self):
|
|
167
|
-
import xarray as xr
|
|
168
|
-
|
|
169
|
-
spw_ids = []
|
|
170
|
-
freq_axis_list = []
|
|
171
|
-
frame = self.get(0).frequency.attrs["frame"]
|
|
172
|
-
for ms_xds in self.values():
|
|
173
|
-
assert (
|
|
174
|
-
frame == ms_xds.frequency.attrs["frame"]
|
|
175
|
-
), "Frequency reference frame not consistent in Processing Set."
|
|
176
|
-
if ms_xds.frequency.attrs["spectral_window_id"] not in spw_ids:
|
|
177
|
-
spw_ids.append(ms_xds.frequency.attrs["spectral_window_id"])
|
|
178
|
-
freq_axis_list.append(ms_xds.frequency)
|
|
179
|
-
|
|
180
|
-
freq_axis = xr.concat(freq_axis_list, dim="frequency").sortby("frequency")
|
|
181
|
-
return freq_axis
|
|
182
|
-
|
|
183
|
-
def _get_ps_max_dims(self):
|
|
184
|
-
max_dims = None
|
|
185
|
-
for ms_xds in self.values():
|
|
186
|
-
if max_dims is None:
|
|
187
|
-
max_dims = dict(ms_xds.sizes)
|
|
188
|
-
else:
|
|
189
|
-
for dim_name, size in ms_xds.sizes.items():
|
|
190
|
-
if dim_name in max_dims:
|
|
191
|
-
if max_dims[dim_name] < size:
|
|
192
|
-
max_dims[dim_name] = size
|
|
193
|
-
else:
|
|
194
|
-
max_dims[dim_name] = size
|
|
195
|
-
return max_dims
|
|
196
|
-
|
|
197
|
-
def get(self, id):
|
|
198
|
-
return self[list(self.keys())[id]]
|
|
199
|
-
|
|
200
|
-
def sel(self, string_exact_match: bool = True, query: str = None, **kwargs):
|
|
201
|
-
"""
|
|
202
|
-
Selects a subset of the Processing Set based on column names and values or a Pandas query.
|
|
203
|
-
|
|
204
|
-
The following columns are supported: name, intents, polarization, spw_name, field_name, source_name, field_coords, start_frequency, end_frequency.
|
|
205
|
-
|
|
206
|
-
This function will not apply any selection on the MS data so data will not be dropped for example if a MS has field_name=['field_0','field_10','field_08'] and ps.sel(field_name='field_0') is done the resulting MS will still have field_name=['field_0','field_10','field_08'].
|
|
207
|
-
|
|
208
|
-
Examples:
|
|
209
|
-
ps.sel(intents='OBSERVE_TARGET#ON_SOURCE', polarization=['RR', 'LL']) # Select all MSs with intents 'OBSERVE_TARGET#ON_SOURCE' and polarization 'RR' or 'LL'.
|
|
210
|
-
ps.sel(query='start_frequency > 100e9 AND end_frequency < 200e9') # Select all MSs with start_frequency greater than 100 GHz and less than 200 GHz.
|
|
211
|
-
|
|
212
|
-
Args:
|
|
213
|
-
query (str): A Pandas query string. Default is None.
|
|
214
|
-
string_exact_match (bool): If True, the selection will be an exact match for string and string list columns. Default is True.
|
|
215
|
-
**kwargs: Keyword arguments representing column names and values to filter the Processing Set.
|
|
216
|
-
|
|
217
|
-
Returns:
|
|
218
|
-
processing_set: The subset of the Processing Set.
|
|
219
|
-
"""
|
|
220
|
-
import numpy as np
|
|
221
|
-
|
|
222
|
-
# def select_rows(df, col, input_strings):
|
|
223
|
-
# return df[df[col].apply(lambda x: any(i in x for i in input_strings))]
|
|
224
|
-
|
|
225
|
-
# def select_rows(df, col, sel, string_exact_match):
|
|
226
|
-
# def check_selection(row_val):
|
|
227
|
-
# if isinstance(row_val, numbers.Number) or string_exact_match:
|
|
228
|
-
# return any(i == row_val for i in sel) #If values are numbers
|
|
229
|
-
# return any(i in row_val for i in sel) #If values are strings
|
|
230
|
-
# return df[df[col].apply(check_selection)]
|
|
231
|
-
|
|
232
|
-
def select_rows(df, col, sel_vals, string_exact_match):
|
|
233
|
-
def check_selection(row_val):
|
|
234
|
-
row_val = to_list(
|
|
235
|
-
row_val
|
|
236
|
-
) # make sure that it is a list so that we can iterate over it.
|
|
237
|
-
|
|
238
|
-
for rw in row_val:
|
|
239
|
-
for s in sel_vals:
|
|
240
|
-
if string_exact_match:
|
|
241
|
-
if rw == s:
|
|
242
|
-
return True
|
|
243
|
-
else:
|
|
244
|
-
if s in rw:
|
|
245
|
-
return True
|
|
246
|
-
return False
|
|
247
|
-
|
|
248
|
-
return df[df[col].apply(check_selection)]
|
|
249
|
-
|
|
250
|
-
summary_table = self.summary()
|
|
251
|
-
for key, value in kwargs.items():
|
|
252
|
-
value = to_list(value) # make sure value is a list.
|
|
253
|
-
|
|
254
|
-
if len(value) == 1 and isinstance(value[0], slice):
|
|
255
|
-
summary_table = summary_table[
|
|
256
|
-
summary_table[key].between(value[0].start, value[0].stop)
|
|
257
|
-
]
|
|
258
|
-
else:
|
|
259
|
-
summary_table = select_rows(
|
|
260
|
-
summary_table, key, value, string_exact_match
|
|
261
|
-
)
|
|
262
|
-
|
|
263
|
-
if query is not None:
|
|
264
|
-
summary_table = summary_table.query(query)
|
|
265
|
-
|
|
266
|
-
sub_ps = ProcessingSet()
|
|
267
|
-
for key, val in self.items():
|
|
268
|
-
if key in summary_table["name"].values:
|
|
269
|
-
sub_ps[key] = val
|
|
270
|
-
|
|
271
|
-
return sub_ps
|
|
272
|
-
|
|
273
|
-
def ms_sel(self, **kwargs):
|
|
274
|
-
"""
|
|
275
|
-
Selects a subset of the Processing Set by applying the `sel` method to each MS.
|
|
276
|
-
|
|
277
|
-
Args:
|
|
278
|
-
**kwargs: Keyword arguments representing column names and values to filter the Processing Set.
|
|
279
|
-
|
|
280
|
-
Returns:
|
|
281
|
-
processing_set: The subset of the Processing Set.
|
|
282
|
-
"""
|
|
283
|
-
sub_ps = ProcessingSet()
|
|
284
|
-
for key, val in self.items():
|
|
285
|
-
sub_ps[key] = val.sel(kwargs)
|
|
286
|
-
return sub_ps
|
|
287
|
-
|
|
288
|
-
def ms_isel(self, **kwargs):
|
|
289
|
-
"""
|
|
290
|
-
Selects a subset of the Processing Set by applying the `isel` method to each MS.
|
|
291
|
-
|
|
292
|
-
Args:
|
|
293
|
-
**kwargs: Keyword arguments representing dimension names and indices to select from the Processing Set.
|
|
294
|
-
|
|
295
|
-
Returns:
|
|
296
|
-
processing_set: The subset of the Processing Set.
|
|
297
|
-
"""
|
|
298
|
-
sub_ps = ProcessingSet()
|
|
299
|
-
for key, val in self.items():
|
|
300
|
-
sub_ps[key] = val.isel(kwargs)
|
|
301
|
-
return sub_ps
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import unittest
|
|
2
|
-
from xradio.src.xradio.correlated_data.processing_set import processing_set
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class TestProcessingSet(unittest.TestCase):
|
|
6
|
-
|
|
7
|
-
def setUp(self):
|
|
8
|
-
# Create a sample processing set
|
|
9
|
-
self.ps = processing_set()
|
|
10
|
-
self.ps["ms1"] = {
|
|
11
|
-
"partition_info": {
|
|
12
|
-
"obs_mode": "OBSERVE_TARGET#ON_SOURCE",
|
|
13
|
-
"spectral_window_name": "spw1",
|
|
14
|
-
},
|
|
15
|
-
"polarization": ["RR", "LL"],
|
|
16
|
-
"visibility": "vis1",
|
|
17
|
-
"frequency": [1e9, 2e9],
|
|
18
|
-
}
|
|
19
|
-
self.ps["ms2"] = {
|
|
20
|
-
"partition_info": {
|
|
21
|
-
"obs_mode": "OBSERVE_TARGET#CALIBRATE_POLARIZATION",
|
|
22
|
-
"spectral_window_name": "spw2",
|
|
23
|
-
},
|
|
24
|
-
"polarization": ["RR"],
|
|
25
|
-
"spectrum": "spec1",
|
|
26
|
-
"frequency": [2e9, 3e9],
|
|
27
|
-
}
|
|
28
|
-
self.ps["ms3"] = {
|
|
29
|
-
"partition_info": {
|
|
30
|
-
"obs_mode": "OBSERVE_TARGET#ON_SOURCE",
|
|
31
|
-
"spectral_window_name": "spw1",
|
|
32
|
-
},
|
|
33
|
-
"polarization": ["LL"],
|
|
34
|
-
"visibility": "vis2",
|
|
35
|
-
"frequency": [3e9, 4e9],
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
def test_summary(self):
|
|
39
|
-
# Test the summary method
|
|
40
|
-
summary = self.ps.summary()
|
|
41
|
-
self.assertEqual(
|
|
42
|
-
len(summary), 3
|
|
43
|
-
) # Check the number of rows in the summary table
|
|
44
|
-
|
|
45
|
-
def test_get_ps_max_dims(self):
|
|
46
|
-
# Test the get_ps_max_dims method
|
|
47
|
-
max_dims = self.ps.get_ps_max_dims()
|
|
48
|
-
self.assertEqual(max_dims, {"frequency": 2, "polarization": 2})
|
|
49
|
-
|
|
50
|
-
def test_get_ps_freq_axis(self):
|
|
51
|
-
# Test the get_ps_freq_axis method
|
|
52
|
-
freq_axis = self.ps.get_ps_freq_axis()
|
|
53
|
-
self.assertEqual(len(freq_axis), 4) # Check the length of the frequency axis
|
|
54
|
-
|
|
55
|
-
def test_sel(self):
|
|
56
|
-
# Test the sel method
|
|
57
|
-
subset = self.ps.sel(
|
|
58
|
-
obs_mode="OBSERVE_TARGET#ON_SOURCE", polarization=["RR", "LL"]
|
|
59
|
-
)
|
|
60
|
-
self.assertEqual(len(subset), 2) # Check the number of MSs in the subset
|
|
61
|
-
|
|
62
|
-
def test_ms_sel(self):
|
|
63
|
-
# Test the ms_sel method
|
|
64
|
-
subset = self.ps.ms_sel(obs_mode="OBSERVE_TARGET#ON_SOURCE", polarization="RR")
|
|
65
|
-
self.assertEqual(len(subset), 1) # Check the number of MSs in the subset
|
|
66
|
-
|
|
67
|
-
def test_ms_isel(self):
|
|
68
|
-
# Test the ms_isel method
|
|
69
|
-
subset = self.ps.ms_isel(obs_mode="OBSERVE_TARGET#ON_SOURCE", polarization="LL")
|
|
70
|
-
self.assertEqual(len(subset), 1) # Check the number of MSs in the subset
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if __name__ == "__main__":
|
|
74
|
-
unittest.main()
|
xradio-0.0.41.dist-info/RECORD
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
xradio/__init__.py,sha256=WHBhQWQie3YQqfIxQBL3LKiKuUcN7ZL7sPMEcdWOp5E,382
|
|
2
|
-
xradio/_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
xradio/_utils/common.py,sha256=GY_fjet9wLhnx9XUINTq6ONBoceyLWRXHXlrNla3j3o,3726
|
|
4
|
-
xradio/_utils/list_and_array.py,sha256=_wznOiHra1pHrWNdtQPXhk-TAXJ8qb9fTGE0czQNpIo,2802
|
|
5
|
-
xradio/_utils/schema.py,sha256=tdGyvQTd-rQivtkzmH9-1f7KMIB9KeSf57EN2v7Mw_o,6855
|
|
6
|
-
xradio/_utils/_casacore/tables.py,sha256=aq6E_4RRAHdTBCwMKrVil1cWhFU2O980DNH9IlRKXLw,1280
|
|
7
|
-
xradio/_utils/zarr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
xradio/_utils/zarr/common.py,sha256=egj3Zma0BUK0msOBDozMa-62rHrcxrjCNE5XkkZUq70,5332
|
|
9
|
-
xradio/correlated_data/__init__.py,sha256=2oVnsJL4afv17FYpuHLH_bxspcJNWCWiT3wYCOn5jLk,423
|
|
10
|
-
xradio/correlated_data/convert_msv2_to_processing_set.py,sha256=Hae-NOHSyxydlMEssiH3DpkYSJorDHTslsp3Dl8Dq08,6422
|
|
11
|
-
xradio/correlated_data/correlated_xds.py,sha256=Q_qlQyAYC-9jhxvvR3wgGjPLy2tBctu2bvaD212BtVY,256
|
|
12
|
-
xradio/correlated_data/load_processing_set.py,sha256=Sn8WQ6kdpnzngsGaW9o2fd6xOqOn2wM7yIKj45SXobQ,5526
|
|
13
|
-
xradio/correlated_data/open_processing_set.py,sha256=BcW03m7ZoKcrdZsugczK6sbyu1YmPgoh2WZY5FYsrz8,4002
|
|
14
|
-
xradio/correlated_data/processing_set.py,sha256=DXh34lr_-15kwy_ZkL3Ee25ptqcEwpQ9gbfJwU14zPI,11951
|
|
15
|
-
xradio/correlated_data/schema.py,sha256=pJuWi0qwQoiJkGnb541f3Iq-YjiB6EsjDbbfW8Tc85c,59247
|
|
16
|
-
xradio/correlated_data/test__processing_set.py,sha256=zWyUfCGr_FwxUqYZInNi3bYAH-ctmE_xB9ORSRaT4fs,2527
|
|
17
|
-
xradio/correlated_data/_utils/__init__.py,sha256=Scu6rKJ2SpO8aG7F-xdTZcYfyWx0viV8gFh8E8ur_gI,93
|
|
18
|
-
xradio/correlated_data/_utils/ms.py,sha256=m7cYGZGbdCD3uSPe1BldgRurZ4Y-K3vJr6aePUVyGjE,4310
|
|
19
|
-
xradio/correlated_data/_utils/zarr.py,sha256=ehXlu0Xh_UZ5Xm2RnHCxESsRZ26c3DQAO5rqMK5MwTk,3947
|
|
20
|
-
xradio/correlated_data/_utils/_ms/chunks.py,sha256=JTPk3il6fk570BjWZMoOAtsbvnLmqPcBv9EPY6A2yOs,2964
|
|
21
|
-
xradio/correlated_data/_utils/_ms/conversion.py,sha256=Gz5_7vu0rUMrLxZJEMyCaCJ9UC9dKvVOemabVM67JCw,40940
|
|
22
|
-
xradio/correlated_data/_utils/_ms/create_antenna_xds.py,sha256=w5yjNV4Ow1mL0zev9avLn7jfRfcBP-wmkpS0rGBGE4Y,17686
|
|
23
|
-
xradio/correlated_data/_utils/_ms/create_field_and_source_xds.py,sha256=IPYbLx4580UGd2ibe2KtTThCCY4Ckz86reIL6s_8u4I,30881
|
|
24
|
-
xradio/correlated_data/_utils/_ms/descr.py,sha256=dYK8mhXxODIh-dfqaOm-YZb7kmoN1N2golX_RFncO94,5215
|
|
25
|
-
xradio/correlated_data/_utils/_ms/msv2_msv3.py,sha256=9AKs2HWly7Ivv_Cjr11dIPGmm33_rtSBoGF9wN5ZwEQ,116
|
|
26
|
-
xradio/correlated_data/_utils/_ms/msv2_to_msv4_meta.py,sha256=gk9gU7g2Lk7dmaiLW8qecOEt574pRtGsCHnUnHXM3D0,1614
|
|
27
|
-
xradio/correlated_data/_utils/_ms/msv4_info_dicts.py,sha256=kQpKNvgIki_ZIpC-lbKRqCKah7aLBoy5Q_NH1Q2vz3g,6895
|
|
28
|
-
xradio/correlated_data/_utils/_ms/msv4_sub_xdss.py,sha256=qZUq6edNe5F9rLPrIEMXAPYehkk60WnVIq42MTqVho0,18440
|
|
29
|
-
xradio/correlated_data/_utils/_ms/optimised_functions.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
30
|
-
xradio/correlated_data/_utils/_ms/partition_queries.py,sha256=hEe3VAzGqtEPg3X4GUhvHaxyesjS6WVy5et421qSdZg,14573
|
|
31
|
-
xradio/correlated_data/_utils/_ms/partitions.py,sha256=_KhRq8bSx2QxuWp9K57fLoLxcU6kvJ35e6wvJ-THbwc,12979
|
|
32
|
-
xradio/correlated_data/_utils/_ms/subtables.py,sha256=_mpOOtHexqhiqEKt7S4LVqImJoNMJKSY18vNVw83r_U,3945
|
|
33
|
-
xradio/correlated_data/_utils/_ms/_tables/load.py,sha256=IR3fdKlq8rgH4bHmB1JTtB5gSGuITIvErJEVjUA8rWM,1799
|
|
34
|
-
xradio/correlated_data/_utils/_ms/_tables/load_main_table.py,sha256=npy30aRt_qtd8vfgGWYQgHRj1YON-ZYjfQi7zzLtToM,14806
|
|
35
|
-
xradio/correlated_data/_utils/_ms/_tables/read.py,sha256=JLhn_8W2spLJy_3MjZ1mdMPKe7GPTq3VwuLeY-DiCjk,42937
|
|
36
|
-
xradio/correlated_data/_utils/_ms/_tables/read_main_table.py,sha256=8AbNt-AxrhPK3EPRa7xqJXffxzIgfVsv1BDfoVJEXLU,26056
|
|
37
|
-
xradio/correlated_data/_utils/_ms/_tables/read_subtables.py,sha256=JM6pGUQtjQR881u9VqakmbJjppEFq-EVKnEZ14JqnAw,12438
|
|
38
|
-
xradio/correlated_data/_utils/_ms/_tables/table_query.py,sha256=q8EGFf_zIwHcHnvFJOn8hPh8zFZQ3f7BGbXvL3bHad4,555
|
|
39
|
-
xradio/correlated_data/_utils/_ms/_tables/write.py,sha256=43XQ-tHhbhex0eUTRknNpPEEOnNR-w1lGCox9WZ9NHE,9540
|
|
40
|
-
xradio/correlated_data/_utils/_ms/_tables/write_exp_api.py,sha256=GDEll8nMwkQGc6vosu4UddFL5_ld7WurRgF9hYFTRmU,15511
|
|
41
|
-
xradio/correlated_data/_utils/_utils/cds.py,sha256=OpvKowSheIthUbcPEv2AoKmxlEt3DqJZS5C1AYh5z10,1179
|
|
42
|
-
xradio/correlated_data/_utils/_utils/partition_attrs.py,sha256=JaePHts_A0EbB4K-0a_uC98RZ2EmfjB9pDSEI11oAwk,3401
|
|
43
|
-
xradio/correlated_data/_utils/_utils/stokes_types.py,sha256=DMa8TmmS7BQ99Xm8c7ZjcRapMtLbrKVxrt4f0qUIOvg,561
|
|
44
|
-
xradio/correlated_data/_utils/_utils/xds_helper.py,sha256=jZWR55e574j9NJ4Yf5HdHD7J7QtKdXbXStbblQ66WdE,13218
|
|
45
|
-
xradio/correlated_data/_utils/_zarr/encoding.py,sha256=GENIlThV6a9CUCL6gIGlu9c6NR3OFWNos6mpxZjMwDc,536
|
|
46
|
-
xradio/correlated_data/_utils/_zarr/read.py,sha256=O9DiwD2Gn8WiatQ-Q6WGGSwjsXwFktG4f81lM-mgcSg,7596
|
|
47
|
-
xradio/correlated_data/_utils/_zarr/write.py,sha256=k5IfqtI44Dm4KBDiKFGhL5hN7kwNOulvVHmeP5Mi7N4,10043
|
|
48
|
-
xradio/image/__init__.py,sha256=HAD0GfopIbhdxOYckyW6S9US_dSWmZrwIl3FHUzZwrE,435
|
|
49
|
-
xradio/image/image.py,sha256=QoJ_BTLoMfeXJzU1yvtidBIhaMmjNA5_-6C3FWJRUeI,15635
|
|
50
|
-
xradio/image/_util/__init__.py,sha256=M9lxD1Gc7kv0ucDEDbjLRuIEuESev-IG8j9EaCKUAkA,77
|
|
51
|
-
xradio/image/_util/casacore.py,sha256=DmBTHUQ6870N5ARuFnYSfjZSLniJYgsjrsICUlCREYM,4234
|
|
52
|
-
xradio/image/_util/common.py,sha256=vQs7Du9FSkb_D64Syt3IkiWkb_GmG9xhDPdgbpgP9Ok,9031
|
|
53
|
-
xradio/image/_util/fits.py,sha256=gyGm06fuCKqVGK7uv-ObvQNfFawUDsIOa_nQyklM3Aw,329
|
|
54
|
-
xradio/image/_util/image_factory.py,sha256=6tPzs20FTm2wEshHc1xqtTV7D0TbKxGLUKAVtvOc68I,10506
|
|
55
|
-
xradio/image/_util/zarr.py,sha256=lhQqVRC1GEWClG3zRbuDr2IlQBfXeDqaLUJIN-MVMxA,1652
|
|
56
|
-
xradio/image/_util/_casacore/__init__.py,sha256=OlsiRE40o1jSbBI4khgQQzgfDYbAlOMKIhO4UFlbGhg,41
|
|
57
|
-
xradio/image/_util/_casacore/common.py,sha256=ky999eTCWta8w-uIs-7P7rPhZRLuh9yTuQXAxPvaPm4,1579
|
|
58
|
-
xradio/image/_util/_casacore/xds_from_casacore.py,sha256=4puiE2_1-7Y1-0yK7L8FYyDp5Ab8hEhDjLvoXiGMx9E,42561
|
|
59
|
-
xradio/image/_util/_casacore/xds_to_casacore.py,sha256=P6c-yoOjuVQkm07ApA7FFKfje4aPwV-MsRFKaRaPq9I,15338
|
|
60
|
-
xradio/image/_util/_fits/xds_from_fits.py,sha256=kpZ2gdbDQtoUD1DdQZymup5OVnB3e73D66LruLYESsw,28445
|
|
61
|
-
xradio/image/_util/_zarr/common.py,sha256=apMX_bF4Hr3pFGjnDFpp36KgmhTYAPBZquNkjBHrsXk,307
|
|
62
|
-
xradio/image/_util/_zarr/xds_from_zarr.py,sha256=4b6KHmAcnrhBbCi-Z7e3Lm6l6wziJL1zaNIohmPAYDk,3601
|
|
63
|
-
xradio/image/_util/_zarr/xds_to_zarr.py,sha256=wogXbwX8n3Sl9PHoc3_Y_LBowQsQ-94HZQFZ5NcxUZA,1624
|
|
64
|
-
xradio/image/_util/_zarr/zarr_low_level.py,sha256=_skL70DhtmVjmxRJsfZaospt3rndB9l-2QoHFF1kAKE,12786
|
|
65
|
-
xradio/schema/__init__.py,sha256=EzEMnOtN8G_wdjo8QBRKfq5MrYgfr_nt1pfunlI6i6Q,733
|
|
66
|
-
xradio/schema/bases.py,sha256=5BiE6gAq2xmaJEyiaGbpCSoNek83ly9f0R0Rv1rx9DM,17081
|
|
67
|
-
xradio/schema/check.py,sha256=Quugw5pC-c3c6C_JujSOQSfU_XVFIwymmg8wM0IZtXY,18521
|
|
68
|
-
xradio/schema/dataclass.py,sha256=Byegqga9tTkgFDMK6JXwLkDo78OX906v3CBElH592N4,12356
|
|
69
|
-
xradio/schema/metamodel.py,sha256=WjtW7pAVzcjLRWifRH3sQoOiN6TV810hARpOIz1M_gw,3845
|
|
70
|
-
xradio/schema/typing.py,sha256=8-o6fZd99kJ4FVdgBYRTIRJ-wDqpcUNXzCTfJvl3TIw,10439
|
|
71
|
-
xradio-0.0.41.dist-info/LICENSE.txt,sha256=9CYIJt7riOXo9AD0eXBZviLxo_HebD-2JJI8oiWtzfg,1807
|
|
72
|
-
xradio-0.0.41.dist-info/METADATA,sha256=vzs61B5tZwpiZDr-p1PQKm_EedSfE8JeA48D_3Kz43k,4510
|
|
73
|
-
xradio-0.0.41.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
74
|
-
xradio-0.0.41.dist-info/top_level.txt,sha256=dQu27fGBZJ2Yk-gW5XeD-dZ76Xa4Xcvk60Vz-dwXp7k,7
|
|
75
|
-
xradio-0.0.41.dist-info/RECORD,,
|
|
File without changes
|
/xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/_tables/read_main_table.py
RENAMED
|
File without changes
|
/xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/_tables/read_subtables.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/xradio/{correlated_data/_utils/_ms → measurement_set/_utils/_msv2}/_tables/write_exp_api.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
|