From bd0c99de88aecf27a2dfa7d079c150c36b59ffca Mon Sep 17 00:00:00 2001 From: Juan Marulanda Date: Wed, 31 Jan 2024 16:38:32 -0500 Subject: [PATCH 1/4] Modified definition of dim_name to fix an error when xarrays are generated in databroker --- nslsii/areadetector/xspress3.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nslsii/areadetector/xspress3.py b/nslsii/areadetector/xspress3.py index e097ac02..7d160f7d 100644 --- a/nslsii/areadetector/xspress3.py +++ b/nslsii/areadetector/xspress3.py @@ -136,11 +136,14 @@ class Xspress3ExternalFileReference(Signal): """ - def __init__(self, *args, dtype_str="uint32", bin_count=4096, dim_name="bin_count", **kwargs): + def __init__(self, *args, dtype_str="uint32", bin_count=4096, dim_name=["frame_number", "number_channels", "bin_count"], **kwargs): super().__init__(*args, **kwargs) self.dtype_str = dtype_str self.shape = (bin_count,) - self.dims = (dim_name,) + if isinstance(dim_name, str): + self.dims = (dim_name,) # Keeping this option for backwards compatibility with some beamlines + else: + self.dims = (*dim_name,) def describe(self): res = super().describe() From 1770cb933f33bf6a3033f01ca6b116ab2e3cb187 Mon Sep 17 00:00:00 2001 From: Juan Marulanda Date: Wed, 31 Jan 2024 17:03:13 -0500 Subject: [PATCH 2/4] Optimized init to include tuples --- nslsii/areadetector/xspress3.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nslsii/areadetector/xspress3.py b/nslsii/areadetector/xspress3.py index 7d160f7d..ea0ad040 100644 --- a/nslsii/areadetector/xspress3.py +++ b/nslsii/areadetector/xspress3.py @@ -136,14 +136,16 @@ class Xspress3ExternalFileReference(Signal): """ - def __init__(self, *args, dtype_str="uint32", bin_count=4096, dim_name=["frame_number", "number_channels", "bin_count"], **kwargs): + def __init__(self, *args, dtype_str="uint32", bin_count=4096, dim_name=("frame_number", "number_channels", "bin_count"), **kwargs): super().__init__(*args, **kwargs) self.dtype_str = dtype_str self.shape = (bin_count,) if isinstance(dim_name, str): self.dims = (dim_name,) # Keeping this option for backwards compatibility with some beamlines - else: + elif isinstance(dim_name, list): self.dims = (*dim_name,) + else: + self.dims = dim_name def describe(self): res = super().describe() From f41736d7bab95d7ae8051c53c3c72e82a4ce77ed Mon Sep 17 00:00:00 2001 From: Juan Marulanda Date: Wed, 31 Jan 2024 17:34:25 -0500 Subject: [PATCH 3/4] Updated test case to support a larger default dim_name --- nslsii/tests/test_xspress3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nslsii/tests/test_xspress3.py b/nslsii/tests/test_xspress3.py index 452dcc59..4261d205 100644 --- a/nslsii/tests/test_xspress3.py +++ b/nslsii/tests/test_xspress3.py @@ -143,7 +143,7 @@ def test_instantiate_channel_class(): assert channel_2.image.dtype_str == "uint32" assert channel_2.image.shape == (4096,) - assert channel_2.image.dims == ("bin_count",) + assert channel_2.image.dims == ('frame_number', 'number_channels', 'bin_count',) assert channel_2.get_external_file_ref().name == "channel_2_image" assert channel_2.sca.clock_ticks.pvname == "Xsp3:C2SCA:0:Value_RBV" From 97be9f13e716085e6feb2edc345b5d546d51d40f Mon Sep 17 00:00:00 2001 From: Juan Marulanda Date: Mon, 20 May 2024 21:10:00 -0400 Subject: [PATCH 4/4] Added pending reviews --- nslsii/areadetector/xspress3.py | 2 +- nslsii/tests/test_xspress3.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nslsii/areadetector/xspress3.py b/nslsii/areadetector/xspress3.py index ea0ad040..eddb2c83 100644 --- a/nslsii/areadetector/xspress3.py +++ b/nslsii/areadetector/xspress3.py @@ -141,7 +141,7 @@ def __init__(self, *args, dtype_str="uint32", bin_count=4096, dim_name=("frame_n self.dtype_str = dtype_str self.shape = (bin_count,) if isinstance(dim_name, str): - self.dims = (dim_name,) # Keeping this option for backwards compatibility with some beamlines + self.dims = (dim_name,) # Keeping this option for backward compatibility with some beamlines elif isinstance(dim_name, list): self.dims = (*dim_name,) else: diff --git a/nslsii/tests/test_xspress3.py b/nslsii/tests/test_xspress3.py index 4261d205..a5578d13 100644 --- a/nslsii/tests/test_xspress3.py +++ b/nslsii/tests/test_xspress3.py @@ -143,7 +143,7 @@ def test_instantiate_channel_class(): assert channel_2.image.dtype_str == "uint32" assert channel_2.image.shape == (4096,) - assert channel_2.image.dims == ('frame_number', 'number_channels', 'bin_count',) + assert channel_2.image.dims == ("frame_number", "number_channels", "bin_count",) assert channel_2.get_external_file_ref().name == "channel_2_image" assert channel_2.sca.clock_ticks.pvname == "Xsp3:C2SCA:0:Value_RBV"