Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
sns-hfir-scse
sans
sans-backend
Commits
5a954ab5
Commit
5a954ab5
authored
Dec 19, 2018
by
Ferraz Leal, Ricardo Miguel
Browse files
Revert "Merge branch 'ricardo-14-normalisation' into 'master'"
This reverts merge request !22
parent
9c9643bf
Pipeline
#57694
passed with stages
in 3 minutes and 36 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ornl/sans/hfir/normalisation.py
deleted
100644 → 0
View file @
9c9643bf
from
__future__
import
print_function
def
time
(
input_ws
):
"""Normalise by time
Used to normalise dark current
Parameters
----------
input_ws : [Mantid Workspace]
"""
run
=
input_ws
.
getRun
()
timer
=
run
.
getProperty
(
"timer"
).
value
# seconds
res
=
input_ws
/
timer
return
res
def
monitor
(
input_ws
):
"""Normalise by the monitor value
Parameters
----------
input_ws : [Mantid Workspace]
"""
run
=
input_ws
.
getRun
()
monitor
=
run
.
getProperty
(
"monitor"
).
value
# counts
res
=
input_ws
/
monitor
return
res
ornl/sans/sns/eqsans/normalisation.py
deleted
100644 → 0
View file @
9c9643bf
from
__future__
import
print_function
from
mantid.simpleapi
import
(
LoadAscii
,
ConvertToHistogram
,
RebinToWorkspace
,
NormaliseToUnity
,
Divide
,
NormaliseByCurrent
,
Multiply
,
DeleteWorkspace
,
Integration
)
from
ornl.settings
import
unique_workspace_name
from
ornl.sans.sns.eqsans
import
dark_current
as
dkc
def
time
(
ws_input
,
ws_dark_current
,
out_ws
):
r
"""
Time normalization. It is only used for dark current.
It does not make sense to use it for other files
Parameters
----------
ws_input : Workspace
The workspace to be normalised
ws_dark_current: EventsWorkspace
Dark current workspace with units in time-of-flight
out_ws: str
Name of the normalized output workspace
Returns
-------
MatrixWorkspace
`ws_input` minus `ws_dark_current`
"""
dark_normal
=
dkc
.
normalise_to_workspace
(
ws_dark_current
,
ws_input
,
unique_workspace_name
())
difference
=
dkc
.
subtract_normalized_dark
(
ws_input
,
dark_normal
,
out_ws
)
DeleteWorkspace
(
dark_normal
)
# a bit of cleanup doesn't hurt
return
difference
def
monitor
(
ws_input
,
ws_monitor
,
ws_flux_to_monitor_ratio
):
r
"""Monitor normalisation
Parameters
----------
ws_input : Workspace
The workspace to be normalised
ws_monitor : Workspace
The workspace with the monitor count
ws_flux_to_monitor_ratio : Workspace
Pre-mesured flux-to-monitor ratio spectrum
Returns
-------
Workspace
[description]
"""
ws_tmp
=
Multiply
(
LHSWorkspace
=
ws_monitor
,
RHSWorkspace
=
ws_flux_to_monitor_ratio
)
ws
=
Divide
(
LHSWorkspace
=
ws_input
,
RHSWorkspace
=
ws_tmp
)
DeleteWorkspace
(
ws_tmp
)
return
ws
def
load_beam_flux_file
(
file_path
,
ws_reference
=
None
,
out_ws
):
r
"""Loads the ascii beam flux file
Parameters
----------
ws_reference : Workspace
The reference workspace to rebin the flux to. If none, does not
rebin the data.
out_ws: str
Name of the output workspace
"""
ws
=
LoadAscii
(
Filename
=
file_path
,
Separator
=
"Tab"
,
Unit
=
"Wavelength"
,
OutputWorkspace
=
out_ws
)
ws
=
ConvertToHistogram
(
InputWorkspace
=
ws
,
OutputWorkspace
=
out_ws
)
if
ws_reference
is
not
None
:
ws
=
RebinToWorkspace
(
WorkspaceToRebin
=
ws
,
WorkspaceToMatch
=
ws_reference
,
OutputWorkspace
=
out_ws
)
ws
=
NormaliseToUnity
(
ws
,
OutputWorkspace
=
out_ws
)
return
ws
def
proton_charge_and_flux
(
ws_input
,
ws_beam_flux
,
out_ws
):
r
"""Normalises ws to proton and measured flux
Parameters
----------
ws_input : Workspace
The workspace to be normalised
ws_beam_flux : Workspace
The measured beam flux file ws
out_ws: str
Name of the output workspace
"""
# Normalise by the flux
ws
=
Divide
(
LHSWorkspace
=
ws_input
,
RHSWorkspace
=
ws_beam_flux
,
OutputWorkspace
=
out_ws
)
# Normalize by Proton charge
NormaliseByCurrent
(
ws
,
OutputWorkspace
=
out_ws
)
return
ws
tests/unit/new/ornl/sans/hfir/test_normalisation.py
deleted
100644 → 0
View file @
9c9643bf
#!/usr/bin/env python
from
__future__
import
print_function
import
pytest
def
test_normalisation_monitor
(
gpsans_f
):
from
ornl.sans.hfir.normalisation
import
monitor
from
ornl.sans.samplelogs
import
SampleLogs
from
mantid.simpleapi
import
LoadSpice2D
from
mantid
import
mtd
input_sample_ws_mame
=
'input_sample_ws_name'
LoadSpice2D
(
Filename
=
gpsans_f
[
'sample_scattering'
],
OutputWorkspace
=
input_sample_ws_mame
)
input_sample_ws
=
mtd
[
input_sample_ws_mame
]
output_sample_ws
=
monitor
(
input_sample_ws
)
sample_logs
=
SampleLogs
(
input_sample_ws
)
monitor_counts
=
sample_logs
.
monitor
.
value
assert
monitor_counts
==
1284652
assert
output_sample_ws
.
readY
(
0
)[
0
]
==
\
pytest
.
approx
(
input_sample_ws
.
readY
(
0
)[
0
]
/
monitor_counts
)
def
test_normalisation_time
(
gpsans_f
):
from
ornl.sans.hfir.normalisation
import
time
from
ornl.sans.samplelogs
import
SampleLogs
from
mantid.simpleapi
import
LoadSpice2D
from
mantid
import
mtd
input_sample_ws_mame
=
'input_sample_ws_name'
LoadSpice2D
(
Filename
=
gpsans_f
[
'sample_scattering'
],
OutputWorkspace
=
input_sample_ws_mame
)
input_sample_ws
=
mtd
[
input_sample_ws_mame
]
output_sample_ws
=
time
(
input_sample_ws
)
sample_logs
=
SampleLogs
(
input_sample_ws
)
timer
=
float
(
sample_logs
.
timer
.
value
)
assert
timer
==
60.0
assert
output_sample_ws
.
readY
(
612
)[
0
]
==
\
pytest
.
approx
(
input_sample_ws
.
readY
(
612
)[
0
]
/
timer
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment