Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
climix
climix
Commits
0ff96c73
Commit
0ff96c73
authored
May 01, 2021
by
Klaus Zimmermann
Browse files
Fix comparison operators in CountPercentileOccurrences (fixes #224)
parent
e2dabd16
Changes
1
Hide whitespace changes
Inline
Side-by-side
climix/index_functions/percentile_functions.py
View file @
0ff96c73
...
...
@@ -4,7 +4,7 @@ import cftime
import
dask.array
as
da
import
numpy
as
np
from
.support
import
IndexFunction
,
parse_timerange
from
.support
import
IndexFunction
,
parse_timerange
,
NUMPY_OPERATORS
,
DASK_OPERATORS
from
..dask_setup
import
progress
from
..dask_take_along_axis
import
dask_take_along_axis
...
...
@@ -186,6 +186,8 @@ class CountPercentileOccurrences(IndexFunction):
self
.
base
=
timerange
percentile
.
convert_units
(
'1'
)
self
.
percentile
=
float
(
percentile
.
points
)
self
.
condition
=
NUMPY_OPERATORS
[
condition
]
self
.
lazy_condition
=
DASK_OPERATORS
[
condition
]
self
.
bootstrapping
=
bootstrapping
def
preprocess
(
self
,
cubes
,
client
):
...
...
@@ -269,7 +271,7 @@ class CountPercentileOccurrences(IndexFunction):
quantiles
=
self
.
quantiler
.
quantiles
(
ignore_year
=
year
,
duplicate_year
=
duplicate_year
)
cond
=
data
[...]
<
quantiles
cond
=
self
.
lazy_condition
(
data
[...]
,
quantiles
)
count
=
da
.
count_nonzero
(
cond
,
axis
=
0
)
counts
.
append
(
count
)
counts
=
da
.
stack
(
counts
,
axis
=-
1
)
...
...
@@ -278,7 +280,7 @@ class CountPercentileOccurrences(IndexFunction):
percents
=
avg_counts
/
(
data
.
shape
[
0
]
/
100.
)
else
:
logging
.
info
(
'Not using bootstrapping'
)
cond
=
data
<
self
.
out_of_base_quantiles
cond
=
self
.
lazy_condition
(
data
,
self
.
out_of_base_quantiles
)
counts
=
da
.
count_nonzero
(
cond
,
axis
=
0
).
astype
(
np
.
float32
)
percents
=
counts
/
(
data
.
shape
[
0
]
/
100.
)
return
percents
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