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
c0216671
Commit
c0216671
authored
Nov 19, 2019
by
Lars Bärring
Committed by
Klaus Zimmermann
Nov 19, 2019
Browse files
Index function statistics (closes #79)
parent
7bfceb07
Changes
3
Hide whitespace changes
Inline
Side-by-side
climix/etc/metadata.yml
View file @
c0216671
...
...
@@ -65,6 +65,13 @@ index_functions:
reducer
:
kind
:
reducer
statistics
:
description
:
|
Calculates a simple statistic of the data.
parameters
:
reducer
:
kind
:
reducer
thresholded_statistics
:
description
:
|
Calculates a simple statistic of the data for which some condition is met.
...
...
climix/index_functions.py
View file @
c0216671
...
...
@@ -241,6 +241,27 @@ class SpellLength:
return
float
(
res
)
class
Statistics
:
def
__init__
(
self
,
reducer
):
self
.
reducer
=
NUMPY_REDUCERS
[
reducer
]
self
.
lazy_reducer
=
DASK_REDUCERS
[
reducer
]
self
.
extra_coords
=
[]
def
prepare
(
self
,
input_cube
):
self
.
standard_name
=
input_cube
.
standard_name
self
.
units
=
input_cube
.
units
def
call_func
(
self
,
data
,
axis
,
**
kwargs
):
axis
=
normalize_axis
(
axis
,
data
.
ndim
)
res
=
self
.
reducer
(
data
,
axis
=
axis
)
return
res
.
astype
(
'float32'
)
def
lazy_func
(
self
,
data
,
axis
,
**
kwargs
):
axis
=
normalize_axis
(
axis
,
data
.
ndim
)
res
=
self
.
lazy_reducer
(
data
,
axis
=
axis
)
return
res
.
astype
(
'float32'
)
class
ThresholdedStatistics
:
def
__init__
(
self
,
threshold
,
condition
,
reducer
):
self
.
threshold
=
threshold
...
...
setup.py
View file @
c0216671
...
...
@@ -55,6 +55,7 @@ setuptools.setup(
'first_occurrence=climix.index_functions:FirstOccurrence'
,
'last_occurrence=climix.index_functions:LastOccurrence'
,
'spell_length=climix.index_functions:SpellLength'
,
'statistics=climix.index_functions:Statistics'
,
'thresholded_statistics=climix.index_functions:ThresholdedStatistics'
,
],
},
...
...
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