Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
nam
ProxPython
Commits
36c294f5
Commit
36c294f5
authored
Mar 27, 2020
by
Matthijs
Browse files
binning with NaN values in array
parent
df4dee90
Changes
1
Show whitespace changes
Inline
Side-by-side
proxtoolbox/Problems/OrbitalTomog/orbitaltomog_data_processor.py
View file @
36c294f5
...
...
@@ -120,6 +120,12 @@ def bin_2d_array(arr, new_shape):
"""
shape
=
(
new_shape
[
0
],
arr
.
shape
[
0
]
//
new_shape
[
0
],
new_shape
[
1
],
arr
.
shape
[
1
]
//
new_shape
[
1
])
if
np
.
any
(
np
.
isnan
(
arr
)):
binfactor
=
1
for
i
,
s
in
enumerate
(
arr
.
shape
):
binfactor
*=
new_shape
[
i
]
/
s
return
np
.
nanmean
(
arr
.
reshape
(
shape
),
axis
=
(
3
,
1
))
*
binfactor
else
:
return
arr
.
reshape
(
shape
).
sum
(
-
1
).
sum
(
1
)
...
...
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