xradio 0.0.31__py3-none-any.whl → 0.0.34__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 (31) hide show
  1. xradio/_utils/list_and_array.py +5 -3
  2. xradio/vis/__init__.py +3 -5
  3. xradio/vis/_processing_set.py +3 -3
  4. xradio/vis/_vis_utils/_ms/_tables/load_main_table.py +4 -4
  5. xradio/vis/_vis_utils/_ms/_tables/read.py +57 -41
  6. xradio/vis/_vis_utils/_ms/_tables/read_main_table.py +17 -18
  7. xradio/vis/_vis_utils/_ms/_tables/read_subtables.py +5 -5
  8. xradio/vis/_vis_utils/_ms/_tables/write.py +2 -4
  9. xradio/vis/_vis_utils/_ms/_tables/write_exp_api.py +19 -13
  10. xradio/vis/_vis_utils/_ms/chunks.py +5 -72
  11. xradio/vis/_vis_utils/_ms/conversion.py +238 -55
  12. xradio/vis/_vis_utils/_ms/{_tables/create_field_and_source_xds.py → create_field_and_source_xds.py} +114 -85
  13. xradio/vis/_vis_utils/_ms/descr.py +8 -8
  14. xradio/vis/_vis_utils/_ms/msv4_sub_xdss.py +249 -77
  15. xradio/vis/_vis_utils/_ms/partition_queries.py +19 -185
  16. xradio/vis/_vis_utils/_ms/partitions.py +18 -22
  17. xradio/vis/_vis_utils/_ms/subtables.py +2 -2
  18. xradio/vis/_vis_utils/_utils/partition_attrs.py +2 -2
  19. xradio/vis/_vis_utils/_utils/xds_helper.py +12 -12
  20. xradio/vis/_vis_utils/ms.py +1 -43
  21. xradio/vis/_vis_utils/zarr.py +0 -1
  22. xradio/vis/convert_msv2_to_processing_set.py +8 -1
  23. xradio/vis/load_processing_set.py +0 -3
  24. xradio/vis/read_processing_set.py +2 -2
  25. {xradio-0.0.31.dist-info → xradio-0.0.34.dist-info}/METADATA +1 -1
  26. {xradio-0.0.31.dist-info → xradio-0.0.34.dist-info}/RECORD +29 -31
  27. {xradio-0.0.31.dist-info → xradio-0.0.34.dist-info}/WHEEL +1 -1
  28. xradio/vis/_vis_utils/ms_column_descriptions_dicts.py +0 -1360
  29. xradio/vis/vis_io.py +0 -146
  30. {xradio-0.0.31.dist-info → xradio-0.0.34.dist-info}/LICENSE.txt +0 -0
  31. {xradio-0.0.31.dist-info → xradio-0.0.34.dist-info}/top_level.txt +0 -0
