Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
f65bb605
Commit
f65bb605
authored
Jun 29, 2021
by
Whitfield, Ross
Browse files
Cleanup temp workspaces
parent
a196b517
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/Calibration/tofpd/group_calibration.py
View file @
f65bb605
...
...
@@ -10,7 +10,7 @@ from mantid.simpleapi import (ConvertUnits, ExtractSpectra,
ApplyDiffCal
,
DiffractionFocussing
,
PDCalibration
,
Load
,
LoadMask
,
LoadDiffCal
,
LoadDetectorsGroupingFile
,
SaveDiffCal
)
SaveDiffCal
,
DeleteWorkspace
)
# Diamond peak positions in d-space
DIAMOND
=
(
0.3117
,
0.3257
,
0.3499
,
0.4205
,
0.4645
,
...
...
@@ -59,28 +59,29 @@ def cc_calibrate_groups(data_ws,
for
group
in
group_list
:
indexes
=
np
.
where
(
group_ws
.
extractY
().
flatten
()
==
group
)[
0
]
ExtractSpectra
(
data_d
,
WorkspaceIndexList
=
indexes
,
OutputWorkspace
=
f
'_tmp_group_
{
group
}
'
)
ExtractUnmaskedSpectra
(
f
'_tmp_group_
{
group
}
'
,
OutputWorkspace
=
f
'_tmp_group_
{
group
}
'
)
if
mtd
[
f
'_tmp_group_
{
group
}
'
].
getNumberHistograms
()
<
2
:
ExtractSpectra
(
data_d
,
WorkspaceIndexList
=
indexes
,
OutputWorkspace
=
'_tmp_group_
cc
'
)
ExtractUnmaskedSpectra
(
'_tmp_group_
cc
'
,
OutputWorkspace
=
'_tmp_group_
cc
'
)
if
mtd
[
'_tmp_group_
cc
'
].
getNumberHistograms
()
<
2
:
continue
Rebin
(
f
'_tmp_group_
{
group
}
'
,
Params
=
f
'
{
Xmin
}
,
{
Step
}
,
{
Xmax
}
'
,
OutputWorkspace
=
f
'_tmp_group_
{
group
}
'
)
CrossCorrelate
(
f
'_tmp_group_
{
group
}
'
,
Rebin
(
'_tmp_group_
cc
'
,
Params
=
f
'
{
Xmin
}
,
{
Step
}
,
{
Xmax
}
'
,
OutputWorkspace
=
'_tmp_group_
cc
'
)
CrossCorrelate
(
'_tmp_group_
cc
'
,
Xmin
=
Xmin
,
XMax
=
Xmax
,
MaxDSpaceShift
=
MaxDSpaceShift
,
WorkspaceIndexMin
=
0
,
WorkspaceIndexMax
=
mtd
[
f
'_tmp_group_
{
group
}
'
].
getNumberHistograms
()
-
1
,
OutputWorkspace
=
f
'_tmp_group_
{
group
}
_
cc'
)
WorkspaceIndexMax
=
mtd
[
'_tmp_group_
cc
'
].
getNumberHistograms
()
-
1
,
OutputWorkspace
=
'_tmp_group_cc'
)
bin_range
=
(
Xmax
-
Xmin
)
/
Step
GetDetectorOffsets
(
InputWorkspace
=
f
'_tmp_group_
{
group
}
_
cc'
,
GetDetectorOffsets
(
InputWorkspace
=
'_tmp_group_cc'
,
Step
=
Step
,
Xmin
=-
bin_range
,
XMax
=
bin_range
,
DReference
=
DReference
,
MaxOffset
=
1
,
OutputWorkspace
=
f
'
{
output_basename
}
_offsets_
{
group
}
'
)
previous_calibration
=
ConvertDiffCal
(
f
'
{
output_basename
}
_offsets_
{
group
}
'
,
OutputWorkspace
=
'_tmp_
group
_cc
'
)
previous_calibration
=
ConvertDiffCal
(
'_tmp_
group
_cc
'
,
PreviousCalibration
=
previous_calibration
,
OutputWorkspace
=
f
'
{
output_basename
}
_cc_diffcal'
)
DeleteWorkspace
(
'_tmp_group_cc'
)
return
mtd
[
f
'
{
output_basename
}
_cc_diffcal'
]
...
...
@@ -124,14 +125,14 @@ def pdcalibration_groups(data_ws,
ApplyDiffCal
(
data_ws
,
CalibrationWorkspace
=
cc_diffcal
)
ConvertUnits
(
data_ws
,
Target
=
'dSpacing'
,
OutputWorkspace
=
'_tmp_data_aligned'
)
DiffractionFocussing
(
'_tmp_data_aligned'
,
GroupingWorkspace
=
group_ws
,
OutputWorkspace
=
'_tmp_data_aligned
_focussed
'
)
DiffractionFocussing
(
'_tmp_data_aligned'
,
GroupingWorkspace
=
group_ws
,
OutputWorkspace
=
'_tmp_data_aligned'
)
# Remove the following line after new CombineDiffCal algorithm is implemented as that will use the calibrated difc
ApplyDiffCal
(
'_tmp_data_aligned
_focussed
'
,
ClearCalibration
=
True
)
ApplyDiffCal
(
'_tmp_data_aligned'
,
ClearCalibration
=
True
)
ConvertUnits
(
'_tmp_data_aligned
_focussed
'
,
Target
=
'TOF'
,
OutputWorkspace
=
'_tmp_data_aligned
_focussed
'
)
ConvertUnits
(
'_tmp_data_aligned'
,
Target
=
'TOF'
,
OutputWorkspace
=
'_tmp_data_aligned'
)
PDCalibration
(
InputWorkspace
=
'_tmp_data_aligned
_focussed
'
,
PDCalibration
(
InputWorkspace
=
'_tmp_data_aligned'
,
TofBinning
=
TofBinning
,
PreviousCalibrationTable
=
previous_calibration
,
PeakFunction
=
PeakFunction
,
...
...
@@ -148,7 +149,7 @@ def pdcalibration_groups(data_ws,
cc_det_to_difc
=
dict
(
zip
(
cc_diffcal
.
column
(
'detid'
),
cc_diffcal
.
column
(
'difc'
)))
grouped
=
mtd
[
'_tmp_data_aligned
_focussed
'
]
grouped
=
mtd
[
'_tmp_data_aligned'
]
specInfo
=
grouped
.
spectrumInfo
()
grouped_det_to_difc
=
{}
...
...
@@ -164,6 +165,8 @@ def pdcalibration_groups(data_ws,
*
cc_det_to_difc
[
detid
]
/
grouped_det_to_difc
[
detid
])
DeleteWorkspace
(
'_tmp_data_aligned'
)
return
mtd
[
f
'
{
output_basename
}
_cc_pd_diffcal'
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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