climate_indices icon indicating copy to clipboard operation
climate_indices copied to clipboard

Add utility function to validate calibration year ranges against actual data year ranges

Open monocongo opened this issue 6 years ago • 0 comments

It would be useful to have a function that validates the calibration start/end year values against the actual years covered by time series input arrays. This sort of check is already present in several places, but not everywhere it should be (for example palmer.pdsi()). This will eliminate duplication of this sort of code and provide a reusable validation function that can be applied at the level of the indices and/or compute calls as appropriate.

Suggested signature:

def validate_calibration(time_series, 
                     periodicity
                     data_start_year, 
                     calibration_year_initial, 
                     calibration_year_final):
"""
:param time_series: numpy array representing the time series, either 1-D 
                    (indeterminate number of values) or 2-D (number of years as the
                    first dimension, 12 or 366 as the second dimension, based on the
                    periodicity)
:param periodicity: either 'monthly' or 'daily', with 'monthly' indicating that the
                    time series array contains 12 values per year corresponding to 
                    the calendar months and that the values begin with January of 
                    the initial year, and 'daily' indicating that the time series
                    array contains 366 values per year and that the values begin 
                    with January 1st of the initial year
:param data_start_year: the initial year of the time series array
:param calibration_year_initial: first year of the calibration period
:param calibration_year_final: last year of the calibration period
"""

monocongo avatar May 14 '18 14:05 monocongo