From ccca1a03edf74dc265e5532032d77f066e9af68a Mon Sep 17 00:00:00 2001 From: Federico Montesino Pouzols Date: Wed, 10 Jun 2026 10:47:30 +0200 Subject: [PATCH] allow None as (no-) compressor(s) and document it, #579 --- src/xradio/measurement_set/_utils/_msv2/conversion.py | 4 ++-- src/xradio/measurement_set/_utils/_zarr/encoding.py | 3 ++- src/xradio/measurement_set/convert_msv2_to_processing_set.py | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/xradio/measurement_set/_utils/_msv2/conversion.py b/src/xradio/measurement_set/_utils/_msv2/conversion.py index 58c3de86..e77d86e8 100644 --- a/src/xradio/measurement_set/_utils/_msv2/conversion.py +++ b/src/xradio/measurement_set/_utils/_msv2/conversion.py @@ -1012,7 +1012,7 @@ def convert_and_write_partition( ephemeris_interpolate: bool = False, phase_cal_interpolate: bool = False, sys_cal_interpolate: bool = False, - compressor: zarr.abc.codec.BytesBytesCodec = zarr.codecs.ZstdCodec(level=2), + compressor: zarr.abc.codec.BytesBytesCodec | None = zarr.codecs.ZstdCodec(level=2), add_reshaping_indices: bool = False, storage_backend="zarr", parallel_mode: str = "none", @@ -1503,7 +1503,7 @@ def antenna_ids_to_names( xds = xds.assign_coords({"antenna_name": xds["baseline_id"].data}) xds = xds.drop_vars("baseline_id") - # drop more vars that seem unwanted in main_sd_xds, but there shouuld be a better way + # drop more vars that seem unwanted in main_sd_xds, but there should be a better way # of not creating them in the first place unwanted_coords_sd = ["baseline_antenna1_id", "baseline_antenna2_id"] for unwanted_coord in unwanted_coords_sd: diff --git a/src/xradio/measurement_set/_utils/_zarr/encoding.py b/src/xradio/measurement_set/_utils/_zarr/encoding.py index c22a173c..d90a0922 100644 --- a/src/xradio/measurement_set/_utils/_zarr/encoding.py +++ b/src/xradio/measurement_set/_utils/_zarr/encoding.py @@ -6,4 +6,5 @@ def add_encoding(xds, compressor, chunks=None): for da_name in list(xds.data_vars): da_chunks = [chunks[dim_name] for dim_name in xds[da_name].sizes] - xds[da_name].encoding = {"compressors": (compressor,), "chunks": da_chunks} + compressors = (compressor,) if compressor else () + xds[da_name].encoding = {"compressors": compressors, "chunks": da_chunks} diff --git a/src/xradio/measurement_set/convert_msv2_to_processing_set.py b/src/xradio/measurement_set/convert_msv2_to_processing_set.py index 6aad20c2..dd7bc507 100644 --- a/src/xradio/measurement_set/convert_msv2_to_processing_set.py +++ b/src/xradio/measurement_set/convert_msv2_to_processing_set.py @@ -66,7 +66,7 @@ def convert_msv2_to_processing_set( phase_cal_interpolate: bool = False, sys_cal_interpolate: bool = False, use_table_iter: bool = False, - compressor: zarr.abc.codec.BytesBytesCodec = zarr.codecs.ZstdCodec(level=2), + compressor: zarr.abc.codec.BytesBytesCodec | None = zarr.codecs.ZstdCodec(level=2), add_reshaping_indices: bool = False, storage_backend: Literal["zarr", "netcdf"] = "zarr", parallel_mode: Literal["none", "partition", "time"] = "none", @@ -114,7 +114,7 @@ def convert_msv2_to_processing_set( use_table_iter : bool, optional Whether to use the table iterator to read the main table of the MS v2. This should be set to True when reading datasets with large number of rows and few partitions, by default False. compressor : numcodecs.abc.Codec, optional - The Blosc compressor to use when saving the converted data to disk using Zarr, by default numcodecs.Zstd(level=2). + The compressor to use when saving the converted data to disk using Zarr, by default numcodecs.Zstd(level=2). None disables compression. add_reshaping_indices : bool, optional Whether to add the tidxs, bidxs and row_id variables to each partition of the main dataset. These can be used to reshape the data back to the original ordering in the MS v2. This is mainly intended for testing and debugging, by default False. storage_backend : Literal["zarr", "netcdf"], optional