xradio/vis/vis_io.py DELETED
@@ -1,146 +0,0 @@
1
- import numcodecs, os
2
- from typing import Dict, List, Tuple, Union
3
-
4
- import xarray as xr
5
-
6
- from ._vis_utils._utils.cds import CASAVisSet
7
- from xradio.vis import _vis_utils
8
-
9
-
10
- def read_vis(
11
- infile: str,
12
- subtables: bool = True,
13
- asdm_subtables: bool = False,
14
- partition_scheme: str = "intent",
15
- chunks: Union[Tuple[int], List[int]] = None,
16
- expand: bool = False,
17
- ) -> CASAVisSet:
18
- """
19
- Read a MeasurementSet (MSv2 format) into a next generation CASA
20
- dataset (visibilities dataset as a set of Xarray datasets).
21
-
22
- The MS is partitioned into multiple sub- Xarray datasets (where the data variables are read as
23
- Dask delayed arrays).
24
- The MS is partitioned by DDI, which guarantees a fixed data shape per partition (in terms of channels
25
- and polarizations) and, subject to experimentation, by scan and subscan. This results in multiple
26
- partitions as xarray datasets (xds) contained within a main xds (mxds).
27
-
28
- Parameters
29
- ----------
30
- infile : str
31
- Input MS filename
32
- subtables : bool (Default value = True)
33
- Also read and include subtables along with main table selection. Default False will
34
- omit subtables (faster)
35
- asdm_subtables : bool (Default value = True)
36
- in addition to MeasurementSet subtables (if enabled), also read extension
37
- subtables names "ASDM_*"
38
- partition_scheme : str (Default value = "intent")
39
- (experimenting) Whether to partition sub-xds datasets by scan/subscan
40
- (in addition to DDI), or other alternative partitioning schemes. Accepted values: 'scan/subscan',
41
- 'scan', 'ddi', 'intent'. Default: 'intent'
42
- chunks : Union[Tuple[int], List[int]] (Default value = None)
43
- Can be used to set a specific chunk shape (with a tuple of ints), or to control the
44
- optimization used for automatic chunking (with a list of ints). A tuple of ints in the form of (row,
45
- chan, pol) will use a fixed chunk shape. A list or numpy array of ints in the form of [idx1, etc]
46
- will trigger auto-chunking optimized for the given indices, with row=0, chan=1, pol=2. Default None
47
- uses auto-chunking with a best fit across all dimensions (probably sub-optimal for most cases).
48
- expand : bool (Default value = False)
49
- (to be removed) Whether or not to return the original flat row structure of the MS (False)
50
- or expand the rows to time x baseline dimensions (True). Expanding the rows allows for easier indexing
51
- and parallelization across time and baseline dimensions, at the cost of some conversion time. Default
52
- False
53
-
54
- Returns
55
- -------
56
- CASAVisSet
57
- ngCASA visisbilities dataset, essentially made of two dictionaries of
58
- metainformation and data partitions
59
- """
60
- infile = os.path.expanduser(infile)
61
- if not os.path.isdir(infile):
62
- raise ValueError(f"invalid input filename to read_vis {infile}")
63
-
64
- if _vis_utils.zarr.is_zarr_vis(infile):
65
- return _vis_utils.zarr.read_vis(infile, subtables, asdm_subtables)
66
- else:
67
- return _vis_utils.ms.read_ms(
68
- infile, subtables, asdm_subtables, partition_scheme, chunks, expand
69
- )
70
-
71
-
72
- def load_vis_block(
73
- infile: str,
74
- block_des: Dict[str, slice],
75
- partition_key: Tuple[int, int, str],
76
- subtables: List[str] = None,
77
- ) -> Dict[Tuple[int, int], xr.Dataset]:
78
- """
79
- Read a chunk of a visibilities dataset into an Xarray dataset, loading the
80
- data in memory.
81
- The input format support is the MeasurementSet v2 (MSv2 format)
82
-
83
- Parameters
84
- ----------
85
- infile : str
86
- Input visibilities path
87
- block_des : Dict[str, slice]
88
- specification of chunk to load
89
- partition_key: Tuple[int, int, str]
90
- key of partition to load
91
- subtables: List[str] (Default value = None)
92
- subtables to load
93
-
94
- Returns
95
- -------
96
- Dict[Tuple[int, int], xr.Dataset]
97
- CASA visibilities dataset holding a chunk of visibility data, for one
98
- partition
99
- (spw_id, pol_setup_id, intent_string triplet)
100
- """
101
- # TODO: use the input partition_key
102
- # the intent str of the partition_key is not yet effectively used
103
- # TODO: support subtables list
104
- return _vis_utils.ms.load_vis_chunk(infile, block_des, partition_key)
105
-
106
-
107
- def write_vis(
108
- cds: CASAVisSet,
109
- outpath: str,
110
- chunks_on_disk: Union[Dict, None] = None,
111
- compressor: Union[numcodecs.abc.Codec, None] = None,
112
- out_format: str = "zarr",
113
- ) -> None:
114
- """
115
- Write CASA vis dataset to disk.
116
- The disk format supported is "zarr". When chunks_on_disk is not specified the
117
- chunking in the input dataset is used. When chunks_on_disk is specified that
118
- dataset is saved using that chunking.
119
-
120
- Parameters
121
- ----------
122
- cds : CASAVisSet
123
- CASA visibilities dataset to write to disk
124
- outpath : str
125
- output path, generally ends in .zarr
126
- chunks_on_disk : Union[Dict, None] (Default value = None)
127
- a dictionary with the chunk size that will
128
- be used when writing to disk. For example {'time': 20, 'chan': 6}.
129
- If chunks_on_disk is not specified the chunking of dataset will
130
- be used.
131
- compressor : Union[numcodecs.abc.Codec, None] (Default value = None)
132
- the blosc compressor to use when saving the
133
- converted data to disk using zarr. If None the zstd compression
134
- algorithm used with compression level 2.
135
- out_format : str (Default value = "zarr")
136
- format to write
137
-
138
- Returns
139
- -------
140
- None
141
- """
142
-
143
- if out_format == "zarr":
144
- return _vis_utils.zarr.write_vis(cds, outpath, chunks_on_disk, compressor)
145
- else:
146
- raise ValueError(f"Unsupported output format: {out_format}")