def post_install_setup_minimum(args):
    """If not all data are available, this scripts allows to
    create dummy datas (temperature and service sector load profiles)

    """
    path_config_file = args.config_file

    config = data_loader.read_config_file(path_config_file)
    path_local_data = config['PATHS']['path_local_data']

    # ==========================================
    # Post installation setup witout access to non publicy available data
    # ==========================================
    print(
        "... running initialisation scripts with only publicly available data")

    local_paths = data_loader.get_local_paths(path_config_file)

    # Create folders to input data
    raw_folder = os.path.join(path_local_data, '_raw_data')

    basic_functions.create_folder(raw_folder)
    basic_functions.create_folder(config['PATHS']['path_processed_data'])
    basic_functions.create_folder(local_paths['path_post_installation_data'])
    basic_functions.create_folder(local_paths['load_profiles'])
    basic_functions.create_folder(local_paths['rs_load_profile_txt'])
    basic_functions.create_folder(local_paths['ss_load_profile_txt'])

    # Load data
    data = {}

    data['paths'] = data_loader.load_paths(path_config_file)

    data['lookups'] = lookup_tables.basic_lookups()

    data['enduses'], data['sectors'], data[
        'fuels'], lookup_enduses, lookup_sector_enduses = data_loader.load_fuels(
            data['paths'])

    # Assumptions
    data['assumptions'] = general_assumptions.Assumptions(
        lookup_enduses=lookup_enduses,
        lookup_sector_enduses=lookup_sector_enduses,
        base_yr=2015,
        weather_by=config['CONFIG']['user_defined_weather_by'],
        simulation_end_yr=config['CONFIG']['user_defined_simulation_end_yr'],
        paths=data['paths'],
        enduses=data['enduses'],
        sectors=data['sectors'])

    # Read in residential submodel shapes
    run(data['paths'], local_paths, config['CONFIG']['base_yr'])

    # --------
    # Dummy service sector load profiles
    # --------
    dummy_sectoral_load_profiles(local_paths, path_config_file)

    print(
        "Successfully finished post installation setup with open source data")
Ejemplo n.º 2
0
def test_get_local_paths(config_file):

    actual = get_local_paths(config_file)

    assert isinstance(actual, dict)
    assert actual[
        'yaml_parameters_scenario'] == '/vagrant/data/energy_demand/config/yaml_parameters_scenario.yml'
Ejemplo n.º 3
0
def test_assign_by_fuel_tech_p(config_file):
    """
    """
    config = data_loader.read_config_file(config_file)

    # Load data
    data = {}
    data['paths'] = config['CONFIG_DATA']
    data['lookups'] = lookup_tables.basic_lookups()
    data['enduses'], data['sectors'], data[
        'fuels'], _, _ = data_loader.load_fuels(data['paths'])

    data['local_paths'] = data_loader.get_local_paths(path_main)

    #Load assumptions
    base_yr = 2015

    data['assumptions'] = general_assumptions.Assumptions(
        submodels_names=['a'],
        base_yr=base_yr,
        curr_yr=None,
        sim_yrs=None,
        paths=data['paths'],
        enduses=data['enduses'],
        sectors=data['sectors'],
        fueltypes=data['lookups']['fueltypes'],
        fueltypes_nr=data['lookups']['fueltypes_nr'])

    strategy_vars_def.load_param_assump(data['paths'], data['local_paths'],
                                        data['assumptions'])

    fuel_tech_p_by = fuel_shares.assign_by_fuel_tech_p(
        data['enduses'], data['sectors'], data['lookups']['fueltypes'],
        data['lookups']['fueltypes_nr'])
Ejemplo n.º 4
0
path_main = os.path.abspath(
    os.path.join(os.path.dirname(__file__), '..', "config_data"))
# Configuration paths
config = configparser.ConfigParser()
config.read(os.path.join(path_config, 'wrapperconfig.ini'))

# --------
# Other configuration
# --------
base_yr = 2015
sim_yrs = [2015, 2050]

paths = data_loader.load_paths(path_main)
data_path = os.path.normpath(config['PATHS']['path_local_data'])

local_paths = data_loader.get_local_paths(data_path)

data = {}

data['enduses'], data['sectors'], data['fuels'] = data_loader.load_fuels(paths)

