ding0.tools package

Submodules

ding0.tools.animation module

class ding0.tools.animation.AnimationDing0(**kwargs)[source]

Bases: object

Class for visual animation of the routing process (solving CVRP).

(basically a central place to store information about output file and count of saved images). Use argument ‘animation=True’ of method ‘NetworkDing0.mv_routing()’ to enable image export. The images are exported to ding0’s home dir which is usually ~/.ding0/ .

Subsequently, FFMPEG can be used to convert images to animation, e.g.

ffmpeg -r 5 -i mv-routing_ani_%04d.png -vframes 200 -r 15 -vcodec libx264 -y -an mv-routing_ani.mp4 -s 640x480

See also

ding0.core.NetworkDing0.mv_routing

ding0.tools.config module

Based on code by oemof development team

This module provides a highlevel layer for reading and writing config files. The config file has to be of the following structure to be imported correctly.

[netCDF]

     RootFolder = c://netCDF

     FilePrefix = cd2_



[mySQL]

    host = localhost

    user = guest

    password = root

    database = znes



[SectionName]

    OptionName = value

    Option2 = value2

Based on code by oemof development team

ding0.tools.config.get(section, key)[source]

Returns the value of a given key of a given section of the main config file.

Parameters:
  • section (str) – the section.
  • key (str) – the key
Returns:

float – the value which will be casted to float, int or boolean. if no cast is successful, the raw string will be returned.

See also

set()

ding0.tools.config.load_config(filename)[source]

Read config file specified by filename

Parameters:filename (str) – Description of filename
ding0.tools.config.set(section, key, value)[source]

Sets a value to a [section] key - pair.

if the section doesn’t exist yet, it will be created.

Parameters:
  • section (str) – the section.
  • key (str) – the key.
  • value (float, int, str) – the value.

See also

get()

ding0.tools.debug module

ding0.tools.debug.compare_graphs(graph1, mode, graph2=None)[source]

Compares graph with saved one which is loaded via networkx’ gpickle

Parameters:
  • graph1 (networkx.graph) – First Ding0 MV graph for comparison
  • graph2 (networkx.graph) – Second Ding0 MV graph for comparison. If a second graph is not provided it will be laoded from disk with hard-coded file name.
  • mode ('write' or 'compare') –
  • Returns
ding0.tools.debug.log_errors(f)[source]

Decorator object that logs every exception into the defined logger object.

ding0.tools.geo module

ding0.tools.geo.calc_edge_geometry(node_source, node_target, srid=3035)[source]

returns straight edge geometry and related length between two nodes as LineString

Parameters:
Returns:

  • geometry (LineString,)
  • float – Distance in m

ding0.tools.geo.calc_geo_branches_in_buffer(node, mv_grid, radius, radius_inc, proj, srid=3035)[source]

NEW PARAM srid=3035 to calculate calc_geo_branches_in_buffer. Before srid=4326 was assumed.

Determines branches in nodes’ associated graph that are at least partly within buffer of radius from node.

If there are no nodes, the buffer is successively extended by radius_inc until nodes are found.

Parameters:
  • node (LVStationDing0, GeneratorDing0, or CableDistributorDing0) – origin node (e.g. LVStationDing0 object) with associated shapely object (attribute geo_data) in any CRS (e.g. WGS84)
  • radius (float) – buffer radius in m
  • radius_inc (float) – radius increment in m
  • proj (int) – pyproj projection object: nodes’ CRS to equidistant CRS (e.g. WGS84 -> ETRS)
Returns:

list of NetworkX Graph Obj – List of branches (NetworkX branch objects)

ding0.tools.geo.calc_geo_branches_in_polygon(mv_grid, polygon, mode, proj, srid=3035)[source]

NEW PARAM srid=3035 to calculate calc_geo_branches_in_buffer. Before srid=4326 was assumed.

Calculate geographical branches in polygon.

For a given mv_grid all branches (edges in the graph of the grid) are tested if they are in the given polygon. You can choose different modes and projections for this operation.

