xradio 0.0.27__tar.gz → 0.0.29__tar.gz

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 (91) hide show
  1. {xradio-0.0.27 → xradio-0.0.29}/LICENSE.txt +6 -1
  2. {xradio-0.0.27/src/xradio.egg-info → xradio-0.0.29}/PKG-INFO +11 -6
  3. {xradio-0.0.27 → xradio-0.0.29}/pyproject.toml +23 -6
  4. xradio-0.0.29/src/xradio/__init__.py +13 -0
  5. xradio-0.0.29/src/xradio/_utils/array.py +90 -0
  6. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/_utils/zarr/common.py +48 -3
  7. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/image/_util/_fits/xds_from_fits.py +10 -5
  8. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/image/_util/_zarr/zarr_low_level.py +27 -24
  9. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/image/_util/common.py +4 -1
  10. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/image/_util/zarr.py +4 -1
  11. xradio-0.0.29/src/xradio/schema/__init__.py +35 -0
  12. xradio-0.0.29/src/xradio/schema/bases.py +444 -0
  13. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/schema/check.py +96 -55
  14. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/schema/dataclass.py +123 -27
  15. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/schema/metamodel.py +21 -4
  16. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/schema/typing.py +33 -18
  17. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/__init__.py +5 -2
  18. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_processing_set.py +30 -9
  19. xradio-0.0.29/src/xradio/vis/_vis_utils/_ms/_tables/create_field_and_source_xds.py +710 -0
  20. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/_ms/_tables/load.py +23 -10
  21. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/_ms/_tables/load_main_table.py +145 -64
  22. xradio-0.0.29/src/xradio/vis/_vis_utils/_ms/_tables/read.py +1254 -0
  23. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/_ms/_tables/read_main_table.py +176 -45
  24. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/_ms/_tables/read_subtables.py +79 -28
  25. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/_ms/_tables/write.py +102 -45
  26. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/_ms/_tables/write_exp_api.py +127 -65
  27. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/_ms/chunks.py +58 -21
  28. xradio-0.0.29/src/xradio/vis/_vis_utils/_ms/conversion.py +912 -0
  29. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/_ms/descr.py +52 -20
  30. xradio-0.0.29/src/xradio/vis/_vis_utils/_ms/msv2_to_msv4_meta.py +146 -0
  31. xradio-0.0.29/src/xradio/vis/_vis_utils/_ms/msv4_infos.py +0 -0
  32. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/_ms/msv4_sub_xdss.py +76 -9
  33. xradio-0.0.29/src/xradio/vis/_vis_utils/_ms/optimised_functions.py +0 -0
  34. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/_ms/partition_queries.py +308 -119
  35. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/_ms/partitions.py +82 -25
  36. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/_ms/subtables.py +32 -14
  37. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/_utils/partition_attrs.py +30 -11
  38. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/_utils/xds_helper.py +136 -45
  39. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/_zarr/read.py +60 -22
  40. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/_zarr/write.py +83 -9
  41. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/ms.py +48 -29
  42. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/zarr.py +44 -20
  43. xradio-0.0.29/src/xradio/vis/convert_msv2_to_processing_set.py +172 -0
  44. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/load_processing_set.py +38 -61
  45. xradio-0.0.29/src/xradio/vis/read_processing_set.py +116 -0
  46. xradio-0.0.29/src/xradio/vis/schema.py +687 -0
  47. xradio-0.0.29/src/xradio/vis/vis_io.py +146 -0
  48. {xradio-0.0.27 → xradio-0.0.29/src/xradio.egg-info}/PKG-INFO +11 -6
  49. {xradio-0.0.27 → xradio-0.0.29}/src/xradio.egg-info/SOURCES.txt +3 -1
  50. {xradio-0.0.27 → xradio-0.0.29}/src/xradio.egg-info/requires.txt +3 -3
  51. xradio-0.0.27/src/xradio/__init__.py +0 -12
  52. xradio-0.0.27/src/xradio/schema/__init__.py +0 -17
  53. xradio-0.0.27/src/xradio/schema/bases.py +0 -6
  54. xradio-0.0.27/src/xradio/vis/_vis_utils/_ms/_tables/read.py +0 -628
  55. xradio-0.0.27/src/xradio/vis/_vis_utils/_ms/conversion.py +0 -443
  56. xradio-0.0.27/src/xradio/vis/_vis_utils/_ms/msv2_to_msv4_meta.py +0 -111
  57. xradio-0.0.27/src/xradio/vis/_vis_utils/_ms/msv4_infos.py +0 -59
  58. xradio-0.0.27/src/xradio/vis/_vis_utils/_ms/optimised_functions.py +0 -46
  59. xradio-0.0.27/src/xradio/vis/convert_msv2_to_processing_set.py +0 -98
  60. xradio-0.0.27/src/xradio/vis/model.py +0 -497
  61. xradio-0.0.27/src/xradio/vis/read_processing_set.py +0 -150
  62. xradio-0.0.27/src/xradio/vis/vis_io.py +0 -114
  63. {xradio-0.0.27 → xradio-0.0.29}/MANIFEST.in +0 -0
  64. {xradio-0.0.27 → xradio-0.0.29}/README.md +0 -0
  65. {xradio-0.0.27 → xradio-0.0.29}/setup.cfg +0 -0
  66. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/_utils/__init__.py +0 -0
  67. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/_utils/_casacore/tables.py +0 -0
  68. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/_utils/common.py +0 -0
  69. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/_utils/zarr/__init__.py +0 -0
  70. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/image/__init__.py +0 -0
  71. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/image/_util/__init__.py +0 -0
  72. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/image/_util/_casacore/__init__.py +0 -0
  73. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/image/_util/_casacore/common.py +0 -0
  74. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/image/_util/_casacore/xds_from_casacore.py +0 -0
  75. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/image/_util/_casacore/xds_to_casacore.py +0 -0
  76. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/image/_util/_zarr/common.py +0 -0
  77. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/image/_util/_zarr/xds_from_zarr.py +0 -0
  78. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/image/_util/_zarr/xds_to_zarr.py +0 -0
  79. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/image/_util/casacore.py +0 -0
  80. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/image/_util/fits.py +0 -0
  81. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/image/_util/image_factory.py +0 -0
  82. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/image/image.py +0 -0
  83. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/__init__.py +0 -0
  84. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/_ms/_tables/table_query.py +0 -0
  85. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/_ms/msv2_msv3.py +0 -0
  86. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/_utils/cds.py +0 -0
  87. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/_utils/stokes_types.py +0 -0
  88. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/_zarr/encoding.py +0 -0
  89. {xradio-0.0.27 → xradio-0.0.29}/src/xradio/vis/_vis_utils/ms_column_descriptions_dicts.py +0 -0
  90. {xradio-0.0.27 → xradio-0.0.29}/src/xradio.egg-info/dependency_links.txt +0 -0
  91. {xradio-0.0.27 → xradio-0.0.29}/src/xradio.egg-info/top_level.txt +0 -0
