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
Klaus Zimmermann
climix
Commits
afb59128
Commit
afb59128
authored
Feb 20, 2020
by
Lars Bärring
Committed by
Klaus Zimmermann
Feb 20, 2020
Browse files
Index function interday diurnal temperature range (closes #154)
parent
b4f83a8b
Changes
4
Hide whitespace changes
Inline
Side-by-side
climix/etc/metadata.yml
View file @
afb59128
...
...
@@ -39,6 +39,13 @@ index_functions:
daily minimum and maximum temperature.
From this it calculated the average diurnal temperature range.
interday_diurnal_temperature_range
:
description
:
|
This index function takes two inputs, low_data and high_data, i.e.
daily minimum and maximum temperature.
From this it calculates the average day-to-day difference in
diurnal temperature range.
first_occurrence
:
description
:
|
Calculates the first time some condition is met.
...
...
climix/index_functions/__init__.py
View file @
afb59128
...
...
@@ -4,6 +4,7 @@ from .index_functions import ( # noqa: F401
CountLevelCrossings
,
CountOccurrences
,
DiurnalTemperatureRange
,
InterdayDiurnalTemperatureRange
,
FirstOccurrence
,
LastOccurrence
,
SpellLength
,
...
...
climix/index_functions/index_functions.py
View file @
afb59128
...
...
@@ -75,6 +75,29 @@ class DiurnalTemperatureRange(IndexFunction):
lazy_func
=
call_func
class
InterdayDiurnalTemperatureRange
(
IndexFunction
):
def
__init__
(
self
):
super
().
__init__
(
units
=
Unit
(
'degree_Celsius'
))
def
prepare
(
self
,
input_cubes
):
props
=
{(
cube
.
dtype
,
cube
.
units
,
cube
.
standard_name
)
for
cube
in
input_cubes
.
values
()}
assert
len
(
props
)
==
1
dtype
,
units
,
standard_name
=
props
.
pop
()
assert
units
in
[
Unit
(
'Kelvin'
),
Unit
(
'degree_Celsius'
)]
super
().
prepare
(
input_cubes
)
def
call_func
(
self
,
data
,
axis
,
**
kwargs
):
res
=
np
.
absolute
(
np
.
diff
(
data
[
'high_data'
]
-
data
[
'low_data'
],
axis
=
axis
)).
mean
(
axis
=
axis
)
return
res
.
astype
(
'float32'
)
def
lazy_func
(
self
,
data
,
axis
,
**
kwargs
):
res
=
da
.
absolute
(
da
.
diff
(
data
[
'high_data'
]
-
data
[
'low_data'
],
axis
=
axis
)).
mean
(
axis
=
axis
)
return
res
.
astype
(
'float32'
)
class
FirstOccurrence
(
ThresholdMixin
,
IndexFunction
):
def
__init__
(
self
,
threshold
,
condition
):
super
().
__init__
(
threshold
,
condition
,
units
=
Unit
(
'days'
))
...
...
setup.py
View file @
afb59128
...
...
@@ -61,6 +61,7 @@ setuptools.setup(
'thresholded_statistics=climix.index_functions:ThresholdedStatistics'
,
'temperature_sum=climix.index_functions:TemperatureSum'
,
'diurnal_temperature_range=climix.index_functions:DiurnalTemperatureRange'
,
'interday_diurnal_temperature_range=climix.index_functions:InterdayDiurnalTemperatureRange'
,
],
},
project_urls
=
{
...
...
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