def test_enduse(): """testing""" out = enduse_func.Enduse(submodel='test', region='test', scenario_data='test', assumptions='test', regional_lp_stock='test', non_regional_lp_stock='test', base_yr='test', curr_yr='test', enduse='test', sector='test', fuel=np.zeros((7, 0)), tech_stock='test', heating_factor_y='test', cooling_factor_y='test', fuel_fueltype_tech_p_by='test', sig_param_tech='test', enduse_overall_change='test', criterias='test', strategy_variables='test', fueltypes_nr='test', fueltypes='test', model_yeardays_nrs='test') assert out.flat_profile_crit == True
def test_enduse(): """testing""" out = enduse_func.Enduse(submodel_name='test_name', region='test', scenario_data='test', assumptions='test', load_profiles='test', base_yr='test', curr_yr='test', enduse='test', sector='test', fuel=np.zeros((7, 0)), tech_stock='test', heating_factor_y='test', cooling_factor_y='test', fuel_tech_p_by='test', criterias='test', strategy_vars='test', fueltypes_nr='test', fueltypes='test') assert out.flat_profile_crit == True
def simulate_region(region, data, criterias, assumptions, weather_yr, weather_by): """Run submodels for a single region Arguments --------- region : str Region name data : dict Data container Returns ------- all_submodels : list List with submodel objects depending on submodels """ submodel_names = assumptions.submodels_names # ---------------------------- # Create Base year and current weather Regions # ---------------------------- weather_region_cy = WeatherRegion( name=region, assumptions=assumptions, technologies=assumptions.technologies, enduses=data['enduses'], temp_by=data['temp_data'][weather_by][region], temp_cy=data['temp_data'][weather_yr][region], tech_lp=data['tech_lp'], sectors=data['sectors'], crit_temp_min_max=criterias['crit_temp_min_max']) # Get region specific disaggregated fuel region_fuel_disagg = get_disaggregated_fuel_of_reg(submodel_names, data['fuel_disagg'], region) # ---------------------------- # Create Region # ---------------------------- region_obj = Region(name=region, longitude=data['reg_coord'][region]['longitude'], latitude=data['reg_coord'][region]['latitude'], region_fuel_disagg=region_fuel_disagg) for submodel_name in submodel_names: for sector in data['sectors'][submodel_name]: for enduse in data['enduses'][submodel_name]: # ------------------------------------------------------ # Configure and select correct Enduse specific inputs # ------------------------------------------------------ if submodel_name == 'industry' and enduse != "is_space_heating": flat_profile_crit = True else: flat_profile_crit = False if not data['dw_stocks'][submodel_name]: dw_stock = False else: dw_stock = data['dw_stocks'][submodel_name][ region_obj.name] # --------------- # Create submodel for region and enduse # --------------- yield endusefunctions.Enduse( submodel_name=submodel_name, region=region_obj.name, scenario_data=data['scenario_data'], assumptions=assumptions, load_profiles=weather_region_cy.load_profiles, base_yr=assumptions.base_yr, curr_yr=assumptions.curr_yr, enduse=enduse, sector=sector, fuel=region_obj.fuels[submodel_name][enduse][sector], tech_stock=weather_region_cy.tech_stock[submodel_name], heating_factor_y=weather_region_cy.f_heat[submodel_name], cooling_factor_y=weather_region_cy. f_colling[submodel_name], fuel_tech_p_by=assumptions.fuel_tech_p_by[enduse][sector], criterias=criterias, strategy_vars=assumptions.regional_vars[region_obj.name], fueltypes_nr=assumptions.fueltypes_nr, fueltypes=assumptions.fueltypes, dw_stock=dw_stock, reg_scen_drivers=assumptions.scenario_drivers, flat_profile_crit=flat_profile_crit)
def simulate_region(region, data, criterias, assumptions, weather_stations, weather_yr, weather_by): """Run submodels for a single region Arguments --------- region : str Region name data : dict Data container Returns ------- all_submodels : list List with submodel objects depending on submodels """ submodel_objs = [] submodel_names = assumptions.submodels_names # Get closest weather region object weather_region_id = weather_station_location.get_closest_station( latitude_reg=data['reg_coord'][region]['latitude'], longitude_reg=data['reg_coord'][region]['longitude'], weather_stations=weather_stations) # ---------------------------- # Create Base year and current weather Regions # ---------------------------- weather_regions_weather_cy = WeatherRegion( name=weather_region_id, latitude=weather_stations[weather_region_id]['latitude'], longitude=weather_stations[weather_region_id]['longitude'], assumptions=assumptions, technologies=assumptions.technologies, enduses=data['enduses'], temp_by=data['temp_data'][weather_by][weather_region_id], temp_cy=data['temp_data'][weather_yr][weather_region_id], tech_lp=data['tech_lp'], sectors=data['sectors'], crit_temp_min_max=criterias['crit_temp_min_max']) weather_regions_weather_by = WeatherRegion( name=weather_region_id, latitude=weather_stations[weather_region_id]['latitude'], longitude=weather_stations[weather_region_id]['longitude'], assumptions=assumptions, technologies=assumptions.technologies, enduses=data['enduses'], temp_by=data['temp_data'][weather_by][weather_region_id], temp_cy=data['temp_data'][weather_yr][weather_region_id], tech_lp=data['tech_lp'], sectors=data['sectors'], crit_temp_min_max=criterias['crit_temp_min_max']) # Get region specific disaggregated fuel region_fuel_disagg = get_disaggregated_fuel_of_reg(submodel_names, data['fuel_disagg'], region) # ---------------------------- # Create Region # ---------------------------- region_obj = Region(name=region, longitude=data['reg_coord'][region]['longitude'], latitude=data['reg_coord'][region]['latitude'], region_fuel_disagg=region_fuel_disagg, weather_reg_cy=weather_regions_weather_cy, weather_reg_by=weather_regions_weather_by) for submodel_name in submodel_names: for sector in data['sectors'][submodel_name]: for enduse in data['enduses'][submodel_name]: # ------------------------------------------------------ # Configure and select correct Enduse specific inputs # ------------------------------------------------------ if submodel_name == 'industry' and enduse != "is_space_heating": flat_profile_crit = True else: flat_profile_crit = False if not data['dw_stocks'][submodel_name]: dw_stock = False else: dw_stock = data['dw_stocks'][submodel_name][ region_obj.name] # --------------- # Create submodel for region and enduse # --------------- submodel_obj = endusefunctions.Enduse( submodel_name=submodel_name, region=region_obj.name, scenario_data=data['scenario_data'], assumptions=assumptions, load_profiles=weather_regions_weather_cy.load_profiles, f_weather_correction=region_obj. f_weather_correction[submodel_name], base_yr=assumptions.base_yr, curr_yr=assumptions.curr_yr, enduse=enduse, sector=sector, fuel=region_obj.fuels[submodel_name][enduse][sector], tech_stock=weather_regions_weather_cy. tech_stock[submodel_name], heating_factor_y=weather_regions_weather_cy. f_heat[submodel_name], cooling_factor_y=weather_regions_weather_cy. f_colling[submodel_name], fuel_tech_p_by=assumptions.fuel_tech_p_by[enduse][sector], criterias=criterias, strategy_vars=assumptions.regional_vars[region_obj.name], fueltypes_nr=assumptions.fueltypes_nr, fueltypes=assumptions.fueltypes, dw_stock=dw_stock, reg_scen_drivers=assumptions.scenario_drivers, flat_profile_crit=flat_profile_crit) submodel_objs.append(submodel_obj) # Collect all submodels with respect to submodel names and store in list # e.g. [[all_residential-submodels], [all_service_submodels]...] all_submodels = [] submodels = lookup_tables.basic_lookups()['submodels_names'] for submodel in submodels: submodels = get_all_submodels(submodel_objs, submodel) all_submodels.append(submodels) return all_submodels
def industry_submodel(region, weather_region, scenario_data, non_regional_lp_stock, assumptions, lookups, criterias, enduses, sectors): """Industry subsector model A flat load profile is assumed except for is_space_heating Arguments ---------- region : int Region data : dict Data containter enduses : list Enduses of industry submodel sectors : list Sectors of industry submodel Return ------ submodules : list Submodule objects """ logging.debug("... industry submodel start") submodels = [] for sector in sectors: for enduse in enduses: # ------------------------------------------------------ # Configure and select correct Enduse() specific inputs # ------------------------------------------------------ if enduse == "is_space_heating": flat_profile_crit = False else: flat_profile_crit = True if criterias['spatial_exliclit_diffusion']: sig_param_tech = assumptions.is_sig_param_tech[enduse][sector][ region.name] strategy_variables = assumptions.regional_strategy_variables[ region.name] else: sig_param_tech = assumptions.is_sig_param_tech[enduse][sector] strategy_variables = assumptions.strategy_variables # ------------------------------------------------------ # Create submodel # ------------------------------------------------------ submodel = endusefunctions.Enduse( submodel='is_submodel', region=region.name, scenario_data=scenario_data, assumptions=assumptions, regional_lp_stock=weather_region.is_load_profiles, non_regional_lp_stock=non_regional_lp_stock, base_yr=assumptions.base_yr, curr_yr=assumptions.curr_yr, enduse=enduse, sector=sector, fuel=region.is_enduses_sectors_fuels[enduse][sector], tech_stock=weather_region.is_tech_stock, heating_factor_y=weather_region.f_heat_is_y, cooling_factor_y=weather_region.f_cooling_is_y, fuel_fueltype_tech_p_by=assumptions.is_fuel_tech_p_by[enduse] [sector], sig_param_tech=sig_param_tech, enduse_overall_change=assumptions.enduse_overall_change, criterias=criterias, strategy_variables=strategy_variables, fueltypes_nr=lookups['fueltypes_nr'], fueltypes=lookups['fueltypes'], model_yeardays_nrs=assumptions.model_yeardays_nrs, reg_scen_drivers=assumptions.scenario_drivers['is_submodule'], flat_profile_crit=flat_profile_crit) submodels.append(submodel) return submodels
def service_submodel(region, weather_region, scenario_data, ss_dw_stock, non_regional_lp_stock, assumptions, lookups, criterias, enduses, sectors): """Create the service submodules per enduse, sector and region and add to list Arguments ---------- data : dict Data container enduses : list All residential enduses sectors : list Service sectors Returns ------- submodels : list List with submodels """ logging.debug("... service submodel start") submodels = [] for sector in sectors: for enduse in enduses: # ------------------------------------------------------ # Configure and select correct Enduse() specific inputs # ------------------------------------------------------ if criterias['spatial_exliclit_diffusion']: sig_param_tech = assumptions.ss_sig_param_tech[enduse][sector][ region.name] strategy_variables = assumptions.regional_strategy_variables[ region.name] else: sig_param_tech = assumptions.ss_sig_param_tech[enduse][sector] strategy_variables = assumptions.strategy_variables # ------------------------------------------------------ # Create submodel # ------------------------------------------------------ submodel = endusefunctions.Enduse( submodel='ss_submodel', region=region.name, scenario_data=scenario_data, assumptions=assumptions, regional_lp_stock=weather_region.ss_load_profiles, non_regional_lp_stock=non_regional_lp_stock, base_yr=assumptions.base_yr, curr_yr=assumptions.curr_yr, enduse=enduse, sector=sector, fuel=region.ss_enduses_sectors_fuels[enduse][sector], tech_stock=weather_region.ss_tech_stock, heating_factor_y=weather_region.f_heat_ss_y, cooling_factor_y=weather_region.f_cooling_ss_y, fuel_fueltype_tech_p_by=assumptions.ss_fuel_tech_p_by[enduse] [sector], sig_param_tech=sig_param_tech, criterias=criterias, strategy_variables=strategy_variables, fueltypes_nr=lookups['fueltypes_nr'], fueltypes=lookups['fueltypes'], model_yeardays_nrs=assumptions.model_yeardays_nrs, enduse_overall_change=assumptions.enduse_overall_change, dw_stock=ss_dw_stock) # Add to list submodels.append(submodel) return submodels