assumptions = general_assumptions.Assumptions(base_yr=user_defined_base_yr,
                                              curr_yr=2015,
                                              sim_yrs=sim_yrs,
                                              paths=paths,
                                              enduses=data['enduses'],
                                              sectors=data['sectors'])

# Write parameters to YAML file
_, _ = strategy_vars_def.load_param_assump(assumptions)
Ejemplo n.º 5
0
def main(path_data_ed, path_shapefile_input, plot_crit_dict, base_yr,
         comparison_year):
    """Read in all results and plot PDFs

    Arguments
    ----------
    path_data_ed : str
        Path to results
    path_shapefile_input : str
        Path to shapefile
    plot_crit_dict : dict
        Criteria to select plots to plot
    base_yr : int
        Base year
    comparison_year : int
        Year to generate comparison plots
    """
    print("...Start creating plots")
    data = {}

    # ---------------------------------------------------------
    # Iterate folders and read out all weather years and stations
    # ---------------------------------------------------------
    to_ignores = ['model_run_pop', 'PDF_validation']

    endings_to_ignore = ['.pdf', '.txt', '.ini']

    all_result_folders = os.listdir(path_data_ed)
    paths_folders_result = []

    for result_folder in all_result_folders:
        if result_folder not in to_ignores and result_folder[
                -4:] not in endings_to_ignore:
            paths_folders_result.append(
                os.path.join(path_data_ed, result_folder))

    ####################################################################
    # Calculate results for every weather year
    ####################################################################
    for path_result_folder in paths_folders_result:

        print("-----------------------")
        print("path_result_folder: " + str(path_result_folder))
        print("-----------------------")
        # Simulation information is read in from .ini file for results
        data['enduses'], data['assumptions'], data[
            'regions'] = data_loader.load_ini_param(os.path.join(path_data_ed))

        # ------------------
        # Load necessary inputs for read in
        # ------------------
        data = {}
        data['local_paths'] = data_loader.get_local_paths(path_result_folder)
        data['result_paths'] = basic_functions.get_result_paths(
            os.path.join(path_result_folder))
        data['lookups'] = lookup_tables.basic_lookups()

        # ---------------
        # Folder cleaning
        # ---------------
        basic_functions.del_previous_setup(
            data['result_paths']['data_results_PDF'])
        basic_functions.del_previous_setup(
            data['result_paths']['data_results_shapefiles'])
        basic_functions.create_folder(data['result_paths']['data_results_PDF'])
        basic_functions.create_folder(
            data['result_paths']['data_results_shapefiles'])
        basic_functions.create_folder(
            data['result_paths']['individual_enduse_lp'])

        # Simulation information is read in from .ini file for results
        data['enduses'], data['assumptions'], data[
            'regions'] = data_loader.load_ini_param(os.path.join(path_data_ed))

        # Other information is read in
        data['assumptions']['seasons'] = date_prop.get_season(
            year_to_model=2015)
        data['assumptions']['model_yeardays_daytype'], data['assumptions'][
            'yeardays_month'], data['assumptions'][
                'yeardays_month_days'] = date_prop.get_yeardays_daytype(
                    year_to_model=2015)

        data['scenario_data'] = {}

        data['scenario_data'][
            'population'] = read_data.read_scenaric_population_data(
                os.path.join(path_data_ed, 'model_run_pop'))

        # --------------------------------------------
        # Reading in results from different model runs
        # --------------------------------------------
        results_container = read_data.read_in_results(
            data['result_paths']['data_results_model_run_results_txt'],
            data['assumptions']['seasons'],
            data['assumptions']['model_yeardays_daytype'])

        # ------------------------------
        # Plotting other results
        # ------------------------------
        plotting_results.run_all_plot_functions(
            results_container,
            data['assumptions']['reg_nrs'],
            data['regions'],
            data['lookups'],
            data['result_paths'],
            data['assumptions'],
            data['enduses'],
            plot_crit=plot_crit_dict,
            base_yr=base_yr,
            comparison_year=comparison_year)

        # ------------------------------
        # Plotting spatial results
        # ------------------------------
        if plot_crit_dict['spatial_results']:
            result_mapping.spatial_maps(
                data,
                results_container,
                data['result_paths']['data_results_shapefiles'],
                data['regions'],
                data['lookups']['fueltypes_nr'],
                data['lookups']['fueltypes'],
                path_shapefile_input,
                plot_crit_dict,
                base_yr=base_yr)

    print("===================================")
    print("... finished reading and plotting results")
    print("===================================")