Main configuration function

config.configuration(config_file)

This function is the main configuration function that calls all the other modules in the code.

Return (paths, param)

The dictionary paths containing all the paths to inputs and outputs, and the dictionary param containing all the user preferences.

Return type

tuple(dict, dict)

config.general_settings()

This function creates and initializes the dictionaries param and paths. It also creates global variables for the root folder root, and the system-dependent file separator fs.

Return (paths, param)

The empty dictionary paths, and the dictionary param including some general information.

Return type

tuple(dict, dict)

Note

Both param and paths will be updated in the code after running the function config.configuration.

Note

root points to the directory that contains all the inputs and outputs. All the paths will be defined relatively to the root, which is located in a relative position to the current folder.

The code differentiates between the geographic scope and the subregions of interest. You can run the first part of the script runme.py once and save results for the whole scope, and then repeat the second part using different subregions within the scope.

config.scope_paths_and_parameters(paths, param, config_file)

This function defines the path of the geographic scope of the output spatial_scope and of the subregions of interest subregions. Both paths should point to shapefiles of polygons or multipolygons. It also associates two name tags for them, respectively region_name and subregions_name, which define the names of output folders.

  • For spatial_scope, only the bounding box around all the features matters. Example: In case of Europe, whether a shapefile of Europe as one multipolygon, or as a set of multiple features (countries, states, etc.) is used, does not make a difference. Potential maps (theoretical and technical) will be later generated for the whole scope of the bounding box.

  • For subregions, the shapes of the individual features matter, but not their scope. For each individual feature that lies within the scope, you can later generate a summary report and time series. The shapefile of subregions does not have to have the same bounding box as spatial_scope. In case it is larger, features that lie completely outside the scope will be ignored, whereas those that lie partly inside it will be cropped using the bounding box of spatial_scope. In case it is smaller, all features are used with no modification.

  • year defines the year of the input data.

  • technology defines the list of technologies that you are interested in. Currently, four technologies are defined: onshore wind 'WindOn', offshore wind 'WindOff', photovoltaics 'PV', concentrated solar power 'CSP'.

Parameters
  • paths (dict) – Dictionary including the paths.

  • param (dict) – Dictionary including the user preferences.

Return (paths, param)

The updated dictionaries paths and param.

Return type

tuple(dict, dict)

Note

We recommend using a name tag that describes the scope of the bounding box of the regions of interest. For example, 'Europe' and 'Europe_without_Switzerland' will actually lead to the same output for the first part of the code.

Note

As of version 1.1.0, it is possible to use different technologies in the same run, but not the same technology with different settings.

Warning

If you intend to use the wind correction feature relying on the Global Wind Atlas, it is recommended that spatial_scope covers all the countries that you are interested in, because the correction is done on a country-level. Also, you have to download the data from the Global Wind Atlas for each country that lies within the scope, even partially, and put it in the corresponding location.

User preferences

config.computation_parameters(param)

This function defines parameters related to the processing:

  • nproc is an integer that limits the number of parallel processes (some modules in potential.py and time_series.py allow parallel processing).

  • CPU_limit is a boolean parameter that sets the level of priority for all processes in the multiprocessesing. Leave True if you plan on using the computer while FLH and TS are being computed, False for fastest computation time.

Parameters

param (dict) – Dictionary including the user preferences.

Return param

The updated dictionary param.

Return type

dict

config.resolution_parameters(param)

This function defines the resolution of weather data (low resolution), and the desired resolution of output rasters (high resolution). Both are numpy arrays with two numbers. The first number is the resolution in the vertical dimension (in degrees of latitude), the second is for the horizontal dimension (in degrees of longitude).

Parameters

param (dict) – Dictionary including the user preferences.

Return param

The updated dictionary param.

Return type

dict

Note

As of version 1.1.0, these settings should not be changed. Only MERRA-2 data can be used in the tool. Its spatial resolution is 0.5° of latitudes and 0.625° of longitudes. The high resolution is 15 arcsec in both directions.

config.csp_parameters(param)

This function sets the parameters for concentrated solar power in the dictionary csp inside param:

  • resource is a dictionary including the parameters related to the resource potential:

    • clearness_correction is a factor that will be multiplied with the clearness index matrix to correct it. If no correction is required, leave it equal to 1.

  • technical is a dictionary including the parameters related to the module:

    • T_avg_HTF is the average temperature in °C of the heat transfer fluid between the inlet and outlet of the solar field.

    • loss_coeff is the the heat loss coefficient in W/(m²K), which does not depend on wind speed (relevant for physical_models.calc_CF_solar).

    • loss_coeff_wind is the the heat loss coefficient in W/(m²K(m/s)^0.6), which depends on wind speed (relevant for physical_models.calc_CF_solar).

    • Flow_coeff is a factor smaller than 1 for the heat transfer to the HTF (Flow or heat removal factor).

    • AbRe_ratio is the ratio between the receiver area and the concentrator aperture.

    • Wind_cutoff is the maximum wind speed for effective tracking in m/s.

  • mask is a dictionary including the parameters related to the masking:

    • slope is the threshold slope in percent. Areas with a larger slope are excluded.

    • lu_suitability is a numpy array of values 0 (unsuitable) or 1 (suitable). It has the same size as the array of land use types.

    • pa_suitability is a numpy array of values 0 (unsuitable) or 1 (suitable). It has the same size as the array of protected area categories.

  • weight is a dictionary including the parameters related to the weighting:

    • lu_availability is a numpy array of values between 0 (completely not available) and 1 (completely available). It has the same size as the array of land use types.

    • pa_availability is a numpy array of values between 0 (completely not available) and 1 (completely available). It has the same size as the array of protected area categories.

    • power_density is the power density of CSP projects in MW/m².

    • f_performance is a number smaller than 1, taking into account all the other losses from the CSP module until the AC substation.

Parameters

param (dict) – Dictionary including the user preferences.

Return param

The updated dictionary param.

Return type

dict

config.file_saving_options(param)

This function sets some options for saving files.

  • savetiff is a boolean that determines whether tif rasters for the potentials are saved (True), or whether only mat files are saved (False). The latter are saved in any case.

  • report_sampling is an integer that sets the sample size for the sorted FLH values per region (relevant for potential.reporting).

Parameters

param (dict) – Dictionary including the user preferences.

Return param

The updated dictionary param.

Return type

dict

config.landuse_parameters(param)

This function sets the land use parameters in the dictionary landuse inside param:

  • type is a numpy array of integers that associates a number to each land use type.

  • type_urban is the number associated to urban areas (useful for input_maps.generate_buffered_population).

  • Ross_coeff is a numpy array of Ross coefficients associated to each land use type (relevant for physical_models.loss).

  • albedo is a numpy array of albedo coefficients between 0 and 1 associated to each land use type (relevant for reflected irradiation, see physical_models.calc_CF_solar).

  • hellmann is a numpy array of Hellmann coefficients associated to each land use type (relevant for correction_functions.generate_wind_correction).

param param

Dictionary including the user preferences.

type param

dict

return param

The updated dictionary param.

rtype

dict

# Landuse reclassification

# 0 No data # 10 Cropland, rain-fed # 11 Herbaceous cover # 12 Tree or shrub cover # 20 Cropland, irrigated or post-flooding # 30 Mosaic cropland (>50%) / natural vegetation (tree, shrub, herbaceous cover) (<50%) # 40 Mosaic natural vegetation (tree, shrub, herbaceous cover) (>50%) / cropland (<50%) # 50 Tree cover, broadleaved, evergreen, closed to open (>15%) # 60 Tree cover, broadleaved, deciduous, closed to open (>15%) # 61 Tree cover, broadleaved, deciduous, closed (>40%) # 62 Tree cover, broadleaved, deciduous, open (15-40%) # 70 Tree cover, needleleaved, evergreen, closed to open (>15%) # 71 Tree cover, needleleaved, evergreen, closed (>40%) # 72 Tree cover, needleleaved, evergreen, open (15-40%) # 80 Tree cover, needleleaved, deciduous, closed to open (>15%) # 81 Tree cover, needleleaved, deciduous, closed (>40%) # 82 Tree cover, needleleaved, deciduous, open (15-40%) # 90 Tree cover, mixed leaf type (broadleaved and needleleaved) # 100 Mosaic tree and shrub (>50%) / herbaceous cover (<50%) # 110 Mosaic herbaceous cover (>50%) / tree and shrub (<50%) # 120 Shrubland # 121 Shrubland evergreen # 122 Shrubland deciduous # 130 Grassland # 140 Lichens and mosses # 150 Sparse vegetation (tree, shrub, herbaceous cover) (<15%) # 151 Sparse tree (<15%) # 152 Sparse shrub (<15%) # 153 Sparse herbaceous cover (<15%) # 160 Tree cover, flooded, fresh or brakish water # 170 Tree cover, flooded, saline water # 180 Shrub or herbaceous cover, flooded, fresh/saline/brakish water # 190 Urban areas # 200 Bare areas # 201 Consolidated bare areas # 202 Unconsolidated bare areas # 210 Water bodies # 220 Permanent snow and ice

