User manual

Installation

Note

We assume that you are familiar with git and conda.

First, clone the git repository in a directory of your choice using a Command Prompt window:

$ ~\directory-of-my-choice> git clone https://github.com/tum-ens/pyGRETA.git

We recommend using conda and installing the environment from the file ren_ts_new.yml that you can find in the repository. In the Command Prompt window, type:

$ cd pyGRETA\env\
$ conda env create -f ren_ts_new.yml

Then activate the environment:

$ conda activate ren_ts_new

In the folder code, you will find multiple files:

File

Description

config.py

used for configuration, see below.

runme.py

main file, which will be run later using python runme.py.

lib\initialization.py

used for initialization.

lib\input_maps.py

used to generate input maps for the scope.

lib\potential.py

contains functions related to the potential estimation.

lib\time_series.py

contains functions related to the generation of time series.

lib\regression.py

contains functions related to the regression.

lib\spatial_functions.py

contains helping functions related to maps, coordinates and indices.

lib\physical_models.py

contains helping functions for the physical/technological modeling.

lib\correction_functions.py

contains helping functions for data correction/cleaning.

lib\util.py

contains minor helping functions and the necessary python libraries to imported.

config.py

This file contains the user preferences, the links to the input files, and the paths where the outputs should be saved. The paths are initialized in a way that follows a particular folder hierarchy. However, you can change the hierarchy as you wish.

runme.py

runme.py calls the main functions of the code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import lib.correction_functions as cf
import lib.spatial_functions as sf
import lib.input_maps as im
import lib.potential as pl
from lib.log import logger
import initialization as ii
import lib.time_series as ts
import lib.regression as rg
import os
import psutil

if __name__ == "__main__":

    # logger.setLevel(logging.DEBUG)    # Comment out to get more information on the console

    if psutil.virtual_memory().available > 50*10**9:    # Check if memory size is large enough for multiprocessing
        multiprocessing = True
    else:
        multiprocessing = False
    logger.info('Multiprocessing: ' + str(multiprocessing))

    configs = sorted(os.listdir('../configs'))
    for config in configs:       # Iterate over all config files for each country in folder 'configs'

        try:        # only interrupt current country run in case of failure
            logger.info('Started: ' + str(config))

            paths, param = ii.initialization(config)    # Initialize for each country with the corresponding config defined in folder 'configs'

            im.downloadGWA(paths, param)    # Download wind speed data from Global Wind Atlas
            im.generate_maps_for_scope(paths, param, multiprocessing)    # Generate input raster maps

            cf.generate_wind_correction(paths, param)

            for tech in param["technology"]:
                logger.info("Tech: " + tech)
                if tech == "Biomass":
                    im.generate_livestock(paths,param)
                    pl.generate_biomass_production(paths, param, tech)
                    pl.report_biomass_potentials(paths, param, tech)

                else:
                    # Generate potential maps and reports
                    pl.calculate_full_load_hours(paths, param, tech, multiprocessing)
                    pl.mask_potential_maps(paths, param, tech)
                    pl.weight_potential_maps(paths, param, tech)
                    pl.report_potentials(paths, param, tech)

                    # Generate time series
                    # ts.find_representative_locations(paths, param, tech)
                    # ts.generate_time_series_for_representative_locations(paths, param, tech)
                    # ts.generate_time_series_for_specific_locations(paths, param, tech)

            # for tech in param["technology"]:
                # logger.info("Tech: " + tech)

                # Generate regression coefficients for FLH and TS model matching
                # rg.get_regression_coefficients(paths, param, tech)

                # Generate times series for combinations of technologies and locations
                # ts.generate_time_series_for_regions(paths, param, tech)
        except Exception:
            logger.info("General exception noted!", exc_info=True)