xradio 0.0.38__tar.gz → 0.0.40__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 (79) hide show
  1. {xradio-0.0.38/src/xradio.egg-info → xradio-0.0.40}/PKG-INFO +3 -2
  2. {xradio-0.0.38 → xradio-0.0.40}/pyproject.toml +3 -2
  3. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/__init__.py +1 -1
  4. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/_utils/common.py +41 -0
  5. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/_utils/schema.py +14 -3
  6. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/image/_util/_casacore/xds_from_casacore.py +1 -1
  7. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/image/_util/_zarr/xds_from_zarr.py +1 -1
  8. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/image/_util/_zarr/zarr_low_level.py +1 -1
  9. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_ms/_tables/load.py +5 -6
  10. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_ms/_tables/load_main_table.py +1 -1
  11. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_ms/_tables/read.py +58 -52
  12. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_ms/_tables/read_main_table.py +1 -1
  13. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_ms/_tables/read_subtables.py +1 -1
  14. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_ms/_tables/write.py +1 -1
  15. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_ms/conversion.py +1 -1
  16. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_ms/create_antenna_xds.py +1 -1
  17. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_ms/create_field_and_source_xds.py +208 -175
  18. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_ms/msv2_to_msv4_meta.py +1 -1
  19. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_ms/msv4_sub_xdss.py +133 -178
  20. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_ms/partition_queries.py +1 -1
  21. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_ms/partitions.py +1 -1
  22. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_ms/subtables.py +1 -1
  23. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_utils/xds_helper.py +10 -12
  24. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_zarr/read.py +1 -1
  25. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_zarr/write.py +1 -1
  26. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/ms.py +1 -1
  27. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/zarr.py +1 -1
  28. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/convert_msv2_to_processing_set.py +1 -1
  29. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/read_processing_set.py +1 -1
  30. {xradio-0.0.38 → xradio-0.0.40/src/xradio.egg-info}/PKG-INFO +3 -2
  31. {xradio-0.0.38 → xradio-0.0.40}/src/xradio.egg-info/requires.txt +2 -1
  32. {xradio-0.0.38 → xradio-0.0.40}/LICENSE.txt +0 -0
  33. {xradio-0.0.38 → xradio-0.0.40}/MANIFEST.in +0 -0
  34. {xradio-0.0.38 → xradio-0.0.40}/README.md +0 -0
  35. {xradio-0.0.38 → xradio-0.0.40}/setup.cfg +0 -0
  36. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/_utils/__init__.py +0 -0
  37. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/_utils/_casacore/tables.py +0 -0
  38. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/_utils/list_and_array.py +0 -0
  39. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/_utils/zarr/__init__.py +0 -0
  40. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/_utils/zarr/common.py +0 -0
  41. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/image/__init__.py +0 -0
  42. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/image/_util/__init__.py +0 -0
  43. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/image/_util/_casacore/__init__.py +0 -0
  44. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/image/_util/_casacore/common.py +0 -0
  45. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/image/_util/_casacore/xds_to_casacore.py +0 -0
  46. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/image/_util/_fits/xds_from_fits.py +0 -0
  47. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/image/_util/_zarr/common.py +0 -0
  48. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/image/_util/_zarr/xds_to_zarr.py +0 -0
  49. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/image/_util/casacore.py +0 -0
  50. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/image/_util/common.py +0 -0
  51. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/image/_util/fits.py +0 -0
  52. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/image/_util/image_factory.py +0 -0
  53. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/image/_util/zarr.py +0 -0
  54. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/image/image.py +0 -0
  55. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/schema/__init__.py +0 -0
  56. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/schema/bases.py +0 -0
  57. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/schema/check.py +0 -0
  58. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/schema/dataclass.py +0 -0
  59. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/schema/metamodel.py +0 -0
  60. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/schema/typing.py +0 -0
  61. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/__init__.py +0 -0
  62. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_processing_set.py +0 -0
  63. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/__init__.py +0 -0
  64. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_ms/_tables/table_query.py +0 -0
  65. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_ms/_tables/write_exp_api.py +0 -0
  66. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_ms/chunks.py +0 -0
  67. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_ms/descr.py +0 -0
  68. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_ms/msv2_msv3.py +0 -0
  69. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_ms/msv4_infos.py +0 -0
  70. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_ms/optimised_functions.py +0 -0
  71. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_utils/cds.py +0 -0
  72. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_utils/partition_attrs.py +0 -0
  73. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_utils/stokes_types.py +0 -0
  74. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/_vis_utils/_zarr/encoding.py +0 -0
  75. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/load_processing_set.py +0 -0
  76. {xradio-0.0.38 → xradio-0.0.40}/src/xradio/vis/schema.py +0 -0
  77. {xradio-0.0.38 → xradio-0.0.40}/src/xradio.egg-info/SOURCES.txt +0 -0
  78. {xradio-0.0.38 → xradio-0.0.40}/src/xradio.egg-info/dependency_links.txt +0 -0
  79. {xradio-0.0.38 → xradio-0.0.40}/src/xradio.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xradio
3
- Version: 0.0.38
3
+ Version: 0.0.40
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
@@ -44,9 +44,10 @@ Requires-Dist: astropy
44
44
  Requires-Dist: dask
45
45
  Requires-Dist: distributed
46
46
  Requires-Dist: graphviper
47
+ Requires-Dist: toolviper
47
48
  Requires-Dist: matplotlib
48
49
  Requires-Dist: numba>=0.57.0
49
- Requires-Dist: numpy<2.0.0
50
+ Requires-Dist: numpy
50
51
  Requires-Dist: prettytable
51
52
  Requires-Dist: pytest
52
53
  Requires-Dist: pytest-cov
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "xradio"
3
- version = "0.0.38"
3
+ version = "0.0.40"
4
4
  description = " Xarray Radio Astronomy Data IO"
5
5
  authors = [
6
6
  {name = "Jan-Willem Steeb", email="jsteeb@nrao.edu"},
@@ -14,9 +14,10 @@ dependencies = [
14
14
  'dask',
15
15
  'distributed',
16
16
  'graphviper',
17
+ 'toolviper',
17
18
  'matplotlib',
18
19
  'numba>=0.57.0',
19
- 'numpy<2.0.0',
20
+ 'numpy',
20
21
  'prettytable',
21
22
  'pytest',
22
23
  'pytest-cov',
@@ -1,5 +1,5 @@
1
1
  import os
2
- from graphviper.utils.logger import setup_logger
2
+ from toolviper.utils.logger import setup_logger
3
3
 
4
4
  # _logger_name = "xradio"
5
5
  # if os.getenv("VIPER_LOGGER_NAME") != _logger_name:
@@ -10,6 +10,47 @@ def cast_to_str(x):
10
10
  return x
11
11
 
12
12
 
13
+ def get_pad_value(col_dtype: np.dtype) -> object:
14
+ """
15
+ Produce a padding/missing/nan value appropriate for a casacore data column
16
+ (for when we need to pad data vars coming from columns with rows of
17
+ variable size array values)
18
+
19
+ Parameters
20
+ ----------
21
+ col_dtype : dtype
22
+ dtype of data being loaded from a table column
23
+
24
+ Returns
25
+ -------
26
+ object
27
+ pad value ("missing" / "fill") for the type given
28
+ """
29
+ # Fill values for missing/NaN data in integer variables, based on usual
30
+ # numpy fill values. See https://github.com/numpy/numpy/issues/21166,
31
+ # https://github.com/casangi/xradio/issues/219, https://github.com/casangi/xradio/pull/177
32
+ fill_value_int32 = np.int32(-2147483648)
33
+ fill_value_int64 = np.int64(-9223372036854775808)
34
+
35
+ if col_dtype == np.int32:
36
+ return fill_value_int32
37
+ elif col_dtype == np.int64 or col_dtype == "int":
38
+ return fill_value_int64
39
+ elif np.issubdtype(col_dtype, np.floating):
40
+ return np.nan
41
+ elif np.issubdtype(col_dtype, np.complexfloating):
42
+ return complex(np.nan, np.nan)
43
+ elif np.issubdtype(col_dtype, np.bool_):
44
+ return False
45
+ elif np.issubdtype(col_dtype, str):
46
+ return ""
47
+ else:
48
+ raise RuntimeError(
49
+ "Padding / missing value not defined for the type requested: "
50
+ f"{col_dtype} (of type: {type(col_dtype)})"
51
+ )
52
+
53
+
13
54
  def convert_to_si_units(xds):
14
55
  for data_var in xds.data_vars:
15
56
  if "units" in xds[data_var].attrs:
@@ -1,12 +1,12 @@
1
- import graphviper.utils.logger as logger
1
+ import toolviper.utils.logger as logger
2
2
  import xarray as xr
3
3
 
4
4
 
5
5
  def convert_generic_xds_to_xradio_schema(
6
6
  generic_xds: xr.Dataset,
7
7
  msv4_xds: xr.Dataset,
8
- to_new_data_variables: dict,
9
- to_new_coords: dict,
8
+ to_new_data_variables: dict[str, list],
9
+ to_new_coords: dict[str, list],
10
10
  ) -> xr.Dataset:
11
11
  """Converts a generic xarray Dataset to the xradio schema.
12
12
 
@@ -55,6 +55,7 @@ def convert_generic_xds_to_xradio_schema(
55
55
  "column_descriptions"
56
56
  ]
57
57
  coords = {}
58
+ coord_attrs = {}
58
59
 
59
60
  name_keys = list(generic_xds.data_vars.keys()) + list(generic_xds.coords.keys())
60
61
 
@@ -80,7 +81,14 @@ def convert_generic_xds_to_xradio_schema(
80
81
  new_coord[1],
81
82
  generic_xds[key].data,
82
83
  )
84
+
85
+ if msv4_measure:
86
+ coord_attrs[new_coord[0]] = msv4_measure
87
+
83
88
  msv4_xds = msv4_xds.assign_coords(coords)
89
+ for coord, coord_attrs in coord_attrs.items():
90
+ msv4_xds.coords[coord].attrs.update(coord_attrs)
91
+
84
92
  return msv4_xds
85
93
 
86
94
 
@@ -102,6 +110,9 @@ def column_description_casacore_to_msv4_measure(
102
110
  casacore_column_description["keywords"]["QuantumUnits"]
103
111
  )
104
112
 
113
+ # Beware: casa_ref won't be found in cases such as the custom
114
+ # 'NRAO_GBT_USER/NRAO_GBT_USER_DIR_REF' in POINTING
115
+ casa_ref = None
105
116
  # Reference frame to convert?
106
117
  if "Ref" in msv4_measure_conversion:
107
118
  # Find reference frame
@@ -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,8 +1,10 @@
1
1
  from typing import Tuple
2
2
 
3
- from casacore import tables
4
3
  import numpy as np
5
4
 
5
+ from casacore import tables
6
+ from ....._utils.common import get_pad_value
7
+
6
8
 
7
9
  def load_col_chunk(
8
10
  tb_tool: tables.table,
@@ -53,11 +55,8 @@ def load_col_chunk(
53
55
  data = tb_tool.getcolslice(col, (d1[0], d2[0]), (d1[1], d2[1]), [], 0, -1)
54
56
 
55
57
  # full data is the maximum of the data shape and chunk shape dimensions
56
- policy = "warn"
57
- if np.issubdtype(data.dtype, np.integer):
58
- policy = "ignore"
59
- with np.errstate(invalid=policy):
60
- chunk = np.full(cshape, np.nan, dtype=data.dtype)
58
+ fill_value = get_pad_value(data.dtype)
59
+ chunk = np.full(cshape, np.fill_value, dtype=data.dtype)
61
60
  if len(didxs) > 0:
62
61
  chunk[tidxs[didxs], bidxs[didxs]] = data[didxs]
63
62
 
@@ -1,4 +1,4 @@
1
- import graphviper.utils.logger as logger
1
+ import toolviper.utils.logger as logger
2
2
  from typing import Dict, List, Tuple, Union
3
3
 
4
4
  import pandas as pd
@@ -1,4 +1,4 @@
1
- import graphviper.utils.logger as logger
1
+ import toolviper.utils.logger as logger
2
2
  import os
3
3
  from pathlib import Path
4
4
  import re
@@ -12,6 +12,7 @@ import astropy.units
12
12
  from casacore import tables
13
13
 
14
14
  from .table_query import open_query, open_table_ro
15
+ from ....._utils.common import get_pad_value
15
16
 
16
17
  CASACORE_TO_PD_TIME_CORRECTION = 3_506_716_800.0
17
18
  SECS_IN_DAY = 86400
@@ -393,35 +394,6 @@ def make_freq_attrs(spw_xds: xr.Dataset, spw_id: int) -> Dict[str, Any]:
393
394
  return cf_attrs
394
395
 
395
396
 
396
- def get_pad_nan(col: np.ndarray) -> np.ndarray:
397
- """
398
- Produce a padding/nan value appropriate for a data column
399
- (for when we need to pad data vars coming from columns with rows of
400
- variable size array values)
401
-
402
- Parameters
403
- ----------
404
- col : np.ndarray
405
- data being loaded from a table column
406
-
407
- Returns
408
- -------
409
- np.ndarray
410
- nan ("nan") value for the type of the input column
411
- """
412
- # This is causing frequent warnings for integers. Cast of nan to "int nan"
413
- # produces -2147483648 but also seems to trigger a
414
- # "RuntimeWarning: invalid value encountered in cast" (new in numpy>=1.24)
415
- policy = "warn"
416
- col_type = np.array(col).dtype
417
- if np.issubdtype(col_type, np.integer):
418
- policy = "ignore"
419
- with np.errstate(invalid=policy):
420
- pad_nan = np.array([np.nan]).astype(col_type)[0]
421
-
422
- return pad_nan
423
-
424
-
425
397
  def redimension_ms_subtable(xds: xr.Dataset, subt_name: str) -> xr.Dataset:
426
398
  """
427
399
  Expand a MeasurementSet subtable xds from single dimension (row)
@@ -471,13 +443,12 @@ def redimension_ms_subtable(xds: xr.Dataset, subt_name: str) -> xr.Dataset:
471
443
  # (ANTENNA_ID=0, TIME=0) and no other columns to figure out the right IDs, such
472
444
  # as "NS_WX_STATION_ID" or similar. (example: X425.pm04.scan4.ms)
473
445
  # - Some GBT MSs have duplicated (ANTENNA_ID=0, TIME=xxx). (example: analytic_variable.ms)
474
- with np.errstate(invalid="ignore"):
475
- rxds = (
476
- rxds.set_index(row=key_dims)
477
- .drop_duplicates("row")
478
- .unstack("row")
479
- .transpose(*key_dims, ...)
480
- )
446
+ rxds = (
447
+ rxds.set_index(row=key_dims)
448
+ .drop_duplicates("row")
449
+ .unstack("row")
450
+ .transpose(*key_dims, ...)
451
+ )
481
452
  # unstack changes type to float when it needs to introduce NaNs, so
482
453
  # we need to reset to the original type.
483
454
  for var in rxds.data_vars:
@@ -999,13 +970,47 @@ def raw_col_data_to_coords_vars(
999
970
  return array_type, array_data
1000
971
 
1001
972
 
973
+ def get_pad_value_in_tablerow_column(trows: tables.tablerow, col: str) -> object:
974
+ """
975
+ Gets the pad value for the type of a column (IMPORTANTLY) as froun in the
976
+ the type specified in the row / column value dict returned by tablerow.
977
+ This can differ from the type of the column as given in the casacore
978
+ column descriptions. See https://github.com/casangi/xradio/issues/242.
979
+
980
+ Parameters
981
+ ----------
982
+ trows : tables.tablerow
983
+ list of rows from a table as loaded by tables.row()
984
+ col: str
985
+ get the pad value for this column
986
+
987
+ Returns
988
+ -------
989
+ object
990
+ pad value as produced by get_pad_value for the appropriate data type from
991
+ tablerow
992
+ """
993
+ col_value = trows[0][col]
994
+ if isinstance(col_value, np.ndarray):
995
+ col_dtype = col_value.dtype
996
+ elif isinstance(col_value, list):
997
+ col_dtype = type(col_value[0])
998
+ else:
999
+ raise RuntimeError(
1000
+ "Found unexpected type (not np.array or list) in column value of "
1001
+ f"first row of column {col}: {col_value}"
1002
+ )
1003
+
1004
+ return get_pad_value(col_dtype)
1005
+
1006
+
1002
1007
  def handle_variable_col_issues(
1003
1008
  inpath: str, col: str, col_type: str, trows: tables.tablerow
1004
1009
  ) -> np.ndarray:
1005
1010
  """
1006
- load variable-size array columns, padding with nans wherever
1007
- needed. This happens for example often in the SPECTRAL_WINDOW
1008
- table (CHAN_WIDTH, EFFECTIVE_BW, etc.).
1011
+ load variable-size array columns, padding with missing/fill/nans
1012
+ wherever needed. This happens for example often in the
1013
+ SPECTRAL_WINDOW table (CHAN_WIDTH, EFFECTIVE_BW, etc.).
1009
1014
  Also handle exceptions gracefully when trying to load the rows.
1010
1015
 
1011
1016
  Parameters
@@ -1015,7 +1020,7 @@ def handle_variable_col_issues(
1015
1020
  col : str
1016
1021
  column being loaded
1017
1022
  col_type : str
1018
- type of the column cell values
1023
+ type of the column cell values (as numpy dtype string)
1019
1024
  trows : tables.tablerow
1020
1025
  rows from a table as loaded by tables.row()
1021
1026
 
@@ -1030,7 +1035,8 @@ def handle_variable_col_issues(
1030
1035
 
1031
1036
  mshape = np.array(max([np.array(row[col]).shape for row in trows]))
1032
1037
  try:
1033
- pad_nan = get_pad_nan(np.array((), dtype=col_type))
1038
+ pad_val = None
1039
+ pad_val = get_pad_value_in_tablerow_column(trows, col)
1034
1040
 
1035
1041
  # TODO
1036
1042
  # benchmark np.stack() performance
@@ -1044,13 +1050,13 @@ def handle_variable_col_issues(
1044
1050
  ),
1045
1051
  [(0, ss) for ss in mshape - np.array(row[col]).shape],
1046
1052
  "constant",
1047
- constant_values=pad_nan,
1053
+ constant_values=pad_val,
1048
1054
  )
1049
1055
  for row in trows
1050
1056
  ]
1051
1057
  )
1052
1058
  except Exception as exc:
1053
- msg = f"{inpath}: failed to load data for column {col}: {exc}"
1059
+ msg = f"{inpath}: failed to load data for column {col}, with {pad_val=}: {exc}"
1054
1060
  if col in known_misbehaving_cols:
1055
1061
  logger.debug(msg)
1056
1062
  else:
@@ -1178,12 +1184,8 @@ def read_col_chunk(
1178
1184
  elif len(cshape) == 4: # DATA and FLAG
1179
1185
  data = query.getcolslice(col, (d1[0], d2[0]), (d1[1], d2[1]), [], 0, -1)
1180
1186
 
1181
- policy = "warn"
1182
- if np.issubdtype(data.dtype, np.integer):
1183
- policy = "ignore"
1184
- with np.errstate(invalid=policy):
1185
- # full data is the maximum of the data shape and chunk shape dimensions
1186
- fulldata = np.full(cshape, np.nan, dtype=data.dtype)
1187
+ fill_value = get_pad_value(data.dtype)
1188
+ fulldata = np.full(cshape, fill_value, dtype=data.dtype)
1187
1189
 
1188
1190
  if len(didxs) > 0:
1189
1191
  fulldata[tidxs[didxs], bidxs[didxs]] = data[didxs]
@@ -1250,9 +1252,11 @@ def read_col_conversion(
1250
1252
 
1251
1253
  # Get dtype of the column. Only read first row from disk
1252
1254
  col_dtype = np.array(tb_tool.col(col)[0]).dtype
1255
+ # Use a custom/safe fill value (https://github.com/casangi/xradio/issues/219)
1256
+ fill_value = get_pad_value(col_dtype)
1253
1257
 
1254
1258
  # Construct a numpy array to populate. `data` has shape (n_times, n_baselines, n_frequencies, n_polarizations)
1255
- data = np.full(cshape + extra_dimensions, np.nan, dtype=col_dtype)
1259
+ data = np.full(cshape + extra_dimensions, fill_value, dtype=col_dtype)
1256
1260
 
1257
1261
  # Use built-in casacore table iterator to populate the data column by unique times.
1258
1262
  if use_table_iter:
@@ -1261,7 +1265,9 @@ def read_col_conversion(
1261
1265
  num_rows = ts.nrows()
1262
1266
 
1263
1267
  # Create small temporary array to store the partial column
1264
- tmp_arr = np.full((num_rows,) + extra_dimensions, np.nan, dtype=col_dtype)
1268
+ tmp_arr = np.full(
1269
+ (num_rows,) + extra_dimensions, fill_value, dtype=col_dtype
1270
+ )
1265
1271
 
1266
1272
  # Note we don't use `getcol()` because it's less safe. See:
1267
1273
  # https://github.com/casacore/python-casacore/issues/130#issuecomment-463202373
@@ -1,4 +1,4 @@
1
- import graphviper.utils.logger as logger
1
+ import toolviper.utils.logger as logger
2
2
  from typing import Any, Dict, List, Tuple, Union
3
3
 
4
4
  import dask, dask.array
@@ -1,4 +1,4 @@
1
- import graphviper.utils.logger as logger
1
+ import toolviper.utils.logger as logger
2
2
  from pathlib import Path
3
3
  from typing import Dict, Tuple, Union
4
4
 
@@ -1,4 +1,4 @@
1
- import graphviper.utils.logger as logger, os
1
+ import toolviper.utils.logger as logger, os
2
2
  from typing import Tuple
3
3
 
4
4
  import numpy as np
@@ -2,7 +2,7 @@ import numcodecs
2
2
  import time
3
3
  from .._zarr.encoding import add_encoding
4
4
  from typing import Dict, Union
5
- import graphviper.utils.logger as logger
5
+ import toolviper.utils.logger as logger
6
6
  import os
7
7
  import pathlib
8
8
 
@@ -1,4 +1,4 @@
1
- import graphviper.utils.logger as logger
1
+ import toolviper.utils.logger as logger
2
2
  import time
3
3
  from typing import Tuple, Union
4
4