config.offshore_wind_paramters(param)

This function sets the parameters for offshore wind in the dictionary windoff inside param:

  • resource is a dictionary including the parameters related to the resource potential:

    • res_correction is either 1 (perform a redistribution of wind speed when increasing the resolution) or 0 (repeat the same value from the low resolution data). It is relevant for correction_functions.generate_wind_correction.

  • technical is a dictionary including the parameters related to the wind turbine:

    • w_in is the cut-in speed in m/s.

    • w_r is the rated wind speed in m/s.

    • w_off is the cut-off wind speed in m/s.

    • P_r is the rated power output in MW.

    • hub_height is the hub height in m.

  • mask is a dictionary including the parameters related to the masking:

    • depth is the threshold depth in meter (negative number). Areas that are deeper are excluded.

    • pa_suitability is a numpy array of values 0 (unsuitable) or 1 (suitable). It has the same size as the array of protected area categories.

  • weight is a dictionary including the parameters related to the weighting:

    • power_density is the power density of offshore wind projects in MW/m².

    • f_performance is a number smaller than 1, taking into account all the other losses from the turbine generator until the AC substation.

Parameters

param (dict) – Dictionary including the user preferences.

Return param

The updated dictionary param.

Return type

dict

config.onshore_wind_parameters(param)

This function sets the parameters for onshore wind in the dictionary windon inside param:

  • resource is a dictionary including the parameters related to the resource potential:

    • res_correction is either 1 (perform a redistribution of wind speed when increasing the resolution) or 0 (repeat the same value from the low resolution data). It is relevant for correction_functions.generate_wind_correction.

    • topo_correction is either 1 (perform a correction of wind speed based on the altitude and the Global Wind Atlas) or 0 (no correction based on altitude).

    • topo_weight is only relevant if topo_correction = 1. It defines how to weight the correction factors of each country. There are three options: 'none' (all countries have the same weight), 'size' (larger countries have a higher weight), or 'capacity' (countries with a higher installed capacity according to IRENA have a higher weight).

  • technical is a dictionary including the parameters related to the wind turbine:

    • w_in is the cut-in speed in m/s.

    • w_r is the rated wind speed in m/s.

    • w_off is the cut-off wind speed in m/s.

    • P_r is the rated power output in MW.

    • hub_height is the hub height in m.

  • mask is a dictionary including the parameters related to the masking:

    • slope is the threshold slope in percent. Areas with a larger slope are excluded.

    • lu_suitability is a numpy array of values 0 (unsuitable) or 1 (suitable). It has the same size as the array of land use types.

    • pa_suitability is a numpy array of values 0 (unsuitable) or 1 (suitable). It has the same size as the array of protected area categories.

    • buffer_pixel_amount is an integer that defines the number of pixels making a buffer of exclusion around urban areas.

  • weight is a dictionary including the parameters related to the weighting:

    • lu_availability is a numpy array of values between 0 (completely not available) and 1 (completely available). It has the same size as the array of land use types.

    • pa_availability is a numpy array of values between 0 (completely not available) and 1 (completely available). It has the same size as the array of protected area categories.

    • power_density is the power density of onshore wind projects in MW/m².

    • f_performance is a number smaller than 1, taking into account all the other losses from the turbine generator until the AC substation.

Parameters

param (dict) – Dictionary including the user preferences.

Return param

The updated dictionary param.

Return type

dict

config.protected_areas_parameters(param)

This function sets the parameters for protected areas in the dictionary protected_areas inside param:

  • type is a numpy array of integers that associates a number to each protection type.

  • IUCN_Category is an array of strings with names associated to each protection type (for your information).

Parameters

param (dict) – Dictionary including the user preferences.

Return param

The updated dictionary param.

Return type

dict

config.time_series_parameters(param)

