def test_assign_by_fuel_tech_p():
    """
    """
    path_main = resource_filename(Requirement.parse("energy_demand"),
                                  'config_data')

    # Load data
    data = {}
    data['paths'] = data_loader.load_paths(path_main)
    data['lookups'] = lookup_tables.basic_lookups()
    data['enduses'], data['sectors'], data['fuels'] = data_loader.load_fuels(
        data['paths'], data['lookups'])
    data['local_paths'] = data_loader.load_local_paths(path_main)

    #Load assumptions
    base_yr = 2015

    data['assumptions'] = non_param_assumptions.Assumptions(
        base_yr=base_yr,
        curr_yr=None,
        simulated_yrs=None,
        paths=data['paths'],
        enduses=data['enduses'],
        sectors=data['sectors'],
        fueltypes=data['lookups']['fueltypes'],
        fueltypes_nr=data['lookups']['fueltypes_nr'])

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

    rs_fuel_tech_p_by, ss_fuel_tech_p_by, is_fuel_tech_p_by = assumptions_fuel_shares.assign_by_fuel_tech_p(
        data['enduses'], data['sectors'], data['lookups']['fueltypes'],
        data['lookups']['fueltypes_nr'])
Exemple #2
0
def test_load_non_param_assump():
    """
    """
    path_main = resource_filename(Requirement.parse("energy_demand"), "config_data")

    # Load data
    data = {}
    paths = data_loader.load_paths(path_main)
    lu = lookup_tables.basic_lookups()
    enduses, sectors, _ = data_loader.load_fuels(paths, lu)

    non_param_assumptions.Assumptions(
        base_yr=2015,
        curr_yr=None,
        simulated_yrs=None,
        paths=paths,
        enduses=enduses,
        sectors=sectors,
        fueltypes=lu['fueltypes'],
        fueltypes_nr=lu['fueltypes_nr'])
def post_install_setup(args):
    """Run this function after installing the energy_demand
    model with smif and putting the data folder with all necessary
    data into a local drive. This scripts only needs to be
    executed once after the energy_demand model has been installed

    Arguments
    ----------
    args : object
        Arguments defined in ``./cli/__init__.py``
    """
    print("... start running initialisation scripts")

    # Paths
    path_main = resource_filename(Requirement.parse("energy_demand"), "config_data")
    path_results = resource_filename(Requirement.parse("energy_demand"), "results")
    local_data_path = args.local_data

    # Initialise logger
    logger_setup.set_up_logger(
        os.path.join(local_data_path, "logging_post_install_setup.log"))
    logging.info("... start local energy demand calculations")

    # Load data
    base_yr = 2015

    data = {}
    data['paths'] = data_loader.load_paths(path_main)
    data['local_paths'] = data_loader.load_local_paths(local_data_path)
    data['result_paths'] = data_loader.load_result_paths(path_results)
    data['lookups'] = lookup_tables.basic_lookups()
    data['enduses'], data['sectors'], data['fuels'] = data_loader.load_fuels(
        data['paths'], data['lookups'])

    # Assumptions
    data['assumptions'] = non_param_assumptions.Assumptions(
        base_yr=base_yr,
        paths=data['paths'],
        enduses=data['enduses'],
        sectors=data['sectors'],
        fueltypes=data['lookups']['fueltypes'],
        fueltypes_nr=data['lookups']['fueltypes_nr'])

    # Delete all previous data from previous model runs
    basic_functions.del_previous_setup(data['local_paths']['data_processed'])
    basic_functions.del_previous_setup(data['result_paths']['data_results'])

    # Create folders and subfolder for data_processed
    basic_functions.create_folder(data['local_paths']['data_processed'])
    basic_functions.create_folder(data['local_paths']['path_post_installation_data'])
    basic_functions.create_folder(data['local_paths']['dir_raw_weather_data'])
    basic_functions.create_folder(data['local_paths']['dir_changed_weather_station_data'])
    basic_functions.create_folder(data['local_paths']['load_profiles'])
    basic_functions.create_folder(data['local_paths']['rs_load_profile_txt'])
    basic_functions.create_folder(data['local_paths']['ss_load_profile_txt'])
    basic_functions.create_folder(data['local_paths']['dir_disaggregated'])

    print("... Read in temperature data from raw files")
    s_raw_weather_data.run(
        data['local_paths'])

    print("... Read in service submodel load profiles")
    s_ss_raw_shapes.run(
        data['paths'],
        data['local_paths'],
        data['lookups'])

    print("... Read in residential submodel load profiles")
    s_rs_raw_shapes.run(
        data['paths'],
        data['local_paths'],
        base_yr)

    print("... successfully finished setup")
    return
Exemple #4
0
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)

    Arguments
    ---------
    path_local_data : str
        Path to `energy_demand_data` folder
    path_energy_demand : str
        Path to energy demand python files
    """
    path_energy_demand = resource_filename(Requirement.parse("energy_demand"), "config_data")
    path_local_data = args.local_data

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

    # Load paths
    local_paths = data_loader.load_local_paths(path_local_data)

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

    basic_functions.create_folder(local_paths['path_post_installation_data'])
    basic_functions.create_folder(local_paths['dir_raw_weather_data'])
    basic_functions.create_folder(local_paths['dir_changed_weather_station_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'])
    basic_functions.create_folder(local_paths['dir_disaggregated'])

    # Load data
    base_yr = 2015
    data = {}

    data['paths'] = data_loader.load_paths(path_energy_demand)
    data['lookups'] = lookup_tables.basic_lookups()
    data['enduses'], data['sectors'], data['fuels'] = data_loader.load_fuels(
        data['paths'], data['lookups'])

    # Assumptions
    data['assumptions'] = non_param_assumptions.Assumptions(
        base_yr=base_yr,
        paths=data['paths'],
        enduses=data['enduses'],
        sectors=data['sectors'],
        fueltypes=data['lookups']['fueltypes'],
        fueltypes_nr=data['lookups']['fueltypes_nr'])

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

    # ==========================================
    # Create not publica available files
    # ==========================================

    # --------
    # Generate dummy weather stations
    # --------
    dummy_raw_weather_station(local_paths)

    # --------
    # Generate dummy temperatures
    # --------
    dummy_raw_weather_data(local_paths)

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

    print("Successfully finished post installation setup with open source data")
Exemple #5
0
    data['reg_coord'] = {}
    for reg in data['regions']:
        data['reg_coord'][reg] = {'longitude': 52.58, 'latitude': -1.091}
        pop_density[reg] = 1
    data['regions'] = list(data['regions'].keys())
    data['pop_density'] = pop_density

    # ------------------------------
    # Assumptions
    # ------------------------------
    # Parameters not defined within smif
    data['assumptions'] = non_param_assumptions.Assumptions(
        base_yr=2015,
        curr_yr=2015,
        simulated_yrs=[2015, 2016, 2030, 2050],
        paths=data['paths'],
        enduses=data['enduses'],
        sectors=data['sectors'],
        fueltypes=data['lookups']['fueltypes'],
        fueltypes_nr=data['lookups']['fueltypes_nr'])

    # Parameters defined within smif
    strategy_variables = param_assumptions.load_param_assump(
        data['paths'], data['local_paths'], data['assumptions'])
    data['assumptions'].update('strategy_variables', strategy_variables)

    data['tech_lp'] = data_loader.load_data_profiles(
        data['paths'], data['local_paths'], data['assumptions'].model_yeardays,
        data['assumptions'].model_yeardays_daytype,
        data['criterias']['plot_tech_lp'])