coseda.nexus package

Submodules

coseda.nexus.detector module

Helpers for detector geometry metadata in NeXus.

coseda.nexus.detector.write_detector_geometry(h5file, camera_length_m, correction_factor=1.0)[source]

Store camera length metadata and NXtransformations for detector placement.

  • camera_length: given value from microscope (m)

  • camera_length_correction: dimensionless multiplier

  • camera_length_effective: corrected length (m)

  • transformations/det_z: translation along +Z by corrected length

Parameters:
  • h5file (h5py.File)

  • camera_length_m (float)

  • correction_factor (float)

Return type:

None

coseda.nexus.goniometer module

Helpers for NeXus goniometer transform chains.

coseda.nexus.goniometer.ensure_goniometer_transforms(h5file, transform_order=None)[source]

Create a goniometer transform chain: stage_z -> alpha -> beta -> stage_x -> stage_y (all relative to sample_pos).

Parameters:
  • h5file (h5py.File)

  • transform_order (str | Sequence[str] | None)

Return type:

None

coseda.nexus.goniometer.get_goniometer_transform_order(config)[source]
Return type:

Tuple[str, …] | None

coseda.nexus.groups module

Helpers to ensure NeXus parent groups exist with NX_class attributes.

coseda.nexus.groups.ensure_nexus_parents(h5file)[source]

Create core NeXus parent groups and set NX_class attributes.

Parameters:

h5file (h5py.File)

Return type:

None

coseda.nexus.images module

NeXus-friendly NXdata view for image stacks.

coseda.nexus.images.ensure_image_nxdata(h5file)[source]

Create an NXdata view for the image dataset without moving the legacy data.

Parameters:

h5file (h5py.File)

Return type:

None

coseda.nexus.indices module

Helpers for index mappings between dense and sparse frame streams.

coseda.nexus.indices.ensure_image_key(h5file)[source]

Ensure /entry/data/image_key exists, mapping current frames to original indices.

If an index dataset exists and matches the image length, reuse it (unless it already contains stripped markers). Otherwise, fall back to arange.

Parameters:

h5file (h5py.File)

Return type:

None

coseda.nexus.logs module

Helpers for dense NXlog views over full-length metadata streams.

coseda.nexus.logs.ensure_dense_logs(h5file)[source]

Create NXlog views for dense metadata streams under /entry/instrument.

Parameters:

h5file (h5py.File)

Return type:

None

coseda.nexus.paths module

NeXus path constants and lookup helpers.

coseda.nexus.paths.get_first_existing_path(h5file, paths)[source]

Return the first existing HDF5 path from paths, or None.

Parameters:

paths (Iterable[str])

Return type:

str | None

coseda.nexus.paths.get_mask_dataset(h5file)[source]

Return the mask dataset if present (NeXus preferred), else None.

coseda.nexus.paths.normalize_dataset_path(path, default='/mask')[source]

Return an absolute HDF5 path for a dataset name.

Parameters:
  • path (str)

  • default (str)

Return type:

str

coseda.nexus.peaks module

NeXus-friendly NXdata views for peakfinding outputs.

coseda.nexus.peaks.ensure_peak_nxdata(h5file)[source]

Create NXdata views for peakfinding outputs without moving legacy datasets.

Parameters:

h5file (h5py.File)

Return type:

None

coseda.nexus.process module

Helpers for writing NeXus NXprocess metadata.

coseda.nexus.process.write_beam_incident_energy(h5file, energy_ev)[source]

Ensure NXbeam exists and write incident_energy in eV.

Parameters:
  • h5file (h5py.File)

  • energy_ev (float)

Return type:

None

coseda.nexus.process.write_nxprocess_centerfinding(h5file, program, method=None, parameters=None, input_path=None, output_path=None)[source]

Write an NXprocess record for beam center finding.

Parameters:
  • h5file (h5py.File)

  • program (str)

  • method (str | None)

  • parameters (Dict[str, Any] | None)

  • input_path (str | None)

  • output_path (str | None)

Return type:

None

coseda.nexus.process.write_nxprocess_centerrefinement(h5file, program, method=None, parameters=None, input_path=None, output_path=None)[source]

Write an NXprocess record for beam center refinement.

Parameters:
  • h5file (h5py.File)

  • program (str)

  • method (str | None)

  • parameters (Dict[str, Any] | None)

  • input_path (str | None)

  • output_path (str | None)

Return type:

None

coseda.nexus.process.write_nxprocess_import(h5file, program, parameters=None, input_path=None, output_path=None)[source]

Write an NXprocess record for import/conversion steps.

Parameters:
  • h5file (h5py.File)

  • program (str)

  • parameters (Dict[str, Any] | None)

  • input_path (str | None)

  • output_path (str | None)

Return type:

None

coseda.nexus.process.write_nxprocess_indexing(h5file, program, method=None, parameters=None, input_path=None, output_path=None)[source]

Write an NXprocess record for indexing/integration runs.

Parameters:
  • h5file (h5py.File)

  • program (str)

  • method (str | None)

  • parameters (Dict[str, Any] | None)

  • input_path (str | None)

  • output_path (str | None)

Return type:

None

coseda.nexus.process.write_nxprocess_merging(h5file, program, method=None, parameters=None, input_path=None, output_path=None)[source]

Write an NXprocess record for merging runs.

Parameters:
  • h5file (h5py.File)

  • program (str)

  • method (str | None)

  • parameters (Dict[str, Any] | None)

  • input_path (str | None)

  • output_path (str | None)

Return type:

None

coseda.nexus.process.write_nxprocess_peakfinding(h5file, parameters, program, inputs=None, outputs=None)[source]

Write an NXprocess record for peakfinding (non-destructive to data).

Parameters:
  • h5file (h5py.File)

  • parameters (Dict[str, Any])

  • program (str)

  • inputs (Iterable[str] | None)

  • outputs (Iterable[str] | None)

Return type:

None

coseda.nexus.process.write_nxprocess_stripping(h5file, threshold, force, input_path=None, output_path=None, kept_frames=None, stripped_frames=None)[source]

Write an NXprocess record for stripping.

Parameters:
  • h5file (h5py.File)

  • threshold (float | None)

  • force (bool | None)

  • input_path (str | None)

  • output_path (str | None)

  • kept_frames (int | None)

  • stripped_frames (int | None)

Return type:

None

Module contents

NeXus helpers and schema wiring.