Parameters:
  • mv_grid (MVGridDing0) – MV Grid object. Edges contained in mv_grid.graph_edges() are taken for the test.
  • polygon (Shapely Point object) – Polygon that contains edges.
  • mode (str) – Choose between ‘intersects’ or ‘contains’.
  • proj (int) – EPSG code to specify projection
Returns:

list of BranchDing0 objects – List of branches

ding0.tools.geo.calc_geo_centre_point(node_source, node_target, srid=3035)[source]

Calculates the geodesic distance between node_source and node_target incorporating the detour factor specified in config_calc.cfg.

Parameters:
Returns:

float – Distance in m.

ding0.tools.geo.calc_geo_dist(node_source, node_target, srid=3035)[source]

Calculates the geodesic distance between node_source and node_target incorporating the detour factor specified in ding0/ding0/config/config_calc.cfg.

Parameters:
Returns:

float – Distance in m

ding0.tools.geo.calc_geo_dist_matrix(nodes_pos, srid=3035)[source]

Calculates the geodesic distance between all nodes in nodes_pos incorporating the detour factor in config_calc.cfg.

For every two points/coord it uses geopy’s geodesic function. As default ellipsoidal model of the earth WGS-84 is used. For more options see

https://geopy.readthedocs.io/en/stable/index.html?highlight=geodesic#geopy.distance.geodesic

Parameters:nodes_pos (dict) –

dictionary of nodes with positions, with x=longitude, y=latitude, and the following format:

{
    'node_1': (x_1, y_1),
    ...,
    'node_n': (x_n, y_n)
}
Returns:dict

dictionary with distances between all nodes (in km), with the following format:

{
    'node_1': {'node_1': dist_11, ..., 'node_n': dist_1n},
    ...,
    'node_n': {'node_1': dist_n1, ..., 'node_n': dist_nn}
}

ding0.tools.logger module

ding0.tools.logger.create_dir(dirpath)[source]

Create directory and report about it

Parameters:dirpath (str) – Directory including path
ding0.tools.logger.create_home_dir(ding0_path=None)[source]

Check if ~/.ding0 exists, otherwise create it

Parameters:ding0_path (str) – Path to store Ding0 related data (logging, etc)
ding0.tools.logger.get_default_home_dir()[source]

Return default home directory of Ding0

Returns:str – Default home directory including its path
ding0.tools.logger.setup_logger(log_dir=None, filename='ding0.log', loglevel=10)[source]

Instantiate logger

Parameters:
  • log_dir (str) – Directory to save log, default: ~/.ding0/logging/
  • filename (str) – Name of log file, default: ding0.log
  • loglevel – Level of logger.

ding0.tools.plots module

ding0.tools.pypsa_io module

ding0.tools.pypsa_io.append_bus_v_mag_set_df(bus_v_mag_set_df, node, node_name=None)[source]

Fills bus v_mag_set data needed for power flow calculation

Parameters:
  • bus_v_mag_set_df (pandas.DataFrame) – Dataframe of buses with entries name, temp_id, v_mag_pu_set
  • node (obj:node object of generator) –
  • node_name (str) – Optional parameter for name of bus
Returns:

bus_v_mag_set_df (pandas.DataFrame) – Dataframe of buses with entries name, temp_id, v_mag_pu_set

ding0.tools.pypsa_io.append_buses_df(buses_df, grid, node, node_name='')[source]

Appends buses to dataframe of buses in pypsa format.

Parameters:
  • buses_df (pandas.DataFrame) – Dataframe of buses with entries name, v_nom, geom, mv_grid_id, lv_grid_id, in_building
  • grid (GridDing0) –
  • node
  • node_name (str) – name of node, per default is set to node.pypsa_bus_id
Returns:

buses_df (pandas.DataFrame) – Dataframe of buses with entries name, v_nom, geom, mv_grid_id, lv_grid_id, in_building

ding0.tools.pypsa_io.append_generator_pq_set_df(conf, generator_pq_set_df, node)[source]

Fills generator pq_set data needed for power flow calculation

Parameters:
  • conf (dict) – dictionary with technical constants
  • generator_pq_set_df (pandas.DataFrame) – Dataframe of generators with entries name, temp_id, p_set and q_set
  • node (obj:node object of generator) –
Returns:

generator_pq_set_df (pandas.DataFrame) – Dataframe of generators with entries name, temp_id, p_set and q_set

ding0.tools.pypsa_io.append_generators_df(generators_df, node, name_bus=None)[source]

Appends generator to dataframe of generators in pypsa format.

Parameters:
  • generators_df (pandas.DataFrame) – Dataframe of generators with entries name, bus, control, p_nom, type, weather_cell_id, subtype
  • node – GeneratorDing0
  • name_bus (str) – Optional parameter for name of bus
Returns:

generators_df (pandas.DataFrame) – Dataframe of generators with entries name, bus, control, p_nom, type, weather_cell_id, subtype

ding0.tools.pypsa_io.append_lines_df(edge, lines_df, buses_df)[source]

Append edge to lines_df

Parameters:
  • edge – Edge of Ding0.Network graph
  • lines_df (pandas.DataFrame) – Dataframe of lines with entries name, bus0, bus1, length, x, r, s_nom, num_parallel, type, geometry
  • buses_df (pandas.DataFrame) – Dataframe of buses with entries name, v_nom, geom, mv_grid_id, lv_grid_id, in_building
Returns:

lines_df (pandas.DataFrame) – Dataframe of lines with entries name, bus0, bus1, length, x, r, s_nom, num_parallel, type

ding0.tools.pypsa_io.append_load_area_to_load_df(sector, load_area, loads_df, name_bus, name_load, return_time_varying_data=False, **kwargs)[source]

Appends LVLoadArea or LVGridDistrict to dataframe of loads in pypsa format.

Parameters:
  • sector (str) – load sector: ‘agricultural’, ‘industrial’, ‘residential’ or ‘retail’
  • load_area – LVGridDistrictDing0 or LVLoadAreaDing0, load area of which load is to be aggregated and added
  • loads_df (pandas.DataFrame) – Dataframe of loads with entries name, bus, p_set, annual_consumption and sector
  • name_bus (str) – name of bus to which load is connected
  • name_load (str) – name of load
  • return_time_varying_data (bool) – Determines whether data for power flow calculation is exported as well
  • kwargs (list of conf, load_pq_set_df) – Both arguments have to be inserted if return_time_varying_data is True.
Returns:

  • loads_df (pandas.DataFrame) – Dataframe of loads with entries name, bus, p_set, annual_consumption and sector
  • load_pq_set_df (pandas.DataFrame) – Dataframe of loads with entries name, temp_id, p_set and q_set, only exported if return_time_varying_data is True

ding0.tools.pypsa_io.append_load_areas_to_df(loads_df, generators_df, node, return_time_varying_data=False, **kwargs)[source]

Appends lv load area (or single lv grid district) to dataframe of loads and generators. Also returns power flow time varying data if return_time_varying_data is True. Each sector (agricultural, industrial, residential, retail) is represented by own entry of load. Each generator in underlying grid districts is added as own entry. Generators and load are connected to BusBar of the respective grid (LVGridDing0 for LVStationDing0 and MVGridDing0 for LVLoadAreaCentreDing0)

Parameters:
  • loads_df (pandas.DataFrame) – Dataframe of loads with entries name, bus, p_set, annual_consumption, sector
  • generators_df (pandas.DataFrame) – Dataframe of generators with entries name, bus, control, p_nom, type, weather_cell_id, subtype
  • node – Node, which is either LVStationDing0 or LVLoadAreaCentreDing0
  • return_time_varying_data (bool) – Determines whether data for power flow calculation is exported as well
  • kwargs (list of conf, load_pq_set_df, generator_pq_set_df) – All three arguments have to be inserted if return_time_varying_data is True.
