Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
climix
climix
Commits
459c52f0
Commit
459c52f0
authored
May 29, 2019
by
Lars Bärring
Committed by
Klaus Zimmermann
May 29, 2019
Browse files
Thresholded statistics (closes #68)
parent
58be214d
Changes
3
Hide whitespace changes
Inline
Side-by-side
climix/etc/metadata.yml
View file @
459c52f0
...
...
@@ -37,6 +37,23 @@ index_functions:
reducer
:
kind
:
reducer
thresholded_statistics
:
description
:
|
Calculates a simple statistic of the data for which some condition is met.
First, the threshold is transformed to the same standard_name and units as
the input data.
Then the thresholding is performed as condition(data, threshold), ie
if condition is <, data < threshold.
Finally, the statistic is calculated for those data values that fulfill
the condition.
parameters
:
threshold
:
kind
:
quantity
condition
:
kind
:
operator
reducer
:
kind
:
reducer
indices
:
cdd
:
reference
:
ETCCDI
...
...
climix/index_functions.py
View file @
459c52f0
...
...
@@ -59,3 +59,20 @@ class SpellLength:
else
:
res
=
self
.
reducer
(
candidates
)
return
float
(
res
)
class
ThresholdedStatistics
:
def
__init__
(
self
,
threshold
,
condition
,
reducer
):
self
.
threshold
=
threshold
self
.
condition
=
condition
self
.
reducer
=
reducer
def
prepare
(
self
,
input_cube
):
change_units
(
self
.
threshold
,
input_cube
.
units
,
input_cube
.
standard_name
)
self
.
standard_name
=
input_cube
.
standard_name
self
.
units
=
input_cube
.
units
def
__call__
(
self
,
raw_data
):
comb
=
self
.
condition
(
raw_data
,
self
.
threshold
.
data
)
res
=
self
.
reducer
(
raw_data
[
comb
])
return
float
(
res
)
setup.py
View file @
459c52f0
...
...
@@ -51,6 +51,7 @@ setuptools.setup(
'climix.index_functions'
:
[
'count_occurrences=climix.index_functions:CountOccurences'
,
'spell_length=climix.index_functions:SpellLength'
,
'thresholded_statistics=climix.index_functions:ThresholdedStatistics'
,
],
},
project_urls
=
{
...
...
Write
Preview
Supports
Markdown
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