This function determines the time series that will be created.

  • quantiles is a list of floats between 100 and 0. Within each subregion, the FLH values will be sorted, and points with FLH values at a certain quantile will be later selected. The time series will be created for these points. The value 100 corresponds to the maximum, 50 to the median, and 0 to the minimum.

  • regression is a dictionary of options for regression.regression_coefficients:

    • solver is the name of the solver for the regression.

    • WindOn is a dictionary containing a list of hub heights that will be considered in the regression, with a name tag for the list.

    • WindOff is a dictionary containing a list of hub heights that will be considered in the regression, with a name tag for the list.

    • PV is a dictionary containing a list of orientations that will be considered in the regression, with a name tag for the list.

    • CSP is a dictionary containing a list of settings that will be considered in the regression, with a name tag for the list.

    If all the available settings should be used, you can leave an empty list.

  • modes is a dictionary that groups the quantiles and assigns names for each subgroup. You can define the groups as you wish. If you want to use all the quantiles in one group without splitting them in subgroups, you can write:

    param["modes"] = {"all": param["quantiles"]}
    
  • combo is a dictionary of options for time_series.generate_stratified_timeseries:

    • WindOn is a dictionary containing the different combinations of hub heights for which stratified time series should be generated, with a name tag for each list.

    • WindOff is a dictionary containing the different combinations of hub heights for which stratified time series should be generated, with a name tag for each list.

    • PV is a dictionary containing the different combinations of orientations for which stratified time series should be generated, with a name tag for each list.

    • CSP is a dictionary containing the different combinations of settings for which stratified time series should be generated, with a name tag for each list.

    If all the available settings should be used, you can leave an empty list.

Parameters

param (dict) – Dictionary including the user preferences.

Return param

The updated dictionary param.

Return type

dict

config.weather_data_parameters(param)

This function defines the coverage of the weather data MERRA_coverage, and how outliers should be corrected using MERRA_correction:

  • MERRA_coverage: If you have downloaded the MERRA-2 data for the world, enter the name tag 'World'. The code will later search for the data in the corresponding folder. It is possible to download the MERRA-2 just for the geographic scope of the analysis. In that case, enter another name tag (we recommend using the same one as the spatial scope).

  • MERRA_correction: MERRA-2 contains some outliers, especially in the wind data. MERRA_correction sets the threshold of the relative distance between the yearly mean of the data point to the yearly mean of its neighbors.

Parameters

param (dict) – Dictionary including the user preferences.

Return param

The updated dictionary param.

Return type

dict

Paths

config.emhires_input_paths(paths, tech)

This function defines the path to the EMHIRES input file for each technology (only 'WindOn', 'WindOff', and 'PV' are supported by EMHIRES).

Parameters
  • paths (dict) – Dictionary including the paths.

  • param (dict) – Dictionary including the user preferences.

  • tech (string) – Name of the technology.

Return paths

The updated dictionary paths.

Return type

dict

config.global_maps_input_paths(paths, param)

This function defines the paths where the global maps are saved:

  • LU_global for the land use raster

  • Topo_tiles for the topography tiles (rasters)

  • Pop_global for the global population raster

  • Bathym_global for the bathymetry raster

  • Protected for the shapefile of protected areas

  • GWA for the country data retrieved from the Global Wind Atlas (missing the country code, which will be filled in a for-loop in :mod:correction_functions.calc_gwa_correction)

  • Countries for the shapefiles of countries

  • EEZ_global for the shapefile of exclusive economic zones of countries

Parameters

paths (dict) – Dictionary including the paths.

Return paths

The updated dictionary paths.

Return type

dict

config.irena_paths(paths, param)

This function defines the paths for the IRENA inputs and outputs:

  • IRENA is a csv file containing statistics for all countries and technologies for a specific year, created using a query tool of IRENA.

  • IRENA_dict is a csv file to convert the code names of countries from the IRENA database to the database of the shapefile of countries.

  • IRENA_summary is a csv file with a summary of renewable energy statistics for the countries within the scope.

Parameters
  • paths (dict) – Dictionary including the paths.

  • param (dict) – Dictionary including the user preferences.

Return paths

The updated dictionary paths.

Return type

dict

config.local_maps_paths(paths, param)

