Skip to content

module TopoPyScale.topo_scale

Toposcale functionalities S. Filhol, Oct 2021

======= Organization of input data to Toposcale ====== dem_description (nb_points) X Y, elev, slope, aspect, svf, x_ERA, y_ERA, elev_ERA,

horizon_angles (nb_points * bins) solar_geom (nb_points * time * 2) surface_climate_data (spatial + time + var) plevels_climate_data (spatial + time + var + plevel)

======= Dataset naming convention: ========= ds_surf => dataset direct from ERA5 single level surface ds_plev => dataset direct from ERA5 pressure levels

ds_surf_pt => 33 grid ERA5 single surface level around a given point (lat,lon) ds_plev_pt => 33 grid ERA5 pressure level around a given point (lat,lon)

plev_interp => horizontal interpolation of the 33 grid at the point (lat,lon) for the pressure levels surf_interp => horizontal interpolation of the 33 grid at the point (lat,lon) for the single surface level

top => closest pressure level above the point (lat,lon,elev) for each timesep bot => closest pressure level below the point (lat,lon,elev) for each timesep

down_pt => downscaled data time series (t, u, v, q, LW, SW, tp)

Global Variables

  • g
  • R

function clear_files

clear_files(path: Union[Path, str])

function pt_downscale_interp

pt_downscale_interp(row, ds_plev_pt, ds_surf_pt, meta)

function pt_downscale_radiations

pt_downscale_radiations(row, ds_solar, horizon_da, meta, output_dir)

function downscale_climate

downscale_climate(
    project_directory,
    climate_directory,
    output_directory,
    df_centroids,
    horizon_da,
    ds_solar,
    target_EPSG,
    start_date,
    end_date,
    tstep,
    interp_method='idw',
    lw_terrain_flag=True,
    precip_lapse_rate_flag=False,
    file_pattern='down_pt*.nc',
    n_core=4
)

Function to perform downscaling of climate variables (t,q,u,v,tp,SW,LW) based on Toposcale logic

Args:

  • project_directory (str): path to project root directory climate_directory (str): output_directory (path):
  • df_centroids (dataframe): containing a list of point for which to downscale (includes all terrain data)
  • horizon_da (dataarray): horizon angles for a list of azimuth
  • target_EPSG (int): EPSG code of the DEM start_date: end_date:
  • interp_method (str): interpolation method for horizontal interp. 'idw' or 'linear'
  • lw_terrain_flag (bool): flag to compute contribution of surrounding terrain to LW or ignore
  • tstep (str): timestep of the input data, default = 1H
  • file_pattern (str): filename pattern for storing downscaled points, default = 'down_pt_*.nc'
  • n_core (int): number of core on which to distribute processing

Returns:

  • dataset: downscaled data organized with time, point_name, lat, long

function read_downscaled

read_downscaled(path='outputs/down_pt*.nc')

Function to read downscaled points saved into netcdf files into one single dataset using Dask

Args:

  • path (str): path and pattern to use into xr.open_mfdataset

Returns:

  • dataset: merged dataset readily to use and loaded in chuncks via Dask

This file was automatically generated via lazydocs.