Returns:

  • loads_df (pandas.DataFrame) – Dataframe of loads with entries name, bus, p_set, annual_consumption, sector
  • generators_df (pandas.DataFrame) – Dataframe of generators with entries name, bus, control, p_nom, type, weather_cell_id, subtype
  • load_pq_set_df (pandas.DataFrame) – Dataframe of loads with entries name, temp_id, p_set and q_set, only exported if return_time_varying_data is True
  • generator_pq_set_df (pandas.DataFrame) – Dataframe of generators with entries name, temp_id, p_set and q_set, only exported if return_time_varying_data is True

ding0.tools.pypsa_io.append_load_pq_set_df(conf, load_pq_set_df, node, node_name=None, peak_load=None)[source]

Fills load pq_set data needed for power flow calculation

Parameters:
  • conf (dict) – dictionary with technical constants
  • load_pq_set_df (pandas.DataFrame) – Dataframe of loads with entries name, temp_id, p_set and q_set
  • node (obj:node object of generator) –
  • node_name (str) – Optional parameter for name of load
  • p_set (float) – Optional parameter for peak_load
Returns:

load_pq_set_df (pandas.DataFrame) – Dataframe of loads with entries name, temp_id, p_set and q_set

ding0.tools.pypsa_io.append_transformers_df(transformers_df, trafo, type=nan, bus0=None, bus1=None)[source]

Appends transformer to dataframe of buses in pypsa format.

Parameters:
  • transformers_df (pandas.DataFrame) – Dataframe of trafos with entries name, bus0, bus1, x, r, s_nom, type
  • trafo (:obj:TransformerDing0) – Transformer to be added
  • type (str) – Optional parameter for type of transformer
  • bus0 (str) – Name of primary side bus. Defaults to None and is set to primary side of transformer station by default.
  • bus1 (str) – Name of secondary side bus. Defaults to None and is set to secondary side of transformer station by default.
Returns:

transformers_df (pandas.DataFrame) – Dataframe of trafos with entries name, bus0, bus1, x, r, s_nom, type

ding0.tools.pypsa_io.assign_bus_results(grid, bus_data)[source]

Write results obtained from PF to graph

Parameters:
ding0.tools.pypsa_io.assign_line_results(grid, line_data)[source]

Write results obtained from PF to graph

Parameters:
  • grid (GridDing0) –
  • line_data (pandas.DataFrame) – DataFrame containing active/reactive at nodes obtained from PF analysis
ding0.tools.pypsa_io.circuit_breakers_to_df(grid, components, component_data, open_circuit_breakers, return_time_varying_data=False)[source]

Appends circuit breakers to component dicts. If circuit breakers are open a virtual bus is added to the respective dataframe and bus1 of the line attached to the circuit breaker is set to the new virtual node.

Parameters:
  • grid (GridDing0) –
  • components (components: dict) – Dictionary of component Dataframes ‘Bus’, ‘Generator’, ‘Line’, ‘Load’, ‘Transformer’
  • component_data (dict) – Dictionary of component Dataframes ‘Bus’, ‘Generator’, ‘Load’, needed for power flow calculations
  • open_circuit_breakers (dict) – Dictionary containing names of open circuit breakers
  • return_time_varying_data (bool) – States whether time varying data needed for power flow calculations are constructed as well. Set to True to run power flow, set to False to export network to csv.
Returns:

  • components (dict) – Dictionary of component Dataframes ‘Bus’, ‘Generator’, ‘Line’, ‘Load’, ‘Transformer’, ‘Switch’
  • component_data (dict) – Dictionary of component Dataframes ‘Bus’, ‘Generator’, ‘Load’, needed for power flow calculations

ding0.tools.pypsa_io.create_powerflow_problem(timerange, components)[source]

Create PyPSA network object and fill with data :param timerange: Time range to be analyzed by PF :type timerange: Pandas DatetimeIndex :param components: :type components: dict

Returns:network (PyPSA powerflow problem object)
ding0.tools.pypsa_io.data_integrity(components, components_data)[source]

Check grid data for integrity

Parameters:
  • components (dict) – Grid components
  • components_data (dict) – Grid component data (such as p,q and v set points)
ding0.tools.pypsa_io.edges_to_dict_of_dataframes(edges, lines_df, buses_df)[source]

Export edges to DataFrame

Parameters:
  • edges (list) – Edges of Ding0.Network graph
  • lines_df (pandas.DataFrame) – Dataframe of lines with entries name, bus0, bus1, length, x, r, s_nom, num_parallel, type
  • buses_df (pandas.DataFrame) – Dataframe of buses with entries name, v_nom, geom, mv_grid_id, lv_grid_id, in_building
Returns:

edges_dict (dict)

ding0.tools.pypsa_io.export_to_dir(network, export_dir)[source]

Exports PyPSA network as CSV files to directory

Parameters:
  • network (:pypsa:pypsa.Network) –
  • export_dir (str) – Sub-directory in output/debug/grid/ where csv Files of PyPSA network are exported to.
ding0.tools.pypsa_io.fill_component_dataframes(grid, buses_df, lines_df, transformer_df, generators_df, loads_df, only_export_mv=False, return_time_varying_data=False)[source]

Returns component and if necessary time varying data for power flow or csv export of inserted mv or lv grid

Parameters:
  • grid (GridDing0) – Grid that is exported
  • buses_df (pandas.DataFrame) – Dataframe of buses with entries name, v_nom, geom, mv_grid_id, lv_grid_id, in_building
  • lines_df (pandas.DataFrame) – Dataframe of lines with entries name, bus0, bus1, length, x, r, s_nom, num_parallel, type_info
  • transformer_df (pandas.DataFrame) – Dataframe of trafos with entries name, bus0, bus1, x, r, s_nom, type
  • generators_df (pandas.DataFrame) – Dataframe of generators with entries name, bus, control, p_nom, type, weather_cell_id, subtype
  • loads_df (pandas.DataFrame) – Dataframe of loads with entries name, bus, p_set, annual_consumption, sector
  • only_export_mv (bool) –
  • return_time_varying_data (bool) – States whether time varying data needed for power flow calculations are constructed as well. Set to True to run power flow, set to False to export network to csv.
Returns:

  • components (dict) – Dictionary of component Dataframes ‘Bus’, ‘Generator’, ‘Line’, ‘Load’, ‘Transformer’, ‘Switch’
  • component_data (dict) – Dictionary of component Dataframes ‘Bus’, ‘Generator’, ‘Load’, needed for power flow calculations

ding0.tools.pypsa_io.fill_mvgd_component_dataframes(mv_grid_district, buses_df, generators_df, lines_df, loads_df, transformer_df, only_export_mv=False, return_time_varying_data=False)[source]

Returns component and if necessary time varying data for power flow or csv export of inserted mv grid district

Parameters:
  • mv_grid_district (MVGridDistrictDing0) –
  • buses_df (pandas.DataFrame) – Dataframe of buses with entries name, v_nom, geom, mv_grid_id, lv_grid_id, in_building
  • lines_df (pandas.DataFrame) – Dataframe of lines with entries name, bus0, bus1, length, x, r, s_nom, num_parallel, type
  • transformer_df (pandas.DataFrame) – Dataframe of trafos with entries name, bus0, bus1, x, r, s_nom, type
  • generators_df (pandas.DataFrame) – Dataframe of generators with entries name, bus, control, p_nom, type, weather_cell_id, subtype
  • loads_df (pandas.DataFrame) – Dataframe of loads with entries name, bus, p_set, building_id, annual_consumption, sector
  • only_export_mv (bool) – Bool that determines export modes for grid district, if True only mv grids are exported with lv grids aggregated at respective station, if False lv grids are fully exported
  • return_time_varying_data (bool) – States whether time varying data needed for power flow calculations are constructed as well. Set to True to run power flow, set to False to export network to csv.
Returns:

  • mv_components (dict) – Dictionary of component Dataframes ‘Bus’, ‘Generator’, ‘Line’, ‘Load’, ‘Transformer’, ‘Switch’
  • network_df (pandas.DataFrame) – Dataframe of network containing name, srid, geom and population
  • mv_component_data (dict) – Dictionary of component Dataframes ‘Bus’, ‘Generator’, ‘Load’, needed for power flow calculations

ding0.tools.pypsa_io.init_pypsa_network(time_range_lim)[source]

Instantiate PyPSA network :param time_range_lim:

Returns:
  • network (PyPSA network object) – Contains powerflow problem
  • snapshots (iterable) – Contains snapshots to be analyzed by powerplow calculation
ding0.tools.pypsa_io.initialize_component_dataframes()[source]

Initializes and returns empty component dataframes

Returns:
  • buses_df (pandas.DataFrame) – Dataframe of buses with entries name, v_nom, geom, mv_grid_id, lv_grid_id, in_building
  • lines_df (pandas.DataFrame) – Dataframe of lines with entries name, bus0, bus1, length, x, r, s_nom, num_parallel, type, geometry (LineString)
  • transformer_df (pandas.DataFrame) – Dataframe of trafos with entries name, bus0, bus1, x, r, s_nom, type
  • generators_df (pandas.DataFrame) – Dataframe of generators with entries name, bus, control, p_nom, type, weather_cell_id, subtype
  • loads_df (pandas.DataFrame) – Dataframe of loads with entries name, bus, p_set, annual_consumption, sector
ding0.tools.pypsa_io.nodes_to_dict_of_dataframes(grid, nodes, buses_df, generators_df, loads_df, transformer_df, only_export_mv=False, return_time_varying_data=False)[source]

Creates dictionary of dataframes containing grid nodes and transformers

Parameters:
  • grid (GridDing0) –
  • nodes (list of ding0 grid components objects) – Nodes of the grid graph
  • buses_df (pandas.DataFrame) – Dataframe of buses with entries name, v_nom, geom, mv_grid_id, lv_grid_id, in_building
  • generators_df (pandas.DataFrame) – Dataframe of generators with entries name, bus, control, p_nom, type, weather_cell_id, subtype
  • loads_df (pandas.DataFrame) – Dataframe of loads with entries name,bus,p_set, building_id, annual_consumption,sector
  • transformer_df (pandas.DataFrame) – Dataframe of trafos with entries name, bus0, bus1, x, r, s_nom, type
  • only_export_mv (bool) – Bool that indicates whether only mv grid should be exported, per default lv grids are exported too
  • return_time_varying_data (bool) – Set to True when running power flow. Then time varying data are returned as well.
Returns:

  • components (dict of pandas.DataFrame) – DataFrames contain components attributes. Dict is keyed by components type
  • component_data (dict) – Dictionary of component Dataframes ‘Bus’, ‘Generator’, ‘Load’, needed for power flow calculations, only exported when return_time_varying_data is True empty dict otherwise.

ding0.tools.pypsa_io.process_pf_results(network)[source]
Parameters:network (pypsa.Network) –
Returns:
ding0.tools.pypsa_io.run_powerflow_onthefly(components, components_data, grid, export_pypsa_dir=None, debug=False, export_result_dir=None)[source]

Run powerflow to test grid stability

Two cases are defined to be tested here:
  1. load case
  2. feed-in case
Parameters:
  • components (dict of pandas.DataFrame) –
  • components_data (dict of pandas.DataFrame) –
  • grid (GridDing0) –
  • export_pypsa_dir (str) – Sub-directory in output/debug/grid/ where csv Files of PyPSA network are exported to. Export is omitted if argument is empty.
  • debug (bool) –
  • export_result_dir (str) – Directory where csv Files of power flow results are exported to. Export is omitted if argument is empty.
ding0.tools.pypsa_io.select_and_append_load_area_trafos(aggregated_load_area, node_name, transformer_df)[source]

