Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
esde
toar-public
toarstats
Commits
376f1b99
Commit
376f1b99
authored
Dec 03, 2021
by
Niklas Selke
Browse files
Added a function to create a reference data frame.
parent
d41eef1b
Changes
2
Hide whitespace changes
Inline
Side-by-side
toarstats/interface.py
View file @
376f1b99
...
...
@@ -5,6 +5,7 @@ calculate_statistics - calculate the requested statistics
"""
from
toarstats.input_checks
import
check_input_parameters
from
toarstats.stats_utils
import
create_reference_data_frame
def
calculate_statistics
(
...
...
@@ -104,3 +105,6 @@ def calculate_statistics(
sampling
,
statistics
,
data
,
metadata
,
seasons
,
crops
,
data_capture
,
datetimes
,
values
,
station_lat
,
station_lon
,
station_climatic_zone
)
reference_data_frame
=
create_reference_data_frame
(
input_parameters
.
data
.
index
)
toarstats/stats_utils.py
View file @
376f1b99
...
...
@@ -3,6 +3,7 @@
This module contains the following functions:
aot40stat - evaluate the sum of values above the given threshold
calc_data_capture - calculate the data capture fraction
create_reference_data_frame - create a reference data frame
dma8_processor - calculate the daily maximum 8-hour running mean
get_elevation_angle - calculate the solar elevation angle
get_growing_season - get the correct season name
...
...
@@ -99,6 +100,23 @@ def calc_data_capture(df, dfref, sampling, how, mincount=0, minfrac=None,
return
dfres
def
create_reference_data_frame
(
index
):
"""Create a reference data frame.
:param index: the given index
:return: A data frame with a date range spanning from the beginning
of the earliest given year to the ending of the latest
given year and filled with zeros
"""
min_date
=
index
.
min
()
max_date
=
index
.
max
()
start_date
=
f
"
{
min_date
.
year
}
-01-01 00:
{
min_date
.
minute
}
"
end_date
=
f
"
{
max_date
.
year
}
-12-31 23:
{
max_date
.
minute
}
"
reference_index
=
pd
.
date_range
(
start
=
start_date
,
end
=
end_date
,
freq
=
"H"
)
return
pd
.
DataFrame
(
np
.
zeros
(
reference_index
.
size
),
index
=
reference_index
)
def
dma8_processor
(
df
,
dfref
,
mtype
,
metadata
,
seasons
,
data_capture
,
tshift
=
0
,
hours
=
[
0
,
23
],
dname
=
""
,
strict
=
False
,
average
=
False
):
"""Calculate the daily maximum 8-hour running mean.
...
...
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