1111from typing import Any , NamedTuple , Optional
1212
1313import h5py
14- import numpy as np
1514from numpy .typing import ArrayLike
1615from pydantic import field_validator
1716
17+ from nexgen .tools .vds_tools import define_vds_dtype_from_bit_depth
1818from nexgen .utils import get_iso_timestamp
1919
2020from .. import log
@@ -230,6 +230,7 @@ def eiger_writer(
230230 vds_offset : int = 0 ,
231231 notes : dict [str , Any ] | None = None ,
232232 data_entry_key : str = "data" ,
233+ bit_depth : int = 32 ,
233234):
234235 """
235236 A function to call the NXmx nexus file writer for Eiger 2X 4M detector.
@@ -251,6 +252,8 @@ def eiger_writer(
251252 dataset name and value its data. Defaults to None.
252253 data_entry_key (str, optional): Dataset entry key in datafiles. eg. for gating mode it's data1.\
253254 Defaults to data.
255+ bit_depth(int, optional): Default bit depth for eiger collections, used to define dtype of vds data. \
256+ Defaults to 32.
254257
255258 Raises:
256259 ValueError: If use_meta is set to False but axes_pos and det_pos haven't been passed.
@@ -338,7 +341,7 @@ def eiger_writer(
338341 logger .info (
339342 "Not using meta file to update metadata, only the external links will be set up."
340343 )
341- vds_dtype = np . uint32
344+ vds_dtype = define_vds_dtype_from_bit_depth ( bit_depth )
342345 # Update axes
343346 # Goniometer
344347 for gax in TR .axes_pos :
@@ -457,6 +460,7 @@ def serial_nexus_writer(
457460 use_meta : bool = False ,
458461 vds_offset : int = 0 ,
459462 n_frames : int | None = None ,
463+ bit_depth : int = 32 ,
460464 notes : dict [str , Any ] | None = None ,
461465):
462466 """Wrapper function to gather all parameters from the beamline and kick off the nexus writer for a \
@@ -473,6 +477,8 @@ def serial_nexus_writer(
473477 n_frames (int | None, optional): Number of images for the nexus file. Only needed if different \
474478 from the tot_num_images in the collection params. If passed, the VDS will only contain the \
475479 number of frames specified here. Defaults to None.
480+ bit_depth(int, optional): Default bit depth for eiger collections, used to define dtype of vds data. \
481+ Defaults to 32.
476482 notes (dict[str, Any] | None, optional): Any additional information to be written as NXnote, \
477483 passed as a dictionary of (key, value) pairs where key represents the dataset name and \
478484 value its data. Defaults to None.
@@ -511,7 +517,8 @@ def serial_nexus_writer(
511517 use_meta ,
512518 n_frames ,
513519 vds_offset ,
514- notes ,
520+ bit_depth = bit_depth ,
521+ notes = notes ,
515522 )
516523 case DetectorName .TRISTAN :
517524 tristan_writer (master_file , collection_params , timestamps , notes )
@@ -523,6 +530,7 @@ def nexus_writer(
523530 timestamps : tuple [datetime , datetime ] = (None , None ),
524531 use_meta : bool = False ,
525532 data_entry_key : str = "data" ,
533+ bit_depth : int = 32 ,
526534):
527535 """Wrapper function to gather all parameters from the beamline and kick off the nexus writer for a \
528536 standard experiment on I19-2.
@@ -536,6 +544,8 @@ def nexus_writer(
536544 all parameters will need to be passed manually. Defaults to False.
537545 data_entry_key (str, optional): Dataset entry key in datafiles. eg. for gating mode it's data1.\
538546 Defaults to data.
547+ bit_depth(int, optional): Default bit depth for eiger collections, used to define dtype of vds data. \
548+ Defaults to 32.
539549 """
540550 collection_params = CollectionParams (** params )
541551 wdir = master_file .parent
@@ -603,6 +613,7 @@ def nexus_writer(
603613 timestamps ,
604614 use_meta ,
605615 data_entry_key = data_entry_key ,
616+ bit_depth = bit_depth ,
606617 )
607618 case DetectorName .TRISTAN :
608619 tristan_writer (
0 commit comments