drtsans.mono package¶
Subpackages¶
- drtsans.mono.biosans package
- Submodules
- drtsans.mono.biosans.api module
- drtsans.mono.biosans.beam_finder module
- drtsans.mono.biosans.cg3_spice_to_nexus module
- drtsans.mono.biosans.prepare_sensitivities_correction module
- drtsans.mono.biosans.reduce_spice module
- Module contents
BinningMethod
BinningParams
abspath()
abspaths()
allow_overwrite()
apply_calibrations()
apply_mask()
apply_transmission_correction()
as_intensities()
bin_all()
bin_annular_into_q1d()
bin_intensity_into_q1d()
bin_intensity_into_q2d()
calculate_apparent_tube_width()
calculate_barscan_calibration()
calculate_solid_angle()
calculate_transmission()
center_detector()
check_iq_for_binning()
circular_mask_from_beam_center()
convert_to_q()
day_stamp()
determine_1d_linear_bins()
determine_1d_log_bins()
empty_beam_scaling()
exists()
fbc_options_json()
find_beam_center()
load_all_files()
load_and_split()
load_calibration()
load_dark_current_workspace()
load_events()
load_events_and_histogram()
load_histogram()
load_iqmod()
load_mono()
normalize_by_flux()
normalize_by_monitor()
normalize_by_thickness()
normalize_by_time()
normalize_dark_current()
plot_IQazimuthal()
plot_IQmod()
plot_detector()
plot_reduction_output()
prepare_data()
prepare_data_workspaces()
process_single_configuration()
reduce_single_configuration()
reduction_parameters()
registered_workspace()
sample_aperture_diameter()
sample_detector_distance()
save_iqmod()
search_sample_detector_distance_meta_name()
search_source_sample_distance_meta_name()
select_i_of_q_by_wedge()
set_init_uncertainties()
solid_angle_correction()
source_aperture_diameter()
source_sample_distance()
split_barscan_run()
standard_sample_scaling()
stitch_profiles()
subtract_dark_current()
sum_data()
transform_to_wavelength()
translate_detector_by_z()
translate_sample_by_z()
update_reduction_parameters()
validate_reduction_parameters()
- drtsans.mono.gpsans package
- Submodules
- drtsans.mono.gpsans.api module
- drtsans.mono.gpsans.attenuation module
- drtsans.mono.gpsans.cg2_spice_to_nexus module
- drtsans.mono.gpsans.prepare_sensitivities_correction module
- drtsans.mono.gpsans.reduce_spice module
- Module contents
BinningMethod
BinningParams
abspath()
abspaths()
adjust_back_panels_to_effective_position()
allow_overwrite()
apply_calibrations()
apply_mask()
apply_transmission_correction()
as_intensities()
attenuation_factor()
bin_all()
bin_annular_into_q1d()
bin_intensity_into_q1d()
bin_intensity_into_q2d()
calculate_apparent_tube_width()
calculate_barscan_calibration()
calculate_solid_angle()
calculate_transmission()
center_detector()
check_iq_for_binning()
circular_mask_from_beam_center()
convert_to_q()
day_stamp()
determine_1d_linear_bins()
determine_1d_log_bins()
empty_beam_scaling()
exists()
fbc_options_json()
find_beam_center()
load_all_files()
load_and_split()
load_calibration()
load_dark_current_workspace()
load_events()
load_events_and_histogram()
load_histogram()
load_iqmod()
load_mono()
normalize_by_flux()
normalize_by_monitor()
normalize_by_thickness()
normalize_by_time()
normalize_dark_current()
plot_IQazimuthal()
plot_IQmod()
plot_detector()
plot_reduction_output()
prepare_data()
prepare_data_workspaces()
process_single_configuration()
reduce_single_configuration()
reduction_parameters()
registered_workspace()
sample_aperture_diameter()
sample_detector_distance()
save_iqmod()
search_sample_detector_distance_meta_name()
search_source_sample_distance_meta_name()
select_i_of_q_by_wedge()
set_init_uncertainties()
solid_angle_correction()
source_aperture_diameter()
source_sample_distance()
split_barscan_run()
standard_sample_scaling()
stitch_profiles()
subtract_dark_current()
sum_data()
transform_to_wavelength()
translate_detector_by_z()
translate_sample_by_z()
update_reduction_parameters()
validate_reduction_parameters()
Submodules¶
drtsans.mono.absolute_units module¶
- drtsans.mono.absolute_units.empty_beam_scaling(input_workspace, empty_beam_workspace, beam_radius=None, unit='mm', attenuator_coefficient=1.0, attenuator_error=0.0, output_workspace=None)[source]¶
Normalize input workspace by the intensity impinging on the detector for an empty beam run, taking into account attenuation.
Mantid Algorithms used: Divide, DeleteWorkspace,
- Parameters:
input_workspace (str, MatrixWorkspace, IEventsWorkspace) – Workspace to be normalized
empty_beam_workspace (str, MatrixWorkspace, IEventsWorkspace) – Attenuated intensities collected at the detector with and empty beam.
beam_radius (float) – Radius of the beam at the detector. If None, it will be estimated with the sample and source apertures.
unit (str) – Units for the beam radius, either meters (‘m’) or mili-miters (‘mm’).
attenuator_coefficient (float) – Fraction of the neutrons allowed to pass through the attenuator. Assumed wavelength independent.
attenuator_error (float) – Estimated error for the attenuator coefficient.
output_workspace (str) – Name of the normalized workspace. If
None
, then the name ofinput_workspace
will be used, thus overwritinginput_workspace
.
- Return type:
MatrixWorkspace, IEventsWorkspace
drtsans.mono.bar_scan_pixel_calibration module¶
- drtsans.mono.bar_scan_pixel_calibration.generate_intermediate_files(bar_scan_files, save_dir)[source]¶
- drtsans.mono.bar_scan_pixel_calibration.generate_pixel_map(bar_scan_files, flood_file, save_dir_root, database_file_base, calib_name_base='CG2_Pixel_Calibration', mask_file='testdata/mask_pixel_map.nxs')[source]¶
Generate pixel calibration map from bar scan
# Mask file containing the detector ID’s comprising the beam center. # mask_file = f’/HFIR/CG2/IPTS-{ipts}/shared/pixel_flood_mask.nxs’
- Parameters:
bar_scan_files
flood_file
save_dir_root
database_file_base
calib_name_base (str) – Base name for calibration file
mask_file
- Returns:
(bar scan data set, flood), calibration (step 1),
- Return type:
generator
- drtsans.mono.bar_scan_pixel_calibration.generate_spice_pixel_map(ipts_number, exp_number, scan_number, pt_numbers, flood_ipts_number, flood_exp_number, flood_scan_number, flood_pt_number, root_dir, save_dir_root, mask_file)[source]¶
- drtsans.mono.bar_scan_pixel_calibration.locate_bar_scan_files(ipts_number, exp_number, scan_number, pt_numbers, root_dir)[source]¶
- drtsans.mono.bar_scan_pixel_calibration.locate_flood_file(ipts_number, exp_number, scan_number, pt_number, root_dir='/HFIR/CG2')[source]¶
Locate flood Nexus file
- Parameters:
ipts_number
exp_number
scan_number
pt_number
root_dir
- Returns:
flood Nexus file path
- Return type:
- drtsans.mono.bar_scan_pixel_calibration.untilt_and_center(a_calibration)[source]¶
Removing the Bar Tilt and Centering the Detector
Thinking of the fitted positions for the bottom and top pixels, we can think of the detector array as a deformed rectangle (angles between sides different than 90 degrees), which must be transformed into a rectangle with squared angles (angles between sides equal to 90 degrees).
We take the tube in the middle of the main detector array as our reference. We will adjust every other tube so that for every tube, its top and bottom fitted pixel positions will coincide with the top and bottom fitted positions of the middle tube.
Also, since top and bottom fitted positions have a different variation with tube index, the fitted tube lenght changes sligtly with tube index. Thus, we will rescale the fitted tube length to coincide with the fitted tube length of the middle tube. This amounts to a rescaling of pixel heights.
Finally, after removing the tilt we displace the detector so that the center of mass lies at Y=0.
drtsans.mono.convert_xml_to_nexus module¶
- class drtsans.mono.convert_xml_to_nexus.EventNexusConverter(beam_line, instrument_name, num_banks)[source]¶
Bases:
ABC
Class to provide service to convert to event NeXus from various input
- static convert_log_units(spice_log_dict)[source]¶
Convert log unit from SPICE log to Nexus log
- Parameters:
spice_log_dict (~dict) – key: Nexus das log name, value: (log value, log unit)
- Returns:
key: DAS log name, value: DasLog
- Return type:
~dict
- property detector_counts¶
Get detector counts
- Returns:
detector counts
- Return type:
array
- generate_event_nexus(target_nexus)[source]¶
Generate event NeXus properly
- num_banks: int
CG2 = 48, CG3 = 88
- Parameters:
target_nexus (str) – name of the output Nexus file
- load_idf(template_nexus_file)[source]¶
Load IDF content from a template NeXus file
- Parameters:
template_nexus_file
drtsans.mono.dark_current module¶
Links to mantid algorithms Minus <https://docs.mantidproject.org/nightly/algorithms/Minus-v1.html> DeleteWorkspace <https://docs.mantidproject.org/nightly/algorithms/DeleteWorkspace-v1.html> Integration <https://docs.mantidproject.org/nightly/algorithms/Integration-v1.html> Scale <https://docs.mantidproject.org/nightly/algorithms/Scale-v1.html>
- drtsans.mono.dark_current.load_dark_current_workspace(dark_current_filename, output_workspace)[source]¶
Loads dark current workspace. Useful to avoid multiple loads from disk.
Mantid algorithms used: LoadEventNexus,
- drtsans.mono.dark_current.normalize_dark_current(dark_workspace, output_workspace=None)[source]¶
Divide a dark current workspace by its duration.
Entry ‘normalizing_duration’ is added to the logs of the normalized dark current to annotate what log entry was used to find the duration
Mantid algorithms used: Scale, DeleteWorkspace,
- Parameters:
dark_workspace (str, MatrixWorkspace) – Dark current workspace
output_workspace (str) – Name of the normalized dark workspace. If None, the name of the input workspace dark_workspace is chosen (and the input workspace is overwritten).
- Returns:
Output workspace
- Return type:
MatrixWorkspace
- drtsans.mono.dark_current.subtract_dark_current(data_workspace, dark, output_workspace=None)[source]¶
Subtract normalized dark from data, taking into account the duration of both the data and dark runs.
normalized_data = data - (data_duration / dark_duration) * dark
Mantid algorithms used: Scale, Minus DeleteWorkspace
- Parameters:
data_workspace (MatrixWorkspace) – Sample scattering with intensities versus wavelength.
dark (int, str, MatrixWorkspace) – run number, file path, workspace name, or
MatrixWorkspace
for dark current.output_workspace (str) – Name of the output workspace. If None, the name of the input workspace data_workspace is chosen (and the input workspace is overwritten).
- Return type:
MatrixWorkspace
drtsans.mono.geometry module¶
- drtsans.mono.geometry.beam_radius(input_workspace, unit='mm')[source]¶
Calculate the beam radius impinging on the detector
R_beam = R_sampleAp + SDD * (R_sampleAp + R_sourceAp) / SSD, where R_sampleAp: radius of the sample aperture, SDD: distance between the sample and the detector, R_sourceAp: radius of the source aperture, SSD: distance between the source and the sample.
- Parameters:
input_workspace (MatrixWorkspace, str) – Input workspace
unit (str) – Units of the output beam radius. Either ‘mm’ or ‘m’.
- Return type:
drtsans.mono.load module¶
- drtsans.mono.load.load_and_split(run, sample_to_si_name, si_nominal_distance, data_dir=None, output_workspace=None, output_suffix='', overwrite_instrument=True, pixel_calibration=False, time_interval: float | List[float] | None = None, time_offset: float = 0.0, time_period: float | None = None, log_name=None, log_value_interval=None, sample_to_si_value=None, sample_detector_distance_value=None, reuse_workspace=False, monitors=False, **kwargs)[source]¶
Load an event NeXus file and filter into a WorkspaceGroup depending on the provided filter options. Either a time_interval must be provided or a log_name and log_value_interval.
Metadata added to output workspace includes the
slice
number,number_of_slices
,slice_parameter
,slice_interval
,slice_start
andslice_end
.For EQSANS two WorkspaceGroup’s are return, one for the filtered data and one for filtered monitors
- Parameters:
run (str, IEventWorkspace) – Examples:
CG3_55555
,CG355555
or file path.sample_to_si_name (str) – Meta data name for sample to Silicon window distance
si_nominal_distance (float) – distance between nominal position to silicon window. unit = meter
output_workspace (str) – If not specified it will be
BIOSANS_55555
determined from the supplied value ofrun
.output_suffix (str) – If the
output_workspace
is not specified, this is appended to the automatically generated output workspace name.overwrite_instrument (bool, str) – If not
False
, ignore the instrument embedeed in the Nexus file. IfTrue
, use the latest instrument definition file (IDF) available in Mantid. Ifstr
, then it should be the filepath to the desired IDF.pixel_calibration (bool) – Adjust pixel heights and widths according to bar-scan and tube-width calibrations.
time_interval – Array for lengths of time intervals for splitters. If the array has one value, then all splitters will have same time intervals. If the size of the array is larger than one, then the splitters can have various time interval values.
time_offset – Offset to be added to the start time of the first splitter, in seconds.
time_period – A multiple integer of the time interval. If specified, it indicates that the time slicing is periodic so that events in time intervals separated by one (or more) period should be reduced together.
sample_to_si_value (float or None) – Sample to silicon window distance to overwrite the EPICS value. None for no operation. unit = meter
sample_detector_distance_value (float or None) – Sample to detector distance to overwrite the EPICS value. None for no operation. unit = meter
log_name (string) – Name of the sample log to use to filter. For example, the pulse charge is recorded in ‘ProtonCharge’.
log_value_interval (float) – Delta of log value to be sliced into from min log value and max log value.
reuse_workspace (bool) – When true, return the
output_workspace
if it already existsmonitors (bool) – flag to load monitors
kwargs (dict) – Additional positional arguments for LoadEventNexus.
- Returns:
Reference to the workspace groups containing all the split workspaces
- Return type:
WorkspaceGroup
- drtsans.mono.load.load_events(run, data_dir=None, output_workspace=None, overwrite_instrument=True, output_suffix='', pixel_calibration=False, detector_offset=0.0, sample_offset=0.0, reuse_workspace=False, **kwargs)[source]¶
Load an event Nexus file produced by the instruments at ORNL.
- Parameters:
run (str, IEventWorkspace) – Examples:
CG3_55555
,CG355555
or file path.output_workspace (str) – If not specified it will be
BIOSANS_55555
determined from the supplied value ofrun
.overwrite_instrument (bool, str) – If not
False
, ignore the instrument embedeed in the Nexus file. IfTrue
, use the latest instrument definition file (IDF) available in Mantid. Ifstr
, then it should be the filepath to the desired IDF.output_suffix (str) – If the
output_workspace
is not specified, this is appended to the automatically generated output workspace name.pixel_calibration (bool, str) – Adjust pixel heights and widths according to bar-scan and tube-width calibrations. Options are (1) No calibration (2) Using default calibration file (True) and (3) User specified calibration file (str)
detector_offset (float) – Additional translation of the detector along the Z-axis, in mm. Positive moves the detector downstream.
sample_offset (float) – Additional translation of the sample, in mm. The sample flange remains at the origin of coordinates. Positive moves the sample downstream.
reuse_workspace (bool) – When true, return the
output_workspace
if it already existskwargs (dict) – Additional positional arguments for LoadEventNexus.
- Returns:
Reference to the events workspace
- Return type:
- drtsans.mono.load.load_events_and_histogram(run, data_dir=None, output_workspace=None, output_suffix='', overwrite_instrument=True, pixel_calibration=False, reuse_workspace=False, sample_to_si_name=None, si_nominal_distance=None, sample_to_si_value=None, sample_detector_distance_value=None, **kwargs)[source]¶
Load one or more event Nexus file produced by the instruments at HFIR. Convert to wavelength and sums the data.
- Parameters:
run (str, list of runs to load) – Examples:
CG3_55555
,CG355555
, file path,CG3_55555,CG3_55556
output_workspace (str) – If not specified it will be
BIOSANS_55555
determined from the supplied value ofrun
.output_suffix (str) – If the
output_workspace
is not specified, this is appended to the automatically generated output workspace name.overwrite_instrument (bool, str) – If not
False
, ignore the instrument embedeed in the Nexus file. IfTrue
, use the latest instrument definition file (IDF) available in Mantid. Ifstr
, then it should be the filepath to the desired IDF.pixel_calibration (bool) – Adjust pixel heights and widths according to bar-scan and tube-width calibrations.
sample_to_si_name (str) – Meta data name for sample to Silicon window distance
si_nominal_distance (float) – distance between nominal position to silicon window. unit = meter
sample_to_si_value (float or None) – Sample to silicon window distance to overwrite the EPICS value. None for no operation. unit = meter
sample_detector_distance_value (float or None) – Sample to detector distance to overwrite the EPICS value. None for no operation. unit = meter
reuse_workspace (bool) – When true, return the
output_workspace
if it already existskwargs (dict) – Additional positional arguments for LoadEventNexus.
- Return type:
- drtsans.mono.load.load_histogram(filename, output_workspace=None, wavelength=None, wavelength_spread=None, sample_det_cent=None)[source]¶
Loads a SANS data file produce by the HFIR instruments at ORNL. The instrument geometry is also loaded. The center of the detector is placed at (0, 0, sample_det_cent )
- Parameters:
filename (str) – The name of the input xml file to load
output_workspace (str, optional) – The optional name of the output workspace. If
None
is the filename stripped of the extension.wavelength (float) – The wavelength value to use when loading the data file (Angstrom). This value will be used instead of the value found in the data file.
wavelength_spread (float) – wavelength spread value to use when loading the data file (Angstrom). This value will be used instead of the value found in the data file.
sample_det_cent (float) – Sample to detector distance to use (overrides meta data) in mm
- Returns:
A reference for the workspace created.
- Return type:
- drtsans.mono.load.load_mono(filename, **kwargs)[source]¶
Loads a SANS data file produce by the HFIR instruments at ORNL.
- Parameters:
- Return type:
- drtsans.mono.load.set_init_uncertainties(input_workspace, output_workspace=None)[source]¶
Set the initial uncertainty of a
MatrixWorkspace
Mantid algorithm SetUncertainties will be called to make sure 1: set the uncertainty to square root of intensity 2: make sure all zero uncertainties will be set to 1
In case of output workspace is py:obj:None, the input workspace will be replaced by output workspace.
- Raises:
RuntimeError – output workspace (string) is empty
Mantid algorithms used: CloneWorkspace SetUncertainties
- Parameters:
input_workspace (MatrixWorkspace) – Input workspace
output_workspace (str) – Output workspace (workspace name or instance) or py:obj:None for in-place operation
- Return type:
- drtsans.mono.load.sum_data(data_list, output_workspace, sum_logs=('duration', 'timer', 'monitor', 'monitor1'))[source]¶
Merge data set together, summing the listed logs
- Parameters:
- Return type:
Workspace2D
- drtsans.mono.load.transform_to_wavelength(input_workspace, output_workspace=None)[source]¶
Transforms the event files with fake time of flight from the SANS instruments at HFIR into histograms in wavelength.
Mantid Algorithms used: HFIRSANS2Wavelength,
- Parameters:
input_workspace (str, IEventWorkspace) – Events workspace in time-of-flight.
output_workspace (str) – Name of the output workspace. If
None
, the name of the input_workspace will be used, thus overwriting the input workspace.
- Return type:
drtsans.mono.meta_data module¶
- drtsans.mono.meta_data.get_sample_detector_offset(workspace, sample_si_meta_name, zero_sample_offset_sample_si_distance, overwrite_sample_si_distance=None, overwrite_sample_detector_distance=None)[source]¶
Get sample offset and detector offset from meta data
This method is based on the assumption and fact that “sample position is set to nominal position (0, 0, 0) regardless of sample log SampleToSi” “detector1 is set to [0, 0, sample_detector_distance] It will be re-implemented
- Parameters:
workspace (str, MatrixWorkspace) – Mantid workspace instance or workspace name
sample_si_meta_name (str) – Sample to Si (window) meta data name
zero_sample_offset_sample_si_distance (float) – default sample to Si window distance, i.e., distance without sample offset. unit = meter
overwrite_sample_si_distance (float or None) – sample to Si window distance to overwrite. Unit = mm (consistent with the unit of original meta data)
overwrite_sample_detector_distance (float or None) – sample detector distance to overwrite. Unit = m (consistent with the unit of original meta data)
- Returns:
sample offset (float) in unit meter and detector offset (float) in unit meter
- Return type:
~tuple
- drtsans.mono.meta_data.parse_json_meta_data(reduction_input, meta_name, unit_conversion_factor, beam_center_run=False, background_run=False, empty_transmission_run=False, transmission_run=False, background_transmission=False, block_beam_run=False, dark_current_run=False)[source]¶
Parse user specified meta data from JSON from configuration part
- Parameters:
reduction_input (dict) – dictionary parsed from JSON
meta_name (str) – meta data name
unit_conversion_factor (float) – unit conversion conversion factor from user preferred unit to drt-sans preferred unit
beam_center_run (bool) – flag whether beam center run will have the same meta data
background_run (bool) – flag whether beam center run will have the same meta data
empty_transmission_run (bool) – flag whether beam center run will have the same meta data
transmission_run – flag whether beam center run will have the same meta data
background_transmission – flag whether beam center run will have the same meta data
block_beam_run – flag whether beam center run will have the same meta data
dark_current_run – flag whether beam center run will have the same meta data
- Returns:
keys: strings stands for sample (run), background (run) and etc used in JSON; value: JSON value if value is None, it indicates that the meta data won’t be overwritten
- Return type:
- drtsans.mono.meta_data.set_meta_data(workspace, wave_length=None, wavelength_spread=None, sample_offset=0.0, sample_aperture_diameter=None, sample_thickness=None, source_aperture_diameter=None, smearing_pixel_size_x=None, smearing_pixel_size_y=None)[source]¶
Set meta data to SANS Mantid Workspace as run properties
- Parameters:
workspace (str, MatrixWorkspace) – Mantid workspace instance or workspace name
wave_length (float, None) – wave length in Angstrom
wavelength_spread (float, None) – wave length spread in Angstrom
sample_offset (float) – offset of sample from origin in unit mm
sample_aperture_diameter (float, None) – sample aperture diameter in mm
sample_thickness (None, float) – sample thickness in unit cm
source_aperture_diameter (float, None) – source aperture size radius in unit mm
smearing_pixel_size_x (float, None) – pixel size in x direction in unit as meter, only for Q-resolution calculation
smearing_pixel_size_y (float, None) – pixel size in Y direction in unit as meter, only for Q-resolution calculation
drtsans.mono.momentum_transfer module¶
- drtsans.mono.momentum_transfer.convert_to_q(ws, mode, resolution_function=<function mono_resolution>, **kwargs)[source]¶
Convert a workspace with units of wavelength into a series of arrays: intensity, error, q (or q components), delta q (or delta q components), and wavelength
Using the scattering angle as \(2\theta\) and azimuthan angle as \(\phi\),the calculaion of momentum transfer is:
‘scalar’ mode:
\[|Q| = \frac{4\pi}{\lambda}\sin\theta\]‘azimuthal’ mode:
\[ \begin{align}\begin{aligned}Q_x=\frac{4\pi}{\lambda}\sin\theta\cos\phi\\Q_y=\frac{4\pi}{\lambda}\sin\theta\sin\phi\end{aligned}\end{align} \]‘crystallographic’ mode:
\[ \begin{align}\begin{aligned}Q_x=\frac{2\pi}{\lambda}\sin(2\theta)\cos\phi\\Q_y=\frac{2\pi}{\lambda}\sin(2\theta)\sin\phi\\Qz_=\frac{2\pi}{\lambda}(\cos(2\theta)-1)\end{aligned}\end{align} \]It calls drtsans.momentum_transfer.convert_to_q
- Parameters:
ws (str, IEventWorkspace, MatrixWorkspace) – Workspace in units of wavelength
mode (str) – Available options are ‘scalar’, ‘azimuthal’, and ‘crystallographic’
resolution_function – Function to calculate resolution
kwargs – Parameters to be passed to the resolution function
- Returns:
A namedtuple with fields for
intensity
error
mod_q (\(|Q|\)) or qx, qy (\(Q_x, Q_y\)) or qx, qy, qz (\(Q_x, Q_y, Q_z\)) (depending on the mode)
delta_q or delta_qx, delta_qy or delta_qx, delta_qy, delta_qz - the resolution along the q components
wavelength
- Return type:
namedtuple
drtsans.mono.normalization module¶
Links to mantid algorithms CreateSingleValuedWorkspace <https://docs.mantidproject.org/nightly/algorithms/CreateSingleValuedWorkspace-v1.html> Divide <https://docs.mantidproject.org/nightly/algorithms/Divide-v1.html>
- drtsans.mono.normalization.normalize_by_flux(ws, method)[source]¶
Normalize to time or monitor
- Parameters:
input_workspace (MatrixWorkspace)
method (str) – Normalization method: ‘time’ or ‘monitor’
- drtsans.mono.normalization.normalize_by_monitor(input_workspace, output_workspace=None)[source]¶
Normalize by the monitor value
Mantid algorithms used: :ref: CreateSingleValuedWorkspace <algm-CreateSingleValuedWorkspace-v1> :ref:`Divide <algm-Divide-v1>,
- Parameters:
input_workspace (MatrixWorkspace)
output_workspace (str) – Optional name of the output workspace. Default is to replace the input workspace
- Returns:
the normalized input workspace
- Return type:
- Raises:
RuntimeError – No monitor metadata found in the sample logs of the input workspace
- drtsans.mono.normalization.normalize_by_time(input_workspace, output_workspace=None)[source]¶
Normalize by time Used to normalize dark current
Mantid algorithms used: Divide,
- Parameters:
input_workspace (MatrixWorkspace)
output_workspace (str) – Optional name of the output workspace. Default is to replace the input workspace
drtsans.mono.spice_data module¶
- class drtsans.mono.spice_data.SpiceRun(beam_line, ipts_number, exp_number, scan_number, pt_number)[source]¶
Bases:
NamedTuple
- property hfir_ipts_dir¶
Standard HFIR SPICE data directory
- Returns:
Path to IPTS directory
- Return type:
- drtsans.mono.spice_data.map_to_nexus(beam_line: str, ipts_number: int, exp_number: int, scan_pt_list: List[Tuple[int, int] | None], nexus_dir: str | None = None) List[str] [source]¶
Map SPICE information to converted NeXus file path
- Parameters:
- Returns:
list of Nexus files with the same order with scan-pt
- Return type:
~list
drtsans.mono.spice_xml_parser module¶
Module contains class and method to parse SPICE SANS XML file for DAS sample logs.
drtsans.mono.transmission module¶
- drtsans.mono.transmission.apply_transmission_correction(input_workspace, trans_workspace=None, trans_value=None, trans_error=0.0, theta_dependent=True, output_workspace=None)[source]¶
Correct the intensities with transmission coefficient(s).
Mantid algorithms used: ApplyTransmissionCorrection ReplaceSpecialValues
- Parameters:
input_workspace (str, MatrixWorkspace) – Input workspace to correct its intensities
trans_workspace (str, MatrixWorkspace) – Workspace containing the transmission coefficient(s). The result of applying calculate_transmission to the input workspace. If
None
, trans_value will be used.trans_value (float) – A single transmission coefficient to correct the intensities. If
None
, trans_workspace will be used.trans_error (float) – Error associated to trans_value.
theta_dependent (bool) – Flag to do theta dependent correction
output_workspace (str) – Name of the workspace containing the corrected intensities. If
None
, the input_workspace will be overwritten.
- Return type:
Module contents¶
- drtsans.mono.empty_beam_scaling(input_workspace, empty_beam_workspace, beam_radius=None, unit='mm', attenuator_coefficient=1.0, attenuator_error=0.0, output_workspace=None)[source]¶
Normalize input workspace by the intensity impinging on the detector for an empty beam run, taking into account attenuation.
Mantid Algorithms used: Divide, DeleteWorkspace,
- Parameters:
input_workspace (str, MatrixWorkspace, IEventsWorkspace) – Workspace to be normalized
empty_beam_workspace (str, MatrixWorkspace, IEventsWorkspace) – Attenuated intensities collected at the detector with and empty beam.
beam_radius (float) – Radius of the beam at the detector. If None, it will be estimated with the sample and source apertures.
unit (str) – Units for the beam radius, either meters (‘m’) or mili-miters (‘mm’).
attenuator_coefficient (float) – Fraction of the neutrons allowed to pass through the attenuator. Assumed wavelength independent.
attenuator_error (float) – Estimated error for the attenuator coefficient.
output_workspace (str) – Name of the normalized workspace. If
None
, then the name ofinput_workspace
will be used, thus overwritinginput_workspace
.
- Return type:
MatrixWorkspace, IEventsWorkspace
- drtsans.mono.load_dark_current_workspace(dark_current_filename, output_workspace)[source]¶
Loads dark current workspace. Useful to avoid multiple loads from disk.
Mantid algorithms used: LoadEventNexus,
- drtsans.mono.normalize_dark_current(dark_workspace, output_workspace=None)[source]¶
Divide a dark current workspace by its duration.
Entry ‘normalizing_duration’ is added to the logs of the normalized dark current to annotate what log entry was used to find the duration
Mantid algorithms used: Scale, DeleteWorkspace,
- Parameters:
dark_workspace (str, MatrixWorkspace) – Dark current workspace
output_workspace (str) – Name of the normalized dark workspace. If None, the name of the input workspace dark_workspace is chosen (and the input workspace is overwritten).
- Returns:
Output workspace
- Return type:
MatrixWorkspace
- drtsans.mono.subtract_dark_current(data_workspace, dark, output_workspace=None)[source]¶
Subtract normalized dark from data, taking into account the duration of both the data and dark runs.
normalized_data = data - (data_duration / dark_duration) * dark
Mantid algorithms used: Scale, Minus DeleteWorkspace
- Parameters:
data_workspace (MatrixWorkspace) – Sample scattering with intensities versus wavelength.
dark (int, str, MatrixWorkspace) – run number, file path, workspace name, or
MatrixWorkspace
for dark current.output_workspace (str) – Name of the output workspace. If None, the name of the input workspace data_workspace is chosen (and the input workspace is overwritten).
- Return type:
MatrixWorkspace