Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
21463dba
Commit
21463dba
authored
7 years ago
by
Peterson, Peter
Browse files
Options
Downloads
Patches
Plain Diff
Only load calibration file once per invocation
parent
c8af42be
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Framework/PythonInterface/plugins/algorithms/AlignAndFocusPowderFromFiles.py
+32
-5
32 additions, 5 deletions
...erface/plugins/algorithms/AlignAndFocusPowderFromFiles.py
with
32 additions
and
5 deletions
Framework/PythonInterface/plugins/algorithms/AlignAndFocusPowderFromFiles.py
+
32
−
5
View file @
21463dba
...
...
@@ -2,7 +2,7 @@ from __future__ import (absolute_import, division, print_function)
from
mantid.api
import
mtd
,
AlgorithmFactory
,
DataProcessorAlgorithm
,
ITableWorkspaceProperty
,
\
MatrixWorkspaceProperty
,
MultipleFileProperty
,
PropertyMode
from
mantid.kernel
import
Direction
from
mantid.kernel
import
ConfigService
,
Direction
from
mantid.simpleapi
import
AlignAndFocusPowder
,
CompressEvents
,
ConvertUnits
,
CreateCacheFilename
,
\
DeleteWorkspace
,
DetermineChunking
,
Divide
,
EditInstrumentGeometry
,
FilterBadPulses
,
Load
,
\
LoadNexusProcessed
,
PDDetermineCharacterizations
,
Plus
,
RenameWorkspace
,
SaveNexusProcessed
...
...
@@ -10,9 +10,11 @@ import os
EXTENSIONS_NXS
=
[
"
_event.nxs
"
,
"
.nxs.h5
"
]
PROPS_FOR_INSTR
=
[
"
PrimaryFlightPath
"
,
"
SpectrumIDs
"
,
"
L2
"
,
"
Polar
"
,
"
Azimuthal
"
]
PROPS_FOR_ALIGN
=
[
"
CalFileName
"
,
"
GroupFilename
"
,
"
GroupingWorkspace
"
,
"
CalibrationWorkspace
"
,
"
OffsetsWorkspace
"
,
"
MaskWorkspace
"
,
"
MaskBinTable
"
,
CAL_FILE
,
GROUP_FILE
=
"
CalFileName
"
,
"
GroupFilename
"
CAL_WKSP
,
GRP_WKSP
,
MASK_WKSP
=
"
CalibrationWorkspace
"
,
"
GroupingWorkspace
"
,
"
MaskWorkspace
"
PROPS_FOR_ALIGN
=
[
CAL_FILE
,
GROUP_FILE
,
GRP_WKSP
,
CAL_WKSP
,
"
OffsetsWorkspace
"
,
MASK_WKSP
,
"
MaskBinTable
"
,
"
Params
"
,
"
ResampleX
"
,
"
Dspacing
"
,
"
DMin
"
,
"
DMax
"
,
"
TMin
"
,
"
TMax
"
,
"
PreserveEvents
"
,
"
RemovePromptPulseWidth
"
,
"
CompressTolerance
"
,
...
...
@@ -99,6 +101,29 @@ class AlignAndFocusPowderFromFiles(DataProcessorAlgorithm):
args
[
name
]
=
prop
.
value
return
args
def
__updateAlignAndFocusArgs
(
self
,
wkspname
):
self
.
log
().
warning
(
'
__updateAlignAndFocusArgs(%s)!!!!!!!
'
%
wkspname
)
# if the files are missing, there is nothing to do
if
(
not
CAL_FILE
in
self
.
kwargs
)
and
(
not
GROUP_FILE
in
self
.
kwargs
):
self
.
log
().
warning
(
'
--> Nothing to do
'
)
self
.
log
().
warning
(
'
--> Updating
'
)
# delete the files from the list of kwargs
if
CAL_FILE
in
self
.
kwargs
:
del
self
.
kwargs
[
CAL_FILE
]
if
CAL_FILE
in
self
.
kwargs
:
del
self
.
kwargs
[
GROUP_FILE
]
# get the instrument name
instr
=
mtd
[
wkspname
].
getInstrument
().
getName
()
instr
=
ConfigService
.
getInstrument
(
instr
).
shortName
()
# use the canonical names if they weren't specifed
for
key
,
ext
in
zip
((
CAL_WKSP
,
GRP_WKSP
,
MASK_WKSP
),
(
'
_cal
'
,
'
_group
'
,
'
_mask
'
)):
if
not
key
in
self
.
kwargs
:
self
.
kwargs
[
key
]
=
instr
+
ext
def
__determineCharacterizations
(
self
,
filename
,
wkspname
):
tempname
=
'
__%s_temp
'
%
wkspname
Load
(
Filename
=
filename
,
OutputWorkspace
=
tempname
,
...
...
@@ -172,6 +197,7 @@ class AlignAndFocusPowderFromFiles(DataProcessorAlgorithm):
prog_start
+=
2.
*
prog_per_chunk_step
# AlignAndFocusPowder counts for two steps
if
j
==
0
:
self
.
__updateAlignAndFocusArgs
(
chunkname
)
RenameWorkspace
(
InputWorkspace
=
chunkname
,
OutputWorkspace
=
wkspname
)
else
:
Plus
(
LHSWorkspace
=
wkspname
,
RHSWorkspace
=
chunkname
,
OutputWorkspace
=
wkspname
,
...
...
@@ -199,7 +225,8 @@ class AlignAndFocusPowderFromFiles(DataProcessorAlgorithm):
for
(
i
,
filename
)
in
enumerate
(
filenames
):
# default name is based off of filename
wkspname
=
os
.
path
.
split
(
filename
)[
-
1
].
split
(
'
.
'
)[
0
]
self
.
__determineCharacterizations
(
filename
,
wkspname
)
self
.
__determineCharacterizations
(
filename
,
wkspname
)
# updates instance variable
cachefile
=
self
.
__getCacheName
(
wkspname
)
wkspname
+=
'
_f%d
'
%
i
# add file number to be unique
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment