xradio 0.0.47__py3-none-any.whl → 0.0.48__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/list_and_array.py +3 -1
- xradio/_utils/schema.py +3 -1
- xradio/measurement_set/_utils/_msv2/conversion.py +50 -35
- 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 +5 -1
- xradio/measurement_set/_utils/_msv2/msv4_sub_xdss.py +21 -22
- xradio/measurement_set/load_processing_set.py +2 -1
- xradio/measurement_set/processing_set.py +119 -93
- xradio/measurement_set/schema.py +189 -116
- xradio/sphinx/schema_table.py +12 -0
- {xradio-0.0.47.dist-info → xradio-0.0.48.dist-info}/METADATA +2 -2
- {xradio-0.0.47.dist-info → xradio-0.0.48.dist-info}/RECORD +16 -16
- {xradio-0.0.47.dist-info → xradio-0.0.48.dist-info}/LICENSE.txt +0 -0
- {xradio-0.0.47.dist-info → xradio-0.0.48.dist-info}/WHEEL +0 -0
- {xradio-0.0.47.dist-info → xradio-0.0.48.dist-info}/top_level.txt +0 -0
xradio/_utils/list_and_array.py
CHANGED
|
@@ -64,10 +64,12 @@ def to_list(x):
|
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
def to_np_array(x):
|
|
67
|
-
if isinstance(x,
|
|
67
|
+
if isinstance(x, np.ndarray):
|
|
68
68
|
if x.ndim == 0:
|
|
69
69
|
return np.array([x.item()])
|
|
70
70
|
return np.array(x) # needed for json serialization
|
|
71
|
+
elif isinstance(x, list):
|
|
72
|
+
return np.array(x)
|
|
71
73
|
return np.array([x])
|
|
72
74
|
|
|
73
75
|
|
xradio/_utils/schema.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import toolviper.utils.logger as logger
|
|
2
2
|
import xarray as xr
|
|
3
|
+
from typing import Union
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
def convert_generic_xds_to_xradio_schema(
|
|
@@ -7,6 +8,7 @@ def convert_generic_xds_to_xradio_schema(
|
|
|
7
8
|
msv4_xds: xr.Dataset,
|
|
8
9
|
to_new_data_variables: dict[str, list],
|
|
9
10
|
to_new_coords: dict[str, list],
|
|
11
|
+
ref_code: Union[int, None] = None,
|
|
10
12
|
) -> xr.Dataset:
|
|
11
13
|
"""Converts a generic xarray Dataset to the xradio schema.
|
|
12
14
|
|
|
@@ -63,7 +65,7 @@ def convert_generic_xds_to_xradio_schema(
|
|
|
63
65
|
|
|
64
66
|
if key in column_description:
|
|
65
67
|
msv4_measure = column_description_casacore_to_msv4_measure(
|
|
66
|
-
column_description[key]
|
|
68
|
+
column_description[key], ref_code
|
|
67
69
|
)
|
|
68
70
|
else:
|
|
69
71
|
msv4_measure = None
|
|
@@ -423,7 +423,7 @@ def create_coordinates(
|
|
|
423
423
|
"baseline_antenna1_id": ("baseline_id", baseline_ant1_id),
|
|
424
424
|
"baseline_antenna2_id": ("baseline_id", baseline_ant2_id),
|
|
425
425
|
"baseline_id": np.arange(len(baseline_ant1_id)),
|
|
426
|
-
"
|
|
426
|
+
"scan_name": ("time", scan_id.astype(str)),
|
|
427
427
|
"uvw_label": ["u", "v", "w"],
|
|
428
428
|
}
|
|
429
429
|
|
|
@@ -1029,7 +1029,7 @@ def convert_and_write_partition(
|
|
|
1029
1029
|
datetime.timezone.utc
|
|
1030
1030
|
).isoformat(),
|
|
1031
1031
|
"xradio_version": importlib.metadata.version("xradio"),
|
|
1032
|
-
"schema_version": "4.0.-
|
|
1032
|
+
"schema_version": "4.0.-9989",
|
|
1033
1033
|
"type": "visibility",
|
|
1034
1034
|
}
|
|
1035
1035
|
)
|
|
@@ -1112,10 +1112,6 @@ def convert_and_write_partition(
|
|
|
1112
1112
|
[xds["baseline_antenna1_id"].data, xds["baseline_antenna2_id"].data]
|
|
1113
1113
|
)
|
|
1114
1114
|
)
|
|
1115
|
-
if phase_cal_interpolate:
|
|
1116
|
-
phase_cal_interp_time = xds.time.values
|
|
1117
|
-
else:
|
|
1118
|
-
phase_cal_interp_time = None
|
|
1119
1115
|
|
|
1120
1116
|
ant_xds = create_antenna_xds(
|
|
1121
1117
|
in_file,
|
|
@@ -1134,6 +1130,10 @@ def convert_and_write_partition(
|
|
|
1134
1130
|
logger.debug("Time gain_curve xds " + str(time.time() - start))
|
|
1135
1131
|
|
|
1136
1132
|
start = time.time()
|
|
1133
|
+
if phase_cal_interpolate:
|
|
1134
|
+
phase_cal_interp_time = xds.time.values
|
|
1135
|
+
else:
|
|
1136
|
+
phase_cal_interp_time = None
|
|
1137
1137
|
phase_calibration_xds = create_phase_calibration_xds(
|
|
1138
1138
|
in_file,
|
|
1139
1139
|
xds.frequency.attrs["spectral_window_id"],
|
|
@@ -1143,17 +1143,6 @@ def convert_and_write_partition(
|
|
|
1143
1143
|
)
|
|
1144
1144
|
logger.debug("Time phase_calibration xds " + str(time.time() - start))
|
|
1145
1145
|
|
|
1146
|
-
# Change antenna_ids to antenna_names
|
|
1147
|
-
with_antenna_partitioning = "ANTENNA1" in partition_info
|
|
1148
|
-
xds = antenna_ids_to_names(
|
|
1149
|
-
xds, ant_xds, is_single_dish, with_antenna_partitioning
|
|
1150
|
-
)
|
|
1151
|
-
# but before, keep the name-id arrays, we need them for the pointing and weather xds
|
|
1152
|
-
ant_xds_name_ids = ant_xds["antenna_name"].set_xindex("antenna_id")
|
|
1153
|
-
ant_xds_station_name_ids = ant_xds["station"].set_xindex("antenna_id")
|
|
1154
|
-
# No longer needed after converting to name.
|
|
1155
|
-
ant_xds = ant_xds.drop_vars("antenna_id")
|
|
1156
|
-
|
|
1157
1146
|
# Create system_calibration_xds
|
|
1158
1147
|
start = time.time()
|
|
1159
1148
|
if sys_cal_interpolate:
|
|
@@ -1163,11 +1152,22 @@ def convert_and_write_partition(
|
|
|
1163
1152
|
system_calibration_xds = create_system_calibration_xds(
|
|
1164
1153
|
in_file,
|
|
1165
1154
|
xds.frequency,
|
|
1166
|
-
|
|
1155
|
+
ant_xds,
|
|
1167
1156
|
sys_cal_interp_time,
|
|
1168
1157
|
)
|
|
1169
1158
|
logger.debug("Time system_calibation " + str(time.time() - start))
|
|
1170
1159
|
|
|
1160
|
+
# Change antenna_ids to antenna_names
|
|
1161
|
+
with_antenna_partitioning = "ANTENNA1" in partition_info
|
|
1162
|
+
xds = antenna_ids_to_names(
|
|
1163
|
+
xds, ant_xds, is_single_dish, with_antenna_partitioning
|
|
1164
|
+
)
|
|
1165
|
+
# but before, keep the name-id arrays, we need them for the pointing and weather xds
|
|
1166
|
+
ant_xds_name_ids = ant_xds["antenna_name"].set_xindex("antenna_id")
|
|
1167
|
+
ant_xds_station_name_ids = ant_xds["station"].set_xindex("antenna_id")
|
|
1168
|
+
# No longer needed after converting to name.
|
|
1169
|
+
ant_xds = ant_xds.drop_vars("antenna_id")
|
|
1170
|
+
|
|
1171
1171
|
# Create weather_xds
|
|
1172
1172
|
start = time.time()
|
|
1173
1173
|
weather_xds = create_weather_xds(in_file, ant_xds_station_name_ids)
|
|
@@ -1211,37 +1211,52 @@ def convert_and_write_partition(
|
|
|
1211
1211
|
else:
|
|
1212
1212
|
ephemeris_interp_time = None
|
|
1213
1213
|
|
|
1214
|
-
if "FIELD_ID" not in partition_scheme:
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
else:
|
|
1220
|
-
|
|
1221
|
-
|
|
1214
|
+
# if "FIELD_ID" not in partition_scheme:
|
|
1215
|
+
# field_id = np.full(time_baseline_shape, -42, dtype=int)
|
|
1216
|
+
# field_id[tidxs, bidxs] = tb_tool.getcol("FIELD_ID")
|
|
1217
|
+
# field_id = np.max(field_id, axis=1)
|
|
1218
|
+
# field_times = utime
|
|
1219
|
+
# else:
|
|
1220
|
+
# field_id = check_if_consistent(tb_tool.getcol("FIELD_ID"), "FIELD_ID")
|
|
1221
|
+
# field_times = None
|
|
1222
|
+
|
|
1223
|
+
field_id = np.full(
|
|
1224
|
+
time_baseline_shape, -42, dtype=int
|
|
1225
|
+
) # -42 used for missing baselines
|
|
1226
|
+
field_id[tidxs, bidxs] = tb_tool.getcol("FIELD_ID")
|
|
1227
|
+
field_id = np.max(field_id, axis=1)
|
|
1228
|
+
field_times = xds.time.values
|
|
1222
1229
|
|
|
1223
1230
|
# col_unique = unique_1d(col)
|
|
1224
1231
|
# assert len(col_unique) == 1, col_name + " is not consistent."
|
|
1225
1232
|
# return col_unique[0]
|
|
1226
1233
|
|
|
1227
|
-
field_and_source_xds, source_id, _num_lines =
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1234
|
+
field_and_source_xds, source_id, _num_lines, field_names = (
|
|
1235
|
+
create_field_and_source_xds(
|
|
1236
|
+
in_file,
|
|
1237
|
+
field_id,
|
|
1238
|
+
xds.frequency.attrs["spectral_window_id"],
|
|
1239
|
+
field_times,
|
|
1240
|
+
is_single_dish,
|
|
1241
|
+
time_min_max,
|
|
1242
|
+
ephemeris_interpolate,
|
|
1243
|
+
)
|
|
1235
1244
|
)
|
|
1245
|
+
|
|
1236
1246
|
logger.debug("Time field_and_source_xds " + str(time.time() - start))
|
|
1237
1247
|
|
|
1238
1248
|
xds = fix_uvw_frame(xds, field_and_source_xds, is_single_dish)
|
|
1249
|
+
xds = xds.assign_coords({"field_name": ("time", field_names)})
|
|
1239
1250
|
|
|
1240
1251
|
partition_info_misc_fields = {
|
|
1241
|
-
"
|
|
1252
|
+
"scan_name": xds.coords["scan_name"].data,
|
|
1242
1253
|
"intents": intents,
|
|
1243
1254
|
"taql_where": taql_where,
|
|
1244
1255
|
}
|
|
1256
|
+
if with_antenna_partitioning:
|
|
1257
|
+
partition_info_misc_fields["antenna_name"] = xds.coords[
|
|
1258
|
+
"antenna_name"
|
|
1259
|
+
].data[0]
|
|
1245
1260
|
info_dicts = create_info_dicts(
|
|
1246
1261
|
in_file, xds, field_and_source_xds, partition_info_misc_fields, tb_tool
|
|
1247
1262
|
)
|