pyku.downscale#
Downscaling library
- class pyku.downscale.Downscaler[source]#
Bases:
objectParent class for downscalers.
The purpose of this class is to gather high-level optimized functions.
- groupby_fit_predict(lowres, groupby_type='time.month', progress=False)[source]#
Group, fit and predict
- Parameters:
ds (
xarray.Dataset) – Dataset to downscale.groupby_type (string) – Data grouping. The correction is applied independently to each group. The value of the groupby_type is expected to be ‘time.month’, but could also be set to ‘time.season’
- groupby_fit_predict_all_variables(lowres, groupby_type='time.month', progress=False)[source]#
Group, fit and predict
- Parameters:
ds (
xarray.Dataset) – Dataset to downscale.groupby_type (string) – Data grouping. The correction is applied independently to each group. The value of the groupby_type is expected to be ‘time.month’, but could also be set to ‘time.season’
- class pyku.downscale.PCA(da, npcs)[source]#
Bases:
objectPrincipal components analysis (PCA) This class is deprecated but kept for now
- class pyku.downscale.SVD(high_res, low_res, max_nsvs=None)[source]#
Bases:
objectSingular Value Decomposition (SVD)
- eigenvectors()[source]#
Get eigenvectors of the singular value decomposition (SVD)
- Returns:
- Tuple[
xarray.Dataset]. The eigenvectors. One in low resolution, one in high resolution.
- Tuple[
- predict(data)[source]#
Predict with singular value decomposition (SVD)
- Parameters:
data (
numpy.ndarray) – data to be recomposed with size (ntimes x nsamples).- Returns:
- predicted values with shape
(ntimes x nsamples)
- Return type:
Notes
Practically the data input have shapes (ntimes x ny*nx) or (ntimes x nvars*ny*nx)
- class pyku.downscale.SVDDownscaler(high_res, low_res, max_nsvs)[source]#
Bases:
DownscalerDownscaler with singular value decomposition (SVD).
Note
Using a multivariable SVD was tried. It kinda worked but results were not convincing and was henced removed. The code can still be found in the old clutils repository.
- eigenvectors()[source]#
Eigenvectors
- Returns:
xarray.Datasetcontaining the eigenvectors
- groupby_fit_predict(lowres, groupby_type='time.month', progress=False)#
Group, fit and predict
- Parameters:
ds (
xarray.Dataset) – Dataset to downscale.groupby_type (string) – Data grouping. The correction is applied independently to each group. The value of the groupby_type is expected to be ‘time.month’, but could also be set to ‘time.season’
- groupby_fit_predict_all_variables(lowres, groupby_type='time.month', progress=False)#
Group, fit and predict
- Parameters:
ds (
xarray.Dataset) – Dataset to downscale.groupby_type (string) – Data grouping. The correction is applied independently to each group. The value of the groupby_type is expected to be ‘time.month’, but could also be set to ‘time.season’