@@ -1,6 +1,11 @@
1
1
  BSD 3-Clause License
2
2
 
3
- Copyright (c) 2023, Associated Universities, Inc.
3
+ All works in this repository are copyrighted 2024.
4
+ For inquiries contact Associated Universities, Inc., 2650 Park Tower Drive Vienna, VA 22180, USA.
5
+
6
+ Portions of this repository are copyrighted by the following entities:
7
+ 1. AUI/NRAO, ESO, NAOJ, in the framework of the ALMA partnership.
8
+ 2. AUI/NRAO in the framework of the ngVLA project.
4
9
 
5
10
  Redistribution and use in source and binary forms, with or without
6
11
  modification, are permitted provided that the following conditions are met:
@@ -1,11 +1,16 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xradio
3
- Version: 0.0.27
4
- Summary: Xarray Radio Astronomy Data IO
3
+ Version: 0.0.29
4
+ Summary: Xarray Radio Astronomy Data IO
5
5
  Author-email: Jan-Willem Steeb <jsteeb@nrao.edu>
6
6
  License: BSD 3-Clause License
7
7
 
8
- Copyright (c) 2023, Associated Universities, Inc.
8
+ All works in this repository are copyrighted 2024.
9
+ For inquiries contact Associated Universities, Inc., 2650 Park Tower Drive Vienna, VA 22180, USA.
10
+
11
+ Portions of this repository are copyrighted by the following entities:
12
+ 1. AUI/NRAO, ESO, NAOJ, in the framework of the ALMA partnership.
13
+ 2. AUI/NRAO in the framework of the ngVLA project.
9
14
 
10
15
  Redistribution and use in source and binary forms, with or without
11
16
  modification, are permitted provided that the following conditions are met:
@@ -42,7 +47,7 @@ Requires-Dist: distributed
42
47
  Requires-Dist: graphviper
43
48
  Requires-Dist: matplotlib
44
49
  Requires-Dist: numba>=0.57.0
