Source code for ewoksxrdct.tasks.create_nxxrdct
import numpy as np
from ewokscore import Task
from ewokscore.model import BaseInputModel
from ewokscore.model import BaseOutputModel
from nxxrdct import NXxrdct
from pydantic import Field
[docs]
class CreateNxxrdctOutputModel(BaseOutputModel):
nx_path: str = Field(
...,
description="Full path to the NX file.",
)
[docs]
class CreateNxxrdct(
Task, input_model=CreateNxxrdctInputModel, output_model=CreateNxxrdctOutputModel
):
[docs]
def run(self):
"""Execute the task to create an NX file from the given inputs."""
self.save_NX_file()
self.outputs.nx_path = self.inputs.nx_path
[docs]
def save_NX_file(self):
"""Create the NX file and save it using the given inputs."""
nx = NXxrdct()
nx.title = self.inputs.title
nx.beam.incident_energy = self.inputs.beam_incident_energy
nx.sample.name = self.inputs.sample_name
nx.sample.rotation_angle = self.inputs.sample_rotation_angle
nx.instrument.detector.data = self.inputs.detector_data
nx.instrument.detector.count_time = self.inputs.detector_count_time
nx.save(file_path=self.inputs.nx_path, data_path="entry")