This function defines the paths where the local maps will be saved:

  • LAND for the raster of land areas within the scope

  • EEZ for the raster of sea areas within the scope

  • SUB for the raster of areas covered by subregions (both land and sea) within the scope

  • LU for the land use raster within the scope

  • BATH for the bathymetry raster within the scope

  • TOPO for the topography raster within the scope

  • SLOPE for the slope raster within the scope

  • PA for the raster of protected areas within the scope

  • POP for the population raster within the scope

  • BUFFER for the raster of population buffer areas within the scope

  • CORR_GWA for correction factors based on the Global Wind Atlas (mat file)

  • CORR_ON for the onshore wind correction factors (raster)

  • CORR_OFF for the offshore wind correction factors (raster)

  • AREA for the area per pixel in m² (mat file)

Parameters
  • paths (dict) – Dictionary including the paths.

  • param (dict) – Dictionary including the user preferences.

Return paths

The updated dictionary paths.

Return type

dict

config.output_folders(paths, param)

This function defines the paths to multiple output folders:

  • region is the main output folder.

  • weather_data is the output folder for the weather data of the spatial scope.

  • local_maps is the output folder for the local maps of the spatial scope.

  • potential is the output folder for the ressource and technical potential maps.

  • regional_analysis is the output folder for the time series and the report of the subregions.

  • regression_in is the folder where the regression parameters (FLH, fitting time series) are saved.

  • regression_out is the output folder for the regression results.

All the folders are created at the beginning of the calculation, if they do not already exist,

Parameters
  • paths (dict) – Dictionary including the paths.

  • param (dict) – Dictionary including the user preferences.

Return paths

The updated dictionary paths.

Return type

dict

config.potential_output_paths(paths, param, tech)

This function defines the paths of the files that will be saved in the folder for the potential outputs:

  • FLH is the file with the full-load hours for all pixels within the scope (mat file).

  • mask is the file with the suitable pixels within the scope (mat file).

  • FLH_mask is the file with the full-load hours for the suitable pixels within the scope (mat file).

  • weight is the power density for all the pixels in the scope (mat file).

  • FLH_weight is the potential energy output for all the pixels in the scope (mat file).

Parameters
  • paths (dict) – Dictionary including the paths.

  • param (dict) – Dictionary including the user preferences.

  • tech (string) – Name of the technology.

Return paths

The updated dictionary paths.

Return type

dict

config.regional_analysis_output_paths(paths, param, tech)

This function defines the paths of the files that will be saved in the folder for the regional analysis outputs:

  • Locations is the shapefile of points that correspond to the selected quantiles in each subregion, for which the time series will be generated.

  • TS is the csv file with the time series for all subregions and quantiles.

  • Region_Stats is the csv file with the summary report for all subregions.

  • Sorted_FLH is the mat file with the sorted samples of FLH for each subregion.

  • Regression_coefficients is the path format for a csv files containing the regression coefficients found by the solver

  • Regression_TS is the path format for a csv files with the regression resulting timeseries for the tech and settings

Parameters
  • paths (dict) – Dictionary including the paths.

  • param (dict) – Dictionary including the user preferences.

  • tech (string) – Name of the technology.

Return paths

The updated dictionary paths.

Return type

dict

config.regression_paths(paths, param, tech)

This function defines the paths for the regression parameters:

  • FLH_regression is a csv file containing FLH statistics for the subregions and the four technologies for a specific year, based on the previously created IRENA_summary.

  • TS_regression is a csv file containing time series to be match for each subregion and technology, based on EMHIRES time series if available.

Parameters

paths (dict) – Dictionary including the paths.

Return paths

The updated dictionary paths.

Return type

dict

config.weather_input_folder(paths, param)

This function defines the path MERRA_IN where the MERRA-2 data is saved. It depends on the coverage of the data and the year.

Parameters
  • paths (dict) – Dictionary including the paths.

  • param (dict) – Dictionary including the user preferences.

Return paths

The updated dictionary paths.

Return type

dict

config.weather_output_paths(paths, param)

This function defines the paths to weather filesfor a specific year:

  • W50M is the file for the wind speed at 50m in m/s.

  • CLEARNESS is the file for the clearness index, e.g. the ratio between total ground horizontal radiation and total top-of-the-atmosphere horizontal radiation.

  • T2M is the file for the temperature at 2m in Kelvin.

Parameters
  • paths (dict) – Dictionary including the paths.

  • param (dict) – Dictionary including the user preferences.

Return paths

The updated dictionary paths.

Return type

dict