Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dead time to scaling factors #26

Merged
merged 5 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions reduction/data/sf_197912_Si_dt_par_42_200.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# y=a+bx
#
# LambdaRequested[Angstroms] S1H[mm] (S2/Si)H[mm] S1W[mm] (S2/Si)W[mm] a b error_a error_b
#
# Medium=Si, runs: [197920, 197921, 197922, 197923, 197924, 197925, 197926, 197927, 197928, 197929, 197930, 197931]
IncidentMedium=Si LambdaRequested=9.74 S1H=0.391 S2iH=0.24999999999999978 S1W=20.005 S2iW=20.000084375 a=1.0888766996055554 b=-5.6872177686659006e-08 error_a=161.84564441183014 error_b=0.003988540742274152
IncidentMedium=Si LambdaRequested=7.043 S1H=0.39 S2iH=0.24999999999999978 S1W=19.952000000000005 S2iW=19.950864375000002 a=7.341821040427503 b=-6.012040147643712e-06 error_a=741.2376390289155 error_b=0.024193504430316405
IncidentMedium=Si LambdaRequested=4.25 S1H=0.39 S2iH=0.24999999999999978 S1W=8.779 S2iW=8.780164375000002 a=9.320962216410319 b=-3.708412514404863e-05 error_a=606.2605886476512 error_b=0.03099199091035445
IncidentMedium=Si LambdaRequested=4.25 S1H=0.39 S2iH=0.24999999999999978 S1W=20.002 S2iW=19.999844375000002 a=30.370149781266015 b=9.763444187558825e-05 error_a=2680.8766315704106 error_b=0.1365883376903538
IncidentMedium=Si LambdaRequested=4.25 S1H=0.77 S2iH=0.49312 S1W=12.489000000000004 S2iW=12.485564375000003 a=62.89965009567662 b=0.0001557592235018875 error_a=5488.459056149113 error_b=0.27948760026302427
IncidentMedium=Si LambdaRequested=4.25 S1H=0.774 S2iH=0.4930399999999997 S1W=20.001000000000005 S2iW=20.000244375 a=120.9852469160573 b=0.00020691590164400054 error_a=11657.27959807004 error_b=0.5869489140907286
IncidentMedium=Si LambdaRequested=4.25 S1H=1.525 S2iH=0.976 S1W=16.384000000000004 S2iW=16.395444375000004 a=356.40436234906264 b=0.0018275069497976878 error_a=36527.53453159627 error_b=1.8464457216875345
IncidentMedium=Si LambdaRequested=4.25 S1H=1.528 S2iH=0.976 S1W=20.004 S2iW=20.000244375 a=455.2870337782051 b=0.0018152748579145265 error_a=50088.87968853836 error_b=2.508098158009919
IncidentMedium=Si LambdaRequested=4.25 S1H=3.016 S2iH=1.9319199999999999 S1W=20.003000000000004 S2iW=20.000164375 a=2380.7392962875742 b=-0.03222957069862086 error_a=184998.5077522072 error_b=9.063057308166101
14 changes: 14 additions & 0 deletions reduction/data/sf_197912_Si_dt_par_46_200.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# y=a+bx
#
# LambdaRequested[Angstroms] S1H[mm] (S2/Si)H[mm] S1W[mm] (S2/Si)W[mm] a b error_a error_b
#
# Medium=Si, runs: [197920, 197921, 197922, 197923, 197924, 197925, 197926, 197927, 197928, 197929, 197930, 197931]
IncidentMedium=Si LambdaRequested=9.74 S1H=0.391 S2iH=0.24999999999999978 S1W=20.005 S2iW=20.000084375 a=1.0888766996055554 b=-5.6872177686659006e-08 error_a=161.84564441183014 error_b=0.003988540742274152
IncidentMedium=Si LambdaRequested=7.043 S1H=0.39 S2iH=0.24999999999999978 S1W=19.952000000000005 S2iW=19.950864375000002 a=7.341821040427503 b=-6.012040147643712e-06 error_a=741.2376390289155 error_b=0.024193504430316405
IncidentMedium=Si LambdaRequested=4.25 S1H=0.39 S2iH=0.24999999999999978 S1W=8.779 S2iW=8.780164375000002 a=9.320962216410319 b=-3.708412514404863e-05 error_a=606.2605886476512 error_b=0.03099199091035445
IncidentMedium=Si LambdaRequested=4.25 S1H=0.39 S2iH=0.24999999999999978 S1W=20.002 S2iW=19.999844375000002 a=30.370149781266015 b=9.763444187558825e-05 error_a=2680.8766315704106 error_b=0.1365883376903538
IncidentMedium=Si LambdaRequested=4.25 S1H=0.77 S2iH=0.49312 S1W=12.489000000000004 S2iW=12.485564375000003 a=62.89965009567662 b=0.0001557592235018875 error_a=5488.459056149113 error_b=0.27948760026302427
IncidentMedium=Si LambdaRequested=4.25 S1H=0.774 S2iH=0.4930399999999997 S1W=20.001000000000005 S2iW=20.000244375 a=120.9852469160573 b=0.00020691590164400054 error_a=11657.27959807004 error_b=0.5869489140907286
IncidentMedium=Si LambdaRequested=4.25 S1H=1.525 S2iH=0.976 S1W=16.384000000000004 S2iW=16.395444375000004 a=356.40436234906264 b=0.0018275069497976878 error_a=36527.53453159627 error_b=1.8464457216875345
IncidentMedium=Si LambdaRequested=4.25 S1H=1.528 S2iH=0.976 S1W=20.004 S2iW=20.000244375 a=455.2870337782051 b=0.0018152748579145265 error_a=50088.87968853836 error_b=2.508098158009919
IncidentMedium=Si LambdaRequested=4.25 S1H=3.016 S2iH=1.9319199999999999 S1W=20.003000000000004 S2iW=20.000164375 a=2380.7392962875742 b=-0.03222957069862086 error_a=184998.5077522072 error_b=9.063057308166101
14 changes: 14 additions & 0 deletions reduction/data/sf_197912_Si_dt_par_46_300.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# y=a+bx
#
# LambdaRequested[Angstroms] S1H[mm] (S2/Si)H[mm] S1W[mm] (S2/Si)W[mm] a b error_a error_b
#
# Medium=Si, runs: [197920, 197921, 197922, 197923, 197924, 197925, 197926, 197927, 197928, 197929, 197930, 197931]
IncidentMedium=Si LambdaRequested=9.74 S1H=0.391 S2iH=0.24999999999999978 S1W=20.005 S2iW=20.000084375 a=0.9696521424239634 b=3.109825930777195e-06 error_a=233.25548699691095 error_b=0.005709869223821722
IncidentMedium=Si LambdaRequested=7.043 S1H=0.39 S2iH=0.24999999999999978 S1W=19.952000000000005 S2iW=19.950864375000002 a=7.888065990554204 b=-2.5851412589413515e-05 error_a=1054.563051347941 error_b=0.033950572631030344
IncidentMedium=Si LambdaRequested=4.25 S1H=0.39 S2iH=0.24999999999999978 S1W=8.779 S2iW=8.780164375000002 a=9.62385188352408 b=-5.570512058074805e-05 error_a=871.2007519922379 error_b=0.043472028815114895
IncidentMedium=Si LambdaRequested=4.25 S1H=0.39 S2iH=0.24999999999999978 S1W=20.002 S2iW=19.999844375000002 a=30.788530271881037 b=7.368170486421024e-05 error_a=3864.1491573285743 error_b=0.1924859170699873
IncidentMedium=Si LambdaRequested=4.25 S1H=0.77 S2iH=0.49312 S1W=12.489000000000004 S2iW=12.485564375000003 a=63.48718014559093 b=0.0001257591150576306 error_a=7921.015153325416 error_b=0.394555674637449
IncidentMedium=Si LambdaRequested=4.25 S1H=0.774 S2iH=0.4930399999999997 S1W=20.001000000000005 S2iW=20.000244375 a=128.62729619621012 b=-0.0002561652398998484 error_a=16762.476487369557 error_b=0.8226687408455199
IncidentMedium=Si LambdaRequested=4.25 S1H=1.525 S2iH=0.976 S1W=16.384000000000004 S2iW=16.395444375000004 a=369.7306065840916 b=0.0010537182539730222 error_a=52662.092278312455 error_b=2.599967726224994
IncidentMedium=Si LambdaRequested=4.25 S1H=1.528 S2iH=0.976 S1W=20.004 S2iW=20.000244375 a=489.54945849091285 b=-0.00023641838136746494 error_a=72046.19892232501 error_b=3.5158122875352493
IncidentMedium=Si LambdaRequested=4.25 S1H=3.016 S2iH=1.9319199999999999 S1W=20.003000000000004 S2iW=20.000164375 a=2761.264907784248 b=-0.05537054457130235 error_a=264191.38397000416 error_b=12.510086943391116
16 changes: 0 additions & 16 deletions reduction/lr_reduction/DeadTimeCorrection.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,6 @@
import numpy as np
import scipy

def call(InputWorkspace, InputErrorEventsWorkspace=None, DeadTime=4.2, TOFStep=100., Paralyzable=False, TOFRange=[0, 0], OutputWorkspace='correction'):
"""
Function to make the algorithm call similar to a normal Mantid call
"""
algo = SingleReadoutDeadTimeCorrection()
algo.PyInit()
algo.setProperty("InputWorkspace", InputWorkspace)
algo.setProperty("InputErrorEventsWorkspace", InputErrorEventsWorkspace)
algo.setProperty("DeadTime", DeadTime)
algo.setProperty("TOFStep", TOFStep)
algo.setProperty("Paralyzable", Paralyzable)
algo.setProperty("TOFRange", TOFRange)
algo.setProperty("OutputWorkspace", OutputWorkspace)
algo.PyExec()
return algo.getProperty('OutputWorkspace').value


class SingleReadoutDeadTimeCorrection(PythonAlgorithm):

Expand Down
31 changes: 17 additions & 14 deletions reduction/lr_reduction/event_reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from . import background
from . import DeadTimeCorrection
from lr_reduction.utils import mantid_algorithm_exec


def get_wl_range(ws):
Expand Down Expand Up @@ -246,26 +247,28 @@ def get_dead_time_correction(self):

run_number = self._ws_sc.getRun().getProperty("run_number").value
error_ws = api.LoadErrorEventsNexus("REF_L_%s" % run_number)
corr_ws = DeadTimeCorrection.call(InputWorkspace=self._ws_sc,
InputErrorEventsWorkspace=error_ws,
DeadTime=self.DEAD_TIME,
TOFStep=self.DEAD_TIME_TOF_STEP,
Paralyzable=self.paralyzable,
TOFRange=[tof_min, tof_max],
OutputWorkspace="corr")
corr_ws = mantid_algorithm_exec(DeadTimeCorrection.SingleReadoutDeadTimeCorrection,
InputWorkspace=self._ws_sc,
InputErrorEventsWorkspace=error_ws,
DeadTime=self.DEAD_TIME,
TOFStep=self.DEAD_TIME_TOF_STEP,
Paralyzable=self.paralyzable,
TOFRange=[tof_min, tof_max],
OutputWorkspace="corr")
corr_sc = corr_ws.readY(0)
wl_bins = corr_ws.readX(0) / self.constant

# Direct beam workspace
run_number = self._ws_db.getRun().getProperty("run_number").value
error_ws = api.LoadErrorEventsNexus("REF_L_%s" % run_number)
corr_ws = DeadTimeCorrection.call(InputWorkspace=self._ws_db,
InputErrorEventsWorkspace=error_ws,
DeadTime=self.DEAD_TIME,
TOFStep=self.DEAD_TIME_TOF_STEP,
Paralyzable=self.paralyzable,
TOFRange=[tof_min, tof_max],
OutputWorkspace="corr")
corr_ws = mantid_algorithm_exec(DeadTimeCorrection.SingleReadoutDeadTimeCorrection,
InputWorkspace=self._ws_db,
InputErrorEventsWorkspace=error_ws,
DeadTime=self.DEAD_TIME,
TOFStep=self.DEAD_TIME_TOF_STEP,
Paralyzable=self.paralyzable,
TOFRange=[tof_min, tof_max],
OutputWorkspace="corr")
corr_db = corr_ws.readY(0)

# Flip the correction since we are going from TOF to Q
Expand Down
Loading
Loading