drtsans.files package¶
Submodules¶
drtsans.files.event_nexus_nodes module¶
- class drtsans.files.event_nexus_nodes.BankNode(name, bank_name)[source]¶
Bases:
GroupNode
Node for bank entry such as /entry/bank12
- set_events(event_id_array, event_index_array, event_time_offset_array, run_start_time, event_time_zero_array)[source]¶
- Parameters:
event_id_array (numpy.ndarray) – pixel IDs for each event. Size is equal to number of events
event_time_offset_array (numpy.ndarray) – TOF of each neutron event. Size is equal to number of events
event_time_zero_array (numpy.ndarray) – Staring time, as seconds offset to run start time, of each pulse
run_start_time (str) – Run start time in ISO standard
event_index_array (numpy.ndarray) – Index of staring event in each pulse. Size is equal to number of pulses
- class drtsans.files.event_nexus_nodes.DasLogsCollectionNode[source]¶
Bases:
GroupNode
Node for ‘/entry/DASlogs’
- class drtsans.files.event_nexus_nodes.DataSetNode(name=None)[source]¶
Bases:
HDFNode
Node for data set
- match(other_node)[source]¶
Match this node with other
- Parameters:
other_node (DataSetNode) – another node to match against
- parse_h5_entry(h5_entry)[source]¶
Parse HDF5 entry
- Parameters:
h5_entry (Group) – hdf5 entry
- Return type:
None
- set_string_value(str_value)[source]¶
Set value from a single string (object)
- Parameters:
str_value (str) – string to be written to an entry’s only value
- set_value(data_array)[source]¶
Set data value (as numpy array)
- Parameters:
data_array (np.ndarray) – data value
- property value¶
- class drtsans.files.event_nexus_nodes.InstrumentNode[source]¶
Bases:
GroupNode
Node for instrument entry (i.e., /entry/instrument)
- class drtsans.files.event_nexus_nodes.MonitorNode(name, monitor_name)[source]¶
Bases:
GroupNode
Node to record monitor counts
- set_monitor_events(event_index_array, event_time_offset_array, run_start_time, event_time_zero_array)[source]¶
Monitor counts are recorded as events
- Parameters:
event_time_offset_array (numpy.ndarray) – TOF of each neutron event. Size is equal to number of events
event_time_zero_array (numpy.ndarray) – Staring time, as seconds offset to run start time, of each pulse
run_start_time (str) – Run start time in ISO standard
event_index_array (numpy.ndarray) – Index of staring event in each pulse. Size is equal to number of pulses
drtsans.files.event_nexus_rw module¶
- class drtsans.files.event_nexus_rw.DasDevice(id, name, target)¶
Bases:
tuple
- id¶
Alias for field number 0
- name¶
Alias for field number 1
- target¶
Alias for field number 2
- class drtsans.files.event_nexus_rw.DasLog(name, times, values, unit, device)¶
Bases:
tuple
- device¶
Alias for field number 4
- name¶
Alias for field number 0
- times¶
Alias for field number 1
- unit¶
Alias for field number 3
- values¶
Alias for field number 2
- class drtsans.files.event_nexus_rw.EventNeXusWriter(beam_line, instrument_name)[source]¶
Bases:
object
Write an Event NeXus file
- generate_event_nexus(nexus_name, start_time, stop_time, monitor_counts)[source]¶
Generate an event Nexus file from scratch :param nexus_name: Output NeXus file name :type nexus_name: str :param start_time: :param stop_time: :param monitor_counts:
- set_bank_histogram(bank_id, bank_histogram)[source]¶
Set a single bank’s counts
- Parameters:
bank_id
bank_histogram (TofHistogram) – Histogram for simulating TOF
- class drtsans.files.event_nexus_rw.NexusEvents(event_id, event_index, event_time_offset, event_time_zero)¶
Bases:
tuple
- event_id¶
Alias for field number 0
- event_index¶
Alias for field number 1
- event_time_offset¶
Alias for field number 2
- event_time_zero¶
Alias for field number 3
- class drtsans.files.event_nexus_rw.RunTime(start, stop)¶
Bases:
tuple
- start¶
Alias for field number 0
- stop¶
Alias for field number 1
- class drtsans.files.event_nexus_rw.TofHistogram(pixel_ids, counts, pulse_duration, tof_min, tof_max)¶
Bases:
tuple
- counts¶
Alias for field number 1
- pixel_ids¶
Alias for field number 0
- pulse_duration¶
Alias for field number 2
- tof_max¶
Alias for field number 4
- tof_min¶
Alias for field number 3
- drtsans.files.event_nexus_rw.convert_events_to_histogram(bank_entry)[source]¶
Convert events information in bank to histogram
- Parameters:
bank_entry
- Returns:
Histogram converted from TOF bank information
- Return type:
- drtsans.files.event_nexus_rw.generate_events_from_histogram(bank_histogram, tof_resolution=0.1, verbose=False)[source]¶
Convert histogram (counts on detector pixels) to ‘fake’ events
- Parameters:
bank_histogram (TofHistogram) – Histogram for a single bank
tof_resolution (float) – resolution of TOF
verbose (bool) – flag to print out events information
- Returns:
Generated TOF events in NeXus format
- Return type:
drtsans.files.hdf5_rw module¶
- class drtsans.files.hdf5_rw.DataSetNode(name=None)[source]¶
Bases:
HDFNode
Node for data set
- match(other_node)[source]¶
Match this node with other
- Parameters:
other_node (DataSetNode) – another node to match against
- parse_h5_entry(h5_entry)[source]¶
Parse HDF5 entry
- Parameters:
h5_entry (Group) – hdf5 entry
- Return type:
None
- set_string_value(str_value)[source]¶
Set value from a single string (object)
- Parameters:
str_value (str) – string to be written to an entry’s only value
- set_value(data_array)[source]¶
Set data value (as numpy array)
- Parameters:
data_array (np.ndarray) – data value
- property value¶
- class drtsans.files.hdf5_rw.GroupNode(name=None)[source]¶
Bases:
HDFNode
Node for an HDF Group
- property children¶
- get_child(child_name, is_short_name=False)[source]¶
Get a child
- Parameters:
- Returns:
Child HDFNode
- Return type:
- parse_h5_entry(h5_entry)[source]¶
Parse HDF5 entry
- Parameters:
h5_entry (Group) – hdf5 entry
- Return type:
None
- set_child(child_node)[source]¶
- Parameters:
child_node (GroupNode, DataSetNode) – child node to append
- class drtsans.files.hdf5_rw.HDFNode(name=None)[source]¶
Bases:
object
an HDF node with more information
- add_attributes(attributes)[source]¶
Add a list of attributes to the HDF5 node
- Parameters:
attributes (~dict) – Attributes to add. key = attribute name, value = attribute value
- property attributes¶
- match(other_node)[source]¶
Compare 2 HDFNode to see whether they are same
If mismatch, an exception will be raised including - TypeError: for nodes are nto same type - ValueError: attribute or node name value mismatch - KeyError: some attribute does not exist in both node
- Parameters:
other_node (HDFNode) – other node to compare
- property name¶