3333test_file = "./example_data/2d_data/BAM_2D.h5"
3434# test_file = "./example_data/2d_data/14250_2D_NoDetInfo_NXcanSAS_v3.h5"
3535# test_file = "./example_data/2d_data/33837rear_2D_1.75_16.5_NXcanSAS_v3.h5"
36+ test_file = "./test/sasdataloader/data/nxcansas_1Dand2D_multisasentry_multisasdata.h5"
3637
3738logger = logging .getLogger (__name__ )
3839
@@ -178,11 +179,8 @@ def find_canSAS_key(node: HDF5Group, canSAS_class: str):
178179 return matches
179180
180181def parse_quantity (node : HDF5Group ) -> Quantity [float ]:
181- """Pull a single quantity with length units out of an HDF5 node"""
182- if node .shape == (): # scalar dataset
183- magnitude = node .astype (float )[()]
184- else : # vector dataset
185- magnitude = node .astype (float )[0 ]
182+ """Pull a single quantity with units out of an HDF5 node"""
183+ magnitude = parse_float (node )
186184 unit = node .attrs ["units" ]
187185 return Quantity (magnitude , parse (unit ))
188186
@@ -193,7 +191,7 @@ def parse_string(node : HDF5Group) -> str:
193191 else : # vector dataset
194192 return node .asstr ()[0 ]
195193
196- def parse_float_first (node : HDF5Group ) -> float :
194+ def parse_float (node : HDF5Group ) -> float :
197195 """Return the first element (or scalar) of a numeric dataset as float."""
198196 if node .shape == ():
199197 return float (node [()].astype (str ))
@@ -319,7 +317,7 @@ def parse_sample(node : HDF5Group) -> Sample:
319317 name = attr_parse (node , "name" )
320318 sample_id = opt_parse (node , "ID" , parse_string )
321319 thickness = opt_parse (node , "thickness" , parse_quantity )
322- transmission = opt_parse (node , "transmission" , parse_float_first )
320+ transmission = opt_parse (node , "transmission" , parse_float )
323321 temperature = opt_parse (node , "temperature" , parse_quantity )
324322 position = opt_parse (node , "position" , parse_vec3 )
325323 orientation = opt_parse (node , "orientation" , parse_rot3 )
0 commit comments