45
- Requires-Dist: numpy
50
+ Requires-Dist: numpy<2.0.0
46
51
  Requires-Dist: prettytable
47
52
  Requires-Dist: pytest
48
53
  Requires-Dist: pytest-cov
@@ -52,12 +57,12 @@ Requires-Dist: scipy
52
57
  Requires-Dist: tqdm
53
58
  Requires-Dist: xarray
54
59
  Requires-Dist: zarr
55
- Requires-Dist: bokeh
56
- Requires-Dist: jupyterlab
57
60
  Requires-Dist: pyarrow
58
61
  Requires-Dist: python_casacore>=3.5.2; sys_platform != "darwin"
59
62
  Requires-Dist: typing_extensions; python_version < "3.10"
63
+ Requires-Dist: typeguard
60
64
  Provides-Extra: docs
65
+ Requires-Dist: jupyterlab; extra == "docs"
61
66
  Requires-Dist: ipykernel; extra == "docs"
62
67
  Requires-Dist: ipympl; extra == "docs"
63
68
  Requires-Dist: ipython; extra == "docs"
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "xradio"
3
- version = "0.0.27"
4
- description = "Xarray Radio Astronomy Data IO"
3
+ version = "0.0.29"
4
+ description = " Xarray Radio Astronomy Data IO"
5
5
  authors = [
6
6
  {name = "Jan-Willem Steeb", email="jsteeb@nrao.edu"},
7
7
  ]
