pyku.resources#

Resources accessible on-the-fly

pyku.resources.generate_fake_cmip6_data(ntime=1, nlat=180, nlon=360, freq='D')[source]#

Generate fake cmip6 data for testing

Parameters:
  • ntime (int) – Number of years

  • nlat (int) – Number of latitudes

  • nlon (int) – Number of longitudes

  • freq (str) – Frequency of the time dimension

Returns:

Fake CMIP6 dataset

Return type:

xarray.Dataset

pyku.resources.generate_fake_datasets_with_datetimes_on_disk(directory=None)[source]#

Generate fake NetCDF datasets with datetimes

Parameters:

directory (str) – The output directory.

Returns:

List of fake files.

Return type:

(List(str))

pyku.resources.get_geodataframe(identifier)[source]#

Get geodataframe from identifier

Parameters:

identifier (str) – The polygon identifier.

Returns:

The polygon(s).

Return type:

geopandas.GeoDataFrame

Example

In [1]: import pyku.resources as resources
   ...: resources.get_geodataframe('germany')
   ...: 
Out[1]: 
         featurecla  ...                                           geometry
49  Admin-0 country  ...  MULTIPOLYGON (((13.81572 48.76643, 13.78586 48...

[1 rows x 169 columns]
pyku.resources.get_polygon_identifiers()[source]#

This function was renamed to pyku.resources.list_polygon_identifiers()

pyku.resources.get_test_data(id)[source]#

Retrieves sample raster datasets for documentation and unit testing.

Parameters:

id (str) – The identifier or alias of the test dataset to retrieve. Available identifiers can be listed using pyku.list_identifiers().

Returns:

The requested test raster data.

Return type:

xarray.Dataset

Raises:

ValueError – If the provided id is not a recognized dataset identifier.

Examples

In [1]: import pyku
   ...: pyku.resources.get_test_data('hyras')
   ...: 
Out[1]: 
<xarray.Dataset> Size: 139MB
Dimensions:             (time: 730, y: 178, x: 133, bnds: 2)
Coordinates:
  * time                (time) datetime64[ns] 6kB 1981-01-01 ... 1982-12-31
  * y                   (y) float64 1kB 3.562e+06 3.556e+06 ... 2.676e+06
  * x                   (x) float64 1kB 4.024e+06 4.028e+06 ... 4.684e+06
    lat                 (y, x) float64 189kB dask.array<chunksize=(178, 133), meta=np.ndarray>
    lon                 (y, x) float64 189kB dask.array<chunksize=(178, 133), meta=np.ndarray>
Dimensions without coordinates: bnds
Data variables:
    crs                 int32 4B ...
    number_of_stations  (time) float64 6kB dask.array<chunksize=(730,), meta=np.ndarray>
    tas                 (time, y, x) float64 138MB dask.array<chunksize=(730, 178, 133), meta=np.ndarray>
    time_bnds           (time, bnds) datetime64[ns] 12kB dask.array<chunksize=(730, 2), meta=np.ndarray>
Attributes: (12/23)
    source:                 surface observations
    institution:            Deutscher Wetterdienst (DWD)
    Conventions:            CF-1.11
    title:                  gridded_temperature_dataset_(HYRAS TAS)
    realization:            v6-1
    project_id:             HYRAS
    ...                     ...
    ConventionsURL:         http://cfconventions.org/Data/cf-conventions/cf-c...
    license:                The HYRAS data, produced by DWD, is licensed unde...
    filename:               tas_hyras_1_1981_v6-1_de.nc
    comment:                Please be aware that the parameters are stored as...
    unique_dataset_id:      DWD_HYRAS_DE_tas_v6-1_1981_3a0bd428-c11d-47f6-9fb...
    CORDEX_domain:          undefined
pyku.resources.list_polygon_identifiers()[source]#

List polygon(s) identifiers

Returns:

List of available polygon identifiers.

Return type:

list

Examples

The function can be loaded and used at the module level:

In [1]: import pyku.resources as resources
   ...: resources.list_polygon_identifiers()
   ...: 
Out[1]: 
['ne_10m_admin_0_countries',
 'ne_10m_coastline',
 'ne_10m_rivers',
 'ne_10m_lakes',
 'germany',
 'austria',
 'german_states',
 'german_cities',
 'ne_10m_geography_regions_polys',
 'eobs_mask',
 'prudence',
 'natural_areas_of_germany',
 'natural_areas_of_germany_merged4',
 'german_directions']

Alternatively, the function can be loaded and used at the pyku level:

In [2]: import pyku
   ...: pyku.list_polygon_identifiers()
   ...: 
Out[2]: 
['ne_10m_admin_0_countries',
 'ne_10m_coastline',
 'ne_10m_rivers',
 'ne_10m_lakes',
 'germany',
 'austria',
 'german_states',
 'german_cities',
 'ne_10m_geography_regions_polys',
 'eobs_mask',
 'prudence',
 'natural_areas_of_germany',
 'natural_areas_of_germany_merged4',
 'german_directions']
pyku.resources.list_test_data(include_aliases=False)[source]#

Returns a list of available dataset identifiers.

Parameters:

include_aliases (bool) – Defaults to False. If True, returns all valid strings. If False, returns only the primary identifier for each group.

Examples

In [1]: import pyku
   ...: pyku.list_test_data(include_aliases=True)
   ...: 
Out[1]: 
['air_temperature (air_temperature_data)',
 'fake_cmip6 (fake_cmip6_data)',
 'cftime_data',
 'hyras (hyras_tas)',
 'hyras_pr',
 'hyras-tas-monthly (hyras-monthly)',
 'monthly-hyras-files (monthly_hyras_files)',
 'small_tas_dataset',
 'cosmo-rea6 (cosmo-rea6-daily)',
 'low-res-hourly-tas-data (low_res_hourly_tas_data)',
 'hourly-tas (hourly_tas, hostrada)',
 'GCM_CanESM5',
 'MPI_ESM1_2_HR_tas',
 'MPI_ESM1_2_HR_pr',
 'tas_hurs',
 'tas_ps_huss',
 'ps_tdew',
 'monthly_eurocordex (cordex_data, model_data)',
 'global_data',
 'icon_grib_files',
 'icon_grid_file',
 'CCCma_CanESM2_Amon_world']