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
518d606a
Commit
518d606a
authored
10 years ago
by
Harry Jeffery
Browse files
Options
Downloads
Patches
Plain Diff
Refs #11353 CutMD: Support up to 5 binning dimensions
parent
51408cec
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/CutMD.py
+43
-39
43 additions, 39 deletions
...nInterface/plugins/algorithms/WorkflowAlgorithms/CutMD.py
with
43 additions
and
39 deletions
Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/CutMD.py
+
43
−
39
View file @
518d606a
...
...
@@ -41,6 +41,9 @@ class CutMD(DataProcessorAlgorithm):
self
.
declareProperty
(
FloatArrayProperty
(
name
=
'
P4Bin
'
,
values
=
[]),
doc
=
'
Projection 4 binning
'
)
self
.
declareProperty
(
FloatArrayProperty
(
name
=
'
P5Bin
'
,
values
=
[]),
doc
=
'
Projection 5 binning
'
)
self
.
declareProperty
(
IMDWorkspaceProperty
(
'
OutputWorkspace
'
,
''
,
\
direction
=
Direction
.
Output
),
doc
=
'
Output cut workspace
'
)
...
...
@@ -240,11 +243,16 @@ class CutMD(DataProcessorAlgorithm):
projection_table
=
self
.
getProperty
(
"
Projection
"
).
value
self
.
__verify_projection_input
(
projection_table
)
p1_bins
=
self
.
getProperty
(
"
P1Bin
"
).
value
p2_bins
=
self
.
getProperty
(
"
P2Bin
"
).
value
p3_bins
=
self
.
getProperty
(
"
P3Bin
"
).
value
p4_bins_property
=
self
.
getProperty
(
"
P4Bin
"
)
p4_bins
=
p4_bins_property
.
value
#Fetch pbins properties
pbins
=
[
None
]
*
5
#Up to 5 dimensions
for
i
in
range
(
len
(
pbins
)):
pbins
[
i
]
=
self
.
getProperty
(
"
P{0}Bin
"
.
format
(
i
+
1
))
#Also check the correct pbin properties are set
if
pbins
[
i
].
isDefault
and
i
<
ndims
:
raise
ValueError
(
"
P{0}Bin dimension binning must be set on a workspace with {1} dimensions.
"
.
format
(
i
+
1
,
ndims
))
elif
not
pbins
[
i
].
isDefault
and
i
>=
ndims
:
raise
ValueError
(
"
Cannot set P{0}Bin dimension binning on a workspace with {1} dimensions.
"
.
format
(
i
+
1
,
ndims
))
x_extents
=
self
.
__extents_in_current_projection
(
to_cut
,
0
)
y_extents
=
self
.
__extents_in_current_projection
(
to_cut
,
1
)
...
...
@@ -257,40 +265,36 @@ class CutMD(DataProcessorAlgorithm):
u
,
v
,
w
=
self
.
__scale_projection
(
projection
,
origin_units
,
target_units
,
to_cut
)
extents
=
self
.
__calculate_extents
(
u
,
v
,
w
,
(
x_extents
,
y_extents
,
z_extents
)
)
extents
,
bins
=
self
.
__calculate_steps
(
extents
,
(
p1_bins
,
p2_bins
,
p3_bins
)
)
if
not
p4_bins_property
.
isDefault
:
if
ndims
==
4
:
n_args
=
len
(
p4_bins
)
min
,
max
=
self
.
__extents_in_current_projection
(
to_cut
,
3
)
d_range
=
max
-
min
if
n_args
==
1
:
step_size
=
p4_bins
[
0
]
nbins
=
d_range
/
step_size
elif
n_args
==
2
:
min
=
p4_bins
[
0
]
max
=
p4_bins
[
1
]
nbins
=
1
elif
n_args
==
3
:
min
=
p4_bins
[
0
]
max
=
p4_bins
[
2
]
step_size
=
p4_bins
[
1
]
dim_range
=
max
-
min
if
step_size
>
dim_range
:
step_size
=
dim_range
nbins
=
int
(
dim_range
/
step_size
)
extents
.
append
(
min
)
extents
.
append
(
max
)
bins
.
append
(
int
(
nbins
))
e_units
=
to_cut
.
getDimension
(
3
).
getUnits
()
temp
=
list
(
target_units
)
temp
.
append
(
target_units
)
target_units
=
tuple
(
temp
)
else
:
raise
ValueError
(
"
Cannot specify P4Bins unless the workspace is of sufficient dimensions
"
)
extents
,
bins
=
self
.
__calculate_steps
(
extents
,
(
pbins
[
0
].
value
,
pbins
[
1
].
value
,
pbins
[
2
].
value
)
)
for
i
in
range
(
3
,
ndims
):
pbin
=
pbins
[
i
].
value
n_args
=
len
(
pbin
)
min
,
max
=
self
.
__extents_in_current_projection
(
to_cut
,
i
)
d_range
=
max
-
min
if
n_args
==
1
:
step_size
=
pbin
[
0
]
nbins
=
d_range
/
step_size
elif
n_args
==
2
:
min
=
pbin
[
0
]
max
=
pbin
[
1
]
nbins
=
1
elif
n_args
==
3
:
min
=
pbin
[
0
]
max
=
pbin
[
2
]
step_size
=
pbin
[
1
]
dim_range
=
max
-
min
if
step_size
>
dim_range
:
step_size
=
dim_range
nbins
=
int
(
dim_range
/
step_size
)
extents
.
append
(
min
)
extents
.
append
(
max
)
bins
.
append
(
int
(
nbins
))
temp
=
list
(
target_units
)
temp
.
append
(
target_units
)
target_units
=
tuple
(
temp
)
projection_labels
=
self
.
__make_labels
(
projection
)
...
...
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