xradio 0.0.39__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 (52) hide show
  1. xradio/__init__.py +1 -1
  2. xradio/_utils/schema.py +14 -3
  3. xradio/{vis → correlated_data}/__init__.py +3 -2
  4. xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/_tables/load_main_table.py +2 -2
  5. xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/_tables/read.py +15 -1
  6. xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/_tables/read_main_table.py +1 -1
  7. xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/_tables/read_subtables.py +1 -1
  8. xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/_tables/write.py +1 -1
  9. xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/conversion.py +117 -58
  10. xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/create_antenna_xds.py +196 -168
  11. xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/create_field_and_source_xds.py +234 -200
  12. xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/msv2_to_msv4_meta.py +1 -1
  13. xradio/correlated_data/_utils/_ms/msv4_info_dicts.py +203 -0
  14. xradio/correlated_data/_utils/_ms/msv4_sub_xdss.py +516 -0
  15. xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/partition_queries.py +1 -1
  16. xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/partitions.py +1 -1
  17. xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/subtables.py +2 -2
  18. xradio/{vis/_vis_utils → correlated_data/_utils}/_utils/xds_helper.py +1 -1
  19. xradio/{vis/_vis_utils → correlated_data/_utils}/_zarr/read.py +1 -1
  20. xradio/{vis/_vis_utils → correlated_data/_utils}/_zarr/write.py +1 -1
  21. xradio/{vis/_vis_utils → correlated_data/_utils}/ms.py +1 -1
  22. xradio/{vis/_vis_utils → correlated_data/_utils}/zarr.py +4 -4
  23. xradio/{vis → correlated_data}/convert_msv2_to_processing_set.py +10 -3
  24. xradio/correlated_data/correlated_xds.py +13 -0
  25. xradio/{vis → correlated_data}/load_processing_set.py +13 -17
  26. xradio/{vis/read_processing_set.py → correlated_data/open_processing_set.py} +21 -23
  27. xradio/{vis/_processing_set.py → correlated_data/processing_set.py} +11 -12
  28. xradio/{vis → correlated_data}/schema.py +572 -186
  29. xradio/correlated_data/test__processing_set.py +74 -0
  30. xradio/image/_util/_casacore/xds_from_casacore.py +1 -1
  31. xradio/image/_util/_zarr/xds_from_zarr.py +1 -1
  32. xradio/image/_util/_zarr/zarr_low_level.py +1 -1
  33. {xradio-0.0.39.dist-info → xradio-0.0.41.dist-info}/METADATA +10 -10
  34. xradio-0.0.41.dist-info/RECORD +75 -0
  35. {xradio-0.0.39.dist-info → xradio-0.0.41.dist-info}/WHEEL +1 -1
  36. xradio/vis/_vis_utils/_ms/msv4_infos.py +0 -0
  37. xradio/vis/_vis_utils/_ms/msv4_sub_xdss.py +0 -351
  38. xradio-0.0.39.dist-info/RECORD +0 -73
  39. /xradio/{vis/_vis_utils → correlated_data/_utils}/__init__.py +0 -0
  40. /xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/_tables/load.py +0 -0
  41. /xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/_tables/table_query.py +0 -0
  42. /xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/_tables/write_exp_api.py +0 -0
  43. /xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/chunks.py +0 -0
  44. /xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/descr.py +0 -0
  45. /xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/msv2_msv3.py +0 -0
  46. /xradio/{vis/_vis_utils → correlated_data/_utils}/_ms/optimised_functions.py +0 -0
  47. /xradio/{vis/_vis_utils → correlated_data/_utils}/_utils/cds.py +0 -0
  48. /xradio/{vis/_vis_utils → correlated_data/_utils}/_utils/partition_attrs.py +0 -0
  49. /xradio/{vis/_vis_utils → correlated_data/_utils}/_utils/stokes_types.py +0 -0
  50. /xradio/{vis/_vis_utils → correlated_data/_utils}/_zarr/encoding.py +0 -0
  51. {xradio-0.0.39.dist-info → xradio-0.0.41.dist-info}/LICENSE.txt +0 -0
  52. {xradio-0.0.39.dist-info → xradio-0.0.41.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,74 @@
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()
@@ -5,7 +5,7 @@ from typing import List, Tuple, Union
5
5
 
6
6
  import dask
7
7
  import dask.array as da
8
- import graphviper.utils.logger as logger
8
+ import toolviper.utils.logger as logger
9
9
  import numpy as np
10
10
  import xarray as xr
11
11
  from astropy import units as u
@@ -1,7 +1,7 @@
1
1
  import copy
2
2
  import dask.array as da
3
3
 
4
- # import graphviper.utils.logger as logger
4
+ # import toolviper.utils.logger as logger
5
5
  import numpy as np
6
6
  import os
7
7
  import xarray as xr
@@ -112,7 +112,7 @@ def write_binary_blob_to_disk(arr, file_path, compressor):
112
112
  Returns:
113
113
  - None
114
114
  """
115
- import graphviper.utils.logger as logger
115
+ import toolviper.utils.logger as logger
116
116
 
117
117
  # Encode the NumPy array using the codec
118
118
  logger.debug("1. Before compressor " + file_path)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xradio
3
- Version: 0.0.39
3
+ Version: 0.0.41
4
4
  Summary: Xarray Radio Astronomy Data IO
5
5
  Author-email: Jan-Willem Steeb <jsteeb@nrao.edu>
6
6
  License: BSD 3-Clause License
@@ -43,17 +43,14 @@ License-File: LICENSE.txt
43
43
  Requires-Dist: astropy
44
44
  Requires-Dist: dask
45
45
  Requires-Dist: distributed
46
- Requires-Dist: graphviper
47
- Requires-Dist: matplotlib
46
+ Requires-Dist: toolviper
48
47
  Requires-Dist: numba >=0.57.0
49
48
  Requires-Dist: numpy
50
- Requires-Dist: prettytable
51
49
  Requires-Dist: pytest
52
50
  Requires-Dist: pytest-cov
53
51
  Requires-Dist: pytest-html
54
52
  Requires-Dist: s3fs
55
53
  Requires-Dist: scipy
56
- Requires-Dist: tqdm
57
54
  Requires-Dist: xarray
58
55
  Requires-Dist: zarr
59
56
  Requires-Dist: pyarrow
@@ -61,11 +58,6 @@ Requires-Dist: typeguard
61
58
  Requires-Dist: typing-extensions ; python_version < "3.10"
62
59
  Requires-Dist: python-casacore >=3.6.1 ; sys_platform != "darwin"
63
60
  Provides-Extra: docs
64
- Requires-Dist: jupyterlab ; extra == 'docs'
65
- Requires-Dist: ipykernel ; extra == 'docs'
66
- Requires-Dist: ipympl ; extra == 'docs'
67
- Requires-Dist: ipython ; extra == 'docs'
68
- Requires-Dist: jupyter-client ; extra == 'docs'
69
61
  Requires-Dist: nbsphinx ; extra == 'docs'
70
62
  Requires-Dist: recommonmark ; extra == 'docs'
71
63
  Requires-Dist: scanpydoc ; extra == 'docs'
@@ -74,6 +66,14 @@ Requires-Dist: sphinx-autosummary-accessors ; extra == 'docs'
74
66
  Requires-Dist: sphinx-rtd-theme ; extra == 'docs'
75
67
  Requires-Dist: twine ; extra == 'docs'
76
68
  Requires-Dist: pandoc ; extra == 'docs'
69
+ Provides-Extra: interactive
70
+ Requires-Dist: matplotlib ; extra == 'interactive'
71
+ Requires-Dist: prettytable ; extra == 'interactive'
72
+ Requires-Dist: jupyterlab ; extra == 'interactive'
73
+ Requires-Dist: ipykernel ; extra == 'interactive'
74
+ Requires-Dist: ipympl ; extra == 'interactive'
75
+ Requires-Dist: ipython ; extra == 'interactive'
76
+ Requires-Dist: jupyter-client ; extra == 'interactive'
77
77
 
78
78
  # xradio
79
79
  Xarray Radio Astronomy Data IO is still in development.
@@ -0,0 +1,75 @@
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,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (74.1.1)
2
+ Generator: setuptools (75.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
File without changes
@@ -1,351 +0,0 @@
1
- import graphviper.utils.logger as logger
2
- import time
3
- from typing import Tuple, Union
4
-
5
- import numpy as np
6
- import xarray as xr
7
-
8
- from xradio._utils.schema import column_description_casacore_to_msv4_measure
9
- from .subtables import subt_rename_ids
10
- from ._tables.read import make_taql_where_between_min_max, load_generic_table
11
-
12
-
13
- def interpolate_to_time(
14
- xds: xr.Dataset,
15
- interp_time: Union[xr.DataArray, None],
16
- message_prefix: str,
17
- time_name: str = "time",
18
- ) -> xr.Dataset:
19
- """
20
- Interpolate the time coordinate of the input xarray dataset to the
21
- a data array. This can be used for example to interpolate a pointing_xds
22
- to the time coord of the (main) MSv4, or similarly the ephemeris
23
- data variables of a field_and_source_xds.
24
-
25
- Uses interpolation method "linear", unless the source number of points is
26
- 1 in which case "nearest" is used, to avoid divide-by-zero issues.
27
-
28
- Parameters:
29
- ----------
30
- xds : xr.Dataset
31
- Xarray dataset to interpolate (presumably a pointing_xds or an xds of
32
- ephemeris variables)
33
- interp_time : Union[xr.DataArray, None]
34
- Time axis to interpolate the dataset to (usually main MSv4 time)
35
- message_prefix: str
36
- A prefix for info/debug/etc. messages
37
-
38
- Returns:
39
- -------
40
- interpolated_xds : xr.Dataset
41
- xarray dataset with time axis interpolated to interp_time.
42
- """
43
- if interp_time is not None:
44
- points_before = xds[time_name].size
45
- if points_before > 1:
46
- method = "linear"
47
- else:
48
- method = "nearest"
49
- xds = xds.interp({time_name: interp_time}, method=method, assume_sorted=True)
50
- points_after = xds[time_name].size
51
- logger.debug(
52
- f"{message_prefix}: interpolating the time coordinate "
53
- f"from {points_before} to {points_after} points"
54
- )
55
-
56
- return xds
57
-
58
-
59
- def create_weather_xds(in_file: str):
60
- """
61
- Creates a Weather Xarray Dataset from a MS v2 WEATHER table.
62
-
63
- Parameters
64
- ----------
65
- in_file : str
66
- Input MS name.
67
-
68
- Returns
69
- -------
70
- xr.Dataset
71
- Weather Xarray Dataset.
72
- """
73
- # Dictionaries that define the conversion from MSv2 to MSv4:
74
- # Dict from col/data_var names in generic_weather_xds (from MSv2) to MSV4
75
- # weather_xds produced here
76
- to_new_data_variable_names = {
77
- "H2O": "H2O",
78
- "IONOS_ELECTRON": "IONOS_ELECTRON",
79
- "PRESSURE": "PRESSURE",
80
- "REL_HUMIDITY": "REL_HUMIDITY",
81
- "TEMPERATURE": "TEMPERATURE",
82
- "DEW_POINT": "DEW_POINT",
83
- "WIND_DIRECTION": "WIND_DIRECTION",
84
- "WIND_SPEED": "WIND_SPEED",
85
- }
86
- data_variable_dims = {
87
- "H2O": ["station_id", "time"],
88
- "IONOS_ELECTRON": ["station_id", "time"],
89
- "PRESSURE": ["station_id", "time"],
90
- "REL_HUMIDITY": ["station_id", "time"],
91
- "TEMPERATURE": ["station_id", "time"],
92
- "DEW_POINT": ["station_id", "time"],
93
- "WIND_DIRECTION": ["station_id", "time"],
94
- "WIND_SPEED": ["station_id", "time"],
95
- }
96
- to_new_coord_names = {
97
- # No MS data cols are turned into xds coords
98
- }
99
- coord_dims = {
100
- # No MS data cols are turned into xds coords
101
- }
102
- to_new_dim_names = {
103
- "ANTENNA_ID": "STATION_ID",
104
- }
105
-
106
- # Read WEATHER table into a Xarray Dataset.
107
- try:
108
- generic_weather_xds = load_generic_table(
109
- in_file,
110
- "WEATHER",
111
- rename_ids=subt_rename_ids["WEATHER"],
112
- )
113
- except ValueError as _exc:
114
- return None
115
-
116
- generic_weather_xds = generic_weather_xds.rename_dims(to_new_dim_names)
117
-
118
- weather_column_description = generic_weather_xds.attrs["other"]["msv2"][
119
- "ctds_attrs"
120
- ]["column_descriptions"]
121
- # ['ANTENNA_ID', 'TIME', 'INTERVAL', 'H2O', 'IONOS_ELECTRON',
122
- # 'PRESSURE', 'REL_HUMIDITY', 'TEMPERATURE', 'DEW_POINT',
123
- # 'WIND_DIRECTION', 'WIND_SPEED']
124
- weather_xds = xr.Dataset(attrs={"type": "weather"})
125
- time_attrs = column_description_casacore_to_msv4_measure(
126
- weather_column_description["TIME"]
127
- )
128
- coords = {
129
- "station_id": generic_weather_xds["STATION_ID"].data,
130
- "time": ("time", generic_weather_xds["TIME"].data, time_attrs),
131
- }
132
- for key in generic_weather_xds:
133
- msv4_measure = column_description_casacore_to_msv4_measure(
134
- weather_column_description[key.upper()]
135
- )
136
- if key in to_new_data_variable_names:
137
- var_name = to_new_data_variable_names[key]
138
- weather_xds[var_name] = xr.DataArray(
139
- generic_weather_xds[key].data, dims=data_variable_dims[key]
140
- )
141
-
142
- if msv4_measure:
143
- weather_xds[var_name].attrs.update(msv4_measure)
144
-
145
- if key in ["INTERVAL"]:
146
- weather_xds[var_name].attrs.update({"units": ["s"], "type": "quantity"})
147
- elif key in ["H2O"]:
148
- weather_xds[var_name].attrs.update(
149
- {"units": ["/m^2"], "type": "quantity"}
150
- )
151
- elif key in ["IONOS_ELECTRON"]:
152
- weather_xds[var_name].attrs.update(
153
- {"units": ["/m^2"], "type": "quantity"}
154
- )
155
- elif key in ["PRESSURE"]:
156
- weather_xds[var_name].attrs.update(
157
- {"units": ["Pa"], "type": "quantity"}
158
- )
159
- elif key in ["REL_HUMIDITY"]:
160
- weather_xds[var_name].attrs.update({"units": ["%"], "type": "quantity"})
161
- elif key in ["TEMPERATURE"]:
162
- weather_xds[var_name].attrs.update({"units": ["K"], "type": "quantity"})
163
- elif key in ["DEW_POINT"]:
164
- weather_xds[var_name].attrs.update({"units": ["K"], "type": "quantity"})
165
- elif key in ["WIND_DIRECTION"]:
166
- weather_xds[var_name].attrs.update(
167
- {"units": ["rad"], "type": "quantity"}
168
- )
169
- elif key in ["WIND_SPEED"]:
170
- weather_xds[var_name].attrs.update(
171
- {"units": ["m/s"], "type": "quantity"}
172
- )
173
-
174
- if key in to_new_coord_names:
175
- coords[to_new_coord_names[key]] = (
176
- coord_dims[key],
177
- generic_weather_xds[key].data,
178
- )
179
-
180
- weather_xds = weather_xds.assign_coords(coords)
181
- return weather_xds
182
-
183
-
184
- def create_pointing_xds(
185
- in_file: str,
186
- ant_xds_name_ids: xr.DataArray,
187
- time_min_max: Union[Tuple[np.float64, np.float64], None],
188
- interp_time: Union[xr.DataArray, None] = None,
189
- ) -> xr.Dataset:
190
- """
191
- Creates a Pointing Xarray Dataset from an MS v2 POINTING (sub)table.
192
-
193
- WIP: details of a few direction variables (and possibly moving some to attributes) to be
194
- settled (see MSv4 spreadsheet).
195
-
196
- Parameters
197
- ----------
198
- in_file : str
199
- Input MS name.
200
- ant_xds_name_ids : xr.Dataset
201
- antenna_name data array from antenna_xds, with name/id information
202
- time_min_max : tuple
203
- min / max times values to constrain loading (from the TIME column)
204
- interp_time : Union[xr.DataArray, None] (Default value = None)
205
- interpolate time to this (presumably main dataset time)
206
-
207
- Returns
208
- -------
209
- xr.Dataset
210
- Pointing Xarray dataset
211
- """
212
- start = time.time()
213
-
214
- # Dictionaries that define the conversion from MSv2 to MSv4:
215
- to_new_data_variable_names = {
216
- # "name": "NAME", # removed
217
- # "time_origin": "TIME_ORIGIN", # removed?
218
- "DIRECTION": "BEAM_POINTING",
219
- "ENCODER": "DISH_MEASURED_POINTING",
220
- "TARGET": "TARGET", # => attribute?
221
- "POINTING_OFFSET": "POINTING_OFFSET",
222
- "SOURCE_OFFSET": "SOURCE_OFFSET",
223
- # "pointing_model_id": "POINTING_MODEL_ID", # removed
224
- # "tracking": "TRACKING", # => attribute
225
- # "on_source": "ON_SOURCE", # removed
226
- "OVER_THE_TOP": "OVER_THE_TOP",
227
- }
228
- time_ant_dims = ["time", "antenna_name"]
229
- time_ant_dir_dims = time_ant_dims + ["sky_dir_label"]
230
- data_variable_dims = {
231
- # "name": ["time", "antenna_name"], # removed
232
- # "time_origin": ["time", "antenna_name"], # removed?
233
- "DIRECTION": time_ant_dir_dims,
234
- "ENCODER": time_ant_dir_dims,
235
- "TARGET": time_ant_dir_dims,
236
- "POINTING_OFFSET": time_ant_dir_dims,
237
- "SOURCE_OFFSET": time_ant_dir_dims,
238
- # "pointing_model_id": ["time", "antenna_name"], # removed
239
- # "tracking": ["time", "antenna_name"], # => attribute
240
- # "on_source": ["time", "antenna_name"], # removed
241
- "OVER_THE_TOP": time_ant_dims,
242
- }
243
- # Unused here
244
- # to_new_coord_names = {"ra/dec": "direction"}
245
- # coord_dims = {}
246
-
247
- taql_time_range = make_taql_where_between_min_max(
248
- time_min_max, in_file, "POINTING", "TIME"
249
- )
250
- # Read POINTING table into a Xarray Dataset.
251
- generic_pointing_xds = load_generic_table(
252
- in_file,
253
- "POINTING",
254
- rename_ids=subt_rename_ids["POINTING"],
255
- taql_where=taql_time_range,
256
- )
257
- if not generic_pointing_xds.data_vars:
258
- # apparently empty MS/POINTING table => produce empty xds
259
- return xr.Dataset()
260
-
261
- # Checking a simple way of using only the one single coefficient of the polynomials
262
- if "n_polynomial" in generic_pointing_xds.sizes:
263
- size = generic_pointing_xds.sizes["n_polynomial"]
264
- if size == 1:
265
- generic_pointing_xds = generic_pointing_xds.sel({"n_polynomial": 0})
266
-
267
- pointing_column_descriptions = generic_pointing_xds.attrs["other"]["msv2"][
268
- "ctds_attrs"
269
- ]["column_descriptions"]
270
-
271
- pointing_xds = xr.Dataset(attrs={"type": "pointing"})
272
- for key in generic_pointing_xds:
273
- if key in to_new_data_variable_names:
274
- data_var_name = to_new_data_variable_names[key]
275
- # Corrects dim sizes of "empty cell" variables, such as empty DIRECTION, TARGET, etc.
276
- # TODO: this should be moved to a function when/if stable - perhaps 'correct_generic_pointing_xds'
277
- if (
278
- "dim_2" in generic_pointing_xds.sizes
279
- and generic_pointing_xds.sizes["dim_2"] == 0
280
- ):
281
- # When all direction variables are "empty"
282
- data_var_data = xr.DataArray(
283
- [[[[np.nan, np.nan]]]],
284
- dims=generic_pointing_xds.dims,
285
- ).isel(n_polynomial=0, drop=True)
286
- elif (
287
- "dir" in generic_pointing_xds.sizes
288
- and generic_pointing_xds.sizes["dir"] == 0
289
- ):
290
- # When some direction variables are "empty" but some are populated properly
291
- if "dim_2" in generic_pointing_xds[key].sizes:
292
- data_var_data = xr.DataArray(
293
- generic_pointing_xds[key].values,
294
- dims=generic_pointing_xds[key].dims,
295
- )
296
- else:
297
- shape = tuple(
298
- generic_pointing_xds.sizes[dim]
299
- for dim in ["TIME", "ANTENNA_ID"]
300
- ) + (2,)
301
- data_var_data = xr.DataArray(
302
- np.full(shape, np.nan),
303
- dims=generic_pointing_xds[key].dims,
304
- )
305
- else:
306
- data_var_data = generic_pointing_xds[key].data
307
-
308
- pointing_xds[data_var_name] = xr.DataArray(
309
- data_var_data, dims=data_variable_dims[key]
310
- )
311
-
312
- msv4_measure = column_description_casacore_to_msv4_measure(
313
- pointing_column_descriptions[key.upper()]
314
- )
315
- if msv4_measure:
316
- pointing_xds[data_var_name].attrs.update(msv4_measure)
317
-
318
- coords = {
319
- "time": generic_pointing_xds["TIME"].values,
320
- "antenna_name": ant_xds_name_ids.sel(
321
- antenna_id=generic_pointing_xds["ANTENNA_ID"]
322
- ).data,
323
- "sky_dir_label": ["ra", "dec"],
324
- }
325
- pointing_xds = pointing_xds.assign_coords(coords)
326
-
327
- # missing attributes
328
- pointing_xds["time"].attrs.update({"units": ["s"], "type": "quantity"})
329
-
330
- if "TRACKING" in generic_pointing_xds.data_vars:
331
- pointing_xds.attrs["tracking"] = generic_pointing_xds.data_vars[
332
- "TRACKING"
333
- ].values[0, 0]
334
-
335
- # Move target from data_vars to attributes?
336
- move_target_as_attr = False
337
- if move_target_as_attr:
338
- target = generic_pointing_xds.data_vars["TARGET"]
339
- pointing_xds.attrs["target"] = {
340
- "dims": ["sky_dir_label"],
341
- "data": target.values[0, 0].tolist(),
342
- "attrs": column_description_casacore_to_msv4_measure(
343
- pointing_column_descriptions["TARGET"]
344
- ),
345
- }
346
- # TODO: move also source_offset/pointing_offset from data_vars to attrs?
347
-
348
- pointing_xds = interpolate_to_time(pointing_xds, interp_time, "pointing_xds")
349
-
350
- logger.debug(f"create_pointing_xds() execution time {time.time() - start:0.2f} s")
351
- return pointing_xds