Skip to content
Snippets Groups Projects
Commit 61bfe594 authored by Niklas Selke's avatar Niklas Selke
Browse files

Switched to internally use a series instead of a data frame.

parent 83d42ea7
No related branches found
No related tags found
1 merge request!5Modified the test for the 'value_count' statistic. Now all available sampling...
......@@ -212,8 +212,7 @@ def check_data(data_in, datetimes_in, values_in):
null values
- the index and values have different lengths
:return: A data frame with a datetime index and a column of float or
int values
:return: A series with a datetime index and float or int values
"""
if data_in is not None:
if isinstance(data_in, (pd.DataFrame, pd.Series)):
......@@ -230,7 +229,7 @@ def check_data(data_in, datetimes_in, values_in):
raise ValueError("Datetime index and values must have the same length")
if index_out.tz:
index_out = index_out.tz_localize(None)
return pd.DataFrame({"values": values_out}, index=index_out)
return pd.Series(values_out, index_out)
def is_in_range(parameter, min_valid, max_valid):
......
......@@ -9,7 +9,7 @@ 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_series, get_seasons,
harmonize_time)
......@@ -124,20 +124,19 @@ def calculate_statistics(
else DEFAULT_CROPS, input_parameters.required.seasons,
input_parameters.required.crops
)
reference_data_frame = create_reference_data_frame(
input_parameters.data.index
)
ref = create_reference_series(input_parameters.data.index)
resample_rule = ("seasonal" if input_parameters.sampling == "vegseason"
else input_parameters.sampling)
data_capture_value = (input_parameters.data_capture
if input_parameters.data_capture is not None else 0.5
if "diurnal_cycle" in input_parameters.statistics
else DEFAULT_DATA_CAPTURE)
results = []
for i, stat in enumerate(input_parameters.statistics):
results.extend(
getattr(stats, stat, getattr(ozone_metrics, stat, None))(
input_parameters.data, reference_data_frame, resample_rule,
input_parameters.data, ref, resample_rule,
input_parameters.metadata, seasons_per_statistic[i],
data_capture_value
)
......@@ -146,4 +145,4 @@ def calculate_statistics(
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})
return pd.DataFrame({res["name"]: res["ser"] for res in results})
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment