energy_demand.geography package

Submodules

energy_demand.geography.region module

Region Class

class energy_demand.geography.region.Region(name, longitude, latitude, region_fuel_disagg)[source]

Bases: object

Region class

Parameters
  • name (str) – Name of region

  • longitude (float) – Longitude coordinate

  • latitude (float) – Latitude coordinate

  • region_fuel_disagg (dict) – Nested dict by region, enduse => np.array, single dimension for fuel type

energy_demand.geography.spatial_diffusion module

This file contains all calculations related to spatial explicit calculations of technology/innovation penetration.

energy_demand.geography.spatial_diffusion.calc_diffusion_f(regions, f_reg, spatial_diff_values, fuels)[source]

From spatial diffusion values calculate diffusion factor for every region (which needs to sum up to one across all regions) and end use. With help of these calculation diffusion factors, a spatial explicit diffusion of innovations can be implemented.

Parameters
  • regions (dict) – Regions

  • f_reg (dict) – Regional not weighted diffusion factors

  • spatial_diff_values (dict) – Spatial diffusion index values

  • fuels (array) – Fuels per enduse or fuel per sector and enduse

Example

If the national assumption of a technology diffusion of 50% is defined (e.g. 50% of service are heat pumps), this percentage can be changed per region, i.e. in some regions with higher diffusion factors, a larger percentage adopt the technology on the expense of other regions, where a lower percentage adopt this technology. In sum however, for all regions, the total service still sums up to 50%.

Note

The total sum can be higher than 1 in case of high values. Therefore the factors need to be capped. TODO MORE INFO

energy_demand.geography.spatial_diffusion.calc_regional_services(enduse, uk_techs_service_p, regions, spatial_factors, fuel_disaggregated, techs_affected_spatial_f, capping_val=1)[source]

Calculate regional specific end year service shares of technologies (rs_reg_enduse_tech_p_ey)

Parameters
  • uk_techs_service_p (dict) – Service shares per technology for future year

  • regions (dict) – Regions

  • spatial_factors (dict) – Spatial factor per enduse and region

  • fuel_disaggregated (dict) – Fuels per region

  • techs_affected_spatial_f (list) – List with technologies where spatial diffusion is affected

  • capping_val (float) – Maximum service share (1.0). This is needed in case of spatial explicit diffusion modelling where the diffusion speed is very large and thus would lead to areas with largher shares than 1

Returns

  • rs_reg_enduse_tech_p_ey (dict) – Regional specific model end year service shares of techs

  • Modelling steps

  • —–

  • A.) Calculation national end use service to reduce – (e.g. 50% heat pumps for all regions) (uk_tech_service_ey_p)

  • B.) Distribute this service according to spatial index for – techs where the spatial explicit diffusion applies (techs_affected_spatial_f). Otherwise disaggregated according to fuel

  • C.) Convert regional service reduction to ey % in region

energy_demand.geography.spatial_diffusion.calc_spatially_diffusion_factors(regions, fuel_disagg, real_values, low_congruence_crit, speed_con_max, p_outlier)[source]

Calculate spatial diffusion values

Parameters
  • regions (dict) – Regions

  • fuel_disagg (dict) – Disaggregated fuel per region

  • real_values (dict) – Real values

  • p_outlier (float) – Percentage of min and max outliers are flattened

Returns

  • f_reg_norm_abs (dict) – Diffusion values with normed population. If no value is larger than 1, the total sum of all shares calculated for every region is identical to the defined scenario variable.

  • spatial_diff_values (dict) – Spatial diffusion values (not normed, only considering differences in speed and congruence values)

  • Explanation

  • ============

  • (I) Load diffusion values

  • (II) Calculate diffusion factors

  • (III) Calculate sigmoid diffusion values for technology – specific enduse service shares for every region

energy_demand.geography.spatial_diffusion.factor_improvements_single(factor_uk, regions, f_reg, f_reg_norm, f_reg_norm_abs, fuel_regs_enduse)[source]

Calculate regional specific end year service shares of technologies (rs_reg_enduse_tech_p_ey)

Parameters
  • factor_uk (float) – Improvement of either an enduse or a variable for the whole UK

  • regions (dict) – Regions

  • f_reg (dict) – Regional spatial factors not normed with fuel demand

  • f_reg_norm (dict) – Regional spatial factors normed with fuel demand (sum is not 1)

  • f_reg_norm_abs (dict) – Regional spatial factors normed with fuel demand and normed that sum is 1

  • spatial_diff_values (dict) – Spatial diffusion values

  • fuel_regs_enduse (dict) – Fuels per region and end use

Returns

  • rs_reg_enduse_tech_p_ey (dict) – Regional specific model end year service shares of techs

  • Modelling steps

  • —–

  • A.) Calculation national end use service to reduce – (e.g. 50% heat pumps for all regions) (uk_tech_service_ey_p)

  • B.) Distribute this service according to spatial index for – techs where the spatial explicit diffusion applies (techs_affected_spatial_f). Otherwise disaggregated according to fuel

  • C.) Convert regional service reduction to ey % in region

energy_demand.geography.spatial_diffusion.get_enduse_regs(enduse, fuels_disagg)[source]

Get a specific enduse for all regions

Parameters
  • enduse (str) – Enduse to sum

  • fuels_disagg (list) – Fuels per disaggregated regions

Returns

fuels_enduse – Fuels of an enduse for all regions {‘reg’: np.array(enduse_fuel)}

Return type

dict

energy_demand.geography.spatial_diffusion.spatial_diffusion_values(regions, real_values, speed_con_max, low_congruence_crit, p_outlier)[source]

Generate spatial diffusion values from real data

Parameters
  • regions (dict) – Regions

  • p_outlier (float (percentage)) – Percentage of outliers which are capped at both ends of the value spectrum of the real data

Returns

diffusion_values – Spatial diffusion values based on speed assumptions

Return type

dict

Example

This function calculates the values which already incorporate different speeds in diffusion.

For example based on real values (e.g. population density) congruence values are calculated. Then, the congruence values are linked to diffusion speed differentes.

energy_demand.geography.weather_region module

energy_demand.geography.weather_station_location module

Weather Station location

energy_demand.geography.weather_station_location.calc_distance_two_points(lat_from, long_from, lat_to, long_to)[source]

Calculate distance between two points

https://pypi.org/project/haversine/#description

Parameters
  • long_from (float) – Longitute coordinate from point

  • lat_from (float) – Latitute coordinate from point

  • long_to (float) – Longitute coordinate to point

  • lat_to (float) – Latitue coordinate to point

Returns

distance – Distance

Return type

float

energy_demand.geography.weather_station_location.get_closest_station(latitude_reg, longitude_reg, weather_stations)[source]

Search ID of closest weater station

Parameters
  • longitude_reg (float) – Longitute coordinate of Region Object

  • latitude_reg (float) – Latitute coordinate of Region Object

  • weather_stations (dict) – Weater station data

Returns

closest_id – ID of closest weather station

Return type

int

energy_demand.geography.write_shp module

Append result to shapefile