Commit 8a5cf006 authored by Niklas Selke's avatar Niklas Selke
Browse files

Finalized the 'calculate_statistics' function.

parent 9bce1c32
......@@ -4,10 +4,13 @@ This module contains the following function:
calculate_statistics - calculate the requested statistics
"""
import pandas as pd
from toarstats import stats, ozone_metrics
from toarstats.defaults import DEFAULT_CROPS, DEFAULT_DATA_CAPTURE
from toarstats.input_checks import check_input_parameters
from toarstats.stats_utils import create_reference_data_frame, get_seasons
from toarstats.stats_utils import (create_reference_data_frame, get_seasons,
harmonize_time)
def calculate_statistics(
......@@ -104,6 +107,9 @@ def calculate_statistics(
- any parameter has the wrong value
- the ``drmdmax1h`` statistic is given
together with ``monthly`` sampling
:return: A data frame containing the calculated statistics and
metrics
"""
input_parameters = check_input_parameters(
sampling, statistics, data, metadata, seasons, crops, data_capture,
......@@ -136,3 +142,8 @@ def calculate_statistics(
data_capture_value
)
)
results = harmonize_time(
results, resample_rule,
"H" if "diurnal_cycle" in input_parameters.statistics else None
)
return pd.DataFrame({res["name"]: res["df"]["values"] for res in results})
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment