postreise.plot package

Subpackages

Submodules

postreise.plot.canvas module

postreise.plot.canvas.create_map_canvas(figsize=None, x_range=None, y_range=None)[source]

Create canvas for maps.

Parameters:
  • figsize (tuple) – size of the bokeh figure (in pixels).

  • x_range (tuple) – x range to zoom plot to (EPSG:3857).

  • y_range (tuple) – y range to zoom plot to (EPSG:3857).

Returns:

(bokeh.plotting.figure) – empty canvas.

Raises:
  • TypeError – if figsize is not a tuple and elements are not int. if x_range or``y_range`` are not tuple and elements are not int/float.

  • ValueError – if figsize, x_range or``y_range`` don’t have exactly two elements. if elements of figsize are negative. if first element of x_range or``y_range`` is greater than the second one.

postreise.plot.check module

postreise.plot.colors module

postreise.plot.plot_bar_generation_max_min_actual module

postreise.plot.plot_bar_generation_max_min_actual.plot_bar_generation_max_min_actual(scenario, interconnect, gen_type, percentage=False, show_as_state=True, fontsize=15, plot_show=True)[source]

Generate for a given scenario the bar plot of total capacity vs. actual generation vs. minimum generation for a specific type of generators in an interconnection.

Parameters:
  • scenario (powersimdata.scenario.scenario.Scenario) – scenario instance.

  • interconnect (str) – the interconnection name of interest.

  • gen_type (str) – type of generator.

  • percentage (bool) – show bars in percentage of total capacity or not, defaults to False.

  • show_as_state (bool) – each bar represents a state within the given interconnection or not, defaults to True, if not, each bar will represent a loadzone instead.

  • fontsize (int/float) – font size of the texts shown on the plot.

  • plot_show – show the plot or not, defaults to True.

Returns:

(matplotlib.axes.Axes) – axes object of the plot.

Raises:
  • TypeError – if interconnect and gen_type are not str if fontsize is not an integer or a float and/or

  • ValueError – if interconnect is not valid

postreise.plot.plot_bar_generation_stack module

postreise.plot.plot_bar_generation_stack.plot_bar_generation_stack(areas, scenario_ids, resources, area_types=None, scenario_names=None, curtailment_split=True, t2c=None, t2l=None, t2hc=None, titles=None, plot_show=True, save=False, filenames=None, filepath=None)[source]

Plot any number of scenarios as generation stack bar for selected resources in each specified areas.

Parameters:
  • areas (list/str) – list of area(s), each area is one of loadzone, state, state abbreviation, interconnect, ‘all’.

  • scenario_ids (int/list/str) – list of scenario id(s), defaults to None.

  • resources (str/list) – one or a list of resources. ‘curtailment’, ‘solar_curtailment’, ‘wind_curtailment’, ‘wind_offshore_curtailment’ are valid entries together with all available generator types in the area(s). The order of the resources determines the stack order in the figure.

  • area_types (list/str) – list of area_type(s), each area_type is one of ‘loadzone’, ‘state’, ‘state_abbr’, ‘interconnect’, defaults to None.

  • scenario_names (list/str) – list of scenario name(s) of same len as scenario ids, defaults to None.

  • curtailment_split (bool) – if curtailments are split into different categories, defaults to True.

  • t2c (dict) – user specified color of resource type to overwrite pre-defined ones key: resource type, value: color code.

  • t2l (dict) – user specified label of resource type to overwrite pre-defined ones key: resource type, value: label.

  • t2hc (dict) – user specified color of curtailable resource hatches to overwrite pre-defined ones. key: resource type, valid keys are ‘curtailment’, ‘solar_curtailment’, ‘wind_curtailment’, ‘wind_offshore_curtailment’, value: color code.

  • titles (dict) – user specified figure titles, key: area, value: new figure title in string, use area as title if None.

  • plot_show (bool) – display the generated figure or not, defaults to True.

  • save (bool) – save the generated figure or not, defaults to False.

  • filenames (dict) – user specified filenames, key: area, value: new filename in string, use area as filename if None.

  • filepath (str) – if save is True, user specified filepath, use current directory if None.

Returns:

(list) – matplotlib.axes.Axes object of each plot in a list.

Raises:
  • TypeError – if resources is not a list or str. if titles is not a dict. if filenames is not a dict.

  • ValueError – if length of area_types and areas is different. if length of scenario_names and scenario_ids is different.

postreise.plot.plot_bar_generation_vs_capacity module

postreise.plot.plot_bar_generation_vs_capacity.make_gen_cap_custom_data(areas, label, gen_data=None, cap_data=None)[source]

Format custom data for plot_bar_generation_vs_capacity().

Parameters:
  • areas (list/str) – list of interest area(s).

  • label (str) – the name of the custom scenario to be shown in the plot.

  • gen_data (pandas.DataFrame) – generation data with rows being resource types and columns being areas in TWh, default to None.

  • cap_data (pandas.DataFrame) – capacity data with rows being reousrce types and columns being areas in GW, defaults to None

Returns:

(dict) – formatted custom data.

postreise.plot.plot_bar_generation_vs_capacity.plot_bar_generation_vs_capacity(areas, area_types=None, scenario_ids=None, scenario_names=None, time_range=None, time_zone=None, custom_data=None, resource_types=None, resource_labels=None, horizontal=False, plot_show=True)[source]

Plot any number of scenarios as bar or horizontal bar charts with two columns per scenario - generation and capacity.

Parameters:
  • areas (list/str) – list of area(s), each area is one of loadzone, state, state abbreviation, interconnect, ‘all’.

  • area_types (list/str) – list of area_type(s), each area_type is one of ‘loadzone’, ‘state’, ‘state_abbr’, ‘interconnect’, defaults to None.

  • scenario_ids (int/list/str) – list of scenario id(s), defaults to None.

  • scenario_names (list/str) – list of scenario name(s) of same len as scenario ids, defaults to None.

  • time_range (tuple) – [start_timestamp, end_timestamp] where each time stamp is pandas.Timestamp/numpy.datetime64/datetime.datetime. If None, the entire time range is used for the given scenario.

  • time_zone (str) – new time zone, defaults to None, which uses UTC.

  • custom_data (list) – list of dictionaries with each element being hand-generated data as returned by make_gen_cap_custom_data(), defaults to None.

  • resource_types (list/str) – list of resource type(s) to show, defaults to None, which shows all available resources in the area of the corresponding scenario.

  • resource_labels (dict) – a dictionary with keys being resource_types and values being labels to show in the plots, defaults to None, which uses resource_types as labels.

  • horizontal (bool) – display bars horizontally, default to False.

Returns:

(matplotlib.axes.Axes) – axes object of the plot.

Raises:
  • TypeError – if resource_labels is not a dict.

  • ValueError – if length of area_types and areas is different. if length of scenario_names and scenario_ids is different. if only one scenario is provided with no custom_data.

postreise.plot.plot_bar_renewable_max_profile_actual module

postreise.plot.plot_bar_renewable_max_profile_actual.plot_bar_renewable_max_profile_actual(scenario, interconnect, gen_type, percentage=False, show_as_state=True, fontsize=15, plot_show=True)[source]

Generate for a given scenario the bar plot of total capacity vs. available energy vs. actual generation for a specific renewable resource in an interconnection.

Parameters:
  • scenario (powersimdata.scenario.scenario.Scenario) – scenario instance.

  • interconnect (str) – the interconnection name of interest.

  • gen_type (str) – renewable resource.

  • percentage (bool) – show bars in percentage of total capacity or not, defaults to False.

  • show_as_state (bool) – each bar represents a state within the given interconnection or not, defaults to True, if not, each bar will represent a loadzone instead.

  • fontsize (int/float) – font size of the texts shown on the plot.

  • plot_show – show the plot or not, defaults to True.

Returns:

(matplotlib.axes.Axes) – axes object of the plot.

Raises:
  • TypeError – if interconnect and gen_type are not str if fontsize is not a int or a float

  • ValueError – if interconnect is not valid

postreise.plot.plot_bar_shortfall module

postreise.plot.plot_bar_shortfall.plot_bar_shortfall(areas, scenario_ids, target_df, strategy=None, scenario_names=None, baseline_scenario=None, baseline_scenario_name=None, plot_show=True)[source]

Plot a stacked bar chart of generation shortfall based on given targets for any number of scenarios.

Parameters:
  • areas (list/str) – list of area(s) to show shortfall bar plots. If the target of an area is not defined in target_df, it will be ignored.

  • scenario_ids (int/list/str) – list of scenario id(s).

  • target_df (pandas.DataFrame) – target data frame, which defines the clean energy target fraction, allowed resources and external historical amount of qualified energy for each area.

  • strategy (dict) – a dictionary with keys being scenario ids and values being strategies, either “collaborative” or “independent”. “collaborative” is used if None.

  • scenario_names (list/str) – list of scenario name(s) of same length as scenario ids, defaults to None.

  • baseline_scenario (str/int) – scenario id that serves as a baseline in the bar chart, default to None.

  • baseline_scenario_name (str) – specify the label of the baseline scenario shown in the bar chart, default to None, in which case the name of the scenario will be used.

  • plot_show (bool) – display the generated figure or not, defaults to True.

Returns:

(matplotlib.axes.Axes) – axes object of the plot.

Raises:
  • ValueError – if length of scenario_names and scenario_ids is different.

  • TypeError – if target_df is not a pandas.DataFrame. if strategy is provided but not in a dict format. if baseline_scenario is provided but not in a str/int format. if baseline_scenario_name is provided but not in a str format.

postreise.plot.plot_capacity_map module

postreise.plot.plot_capacity_map.add_plant_capacity(canvas, scenario, resources, disaggregation=None, min_capacity=1, size_factor=1, alpha=0.5)[source]

Adds renewables capacity to a plot.

Parameters:
  • canvas (bokeh.plotting.figure.Figure) – canvas to plot capacities onto.

  • scenario (powersimdata.scenario.scenario.Scenario) – scenario instance.

  • resources (iterable) – which types of resources to plot.

  • figsize (tuple) – size of the bokeh figure (in pixels).

  • x_range (tuple) – x range to zoom plot to (EPSG:3857).

  • y_range (tuple) – y range to zoom plot to (EPSG:3857).

  • disaggregation (str) – method used to disaggregate plants: if “new_vs_existing_plants”: separates plants into added vs. existing. if None, no disaggregation.

  • min_capacity (float/int) – minimum bus capacity (MW) for markers to be plotted.

  • size_factor (float/int) – scale size of glyphs.

  • alpha (float/int) – opacity of circles (between 0 and 1).

Raises:

ValueError – if disaggregation is not ‘new_vs_existing_plants’ or None.

Returns:

(bokeh.plotting.figure.Figure) – map with color-coded upgrades.

postreise.plot.plot_capacity_map.map_plant_capacity(scenario, resources, figsize=(1400, 800), x_range=None, y_range=None, disaggregation=None, state_borders_kwargs=None, min_capacity=1, size_factor=1, alpha=0.5, legend_font_size=12, legend_location='bottom_right')[source]

Make map of plant capacities, optionally disaggregated by new/existing. Area is proportional to capacity.

Parameters:
  • scenario (powersimdata.scenario.scenario.Scenario) – scenario instance.

  • resources (iterable) – which types of resources to plot.

  • figsize (tuple) – size of the bokeh figure (in pixels).

  • x_range (tuple) – x range to zoom plot to (EPSG:3857).

  • y_range (tuple) – y range to zoom plot to (EPSG:3857).

  • disaggregation (str) – method used to disaggregate plants: if “new_vs_existing_plants”: separates plants into added vs. existing. if None, no disaggregation.

  • state_borders_kwargs (dict) – keyword arguments to pass to postreise.plot.plot_states.add_state_borders().

  • min_capacity (float/int) – minimum bus capacity (MW) for markers to be plotted.

  • size_factor (float/int) – scale size of glyphs.

  • alpha (float/int) – opacity of circles (between 0 and 1).

  • legend_font_size (int/float) – font size for legend.

  • legend_location (str) – location for legend.

Returns:

(bokeh.plotting.figure.Figure) – map with color-coded upgrades.

postreise.plot.plot_carbon_bar module

postreise.plot.plot_carbon_bar.plot_carbon_bar(*args, labels=None, labels_size=15, plot_show=True)[source]

Make bar chart of carbon emissions by fuel type for n scenarios.

Parameters:
  • args (powersimdata.scenario.scenario.Scenario) – scenario instances.

  • labels (list/tuple/set) – labels on plot. Default to scenario id.

  • labels_size (int) – size of labels.

  • plot_show (bool) – whether to show the plot.

Raises:
  • ValueError – if args are not scenario instances. if labels has a different length than the number of passed scenarios.

  • TypeError – if labels is not an iterable. if labels_size is not an int.

Returns:

(tuple) – the figure elements that can be further modified.

postreise.plot.plot_carbon_map module

postreise.plot.plot_carbon_map.add_emission(canvas, emission, scale_factor)[source]

Add emission.

Parameters:
  • emission (pandas.DataFrame) – emission data for plotting.

  • scale_factor (float) – scaling factor for size of emissions circles glyphs.

Returns:

(bokeh.plotting.figure) – carbon emission map.

postreise.plot.plot_carbon_map.aggregate_bus_emission_difference(bus, coordinate_rounding)[source]

Aggregate emission for buses based on similar lat/lon coordinates

Parameters:
  • bus (pandas.DataFrame) – bus data frame containing ‘coal’, ‘ng’, ‘lat’, ‘lon’ ‘type’ and ‘color’ columns.

  • coordinate_rounding (int) – number of digits to round lat/lon for aggregation.

Returns:

(pandas.DataFrame) – aggregated data frame.

postreise.plot.plot_carbon_map.aggregate_bus_emission_generator(bus, coordinate_rounding)[source]

Aggregate emission for buses based on similar lat/lon coordinates

Parameters:
  • bus (pandas.DataFrame) – bus data frame containing ‘coal’, ‘ng’, ‘lat’, ‘lon’ ‘type’ and ‘color’ columns.

  • coordinate_rounding (int) – number of digits to round lat/lon for aggregation.

Returns:

(pandas.DataFrame) – aggregated data frame.

postreise.plot.plot_carbon_map.combine_bus_info_and_emission(scenario)[source]

Build data frame needed for plotting carbon emitted by thermal generators.

Parameters:

scenario (powersimdata.scenario.scenario.Scenario) – scenario instance.

Returns:

(pandas.DataFrame) – bus data frame with emission.

postreise.plot.plot_carbon_map.map_carbon_emission_difference(scenario_1, scenario_2, coordinate_rounding=1, figsize=(1400, 800), color_increase='#FF8563', color_decrease='#78D911', scale_factor=1, state_borders_kwargs=None)[source]

Make map of difference in emissions between two scenarios at bus level. Color of markers indicates increase/decrease in emissions (scenario_2 w.r,t. scenario_1) and size reflects relative difference in emissions.

Parameters:
Returns:

(bokeh.plotting.figure) – carbon emission map.

Raises:
  • TypeError – if coordinate_rounding is not int. if color_increase and color_decrease are not str. if scale_factor is not int or float.

  • ValueError – if coordinate_rounding is negative. if scale_factor is negative.

postreise.plot.plot_carbon_map.map_carbon_emission_generator(scenario, coordinate_rounding=1, figsize=(1400, 800), color_coal='black', color_ng='#8B36FF', scale_factor=1, state_borders_kwargs=None)[source]

Make map of carbon emissions at bus level. Color of markers indicates generator type and size reflects emissions level.

Parameters:
  • scenario (powersimdata.scenario.scenario.Scenario) – scenario instance.

  • coordinate_rounding (int) – number of digits to round lat/lon for aggregation.

  • figsize (tuple) – size of the bokeh figure (in pixels).

  • color_ng (str) – color assigned for ng, default to BE purple.

  • color_coal (str) – color associated with coal, default to black/gray.

  • scale_factor (int/float) – scaling factor for size of emissions circles glyphs.

  • state_borders_kwargs (dict) – keyword arguments to be passed to postreise.plot.plot_states.add_state_borders().

Returns:

(bokeh.plotting.figure) – carbon emission map.

Raises:
  • TypeError – if coordinate_rounding is not int. if color_coal and color_ng are not str. if scale_factor is not int or float.

  • ValueError – if coordinate_rounding is negative. if scale_factor is negative.

postreise.plot.plot_carbon_map.prepare_bus_data_difference(bus_emission, coordinate_rounding, color_up, color_down)[source]

Prepare data with amount of emissions and type for hover tips

Parameters:
  • bus_emission (pandas.DataFrame) – bus data frame with emission as returned by combine_bus_info_and_emission().

  • coordinate_rounding (int) – number of digits to round lat/lon for aggregation.

  • color_up (str) – color assigned to ‘increase’ in emissions.

  • color_down (str) – color assigned to ‘decrase’ in emissions.

Returns:

(pandas.DataFrame) – data for plotting.

postreise.plot.plot_carbon_map.prepare_bus_data_generator(bus_emission, coordinate_rounding, color_ng, color_coal)[source]

Prepare data with amount of emissions.

Parameters:
  • bus_emission (pandas.DataFrame) – bus data frame with emission as returned by combine_bus_info_and_emission().

  • coordinate_rounding (int) – number of digits to round lat/lon for aggregation.

  • color_ng (str) – color assigned for ng, default to BE purple.

  • color_coal (str) – color assigned for coal, default to black/gray.

Returns:

(pandas.DataFrame) – data for plotting.

postreise.plot.plot_curtailment_ts module

postreise.plot.plot_curtailment_ts.plot_curtailment_time_series(scenario, area, resources, area_type=None, time_range=None, time_zone='utc', time_freq='H', show_demand=True, percentage=True, t2c=None, t2l=None, title=None, label_fontsize=20, title_fontsize=22, tick_fontsize=15, legend_fontsize=18, save=False, filename=None, filepath=None)[source]

Generate time series curtailment plot of each specified resource in a certain area of a scenario.

Parameters:
  • scenario (powersimdata.scenario.scenario.Scenario) – scenario instance

  • area (str) – one of loadzone, state, state abbreviation, interconnect, ‘all’

  • resources (str/list) – one or a list of resources.

  • area_type (str) – one of ‘loadzone’, ‘state’, ‘state_abbr’, ‘interconnect’

  • time_range (tuple) – [start_timestamp, end_timestamp] where each time stamp is pandas.Timestamp/numpy.datetime64/datetime.datetime. If None, the entire time range is used for the given scenario.

  • time_zone (str) – new time zone.

  • time_freq (str) – frequency. Either ‘D’ (day), ‘W’ (week), ‘M’ (month).

  • show_demand (bool) – show demand line in the plot or not, default is True.

  • percentage (bool) – plot the curtailment in terms of percentage or not, default is True.

  • t2c (dict) – user specified color of resource type to overwrite type2color default dict. key: resource type, value: color code.

  • t2l (dict) – user specified label of resource type to overwrite type2label default dict. key: resource type, value: label.

  • title (str) – user specified title of the figure.

  • label_fontsize (float) – user specified label fontsize, default is 20.

  • title_fontsize (float) – user specified title fontsize, default is 22.

  • tick_fontsize (float) – user specified ticks of axes fontsize, default is 15.

  • legend_fontsize (float) – user specified legend fontsize, default is 18.

  • save (bool) – save the generated figure or not, default is False.

  • filename (str) – if save is True, user specified filename, use area if None.

  • filepath (str) – if save is True, user specified filepath, use current directory if None.

postreise.plot.plot_energy_carbon_stack module

postreise.plot.plot_energy_carbon_stack.plot_n_scenarios(*args)[source]

For 1-to-n scenarios, plot stacked energy and carbon side-by-side.

Parameters:

args (powersimdata.scenario.scenario.Scenario) – scenario instances.

Raises:

ValueError – if arguments are not scenario instances.

postreise.plot.plot_generation_ts_stack module

postreise.plot.plot_generation_ts_stack.plot_generation_time_series_stack(scenario, area, resources, area_type=None, time_range=None, time_zone='utc', time_freq='H', show_demand=True, show_net_demand=True, normalize=False, t2c=None, t2l=None, t2hc=None, title=None, label_fontsize=20, title_fontsize=22, tick_fontsize=15, legend_fontsize=18, save=False, filename=None, filepath=None)[source]

Generate time series generation stack plot in a certain area of a scenario.

Parameters:
  • scenario (powersimdata.scenario.scenario.Scenario) – scenario instance

  • area (str) – one of loadzone, state, state abbreviation, interconnect, ‘all’

  • resources (str/list) – one or a list of resources. ‘solar_curtailment’, ‘wind_curtailment’, ‘wind_offshore_curtailment’ are valid entries together with all available generator types in the area. The order of the resources determines the stack order in the figure.

  • area_type (str) – one of ‘loadzone’, ‘state’, ‘state_abbr’, ‘interconnect’

  • time_range (tuple) – [start_timestamp, end_timestamp] where each time stamp is pandas.Timestamp/numpy.datetime64/datetime.datetime. If None, the entire time range is used for the given scenario.

  • time_zone (str) – new time zone.

  • time_freq (str) – frequency. Either ‘D’ (day), ‘W’ (week), ‘M’ (month).

  • show_demand (bool) – show demand line in the plot or not, default is True.

  • show_net_demand (bool) – show net demand line in the plot or not, default is True.

  • normalize (bool) – normalize the generation based on capacity or not, default is False.

  • t2c (dict) – user specified color of resource type to overwrite type2color default dict. key: resource type, value: color code.

  • t2l (dict) – user specified label of resource type to overwrite type2label default dict. key: resource type, value: label.

  • t2hc (dict) – user specified color of curtailable resource hatches to overwrite pre-defined ones. key: resource type, valid keys are ‘wind_curtailment’, ‘solar_curtailment’, ‘wind_offshore_curtailment’, value: color code.

  • title (str) – user specified title of the figure, default is set to be area.

  • label_fontsize (float) – user specified label fontsize, default is 20.

  • title_fontsize (float) – user specified title fontsize, default is 22.

  • tick_fontsize (float) – user specified ticks of axes fontsize, default is 15.

  • legend_fontsize (float) – user specified legend fontsize, default is 18.

  • save (bool) – save the generated figure or not, default is False.

  • filename (str) – if save is True, user specified filename, use area if None.

  • filepath (str) – if save is True, user specified filepath, use current directory if None.

postreise.plot.plot_heatmap module

postreise.plot.plot_heatmap.plot_heatmap(series, time_zone=None, time_zone_label=None, title=None, cmap='PiYG', scale=None, save_filename=None, origin='upper', vmin=None, vmax=None, cbar_format=None, cbar_tick_values=None, cbar_label=None, cbar_tick_labels=None, contour_levels=None, figsize=(16, 8))[source]

Show time-series values via an imshow where each column is one color-coded day.

Parameters:
  • series (pandas.Series) – a time-series of values to be color-coded.

  • time_zone (str) – a time zone to be passed as tz kwarg to postreise.analyze.time.change_time_zone().

  • time_zone_label (str) – a time zone label to be added to the y axis label.

  • title (str) – a title to be added to the figure.

  • cmap (str/matplotlib.colors.Colormap) – colormap specification to be passed as cmap kwarg to matplotlib.pyplot.imshow().

  • scale (int/float) – a scaling factor to be applied to the series values.

  • save_filename (str) – a path to save the figure to.

  • origin (str) – the vertical location of the origin, either “upper” or “lower”.

  • vmin (int/float) – Minimum value for coloring, to be passed as vmin kwarg to matplotlib.pyplot.imshow().

  • vmax (int/float) – Maximum value for coloring, to be passed as vmax kwarg to matplotlib.pyplot.imshow().

  • cbar_format (str/matplotlib.ticker.Formatter) – a formatter for colorbar labels, to be passed as format kwarg to matplotlib.pyplot.colorbar().

  • cbar_tick_values (iterable) – colorbar tick locations, to be passed as ticks kwarg to matplotlib.pyplot.colorbar().

  • cbar_label (str) – axis label for colorbar.

  • cbar_tick_labels (iterable) – colorbar tick labels.

  • contour_levels (iterable) – values at which to draw contours, passed as levels kwarg to matplotlib.pyplot.contour().

  • figsize (tuple(int/float, int/float)) – size of figure.

postreise.plot.plot_interconnection_map module

postreise.plot.plot_interconnection_map.count_nodes_per_state(grid)[source]

Count nodes per state to add as hover-over info in :func`map_interconnections`

Parameters:

grid (powersimdata.input.grid.Grid) – grid object.

Returns:

(pandas.Series) – index: state names, values: number of nodes.

postreise.plot.plot_interconnection_map.map_interconnections(grid, branch_distance_cutoff=5, figsize=(1400, 800), branch_width_scale_factor=0.5, hvdc_width_scale_factor=1, b2b_size_scale_factor=50, state_borders_kwargs=None)[source]

Map transmission lines color coded by interconnection.

Parameters:
  • grid (powersimdata.input.grid.Grid) – grid object.

  • branch_distance_cutoff (int/float) – distance cutoff for branch display.

  • figsize (tuple) – size of the bokeh figure (in pixels).

  • branch_width_scale_factor (int/float) – scale factor for branch capacities.

  • hvdc_width_scale_factor (int/float) – scale factor for hvdc capacities.

  • b2b_size_scale_factor (int/float) – scale factor for back-to_back capacities.

  • state_borders_kwargs (dict) – keyword arguments to be passed to postreise.plot.plot_states.add_state_borders().

Returns:

(bokeh.plotting.figure) – interconnection map with lines and nodes.

Raises:
  • TypeError – if branch_device_cutoff is not float. if branch_width_scale_factor is not int or float. if hvdc_width_scale_factor is not int or float. if b2b_size_scale_factor is not int or float.

  • ValueError – if branch_device_cutoff is negative. if branch_width_scale_factor is negative. if hvdc_width_scale_factor is negative. if b2b_size_scale_factor is negative. if grid model is not supported.

postreise.plot.plot_lmp_map module

postreise.plot.plot_lmp_map.add_lmp(bus_with_lmp, coordinate_rounding, lmp_min, lmp_max, num_ticks, figsize, scale_factor, state_borders_kwargs)[source]

Add LMP to canvas.

Parameters:
  • bus_with_lmp (list) – bus data frame with LMP values.

  • coordinate_rounding (int) – number of digits to round lat/lon for aggregation.

  • file_name (str) – name for output png file.

  • lmp_min (int) – minimum LMP to clamp plot range to.

  • lmp_max (int) – maximum LMP to clamp plot range to.

  • num_ticks (int) – number of ticks to display on the color bar.

  • figsize (tuple) – size of the bokeh figure (in pixels).

  • scale_factor (int/float) – scaling factor for size of circles centered on buses.

  • state_borders_kwargs (dict) – keyword arguments to be passed to postreise.plot.plot_states.add_state_borders().

Returns:

(bokeh.plotting.figure) – canvas with LMP..

postreise.plot.plot_lmp_map.aggregate_bus_lmp(bus, coordinate_rounding)[source]

Aggregate LMP for buses based on similar lat/lon coordinates.

Parameters:
  • bus (pandas.DataFrame) – data frame containing ‘lat’, ‘lon’, ‘lmp’ columns.

  • coordinate_rounding (int) – number of digits to round lat/lon for aggregation.

Returns:

(pandas.DataFrame) – aggregated data frame.

postreise.plot.plot_lmp_map.map_lmp(scenario, coordinate_rounding=1, lmp_min=20, lmp_max=45, num_ticks=6, figsize=(1400, 800), scale_factor=1, state_borders_kwargs=None)[source]

Plot average LMP at bus level.

Parameters:
  • scenario (powersimdata.scenario,scenario.Scenario) – scenario instance..

  • coordinate_rounding (int) – number of digits to round lat/lon for aggregation.

  • lmp_min (int) – minimum LMP to clamp plot range to.

  • lmp_max (int) – maximum LMP to clamp plot range to.

  • num_ticks (int) – number of ticks to display on the color bar.

  • figsize (tuple) – size of the bokeh figure (in pixels).

  • scale_factor (int/float) – scaling factor for size of circles centered on buses.

  • state_borders_kwargs (dict) – keyword arguments to be passed to postreise.plot.plot_states.add_state_borders().

Returns:

(bokeh.plotting.figure) – LMP map.

Raises:
  • TypeError – if coordinate_rounding is not int. if lmp_min and lmp_max are not int. if num_ticks is not int. if scale_factor is not int or float.

  • ValueError – if coordinate_rounding is not positive. if num_ticks is negative. if lmp_min or lmp_max is negative or lmp_min >= lmp_max. if scale_factor is negative.

postreise.plot.plot_pie_generation_vs_capacity module

postreise.plot.plot_pie_generation_vs_capacity.plot_pie_generation_vs_capacity(areas, area_types=None, scenario_ids=None, scenario_names=None, time_range=None, time_zone=None, custom_data=None, resource_labels=None, resource_colors=None, min_percentage=0)[source]

Plot any number of scenarios as pie charts with two columns per scenario - generation and capacity.

Parameters:
  • areas (list/str) – name of the area to focus on. Could be a loadzone, a state, a country, etc. This will depend on the grid model.

  • area_types (list/str) – area supported by the grid model. See the powersimdata.network.model.area_to_loadzone() function for more details.

  • scenario_ids (int/list/str) – list of scenario id(s), defaults to None.

  • scenario_names (list/str) – list of scenario name(s) of same len as scenario ids, defaults to None

  • time_range (tuple) – [start_timestamp, end_timestamp] where each time stamp is pandas.Timestamp/numpy.datetime64/datetime.datetime. If None, the entire time range is used for the given scenario.

  • time_zone (str) – new time zone, defaults to None, which uses UTC.

  • custom_data (list) – list of dictionaries with each element being hand-generated data as returned by postreise.plot_bar_generation_vs_capacity.make_gen_cap_custom_data(), defaults to None.

  • resource_labels (dict) – a dictionary with keys being resource types and values being labels, which is used to customize resource labels for selected resource types to show in the plots. Defaults to None, in which case a default set of labels is used.

  • resource_colors (dict) – a dictionary with keys being resource types and values being colors, which is used to customize resource colors for selected resource types to show in the plots. Defaults to None, in which case a default set of colors is used.

  • min_percentage (float) – roll up small pie pieces into a single category, resources with percentage less than the set value will be pooled together, defaults to 0.

Raises:
  • ValueError – if length of area_types and areas is different. if length of scenario_names and scenario_ids is different. if less than two scenario_ids and/or custom_data in total is provided.

  • TypeError – if resource_labels are provided but not in a dict format. if resource_colors are provided but not in a dict format.

Note

if one wants to plot scenario data and custom data together, custom data MUST be in TWh for generation and GW for capacity in order to conduct appropriate comparison.

postreise.plot.plot_powerflow_snapshot module

postreise.plot.plot_powerflow_snapshot.add_arrows(canvas, branch, color, pf_threshold=0, dist_threshold=0, n=1)[source]

Add addorws for powerflow to figure.

Parameters:
  • canvas (bokeh.plotting.figure.Figure) – canvas to plot arrows onto.

  • branch (pandas.DataFrame) – data frame containing: ‘pf’, ‘dist’, ‘arrow_size’, ‘from_x’, ‘from_y’, ‘to_x’, ‘to_y’. x/y coordinates for to/from can be obtained from lat/lon coordinates using postreise.plot.projection_helpers.project_branch().

  • color (str) – arrow line color.

  • pf_threshold (int/float) – minimum power flow for a branch to get arrow(s).

  • pf_threshold – minimum distance for a branch to get arrow(s).

  • n (int) – number of arrows to plot along each branch.

postreise.plot.plot_powerflow_snapshot.aggregate_plant_generation(plant, coordinate_rounding=0)[source]

Aggregate generation for plants based on similar lat/lon coordinates.

Parameters:
  • coordinate_rounding (int) – number of digits to round lat & lon for aggregation.

  • plant (pandas.DataFrame) – data frame containing: ‘lat’, ‘lon’, ‘x’, ‘y’, ‘pg’.

Returns:

(pandas.DataFrame) – data frame aggregated to the desired precision.

postreise.plot.plot_powerflow_snapshot.plot_powerflow_snapshot(scenario, hour, b2b_dclines=None, demand_centers=None, ac_branch_color='#8B36FF', dc_branch_color='#01D4ED', solar_color='#FFBB45', wind_color='#78D911', demand_color='gray', figsize=(1400, 800), circle_scale_factor=0.25, bg_width_scale_factor=0.001, pf_width_scale_factor=0.00125, arrow_pf_threshold=3000, arrow_dist_threshold=20, num_ac_arrows=1, num_dc_arrows=1, min_arrow_size=5, branch_alpha=0.5, state_borders_kwargs=None, x_range=None, y_range=None, legend_font_size=None)[source]

Plot a snapshot of powerflow.

Parameters:
  • scenario (powersimdata.scenario.scenario.Scenario) – scenario to plot.

  • hour (pandas.Timestamp/numpy.datetime64/datetime.datetime) – snapshot interval.

  • b2b_dclines (dict) – which DC lines are actually B2B facilities. Keys are: {“from”, “to”}, values are iterables of DC line indices to plot (indices in “from” get plotted at the “from” end, and vice versa).

  • demand_centers (pandas.DataFrame) – lat/lon centers at which to plot the demand from each load zone.

  • ac_branch_color (str) – color to plot AC branches.

  • dc_branch_color (str) – color to plot DC branches.

  • solar_color (str) – color to plot solar generation.

  • wind_color (str) – color to plot wind generation.

  • demand_color (str) – color to plot demand.

  • figsize (tuple) – size of the bokeh figure (in pixels).

  • circle_scale_factor (int/float) – scale factor for demand/solar/wind circles.

  • bg_width_scale_factor (int/float) – scale factor for grid capacities.

  • pf_width_scale_factor (int/float) – scale factor for power flows.

  • arrow_pf_threshold (int/float) – minimum power flow (MW) for adding arrows.

  • arrow_dist_threshold (int/float) – minimum distance (miles) for adding arrows.

  • num_ac_arrows (int) – number of arrows for each AC branch.

  • num_dc_arrows (int) – number of arrows for each DC branch.

  • min_arrow_size (int/float) – minimum arrow size.

  • branch_alpha (int/float) – opaqueness of branches.

  • state_borders_kwargs (dict) – keyword arguments to be passed to postreise.plot.plot_states.add_state_borders().

  • x_range (tuple(float, float)) – x range to zoom plot to (EPSG:3857).

  • y_range (tuple(float, float)) – y range to zoom plot to (EPSG:3857).

  • legend_font_size (int/str) – size to display legend specified as e.g. 12/’12pt’.

Returns:

(bokeh.plotting.figure) – power flow snapshot map.

postreise.plot.plot_scatter_capacity_vs_capacity_factor module

postreise.plot.plot_scatter_capacity_vs_capacity_factor.plot_scatter_capacity_vs_capacity_factor(scenario, area, resources, time_zone='utc', time_range=None, area_type=None, between_time=None, dayofweek=None, markersize=50, fontsize=20, title=None, percentage=False, plot_show=True)[source]

Generate for a given scenario the scatter plot of the capacity (x-axis) vs capacity factor (y-axis) of generators located in area and fueled by resources over a time range.

Parameters:
  • scenario (powersimdata.scenario.scenario.Scenario) – scenario instance

  • area (str) – name of the area to focus on. Could be a loadzone, a state, a country, etc. This will depend on the grid model.

  • resources (str/list) – one or a list of resources.

  • time_zone (str) – new time zone, default to be ‘utc’.

  • time_range (tuple) – [start_timestamp, end_timestamp] where each time stamp is pandas.Timestamp/numpy.datetime64/datetime.datetime. If None, the entire time range is used for the given scenario.

  • area_type (str) – area supported by the grid model. For more details, see the powersimdata.network.model.area_to_loadzone() function.

  • between_time (list) – specify the start hour and end hour of each day inclusively, default to None, which includes every hour of a day. Note that if the end hour is set before the start hour, the complementary hours of a day are picked.

  • dayofweek (set) – specify the interest days of week, which is a subset of integers in [0, 6] with 0 being Monday and 6 being Sunday, default to None, which includes every day of a week.

  • markersize (int/float) – marker size, default to 50.

  • fontsize (int/float) – font size, default to 20.

  • title (str) – user specified figure title, default to None.

  • percentage (bool) – show capacity factor in percentage or not, default to False

  • plot_show (bool) – show the plot or not, default to True.

Returns:

(tuple) – the first entry is matplotlib.axes.Axes object of the plot, the second entry is the capacity weighted average of capacity factors over the selected time range.

Raises:

TypeError – if area is not a str. if resources is not a str or a list of str. if time_zone is not a str. if markersize is not an int or a float. if fontsize is not an int or a float. if title is provided but not a str.

postreise.plot.plot_scatter_capacity_vs_cost_curve_slope module

postreise.plot.plot_scatter_capacity_vs_cost_curve_slope.plot_scatter_capacity_vs_cost_curve_slope(scenario, area, resources, area_type=None, markersize=50, fontsize=20, title=None, plot_show=True)[source]

Generate for a given scenario the scatter plot of the capacity (x-axis) vs cost curve slope (y-axis) of generators located in area and fueled by resources

Parameters:
  • scenario (powersimdata.scenario.scenario.Scenario) – scenario instance

  • area (str) – ame of the area to focus on. Could be a loadzone, a state, a country, etc. This will depend on the grid model.

  • resources (str/list) – one or a list of resources.

  • area_type (str) – area supported by the grid model. For more details, see the powersimdata.network.model.area_to_loadzone() function.

  • markersize (int/float) – marker size, default to 50.

  • fontsize (int/float) – font size, default to 20.

  • title (str) – user specified figure title, default to None.

  • plot_show (bool) – show the plot or not, default to True.

Returns:

(tuple) – the first entry is matplotlib.axes.Axes object of the plot, the second entry is the capacity weighted average of cost curve slopes over the selected time range.

Raises:

TypeError – if area is not a str. if resources is not a str or a list of str. if markersize is not an int or a float. if fontsize is not an int or a float. if title is provided but not a str.

postreise.plot.plot_scatter_capacity_vs_curtailment module

postreise.plot.plot_scatter_capacity_vs_curtailment.plot_scatter_capacity_vs_curtailment(scenario, area, resources, time_zone='utc', time_range=None, area_type=None, between_time=None, dayofweek=None, markersize=50, fontsize=20, title=None, percentage=False, plot_show=True)[source]

Generate for a given scenario the scatter plot of the capacity (x-axis) vs curtailment as a fraction of available resources (y-axis) of generators located in area and fueled by resources over a time range.

Parameters:
  • scenario (powersimdata.scenario.scenario.Scenario) – scenario instance

  • area (str) – name of the area to focus on. Could be a loadzone, a state, a country, etc. This will depend on the grid model.

  • resources (str/list) – one or a list of resources.

  • time_zone (str) – new time zone, default to be ‘utc’.

  • time_range (tuple) – [start_timestamp, end_timestamp] where each time stamp is pandas.Timestamp/numpy.datetime64/datetime.datetime. If None, the entire time range is used for the given scenario.

  • area_type (str) – area supported by the grid model. For more details, see the powersimdata.network.model.area_to_loadzone() function.

  • between_time (list) – specify the start hour and end hour of each day inclusively, default to None, which includes every hour of a day. Note that if the end hour is set before the start hour, the complementary hours of a day are picked.

  • dayofweek (set) – specify the interest days of week, which is a subset of integers in [0, 6] with 0 being Monday and 6 being Sunday, default to None, which includes every day of a week.

  • markersize (int/float) – marker size, default to 50.

  • fontsize (int/float) – font size, default to 20.

  • title (str) – user specified figure title, default to None.

  • percentage (bool) – show capacity factor in percentage or not, default to False

  • plot_show (bool) – show the plot or not, default to True.

Returns:

(tuple) – the first entry is matplotlib.axes.Axes object of the plot, the second entry is the capacity weighted average of curtailment over the selected time range.

Raises:

TypeError – if area is not a str. if resources is not a str or a list of str. if time_zone is not a str. if markersize is not an int or a float. if fontsize is not an int or a float. if title is provided but not in a string format.

postreise.plot.plot_shadowprice_map module

postreise.plot.plot_shadowprice_map.plot_shadowprice(scenario_id, datetime, lmp_split_points=None)[source]

Map lmp variation and shadow prices

Parameters:
  • scenario_id (str/int) – scenario id

  • datetime (pandas.Timestamp/numpy.datetime64/datetime.datetime) – timestamp of the hour to analyze

  • lmp_split_points (list/tuple/set/numpy.array) – the locational marginal pricing (lmp) values we have chosen to split the bus data. Includes min and max values. Must have 10 items or fewer. defaults to None. Example: [-1, 1, 20, 25, 30, 35, 40, 100]

Returns:

(bokeh.models.layout.Row) – bokeh map visual in row layout.

Raises:
  • TypeError – if ‘scenario_id’ is not a str/int, ‘datetime’ is not a str or ‘lmp_split_points’ is not a list

  • ValueError – if ‘lmp_split_points’ array has more than 10 elements

postreise.plot.plot_sim_vs_hist module

class postreise.plot.plot_sim_vs_hist.PlotSettings[source]

Bases: object

fontsize = 15
size_inches = (20, 10)
width = 0.3
postreise.plot.plot_sim_vs_hist.plot_generation_sim_vs_hist(scenario, hist_gen, state, show_max=True, plot_show=True)[source]

Plot simulated vs historical generation of each resource in the scenario for the given state. Optionally include max generation.

Parameters:
  • scenario (powersimdata.scenario.scenario.Scenario) – scenario instance.

  • hist_gen (pandas.DataFrame) – historical generation data frame. Columns are resources and indices are state names.

  • state (str) – the US state

  • show_max (bool) – determine whether to additionally plot max generation of each resource.

  • plot_show – show the plot or not, defaults to True.

Returns:

(matplotlib.axes.Axes) – axes object of the plot.

Raises:
  • TypeError – if hist_gen is not a data frame. if state is not a str.

  • ValueError – if state is not in hist_gen or scenario.

postreise.plot.plot_states module

postreise.plot.plot_states.add_state_borders(canvas, state_list=None, background_map=False, line_color='grey', line_width=1, fill_alpha=1)[source]

Add state borders onto canvas.

Parameters:
  • canvas (bokeh.plotting.figure) – canvas.

  • state_list (list) – list of states to display, default to continental US.

  • background_map (bool) – add background behind state borders.

  • line_color (str) – color of state outlines.

  • line_width (int/float) – thickness of state outlines.

  • fill_alpha (int/float) – opaqueness for state patches.

Returns:

(bokeh.plotting.figure.Figure) – canvas with state borders.

Raises:

TypeError – if background_map is not a boolean. if line_color is not a str. if line_width is not a int or float. if fill_alpha is not a int or float.

postreise.plot.plot_states.add_state_colors(canvas, state2color)[source]

Color states.

Parameters:
  • canvas (bokeh.plotting.figure) – canvas.

  • state2color (dict) – keys are states abbreviation and values are colors.

Returns:

(bokeh.plotting.figure.Figure) – canvas with colored state.

postreise.plot.plot_states.add_state_legends(canvas, state2label=None, title=None, location='bottom_right', title_size='12pt', label_size='12pt')[source]

Add legend.

Parameters:
  • canvas (bokeh.plotting.figure) – canvas.

  • state2label (dict) – keys are states abbreviation and values are labels.

  • title (str) – title for legend.

  • location (str) – legend location on canvas. Default is bottom right.

  • title_size (str) – legend title font size. Default is 12pt.

  • label_size (str) – legend labels font size. Default is 12pt.

Returns:

(bokeh.plotting.figure.Figure) – canvas with colored state.

Raises:

TypeError – if title is not None or str. if location is not a str. if title_size is not a str. if label_size is not a str.

postreise.plot.plot_states.add_state_tooltips(canvas, tooltip_title, state2label)[source]

Add tooltip to states.

Parameters:
  • canvas (bokeh.plotting.figure) – canvas.

  • state2label (dict) – keys are states abbreviation and values are labels.

Returns:

(bokeh.plotting.figure.Figure) – canvas with toolips.

postreise.plot.plot_states.download_states_json()[source]

Downloads json file containing coordinates for U.S. state outlines.

Returns:

(str) – path to json file.

postreise.plot.plot_states.download_states_shapefile()[source]

Downloads shapefile for U.S. states.

Returns:

(str) – path to shapefile.

postreise.plot.plot_states.expand_data_source(patches, state2data, key_name)[source]

Add data to a bokeh patch object

Parameters:
  • patches (bokeh.models.renderers.GlyphRenderer) – states as glyphs.

  • state2data (dict) – keys are states abbreviation and values are data.

  • key_name (str) – name to use for the key in data source.

Returns:

(bokeh.models.renderers.GlyphRenderer) – updated patches.

Raises:
  • TypeError – if state2data is not a dict. if key_name is not a str.

  • ValueError – if states in state2data and patches differ.

postreise.plot.plot_states.get_state_borders()[source]

Get state borders as a dictionary of coordinate arrays.

Returns:

(dict) – dictionary with keys from the specified shapefile column, values are dict with keys of {“lat”, “lon”}, values are coordinates, padded by nan values to indicate the end of each polygon before the start of the next one.

postreise.plot.plot_states.plot_states(figsize=(1400, 800), state_borders_kwargs=None, state_colors_args=None, state_tooltips_args=None, state_legends_kwargs=None)[source]

Add states on canvas and optionally add colors, tooltips and legends.

Parameters:
  • figsize (tuple) – size of the bokeh figure (in pixels).

  • state_borders_kwargs (dict) – keyword argument(s) to be passed to postreise.add_state_borders().

  • state_colors_args (dict) – arguments to be passed to postreise.add_state_colors().

  • state_tooltips_args (dict) – argument(s) to be passed to postreise.add_state_tooltips().

  • state_legends_kwargs (dict) – keyword argument(s) to be passed to postreise.add_state_legends().

Raises:

TypeError – if state_borders_kwargs is not None or dict. if state_colors_args is not None or dict. if state_tooltips_args is not None or dict. if state_legends_kwargs is not None or dict.

Returns:

(bokeh.plotting.figure.Figure) – map of us states.

postreise.plot.plot_tornado module

postreise.plot.plot_tornado.plot_tornado(title, data, sorted=False, plot_show=True)[source]

Plots a tornado graph (horizontal bar with both positive and neg values)

Parameters:
  • title (str) – title of the plot

  • data (dict) – dictionary of data to be plotted

  • sorted (bool) – whether the values should be sorted smallest to largest

  • plot_show (bool) – show the plot or not, default to True.

Returns:

(matplotlib.axes.Axes) – axes object of the plot.

Raises:

TypeError – if title is not a str. if data is not a dict, keys are not str and values are not int or float. if sorted is not a bool. if plot_show is not a bool.

postreise.plot.plot_transmission_upgrades_map module

postreise.plot.plot_transmission_upgrades_map.add_transmission_upgrades(canvas, branch_merge, dc_merge, b2b_indices=None, diff_threshold=100, all_branch_scale=1, diff_branch_scale=1, all_branch_min=0.1, diff_branch_min=1.0, b2b_scale=5, dcline_upgrade_dist_threshold=0)[source]

Make map of branches showing upgrades.

