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
1c899f47
Commit
1c899f47
authored
Feb 20, 2020
by
Klaus Zimmermann
Browse files
Index function extreme_temperature_range, etr (closes #166)
parent
afb59128
Changes
4
Hide whitespace changes
Inline
Side-by-side
climix/etc/metadata.yml
View file @
1c899f47
...
...
@@ -46,6 +46,14 @@ index_functions:
From this it calculates the average day-to-day difference in
diurnal temperature range.
extreme_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 extreme temperature range as the
maximum of daily maximum temperature minus the minimum of daily
minimum temperature.
first_occurrence
:
description
:
|
Calculates the first time some condition is met.
...
...
climix/index_functions/__init__.py
View file @
1c899f47
...
...
@@ -5,6 +5,7 @@ from .index_functions import ( # noqa: F401
CountOccurrences
,
DiurnalTemperatureRange
,
InterdayDiurnalTemperatureRange
,
ExtremeTemperatureRange
,
FirstOccurrence
,
LastOccurrence
,
SpellLength
,
...
...
climix/index_functions/index_functions.py
View file @
1c899f47
...
...
@@ -75,6 +75,26 @@ class DiurnalTemperatureRange(IndexFunction):
lazy_func
=
call_func
class
ExtremeTemperatureRange
(
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
==
Unit
(
'Kelvin'
))
or
(
units
==
Unit
(
'degree_Celsius'
))
super
().
prepare
(
input_cubes
)
def
call_func
(
self
,
data
,
axis
,
**
kwargs
):
res
=
(
data
[
'high_data'
].
max
(
axis
=
axis
)
-
data
[
'low_data'
].
min
(
axis
=
axis
))
return
res
.
astype
(
'float32'
)
lazy_func
=
call_func
class
InterdayDiurnalTemperatureRange
(
IndexFunction
):
def
__init__
(
self
):
super
().
__init__
(
units
=
Unit
(
'degree_Celsius'
))
...
...
setup.py
View file @
1c899f47
...
...
@@ -62,6 +62,7 @@ setuptools.setup(
'temperature_sum=climix.index_functions:TemperatureSum'
,
'diurnal_temperature_range=climix.index_functions:DiurnalTemperatureRange'
,
'interday_diurnal_temperature_range=climix.index_functions:InterdayDiurnalTemperatureRange'
,
'extreme_temperature_range=climix.index_functions:ExtremeTemperatureRange'
,
],
},
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