@@ -17,7 +17,7 @@ dependencies = [
17
17
  'graphviper',
18
18
  'matplotlib',
19
19
  'numba>=0.57.0',
20
- 'numpy',
20
+ 'numpy<2.0.0',
21
21
  'prettytable',
22
22
  'pytest',
23
23
  'pytest-cov',
@@ -27,15 +27,15 @@ dependencies = [
27
27
  'tqdm',
28
28
  'xarray',
29
29
  'zarr',
30
- 'bokeh',
31
- 'jupyterlab',
32
30
  'pyarrow',
33
31
  'python_casacore>=3.5.2; sys_platform != "darwin" ',
34
- 'typing_extensions; python_version < "3.10"'
32
+ 'typing_extensions; python_version < "3.10"',
33
+ 'typeguard'
35
34
  ]
36
35
 
37
36
  [project.optional-dependencies]
38
37
  docs = [
38
+ 'jupyterlab',
39
39
  'ipykernel',
40
40
  'ipympl',
41
41
  'ipython',
@@ -49,3 +49,20 @@ docs = [
49
49
  'twine',
50
50
  'pandoc'
51
51
  ]
52
+
53
+ [tool.pytest.ini_options]
54
+ addopts = [
55
+ "--import-mode=importlib",
56
+ "--strict-markers"
57
+ ]
58
+ testpaths = [
59
+ "tests"
60
+ ]
61
+ pythonpath = [
62
+ "."
63
+ ]
64
+
65
+ [tool.black]
66
+ line-length = 88
67
+ target-version = ['py39']
68
+ include = '\.py$'
@@ -0,0 +1,13 @@
1
+ import os
2
+ from graphviper.utils.logger import setup_logger
3
+
4
+ _logger_name = "xradio"
5
+ if os.getenv("VIPER_LOGGER_NAME") != _logger_name:
6
+ os.environ["VIPER_LOGGER_NAME"] = _logger_name
7
+ setup_logger(
8
+ logger_name="xradio",
9
+ log_to_term=True,
10
+ log_to_file=False, # True
11
+ log_file="xradio-logfile",
12
+ log_level="DEBUG",
13
+ )
@@ -0,0 +1,90 @@
1
+ """Contains optimised functions to be used within other modules."""
2
+
3
+ import numpy as np
4
+
5
+
6
+ def check_if_consistent(array: np.ndarray, array_name: str) -> np.ndarray:
7
+ """_summary_
8
+
9
+ Parameters
10
+ ----------
11
+ col : _type_
12
+ _description_
13
+ col_name : _type_
14
+ _description_
15
+
16
+ Returns
17
+ -------
18
+ _type_
19
+ _description_
20
+ """
21
+ if array.ndim == 0:
22
+ return array.item()
23
+
24
+ array_unique = unique_1d(array)
25
+ assert len(array_unique) == 1, array_name + " is not consistent."
26
+ return array_unique[0]
27
+
28
+
29
+ import numpy as np
30
+ import pandas as pd
31
+
32
+
33
+ def unique_1d(array: np.ndarray) -> np.ndarray:
34
+ """
35
+ Optimised version of np.unique for 1D arrays.
36
+
37
+ Parameters
38
+ ----------
39
+ array : np.ndarray
40
+ a 1D array of values.
41
+
42
+ Returns
43
+ -------
44
+ np.ndarray
45
+ a sorted array of unique values.
46
+
47
+ """
48
+ return np.sort(pd.unique(array))
49
+
50
+
51
+ def pairing_function(antenna_pairs: np.ndarray) -> np.ndarray:
52
+ """
53
+ Pairing function to convert each array pair to a single value.
54
+
55
+ This custom pairing function will only work if the maximum value is less
56
+ than 2**20 and less than 2,048 if using signed 32-bit integers.
57
+
58
+ Parameters
59
+ ----------
60
+ antenna_pairs : np.ndarray
61
+ a 2D array containing antenna 1 and antenna
62
+ 2 ids, which forms a baseline.
63
+
64
+ Returns
65
+ -------
66
+ np.ndarray
67
+ a 1D array of the paired values.
68
+
69
+ """
70
+ return antenna_pairs[:, 0] * 2**20 + antenna_pairs[:, 1]
71
+
72
+
73
+ def inverse_pairing_function(paired_array: np.ndarray) -> np.ndarray:
74
+ """
75
+ Inverse pairing function to convert each paired value to an antenna pair.
76
+
77
+ This inverse pairing function is the inverse of the custom pairing function.
78
+
79
+ Parameters
80
+ ----------
81
+ paired_array : np.ndarray
82
+ a 1D array of the paired values.
83
+
84
+ Returns
85
+ -------
86
+ np.ndarray
87
+ a 2D array containing antenna 1 and antenna 2 ids.
88
+
89
+ """
90
+ return np.column_stack(np.divmod(paired_array, 2**20))
@@ -2,9 +2,54 @@ import copy
2
2
  import xarray as xr
3
3
  import zarr
4
4
  import s3fs
5
+ import os
6
+ from botocore.exceptions import NoCredentialsError
7
+
8
+
9
+ def _get_ms_stores_and_file_system(ps_store: str):
10
+
11
+ if os.path.isdir(ps_store):
12
+ # default to assuming the data are accessible on local file system
13
+ items = os.listdir(ps_store)
14
+ file_system = os
15
+
16
+ elif ps_store.startswith("s3"):
17
+ # only if not found locally, check if dealing with an S3 bucket URL
18
+ # if not ps_store.endswith("/"):
19
+ # # just for consistency, as there is no os.path equivalent in s3fs
20
+ # ps_store = ps_store + "/"
21
+
22
+ try:
23
+ # initialize the S3 "file system", first attempting to use pre-configured credentials
24
+ file_system = s3fs.S3FileSystem(anon=False, requester_pays=False)
25
+ items = [
26
+ bd.split(sep="/")[-1]
27
+ for bd in file_system.listdir(ps_store, detail=False)
28
+ ]
29
+
30
+ except (NoCredentialsError, PermissionError) as e:
31
+ # only public, read-only buckets will be accessible
32
+ # we will want to add messaging and error handling here
33
+ file_system = s3fs.S3FileSystem(anon=True)
34
+ items = [
35
+ bd.split(sep="/")[-1]
36
+ for bd in file_system.listdir(ps_store, detail=False)
37
+ ]
38
+ else:
39
+ raise (
40
+ FileNotFoundError,
41
+ f"Could not find {ps_store} either locally or in the cloud.",
42
+ )
43
+
44
+ items = [
45
+ item for item in items if not item.startswith(".")
46
+ ] # Mac OS likes to place hidden files in the directory (.DStore).
47
+ return file_system, items
5
48
 
6
49
 
7
- def _open_dataset(store, xds_isel=None, data_variables=None, load=False, **kwargs):
50
+ def _open_dataset(
51
+ store, file_system=os, xds_isel=None, data_variables=None, load=False
52
+ ):
8
53
  """
9
54
 
10
55
  Parameters
@@ -26,8 +71,8 @@ def _open_dataset(store, xds_isel=None, data_variables=None, load=False, **kwarg
26
71
 
27
72
  import dask
28
73
 
29
- if "s3" in kwargs.keys():
30
- mapping = s3fs.S3Map(root=store, s3=kwargs["s3"], check=False)
74
+ if isinstance(file_system, s3fs.core.S3FileSystem):
75
+ mapping = s3fs.S3Map(root=store, s3=file_system, check=False)
31
76
  xds = xr.open_zarr(store=mapping)
32
77
  else:
33
78
  xds = xr.open_zarr(store)
@@ -101,7 +101,7 @@ def _add_vel_attrs(xds: xr.Dataset, helpers: dict) -> xr.Dataset:
101
101
  vel_coord = xds.coords["velocity"]
102
102
  meta = {"units": "m/s"}
103
103
  if helpers["has_freq"]:
104
- meta["doppler_type"] = helpers["doppler"]
104
+ meta["doppler_type"] = helpers.get("doppler", "RADIO")
105
105
  else:
106
106
  meta["doppler_type"] = _doppler_types[0]
107
107
  meta["type"] = "doppler"
@@ -570,8 +570,8 @@ def _get_freq_values(helpers: dict) -> list:
570
570
  crval=helpers["crval"][freq_idx],
571
571
  crpix=helpers["crpix"][freq_idx],
572
572
  cdelt=helpers["cdelt"][freq_idx],
573
- cunit=helpers["cunit"][freq_idx],
574
573
  )
574
+ cunit = helpers["cunit"][freq_idx]
575
575
  helpers["frequency"] = vals * u.Unit(cunit)
576
576
  return vals
577
577
  elif "VOPT" in ctype:
@@ -606,9 +606,9 @@ def _get_velocity_values(helpers: dict) -> list:
606
606
  return helpers["velocity"].to(u.m / u.s).value
607
607
  elif "frequency" in helpers:
608
608
  v = _compute_velocity_values(
609
- restfreq=helpers["reestfreq"],
609
+ restfreq=helpers["restfreq"],
610
610
  freq_values=helpers["frequency"].to("Hz").value,
611
- doppler=helpers["doppler"],
611
+ doppler=helpers.get("doppler", "RADIO"),
612
612
  )
613
613
  helpers["velocity"] = v * (u.m / u.s)
614
614
  return v
@@ -796,7 +796,12 @@ def _get_transpose_list(helpers: dict) -> tuple:
796
796
  transpose_list[4] = i
797
797
  not_covered.remove("m")
798
798
  not_covered.remove("v")
799
- elif b.startswith("frequency") or b.startswith("vopt") or b.startswith("vrad"):
799
+ elif (
800
+ b.startswith("frequency")
801
+ or b.startswith("freq")
802
+ or b.startswith("vopt")
803
+ or b.startswith("vrad")
804
+ ):
800
805
  transpose_list[2] = i
801
806
  not_covered.remove("f")
802
807
  elif b.startswith("stok"):
@@ -110,53 +110,56 @@ def write_binary_blob_to_disk(arr, file_path, compressor):
110
110
  - None
111
111
  """
112
112
  import graphviper.utils.logger as logger
113
+
113
114
  # Encode the NumPy array using the codec
114
- logger.debug('1. Before compressor ' + file_path)
115
+ logger.debug("1. Before compressor " + file_path)
115
116
  compressed_arr = compressor.encode(np.ascontiguousarray(arr))
116
117
 
117
- logger.debug('2. Before makedir')
118
+ logger.debug("2. Before makedir")
118
119
  # Ensure the directory exists before saving the file
119
120
  os.makedirs(os.path.dirname(file_path), exist_ok=True)
120
121
 
121
122
  arr_len = len(compressed_arr)
122
- logger.debug('3. Before write the len is: ' + str(arr_len))
123
- #Save the compressed array to disk
123
+ logger.debug("3. Before write the len is: " + str(arr_len))
124
+ # Save the compressed array to disk
124
125
  # with open(file_path, "wb") as file:
125
126
  # file.write(compressed_arr)
126
-
127
- logger.debug('4. Using new writer: ' + str(arr_len))
127
+
128
+ logger.debug("4. Using new writer: " + str(arr_len))
128
129
  write_to_lustre_chunked(file_path, compressed_arr)
129
-
130
+
130
131
  # /.lustre/aoc/sciops/pford/CHILES/cube_image/uid___A002_Xee7674_X2844_Cube_3.img.zarr/SKY/0.0.110.0.0
131
132
  # 348192501 bytes
132
133
  # 332.0622453689575 M
133
-
134
+
134
135
  # from io import BufferedWriter
135
136
  # # Calculate buffer size based on compressed_arr size (adjust multiplier)
136
137
  # buffer_size = min(len(compressed_arr), 1024 * 1024 * 4) # Max 4 MB buffer
137
138
  # with BufferedWriter(open(file_path, "wb"), buffer_size) as f:
138
139
  # f.write(compressed_arr)
139
- # f.flush() # Ensure data gets written to disk
140
-
141
-
142
- logger.debug('4. Write completed')
140
+ # f.flush() # Ensure data gets written to disk
141
+
142
+ logger.debug("4. Write completed")
143
143
 
144
144
  # print(f"Compressed array saved to {file_path}")
145
145
 
146
146
 
147
- def write_to_lustre_chunked(file_path, compressed_arr, chunk_size=1024 * 1024 * 128): # 128 MiB chunks
148
- """
149
- Writes compressed data to a Lustre file path with chunking.
147
+ def write_to_lustre_chunked(
148
+ file_path, compressed_arr, chunk_size=1024 * 1024 * 128
149
+ ): # 128 MiB chunks
150
+ """
151
+ Writes compressed data to a Lustre file path with chunking.
152
+
153
+ Args:
154
+ file_path: Path to the file for writing.
155
+ compressed_arr: Compressed data array to write.
156
+ chunk_size: Size of each data chunk in bytes (default: 128 MiB).
157
+ """
158
+ with open(file_path, "wb") as f:
159
+ for i in range(0, len(compressed_arr), chunk_size):
160
+ chunk = compressed_arr[i : i + chunk_size]
161
+ f.write(chunk)
150
162
 
151
- Args:
152
- file_path: Path to the file for writing.
153
- compressed_arr: Compressed data array to write.
154
- chunk_size: Size of each data chunk in bytes (default: 128 MiB).
155
- """
156
- with open(file_path, "wb") as f:
157
- for i in range(0, len(compressed_arr), chunk_size):
158
- chunk = compressed_arr[i:i + chunk_size]
159
- f.write(chunk)
160
163
 
161
164
  def read_binary_blob_from_disk(file_path, compressor, dtype=np.float64):
162
165
  """
@@ -33,7 +33,10 @@ def _convert_beam_to_rad(beam: dict) -> dict:
33
33
  """
34
34
  mybeam = {}
35
35
  for k in beam:
36
- q = u.quantity.Quantity(f"{beam[k]['value']}{beam[k]['unit']}")
36
+ try:
37
+ q = u.quantity.Quantity(f"{beam[k]['value']}{beam[k]['unit']}")
38
+ except:
39
+ q = u.quantity.Quantity(f"{beam[k]['value']}{beam[k]['units']}")
37
40
  q = q.to("rad")
38
41
  j = "pa" if k == "positionangle" else k
39
42
  mybeam[j] = {"type": "quantity", "value": q.value, "units": "rad"}
@@ -25,7 +25,10 @@ def _xds_from_zarr(
25
25
 
26
26
 
27
27
  def _load_image_from_zarr_no_dask(zarr_file: str, selection: dict) -> xr.Dataset:
28
- image_xds = _open_dataset(zarr_file, selection, load=True)
28
+ # At the moment image module does not support S3 file system. file_system=os is hardcoded.
29
+ image_xds = _open_dataset(
30
+ store=zarr_file, file_system=os, xds_isel=selection, load=True
31
+ )
29
32
  for h in ["HISTORY", "_attrs_xds_history"]:
30
33
  history = os.sep.join([zarr_file, h])
31
34
  if os.path.isdir(history):
@@ -0,0 +1,35 @@
1
+ from .dataclass import (
2
+ xarray_dataclass_to_array_schema,
3
+ xarray_dataclass_to_dataset_schema,
4
+ xarray_dataclass_to_dict_schema,
5
+ )
6
+ from .bases import (
7
+ xarray_dataarray_schema,
8
+ xarray_dataset_schema,
9
+ dict_schema,
10
+ )
11
+ from .check import (
12
+ SchemaIssue,
13
+ SchemaIssues,
14
+ check_array,
15
+ check_dataset,
16
+ check_dict,
17
+ schema_checked,
18
+ )
19
+
20
+ __all__ = [
21
+ "xarray_dataclass_to_array_schema",
22
+ "xarray_dataclass_to_dataset_schema",
23
+ "xarray_dataclass_to_dict_schema",
24
+ "AsDataArray",
25
+ "AsDataset",
26
+ "AsDict",
27
+ "xarray_dataarray_schema",
28
+ "xarray_dataset_schema",
29
+ "SchemaIssue",
30
+ "SchemaIssues",
31
+ "check_array",
32
+ "check_dataset",
33
+ "check_dict",
34
+ "schema_checked",
35
+ ]