Parameters:
  • canvas (bokeh.plotting.figure.Figure) – canvas to add upgrades to.

  • branch_merge (pandas.DataFrame) – branch of scenarios 1 and 2

  • dc_merge (pandas.DataFrame) – dclines for scenarios 1 and 2

  • b2b_indices (list/set/tuple) – indices of HVDC lines which are back-to-backs.

  • diff_threshold (int/float) – difference threshold (in MW), above which branches are highlighted.

  • all_branch_scale (int/float) – scale factor for plotting all branches (pixels/GW).

  • diff_branch_scale (int/float) – scale factor for plotting branches with differences above the threshold (pixels/GW).

  • all_branch_min (int/float) – minimum width to plot all branches.

  • diff_branch_min (int/float) – minimum width to plot branches with significant differences.

  • b2b_scale (int/float) – scale factor for plotting b2b facilities (pixels/GW).

  • dcline_upgrade_dist_threshold (int/float) – minimum distance (miles) for plotting DC line upgrades (if none are longer, no legend entry will be created).

Returns:

(bokeh.plotting.figure.Figure) – Bokeh map plot of color-coded upgrades.

postreise.plot.plot_transmission_upgrades_map.map_transmission_upgrades(scenario1, scenario2, b2b_indices=None, figsize=(1400, 800), x_range=None, y_range=None, state_borders_kwargs=None, legend_font_size=20, legend_location='bottom_left', **plot_kwargs)[source]

Plot capacity differences for branches & HVDC lines between two scenarios.

Parameters:
Raises:

ValueError – if grid model and interconnect of scenarios differ.

Returns:

(bokeh.plotting.figure.Figure) – map with color-coded upgrades.

postreise.plot.plot_utilization_map module

postreise.plot.plot_utilization_map.map_risk_bind(risk_or_bind, scenario=None, congestion_stats=None, branch=None, us_states_dat=None, vmin=None, vmax=None, color_bar_width=500, palette=None, all_branch_scale_factor=0.5, all_branch_min_width=0.2, select_branch_scale_factor=1, select_branch_min_width=2, figsize=(1400, 800), show_color_bar=True, state_borders_kwargs=None)[source]

Make map showing risk or binding incidents on US states map. Either scenario XOR (congestion_stats AND branch) must be specified.

Parameters:
  • risk_or_bind (str) – specify plotting “risk” or “bind”.

  • scenario (powersimdata.scenario.scenario.Scenario) – scenario to analyze.

  • congestion_stats (pandas.DataFrame) – data frame as returned by postreise.analyze.transmission.utilization.generate_cong_stats().

  • branch (pandas.DataFrame) – branch data frame.

  • vmin (int/float) – minimum value for color range. If None, use data minimum.

  • vmax (int/float) – maximum value for color range. If None, use data maximum.

  • color_bar_width (int) – width of color bar (pixels).

  • palette (iterable) – sequence of colors used for color range, passed as palette kwarg to bokeh.transform.linear_cmap(). If None, default to postreise.plot.colors.traffic_palette.

  • all_branch_scale_factor (int/float) – scale factor for unhighlighted branches (pixels/GW).

  • all_branch_min_width (int/float) – minimum width for unhighlighted branches (pixels).

  • select_branch_scale_factor (int/float) – scale factor for highlighted branches (pixels/GW).

  • select_branch_min_width (int/float) – minimum width for highlighted branches (pixels).

  • figsize (tuple(int, int)) – size of the bokeh figure (in pixels).

  • show_color_bar (bool) – whether to render the color bar on the figure.

  • state_borders_kwargs (dict) – keyword arguments to be passed to postreise.plot.plot_states.add_state_borders().

Raises:

ValueError – if (scenario XOR (congestion_stats AND branch)) are not properly specified.

Returns:

(bokeh.plotting.figure) – map of lines with risk and bind incidents color coded.

postreise.plot.plot_utilization_map.map_utilization(scenario=None, utilization_df=None, branch=None, vmin=None, vmax=None, color_bar_width=500, palette=None, branch_scale_factor=0.5, branch_min_width=0.2, figsize=(1400, 800), show_color_bar=True, state_borders_kwargs=None)[source]

Make map showing utilization. Utilization input can either be medians only, or can be normalized utilization dataframe. Either scenario XOR (utilization_df AND branch) must be specified.

Parameters:
  • scenario (powersimdata.scenario.scenario.Scenario) – scenario to analyze.

  • utilization_df (pandas.DataFrame) – utilization returned by postreise.analyze.transmission.utilization.get_utilization()

  • branch (pandas.DataFrame) – branch data frame.

  • vmin (int/float) – minimum value for color range. If None, use data minimum.

  • vmax (int/float) – maximum value for color range. If None, use data maximum.

  • color_bar_width (int) – width of color bar (pixels).

  • palette (iterable) – sequence of colors used for color range, passed as palette kwarg to bokeh.transform.linear_cmap(). If None, default to postreise.plot.colors.traffic_palette.

  • branch_scale_factor (int/float) – scale factor for branches (pixels/GW).

  • branch_min_width (int/float) – minimum width for branches (pixels).

  • figsize (tuple(int, int)) – size of the bokeh figure (in pixels).

  • state_borders_kwargs (dict) – keyword arguments to be passed to postreise.plot.plot_states.add_state_borders().

Raises:

ValueError – if (scenario XOR (utilization_df AND branch)) are not properly specified.

Returns:

(bokeh.plotting.figure) – map of lines with median utilization color coded.

postreise.plot.projection_helpers module

postreise.plot.projection_helpers.convert_shapefile_to_latlon_dict(filename, key)[source]

Converts a shapefile to a dictionary of lat/lon data.

Parameters:
  • filename (str) – the location of the shapefile to interpret.

  • key (str) – the shapefile column values used as dictionary keys.

Returns:

(dict) – dictionary with keys from the specified shapefile column, values are dict with keys of {“lat”, “lon”}, values are coordinates, padded by nan values to indicate the end of each polygon before the start of the next one.

Raises:

ValueError – if the specified key is not present in the shapefile, or the shapefile contains at least one polygon with a hole.

postreise.plot.projection_helpers.project_borders(us_states_dat, state_list=None)[source]

Prepares US state borders data for use on the map.

Parameters:
  • us_states_dat (dict) – keys are state abbrevs, values are dicts with keys of {“lats”, “lons”}, values of coordinates.

  • state_list (iterable) – abbrevs of states to project, defaults to the keys of us_states_dat minus AK, HI, DC, & PR.

Returns:

(tuple) – reprojected coordinates for use on map.

postreise.plot.projection_helpers.project_branch(branch)[source]

Projects branches on new coordinates system.

Parameters:

branch (pandas.DataFrame) – branch data frame.

Returns:

(pandas.DataFrame) – projected branch data frame.

postreise.plot.projection_helpers.project_bus(bus)[source]

Projects buses on new coordinates system.

Parameters:

bus (pandas.DataFrame) – bus data frame.

Returns:

(pandas.DataFrame) – projected bus data frame.

Module contents