forked from npshub/mantid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sns_command_interface.py
144 lines (98 loc) · 6.17 KB
/
sns_command_interface.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
# NScD Oak Ridge National Laboratory, European Spallation Source,
# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +
#pylint: disable=invalid-name,unused-import
"""
Command set for EQSANS reduction
"""
# Import the specific commands that we need - some of these are used in systemtests
from reduction_workflow.command_interface import *
# The following imports allow users to import this file and have all functionality automatically imported
# Do not remove these imports as it will break user scripts which rely on them
from .hfir_command_interface import DarkCurrent, NoDarkCurrent, NoNormalization # noqa: F401
from .hfir_command_interface import SolidAngle, NoSolidAngle # noqa: F401
from .hfir_command_interface import DirectBeamCenter, ScatteringBeamCenter # noqa: F401
from .hfir_command_interface import SetBeamCenter as BaseSetBeamCenter # noqa: F401
from .hfir_command_interface import SensitivityCorrection, SetSensitivityBeamCenter # noqa: F401
from .hfir_command_interface import SensitivityDirectBeamCenter, SensitivityScatteringBeamCenter # noqa: F401
from .hfir_command_interface import NoSensitivityCorrection, DivideByThickness # noqa: F401
from .hfir_command_interface import IQxQy, NoIQxQy, SaveIq, NoSaveIq, SaveIqAscii # noqa: F401
from .hfir_command_interface import DirectBeamTransmission, TransmissionDarkCurrent # noqa: F401
from .hfir_command_interface import ThetaDependentTransmission # noqa: F401
from .hfir_command_interface import SetTransmissionBeamCenter, TransmissionDirectBeamCenter # noqa: F401
from .hfir_command_interface import SetTransmission, NoTransmission # noqa: F401
from .hfir_command_interface import Background, NoBackground, NoBckTransmission # noqa: F401
from .hfir_command_interface import SetBckTransmission, BckDirectBeamTransmission # noqa: F401
from .hfir_command_interface import SetBckTransmissionBeamCenter, BckThetaDependentTransmission # noqa: F401
from .hfir_command_interface import BckTransmissionDirectBeamCenter, BckTransmissionDarkCurrent # noqa: F401
from .hfir_command_interface import SetSampleDetectorOffset, SetSampleDetectorDistance # noqa: F401
from .hfir_command_interface import Mask, MaskRectangle, MaskDetectors, MaskDetectorSide # noqa: F401
from .hfir_command_interface import SetAbsoluteScale, SetDirectBeamAbsoluteScale # noqa: F401
from .hfir_command_interface import Stitch # noqa: F401
from reduction_workflow.find_data import find_data
def EQSANS(keep_events=False, property_manager=None):
Clear()
ReductionSingleton().set_instrument("EQSANS",
"SetupEQSANSReduction",
"SANSReduction")
ReductionSingleton().reduction_properties["PreserveEvents"]=keep_events
SolidAngle()
AzimuthalAverage()
if property_manager is not None:
ReductionSingleton().set_reduction_table_name(property_manager)
def SetBeamCenter(x,y):
if x==0 and y==0:
ReductionSingleton().reduction_properties["UseConfigBeam"]=True
else:
BaseSetBeamCenter(x,y)
def TotalChargeNormalization(normalize_to_beam=True, beam_file=''):
if normalize_to_beam:
ReductionSingleton().reduction_properties["Normalisation"]="BeamProfileAndCharge"
ReductionSingleton().reduction_properties["MonitorReferenceFile"]=beam_file
else:
ReductionSingleton().reduction_properties["Normalisation"]="Charge"
def BeamMonitorNormalization(reference_flux_file):
reference_flux_file = find_data(reference_flux_file, instrument=ReductionSingleton().get_instrument())
ReductionSingleton().reduction_properties["Normalisation"]="Monitor"
ReductionSingleton().reduction_properties["MonitorReferenceFile"]=reference_flux_file
def PerformFlightPathCorrection(do_correction=True):
ReductionSingleton().reduction_properties["CorrectForFlightPath"]=do_correction
def SetTOFTailsCutoff(low_cut=0.0, high_cut=0.0):
ReductionSingleton().reduction_properties["LowTOFCut"]=low_cut
ReductionSingleton().reduction_properties["HighTOFCut"]=high_cut
def UseConfigTOFTailsCutoff(use_config=True):
ReductionSingleton().reduction_properties["UseConfigTOFCuts"]=use_config
def SkipTOFCorrection(skip=True):
ReductionSingleton().reduction_properties["SkipTOFCorrection"]=skip
def UseConfigMask(use_config=True):
ReductionSingleton().reduction_properties["UseConfigMask"]=use_config
def SetWavelengthStep(step=0.1):
ReductionSingleton().reduction_properties["WavelengthStep"]=step
def UseConfig(use_config=True):
ReductionSingleton().reduction_properties["UseConfig"]=use_config
def AzimuthalAverage(suffix="_Iq", n_bins=100, n_subpix=1, log_binning=False,
scale=True):
# Suffix is no longer used but kept for backward compatibility
# N_subpix is also no longer used
ReductionSingleton().reduction_properties["DoAzimuthalAverage"]=True
ReductionSingleton().reduction_properties["IQNumberOfBins"]=n_bins
ReductionSingleton().reduction_properties["IQLogBinning"]=log_binning
ReductionSingleton().reduction_properties["IQScaleResults"]=scale
def CombineTransmissionFits(combine_frames=True):
ReductionSingleton().reduction_properties["FitFramesTogether"]=combine_frames
def BckCombineTransmissionFits(combine_frames=True):
ReductionSingleton().reduction_properties["BckFitFramesTogether"]=combine_frames
def Resolution(sample_aperture_diameter=10.0):
ReductionSingleton().reduction_properties["ComputeResolution"]=True
ReductionSingleton().reduction_properties["SampleApertureDiameter"]=sample_aperture_diameter
def IndependentBinning(independent_binning=True):
ReductionSingleton().reduction_properties["IQIndependentBinning"]=independent_binning
def SetDetectorOffset(distance):
ReductionSingleton().reduction_properties["DetectorOffset"] = distance
def SetSampleOffset(distance):
ReductionSingleton().reduction_properties["SampleOffset"] = distance
def LoadNexusInstrumentXML(value=True):
ReductionSingleton().reduction_properties["LoadNexusInstrumentXML"] = value