primap2.csg.FitParameters#
- class primap2.csg.FitParameters(fit_degree: int = 1, fallback_degree: int = 0, trend_length: int = 10, trend_length_unit: str = 'YS', min_trend_points: int = 5)[source]#
Class to represent parameters for a polynomial fit.
While min_data_points refers to the actual number of data points trend_length does not. trend_length and trend_length_unit together define a time span which is independent of the actual data points and their spacing.
- Note:
Very unevenly distributed data points can lead to fit problems, e.g. if we use a 10 year period and have 5 data point all in one year. But as the normal use case are evenly distributed data points, sometimes with gaps it’s currently not relevant
- Attributes:
- fit_degree
degree of the polynomial to fit to calculate the trend value. 0 for mean value and 1 for linear trend make most sense. The higher the order, the higher the chance of unexpected results
- fallback_degree
Fallback degree to use if less than min_trend_points of not-nan data
- trend_length
length of the trend in time steps (usually years)
- trend_length_unit
Unit for the length of the trend. String passed to the freq argument of pd.date_range. Default is ‘YS’ (yearly at start of year)
- min_trend_points
minimal number of points to calculate the trend. Default is 1, but if the degree of the fit polynomial is higher than 1, the minimal number of data points the degree of the fit polynomial
Methods
get_fallback()Return FitParameters object with the fit_degree set to the fallback_degree of the original object.
log_string([fallback])Create a string with the classes parameters.
- __init__(fit_degree: int = 1, fallback_degree: int = 0, trend_length: int = 10, trend_length_unit: str = 'YS', min_trend_points: int = 5) None#
Method generated by attrs for class FitParameters.
Methods
__init__([fit_degree, fallback_degree, ...])Method generated by attrs for class FitParameters.
get_fallback()Return FitParameters object with the fit_degree set to the fallback_degree of the original object.
log_string([fallback])Create a string with the classes parameters.
Attributes
fit_degreefallback_degreetrend_lengthtrend_length_unitmin_trend_points