@@ -164,7 +164,7 @@ def _add_lauetof_instrument(nx_entry: h5py.Group):
164164
165165
166166def _add_lauetof_detector_group (dg : sc .DataGroup , nx_instrument : h5py .Group ) -> None :
167- nx_detector = nx_instrument .create_group (dg ["name" ]) # Detector name
167+ nx_detector = nx_instrument .create_group (dg ["name" ]. value ) # Detector name
168168 nx_detector .attrs ["NX_class" ] = "NXdetector"
169169 # Polar angle
170170 _create_dataset_from_var (
@@ -181,22 +181,19 @@ def _add_lauetof_detector_group(dg: sc.DataGroup, nx_instrument: h5py.Group) ->
181181 # Data - shape: [n_x_pixels, n_y_pixels, n_tof_bins]
182182 # The actual application definition defines it as integer,
183183 # but we keep the original data type for now
184+ num_x , num_y = dg ["detector_shape" ].values [0 ] # Probably better way to do this...
184185 _create_dataset_from_var (
185186 name = "data" ,
186187 root_entry = nx_detector ,
187- var = sc .scalar ( 0 , unit = '' ), # TODO: Add real data
188+ var = sc .fold ( dg [ "counts" ]. data , dim = 'id' , sizes = { 'x' : num_x , 'y' : num_y }),
188189 )
189190 # x_pixel_size
190191 _create_dataset_from_var (
191- name = "x_pixel_size" ,
192- root_entry = nx_detector ,
193- var = sc .scalar (0 , unit = 'mm' ), # TODO: Add real data
192+ name = "x_pixel_size" , root_entry = nx_detector , var = dg ["x_pixel_size" ]
194193 )
195194 # y_pixel_size
196195 _create_dataset_from_var (
197- name = "y_pixel_size" ,
198- root_entry = nx_detector ,
199- var = sc .scalar (0 , unit = 'mm' ), # TODO: Add real data
196+ name = "y_pixel_size" , root_entry = nx_detector , var = dg ["y_pixel_size" ]
200197 )
201198 # distance
202199 _create_dataset_from_var (
@@ -208,7 +205,7 @@ def _add_lauetof_detector_group(dg: sc.DataGroup, nx_instrument: h5py.Group) ->
208205 _create_dataset_from_var (
209206 name = "time_of_flight" ,
210207 root_entry = nx_detector ,
211- var = sc .scalar ( 0 , unit = 's' ), # TODO: Add real data
208+ var = sc .midpoints ( dg [ "counts" ]. coords [ 't' ]),
212209 # It should be actual time of flight values of each bin
213210 # Not sure if it should be median/mean of the bin or bin edges
214211 )
@@ -274,6 +271,7 @@ def export_panel_independent_data_as_nxlauetof(
274271 _add_lauetof_definition (nx_entry )
275272 _add_lauetof_instrument (nx_entry )
276273 _add_lauetof_sample_group (data , nx_entry )
274+ # Placeholder for ``monitor`` group
277275 _add_lauetof_monitor_group (data , nx_entry )
278276 # Skipping ``name`` field
279277
@@ -288,10 +286,12 @@ def export_panel_dependent_data_as_nxlauetof(
288286
289287
290288def export_as_nxlauetof (
291- data : sc .DataGroup , output_file : str | pathlib .Path | io .BytesIO
289+ dg : sc . DataGroup , * dgs : sc .DataGroup , output_file : str | pathlib .Path | io .BytesIO
292290) -> None :
293291 """Export the reduced data into a nxlauetof format.
294292
295293 Exporting step is not expected to be part of sciline pipelines.
296294 """
297- export_panel_independent_data_as_nxlauetof (data , output_file )
295+
296+ export_panel_independent_data_as_nxlauetof (dg , output_file )
297+ export_panel_dependent_data_as_nxlauetof (dg , * dgs , output_file = output_file )
0 commit comments