xradio 0.0.40__py3-none-any.whl → 0.0.41__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.
Files changed (47) hide show
  1. xradio/{vis → correlated_data}/__init__.py +3 -2
  2. xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/_tables/load_main_table.py +1 -1
  3. xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/_tables/read.py +14 -0
  4. xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/conversion.py +117 -58
  5. xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/create_antenna_xds.py +195 -167
  6. xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/create_field_and_source_xds.py +40 -39
  7. xradio/correlated_data/_utils/_ms/msv4_info_dicts.py +203 -0
  8. xradio/correlated_data/_utils/_ms/msv4_sub_xdss.py +516 -0
  9. xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/subtables.py +1 -1
  10. xradio/{vis/_vis_utils → correlated_data/_utils}/zarr.py +3 -3
  11. xradio/{vis → correlated_data}/convert_msv2_to_processing_set.py +9 -2
  12. xradio/correlated_data/correlated_xds.py +13 -0
  13. xradio/{vis → correlated_data}/load_processing_set.py +13 -17
  14. xradio/{vis/read_processing_set.py → correlated_data/open_processing_set.py} +20 -22
  15. xradio/{vis/_processing_set.py → correlated_data/processing_set.py} +11 -12
  16. xradio/{vis → correlated_data}/schema.py +572 -186
  17. xradio/correlated_data/test__processing_set.py +74 -0
  18. {xradio-0.0.40.dist-info → xradio-0.0.41.dist-info}/METADATA +9 -10
  19. xradio-0.0.41.dist-info/RECORD +75 -0
  20. {xradio-0.0.40.dist-info → xradio-0.0.41.dist-info}/WHEEL +1 -1
  21. xradio/vis/_vis_utils/_ms/msv4_infos.py +0 -0
  22. xradio/vis/_vis_utils/_ms/msv4_sub_xdss.py +0 -306
  23. xradio-0.0.40.dist-info/RECORD +0 -73
  24. /xradio/{vis/_vis_utils → correlated_data/_utils}/__init__.py +0 -0
  25. /xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/_tables/load.py +0 -0
  26. /xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/_tables/read_main_table.py +0 -0
  27. /xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/_tables/read_subtables.py +0 -0
  28. /xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/_tables/table_query.py +0 -0
  29. /xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/_tables/write.py +0 -0
  30. /xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/_tables/write_exp_api.py +0 -0
  31. /xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/chunks.py +0 -0
  32. /xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/descr.py +0 -0
  33. /xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/msv2_msv3.py +0 -0
  34. /xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/msv2_to_msv4_meta.py +0 -0
  35. /xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/optimised_functions.py +0 -0
  36. /xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/partition_queries.py +0 -0
  37. /xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/partitions.py +0 -0
  38. /xradio/{vis/_vis_utils → correlated_data/_utils}/_utils/cds.py +0 -0
  39. /xradio/{vis/_vis_utils → correlated_data/_utils}/_utils/partition_attrs.py +0 -0
  40. /xradio/{vis/_vis_utils → correlated_data/_utils}/_utils/stokes_types.py +0 -0
  41. /xradio/{vis/_vis_utils → correlated_data/_utils}/_utils/xds_helper.py +0 -0
  42. /xradio/{vis/_vis_utils → correlated_data/_utils}/_zarr/encoding.py +0 -0
  43. /xradio/{vis/_vis_utils → correlated_data/_utils}/_zarr/read.py +0 -0
  44. /xradio/{vis/_vis_utils → correlated_data/_utils}/_zarr/write.py +0 -0
  45. /xradio/{vis/_vis_utils → correlated_data/_utils}/ms.py +0 -0
  46. {xradio-0.0.40.dist-info → xradio-0.0.41.dist-info}/LICENSE.txt +0 -0
  47. {xradio-0.0.40.dist-info → xradio-0.0.41.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,5 @@
1
1
  import os
2
- from ._processing_set import processing_set
2
+ from xradio.correlated_data import ProcessingSet
3
3
  from typing import Dict, Union
4
4
 
5
5
 
@@ -8,7 +8,7 @@ def load_processing_set(
8
8
  sel_parms: dict,
9
9
  data_variables: Union[list, None] = None,
10
10
  load_sub_datasets: bool = True,
11
- ) -> processing_set:
11
+ ) -> ProcessingSet:
12
12
  """Loads a processing set into memory.
13
13
 
14
14
  Parameters
@@ -29,18 +29,18 @@ def load_processing_set(
29
29
  data_variables : Union[list, None], optional
30
30
  The list of data variables to load into memory for example ['VISIBILITY', 'WEIGHT, 'FLAGS']. By default None which will load all data variables into memory.
31
31
  load_sub_datasets : bool, optional
32
- If true sub-datasets (for example weather_xds, antenna_xds, pointing_xds, ...) will be loaded into memory, by default True.
32
+ If true sub-datasets (for example weather_xds, antenna_xds, pointing_xds, system_calibration_xds ...) will be loaded into memory, by default True.
33
33
 
34
34
  Returns
35
35
  -------
36
- processing_set
36
+ ProcessingSet
37
37
  In memory representation of processing set (data is represented by Dask.arrays).
38
38
  """
