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
b11e7356
Commit
b11e7356
authored
9 years ago
by
Peterson, Peter
Browse files
Options
Downloads
Patches
Plain Diff
Adding algorithm to create PDFgetN input file from raw data
parent
f821234b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Code/Mantid/Framework/PythonInterface/plugins/algorithms/PDToPDFgetN.py
+129
-0
129 additions, 0 deletions
...amework/PythonInterface/plugins/algorithms/PDToPDFgetN.py
with
129 additions
and
0 deletions
Code/Mantid/Framework/PythonInterface/plugins/algorithms/PDToPDFgetN.py
0 → 100644
+
129
−
0
View file @
b11e7356
from
mantid.simpleapi
import
*
from
mantid.api
import
*
from
mantid.kernel
import
Direction
,
FloatArrayProperty
import
mantid
COMPRESS_TOL_TOF
=
.
01
class
PDToPDFgetN
(
DataProcessorAlgorithm
):
def
category
(
self
):
return
"
Workflow
\\
Diffraction;PythonAlgorithms
"
def
name
(
self
):
return
"
PDToPDFgetN
"
def
summary
(
self
):
return
"
The algorithm used converting raw data to pdfgetn input files
"
def
PyInit
(
self
):
self
.
declareProperty
(
FileProperty
(
name
=
"
Filename
"
,
defaultValue
=
""
,
action
=
FileAction
.
Load
,
extensions
=
[
"
_event.nxs
"
,
"
.nxs.h5
"
]),
"
Event file
"
)
self
.
declareProperty
(
"
MaxChunkSize
"
,
0.0
,
"
Specify maximum Gbytes of file to read in one chunk. Default is whole file.
"
)
self
.
declareProperty
(
"
FilterBadPulses
"
,
95.
,
doc
=
"
Filter out events measured while proton
"
+
"
charge is more than 5% below average
"
)
self
.
declareProperty
(
MatrixWorkspaceProperty
(
"
InputWorkspace
"
,
""
,
direction
=
Direction
.
Input
,
optional
=
PropertyMode
.
Optional
),
doc
=
"
Handle to reduced workspace
"
)
self
.
declareProperty
(
FileProperty
(
name
=
"
CalibrationFile
"
,
defaultValue
=
""
,
action
=
FileAction
.
OptionalLoad
,
extensions
=
[
"
.h5
"
,
"
.hd5
"
,
"
.hdf
"
,
"
.cal
"
]))
self
.
declareProperty
(
FileProperty
(
name
=
"
CharacterizationRunsFile
"
,
defaultValue
=
""
,
action
=
FileAction
.
OptionalLoad
,
extensions
=
[
"
txt
"
]),
"
File with characterization runs denoted
"
)
self
.
declareProperty
(
"
RemovePromptPulseWidth
"
,
0.0
,
"
Width of events (in microseconds) near the prompt pulse to remove. 0 disables
"
)
self
.
declareProperty
(
"
CropWavelengthMin
"
,
0.
,
"
Crop the data at this minimum wavelength.
"
)
self
.
declareProperty
(
"
CropWavelengthMax
"
,
0.
,
"
Crop the data at this maximum wavelength.
"
)
self
.
declareProperty
(
FloatArrayProperty
(
"
Binning
"
,
values
=
[
0.
,
0.
,
0.
],
direction
=
Direction
.
Input
),
"
Positive is linear bins, negative is logorithmic
"
)
self
.
declareProperty
(
"
ResampleX
"
,
0
,
"
Number of bins in x-axis. Non-zero value overrides
\"
Params
\"
property.
"
+
"
Negative value means logorithmic binning.
"
)
self
.
declareProperty
(
MatrixWorkspaceProperty
(
"
OutputWorkspace
"
,
""
,
direction
=
Direction
.
Output
),
doc
=
"
Handle to reduced workspace
"
)
self
.
declareProperty
(
FileProperty
(
name
=
"
PDFgetNFile
"
,
defaultValue
=
""
,
action
=
FileAction
.
Save
,
extensions
=
[
"
.getn
"
]),
"
Output filename
"
)
def
_loadCharacterizations
(
self
):
self
.
_focusPos
=
{}
self
.
_iparmFile
=
None
charFilename
=
self
.
getProperty
(
"
CharacterizationRunsFile
"
).
value
if
charFilename
is
None
or
len
(
charFilename
)
<=
0
:
return
results
=
PDLoadCharacterizations
(
Filename
=
charFilename
,
OutputWorkspace
=
"
characterizations
"
)
self
.
_iparmFile
=
results
[
1
]
self
.
_focusPos
[
'
PrimaryFlightPath
'
]
=
results
[
2
]
self
.
_focusPos
[
'
SpectrumIDs
'
]
=
results
[
3
]
self
.
_focusPos
[
'
L2
'
]
=
results
[
4
]
self
.
_focusPos
[
'
Polar
'
]
=
results
[
5
]
self
.
_focusPos
[
'
Azimuthal
'
]
=
results
[
6
]
def
PyExec
(
self
):
filename
=
self
.
getProperty
(
"
Filename
"
).
value
self
.
_loadCharacterizations
()
wksp
=
LoadEventAndCompress
(
Filename
=
self
.
getProperty
(
"
Filename
"
).
value
,
OutputWorkspace
=
self
.
getPropertyValue
(
"
OutputWorkspace
"
),
MaxChunkSize
=
self
.
getProperty
(
"
MaxChunkSize
"
).
value
,
FilterBadPulses
=
self
.
getProperty
(
"
FilterBadPulses
"
).
value
,
CompressTOFTolerance
=
COMPRESS_TOL_TOF
)
charac
=
""
if
mtd
.
doesExist
(
"
characterizations
"
):
charac
=
"
characterizations
"
# get the correct row of the table
PDDetermineCharacterizations
(
InputWorkspace
=
wksp
,
Characterizations
=
charac
,
ReductionProperties
=
"
__snspowderreduction
"
)
wksp
=
AlignAndFocusPowder
(
InputWorkspace
=
wksp
,
OutputWorkspace
=
wksp
,
CalFileName
=
self
.
getProperty
(
"
CalibrationFile
"
).
value
,
Params
=
self
.
getProperty
(
"
Binning
"
).
value
,
ResampleX
=
self
.
getProperty
(
"
ResampleX
"
).
value
,
Dspacing
=
True
,
PreserveEvents
=
False
,
RemovePromptPulseWidth
=
self
.
getProperty
(
"
RemovePromptPulseWidth
"
).
value
,
CompressTolerance
=
COMPRESS_TOL_TOF
,
CropWavelengthMin
=
self
.
getProperty
(
"
CropWavelengthMin
"
).
value
,
CropWavelengthMax
=
self
.
getProperty
(
"
CropWavelengthMax
"
).
value
,
ReductionProperties
=
"
__snspowderreduction
"
,
**
(
self
.
_focusPos
))
wksp
=
NormaliseByCurrent
(
InputWorkspace
=
wksp
,
OutputWorkspace
=
wksp
)
wksp
.
getRun
()[
'
gsas_monitor
'
]
=
1
if
self
.
_iparmFile
is
not
None
:
wksp
.
getRun
()[
'
iparm_file
'
]
=
self
.
_iparmFile
wksp
=
SetUncertainties
(
InputWorkspace
=
wksp
,
OutputWorkspace
=
wksp
,
SetError
=
"
sqrt
"
)
SaveGSS
(
InputWorkspace
=
wksp
,
Filename
=
self
.
getProperty
(
"
PDFgetNFile
"
).
value
,
SplitFiles
=
False
,
Append
=
False
,
MultiplyByBinWidth
=
False
,
Bank
=
mantid
.
pmds
[
"
__snspowderreduction
"
][
"
bank
"
].
value
,
Format
=
"
SLOG
"
,
ExtendedHeader
=
True
)
self
.
setProperty
(
"
OutputWorkspace
"
,
wksp
)
# Register algorithm with Mantid.
AlgorithmFactory
.
subscribe
(
PDToPDFgetN
)
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