Selects the right trafos for aggregrated load areas and appends them to the transformer dataframe.

Parameters:
  • aggregated_load_area (LVLoadAreaDing0) – Aggregated load area to be appended
  • node_name (str) – Name of LV side bus for appending LV load area
  • transformer_df (pandas.DataFrame) – Transformer dataframe of network
Returns:

pandas.DataFrame – Transformer dataframe of network with appended transformers

ding0.tools.pypsa_io.transform_timeseries4pypsa(timeseries, timerange, column=None)[source]

Transform pq-set timeseries to PyPSA compatible format :param timeseries: Containing timeseries :type timeseries: Pandas DataFrame

Returns:pypsa_timeseries (Pandas DataFrame) – Reformated pq-set timeseries

ding0.tools.results module

ding0.tools.tests module

ding0.tools.tools module

ding0.tools.tools.create_poly_from_source(source_point, left_m, right_m, up_m, down_m)[source]

Create a rectangular polygon given a source point and the number of meters away from the source point the edges have to be.

Parameters:
  • source_point (Shapely Point object) – The start point in WGS84 or epsg 4326 coordinates
  • left_m (float) – The distance from the source at which the left edge should be.
  • right_m (float) – The distance from the source at which the right edge should be.
  • up_m (float) – The distance from the source at which the upper edge should be.
  • down_m (float) – The distance from the source at which the lower edge should be.
ding0.tools.tools.get_cart_dest_point(source_point, east_meters, north_meters)[source]

Get the WGS84 point in the coordinate reference system epsg 4326 at in given a cartesian form of input i.e. providing the position of the destination point in relative meters east and meters north from the source point. If the source point is (0, 0) and you would like the coordinates of a point that lies 5 meters north and 3 meters west of the source, the bearing in degrees is hard to find on the fly. This function allows the input as follows: >>> get_cart_dest_point(source_point, -3, 5) # west is negative east

Parameters:
  • source_point (Shapely Point object) – The start point in WGS84 or epsg 4326 coordinates
  • east_meters (float) – Meters to the east of source, negative number means west
  • north_meters (float) – Meters to the north of source, negative number means south
Returns:

Shapely Point object – The point in WGS84 or epsg 4326 coordinates at the destination which is north_meters north of the source and east_meters east of source.

ding0.tools.tools.get_dest_point(source_point, distance_m, bearing_deg)[source]

Get the WGS84 point in the coordinate reference system epsg 4326 at a distance (in meters) from a source point in a given bearing (in degrees) (0 degrees being North and clockwise is positive).

Parameters:
  • source_point (Shapely Point object) – The start point in WGS84 or epsg 4326 coordinates
  • distance_m (float) – Distance of destination point from source in meters
  • bearing_deg (float) – Bearing of destination point from source in degrees, 0 degrees being North and clockwise is positive.
Returns:

Shapely Point object – The point in WGS84 or epsg 4326 coordinates at the destination which is distance meters away from the source_point in the bearing provided

ding0.tools.tools.merge_two_dicts(x, y)[source]

Given two dicts, merge them into a new dict as a shallow copy.

Parameters:

Notes

This function was originally proposed by http://stackoverflow.com/questions/38987/how-to-merge-two-python-dictionaries-in-a-single-expression

Credits to Thomas Vander Stichele. Thanks for sharing ideas!

Returns:dict – Merged dictionary keyed by top-level keys of both dicts
ding0.tools.tools.merge_two_dicts_of_dataframes(dict1, dict2)[source]

Merge two dicts of pandas.DataFrame with the same keys

Parameters:
  • dict1 (dict of dataframes) –
  • dict2 (dict of dataframes) –

ding0.tools.validation module

ding0.tools.write_openego_header module

ding0.tools.write_openego_header.absolute_file_paths(directory)[source]
ding0.tools.write_openego_header.line_prepender(filename, line)[source]
ding0.tools.write_openego_header.openego_header()[source]

openego header in files

Returns:str – openego group py-file header

Module contents