Commit d41eef1b authored by Niklas Selke's avatar Niklas Selke
Browse files

Wrapped all input parameter checks in a single function. Broke down the checks into smaller parts.

parent 396b459d
This diff is collapsed.
......@@ -4,10 +4,7 @@ This module contains the following function:
calculate_statistics - calculate the requested statistics
"""
from toarstats.input_checks import (
check_crops, check_data, check_data_capture, check_metadata,
check_sampling, check_seasons, check_statistics, mark_required_arguments
)
from toarstats.input_checks import check_input_parameters
def calculate_statistics(
......@@ -94,22 +91,16 @@ def calculate_statistics(
:param station_climatic_zone: station's climatic zone, used if
missing in the ``metadata`` argument
:raises ValueError: raised if there is any problem with any of the
given user inputs
:raises KeyError: raised if any key in the metadata parameter is not
recognized
:raises TypeError: raised if any parameter has the wrong type or any
required parameter is missing
:raises ValueError: raised if
- any parameter has the wrong value
- the ``drmdmax1h`` statistic is given
together with ``monthly`` sampling
"""
sampling_method = check_sampling(sampling)
stats_list = check_statistics(statistics)
if "drmdmax1h" in stats_list and sampling_method == "monthly":
raise ValueError("The drmdmax1h statistic cannot be evaluated with"
" monthly sampling")
data_frame = check_data(data, datetimes, values)
(station_lat_req, station_lon_req, station_climatic_zone_req, seasons_req,
crops_req) = mark_required_arguments(sampling_method, stats_list,
seasons is not None)
metadata_tuple = check_metadata(
metadata, station_lat, station_lon, station_climatic_zone,
station_lat_req, station_lon_req, station_climatic_zone_req
input_parameters = check_input_parameters(
sampling, statistics, data, metadata, seasons, crops, data_capture,
datetimes, values, station_lat, station_lon, station_climatic_zone
)
seasons_list = check_seasons(seasons, seasons_req)
crops_list = check_crops(crops, crops_req)
data_capture_value = check_data_capture(data_capture)
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