39
39
  from xradio._utils.zarr.common import _open_dataset, _get_file_system_and_items
40
40
 
41
41
  file_system, ms_store_list = _get_file_system_and_items(ps_store)
42
42
 
43
- ps = processing_set()
43
+ ps = ProcessingSet()
44
44
  for ms_name, ms_xds_isel in sel_parms.items():
45
45
  ms_store = os.path.join(ps_store, ms_name)
46
46
  ms_main_store = os.path.join(ms_store, "MAIN")
@@ -55,9 +55,9 @@ def load_processing_set(
55
55
  data_groups = xds.attrs["data_groups"]
56
56
 
57
57
  if load_sub_datasets:
58
- from xradio.vis.read_processing_set import _read_sub_xds
58
+ from xradio.correlated_data.open_processing_set import _open_sub_xds
59
59
 
60
- sub_xds_dict, field_and_source_xds_dict = _read_sub_xds(
60
+ sub_xds_dict, field_and_source_xds_dict = _open_sub_xds(
61
61
  ms_store, file_system=file_system, load=True, data_groups=data_groups
62
62
  )
63
63
 
@@ -66,14 +66,10 @@ def load_processing_set(
66
66
  **sub_xds_dict,
67
67
  }
68
68
  for data_group_name, data_group_vals in data_groups.items():
69
- if "visibility" in data_group_vals:
70
- xds[data_group_vals["visibility"]].attrs["field_and_source_xds"] = (
71
- field_and_source_xds_dict[data_group_name]
72
- )
73
- elif "spectrum" in data_group_vals:
74
- xds[data_group_vals["spectrum"]].attrs["field_and_source_xds"] = (
75
- field_and_source_xds_dict[data_group_name]
76
- )
69
+
70
+ xds[data_group_vals["correlated_data"]].attrs[
71
+ "field_and_source_xds"
72
+ ] = field_and_source_xds_dict[data_group_name]
77
73
 
78
74
  ps[ms_name] = xds
79
75
 
@@ -85,7 +81,7 @@ class processing_set_iterator:
85
81
  self,
86
82
  sel_parms: dict,
87
83
  input_data_store: str,
88
- input_data: Union[Dict, processing_set, None] = None,
84
+ input_data: Union[Dict, ProcessingSet, None] = None,
89
85
  data_variables: list = None,
90
86
  load_sub_datasets: bool = True,
91
87
  ):
@@ -110,7 +106,7 @@ class processing_set_iterator:
110
106
  data_variables : list, optional
111
107
  The list of data variables to load into memory for example ['VISIBILITY', 'WEIGHT, 'FLAGS']. By default None which will load all data variables into memory.
112
108
  load_sub_datasets : bool, optional
113
- If true sub-datasets (for example weather_xds, antenna_xds, pointing_xds, ...) will be loaded into memory, by default True.
109
+ If true sub-datasets (for example weather_xds, antenna_xds, pointing_xds, system_calibration_xds ...) will be loaded into memory, by default True.
114
110
  """
115
111
 
116
112
  self.input_data = input_data
@@ -1,24 +1,24 @@
1
1
  import os
2
2
 
3
- from ._processing_set import processing_set
3
+ from xradio.correlated_data import ProcessingSet
4
4
  import toolviper.utils.logger as logger
5
5
  from xradio._utils.zarr.common import _open_dataset, _get_file_system_and_items
6
6
  import s3fs
7
7
 
8
8
 
9
- def read_processing_set(
9
+ def open_processing_set(
10
10
  ps_store: str,
11
- obs_modes: list = None,
12
- ) -> processing_set:
11
+ intents: list = None,
12
+ ) -> ProcessingSet:
13
13
  """Creates a lazy representation of a Processing Set (only meta-data is loaded into memory).
14
14
 
15
15
  Parameters
16
16
  ----------
17
17
  ps_store : str
18
18
  String of the path and name of the processing set. For example '/users/user_1/uid___A002_Xf07bba_Xbe5c_target.lsrk.vis.zarr'.
19
- obs_modes : list, optional
20
- A list of obs_mode to be read for example ['OBSERVE_TARGET#ON_SOURCE']. The obs_mode in a processing set can be seen by calling processing_set.summary().
21
- By default None, which will read all obs_mode.
19
+ intents : list, optional
20
+ A list of intents to be open for example ['OBSERVE_TARGET#ON_SOURCE']. The intents in a processing set can be seen by calling processing_set.summary().
21
+ By default None, which will open all intents.
22
22
 
23
23
  Returns
24
24
  -------
@@ -27,7 +27,7 @@ def read_processing_set(
27
27
  """
28
28
  file_system, ms_store_list = _get_file_system_and_items(ps_store)
29
29
 
30
- ps = processing_set()
30
+ ps = ProcessingSet()
31
31
  data_group = "base"
32
32
  for ms_name in ms_store_list:
33
33
  # try:
@@ -37,10 +37,10 @@ def read_processing_set(
37
37
  xds = _open_dataset(ms_main_store, file_system)
38
38
  data_groups = xds.attrs["data_groups"]
39
39
 
40
- if (obs_modes is None) or (
41
- bool(set(xds.attrs["partition_info"]["obs_mode"]).intersection(obs_modes))
40
+ if (intents is None) or (
41
+ bool(set(xds.attrs["partition_info"]["intents"]).intersection(intents))
42
42
  ):
43
- sub_xds_dict, field_and_source_xds_dict = _read_sub_xds(
43
+ sub_xds_dict, field_and_source_xds_dict = _open_sub_xds(
44
44
  ms_store, file_system=file_system, data_groups=data_groups
45
45
  )
46
46
 
@@ -50,31 +50,29 @@ def read_processing_set(
50
50
  }
51
51
 
52
52
  for data_group_name, data_group_vals in data_groups.items():
53
- if "visibility" in data_group_vals:
54
- xds[data_group_vals["visibility"]].attrs["field_and_source_xds"] = (
55
- field_and_source_xds_dict[data_group_name]
56
- )
57
- elif "spectrum" in data_group_vals:
58
- xds[data_group_vals["spectrum"]].attrs["field_and_source_xds"] = (
59
- field_and_source_xds_dict[data_group_name]
60
- )
53
+ xds[data_group_vals["correlated_data"]].attrs[
54
+ "field_and_source_xds"
55
+ ] = field_and_source_xds_dict[data_group_name]
61
56
 
62
57
  ps[ms_name] = xds
63
58
  # except Exception as e:
64
- # logger.warning(f"Could not read {ms_name} due to {e}")
59
+ # logger.warning(f"Could not open {ms_name} due to {e}")
65
60
  # continue
66
61
 
67
62
  return ps
68
63
 
69
64
 
70
- def _read_sub_xds(ms_store, file_system, data_groups, load=False):
65
+ def _open_sub_xds(ms_store, file_system, data_groups, load=False):
71
66
  sub_xds_dict = {}
72
67
  field_and_source_xds_dict = {}
73
68
 
74
69
  xds_names = {
75
70
  "ANTENNA": "antenna_xds",
76
- "WEATHER": "weather_xds",
77
71
  "POINTING": "pointing_xds",
72
+ "SYSCAL": "system_calibration_xds",
73
+ "GAIN_CURVE": "gain_curve_xds",
74
+ "PHASE_CAL": "phase_calibration_xds",
75
+ "WEATHER": "weather_xds",
78
76
  }
79
77
 
80
78
  if isinstance(file_system, s3fs.core.S3FileSystem):
@@ -3,7 +3,7 @@ from xradio._utils.list_and_array import to_list
3
3
  import numbers
4
4
 
5
5
 
6
- class processing_set(dict):
6
+ class ProcessingSet(dict):
7
7
  """
8
8
  A dictionary subclass representing a Processing Set (PS) that is a set of Measurement Sets v4 (MS).
9
9
 
@@ -74,7 +74,7 @@ class processing_set(dict):
74
74
  def _summary(self, data_group="base"):
75
75
  summary_data = {
76
76
  "name": [],
77
- "obs_mode": [],
77
+ "intents": [],
78
78
  "shape": [],
79
79
  "polarization": [],
80
80
  "scan_number": [],
@@ -94,7 +94,7 @@ class processing_set(dict):
94
94
 
95
95
  for key, value in self.items():
96
96
  summary_data["name"].append(key)
97
- summary_data["obs_mode"].append(value.attrs["partition_info"]["obs_mode"])
97
+ summary_data["intents"].append(value.attrs["partition_info"]["intents"])
98
98
  summary_data["spw_name"].append(
99
99
  value.attrs["partition_info"]["spectral_window_name"]
100
100
  )
@@ -102,13 +102,12 @@ class processing_set(dict):
102
102
  summary_data["scan_number"].append(
103
103
  value.attrs["partition_info"]["scan_number"]
104
104
  )
105
+ data_name = value.attrs["data_groups"][data_group]["correlated_data"]
105
106
 
106
- if "visibility" in value.attrs["data_groups"][data_group]:
107
- data_name = value.attrs["data_groups"][data_group]["visibility"]
107
+ if "VISIBILITY" in data_name:
108
108
  center_name = "FIELD_PHASE_CENTER"
109
109
 
110
- if "spectrum" in value.attrs["data_groups"][data_group]:
111
- data_name = value.attrs["data_groups"][data_group]["spectrum"]
110
+ if "SPECTRUM" in data_name:
112
111
  center_name = "FIELD_REFERENCE_CENTER"
113
112
 
114
113
  summary_data["shape"].append(value[data_name].shape)
@@ -202,12 +201,12 @@ class processing_set(dict):
202
201
  """
203
202
  Selects a subset of the Processing Set based on column names and values or a Pandas query.
204
203
 
205
- The following columns are supported: name, obs_mode, polarization, spw_name, field_name, source_name, field_coords, start_frequency, end_frequency.
204
+ The following columns are supported: name, intents, polarization, spw_name, field_name, source_name, field_coords, start_frequency, end_frequency.
206
205
 
207
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'].
208
207
 
209
208
  Examples:
210
- ps.sel(obs_mode='OBSERVE_TARGET#ON_SOURCE', polarization=['RR', 'LL']) # Select all MSs with obs_mode 'OBSERVE_TARGET#ON_SOURCE' and polarization 'RR' or 'LL'.
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'.
211
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.
212
211
 
213
212
  Args:
@@ -264,7 +263,7 @@ class processing_set(dict):
264
263
  if query is not None:
265
264
  summary_table = summary_table.query(query)
266
265
 
267
- sub_ps = processing_set()
266
+ sub_ps = ProcessingSet()
268
267
  for key, val in self.items():
269
268
  if key in summary_table["name"].values:
270
269
  sub_ps[key] = val
@@ -281,7 +280,7 @@ class processing_set(dict):
281
280
  Returns:
282
281
  processing_set: The subset of the Processing Set.
283
282
  """
284
- sub_ps = processing_set()
283
+ sub_ps = ProcessingSet()
285
284
  for key, val in self.items():
286
285
  sub_ps[key] = val.sel(kwargs)
287
286
  return sub_ps
@@ -296,7 +295,7 @@ class processing_set(dict):
296
295
  Returns:
297
296
  processing_set: The subset of the Processing Set.
298
297
  """
299
- sub_ps = processing_set()
298
+ sub_ps = ProcessingSet()
300
299
  for key, val in self.items():
301
300
  sub_ps[key] = val.isel(kwargs)
302
301
  return sub_ps