Export and plotting classes and functions

pydantic model flodym.export.PlotlyArrayPlotter
Config:
  • arbitrary_types_allowed: bool = True

  • extra: str = allow

  • protected_namespaces: tuple = ()

Fields:
  • array (flodym.flodym_arrays.FlodymArray)

  • display_names (dict | None)

  • fig (plotly.graph_objs._figure.Figure)

  • intra_line_dim (str)

  • line_label (str)

  • linecolor_dim (str)

  • subplot_dim (str)

  • title (str)

  • x_array (flodym.flodym_arrays.FlodymArray)

  • xlabel (str)

  • ylabel (str)

Validators:
  • check_colors » all fields

  • check_dims » all fields

field array: FlodymArray [Required]

Values to plot, usually a Flow or Stock; sliced or summed along excess dimensions.

field display_names: dict | None = {}

Dictionary for string replacement in figures. Keys are strings to be replaced (like process names, etc.), values are strings to display instead. All strings not in this dictionary will be displayed as is.

field fig: Figure = None

A previously created plotly figure object, for adding lines to an existing figure. If None, a new figure is created.

field intra_line_dim: str [Required]

Name of the dimension along which lines are plotted (if no x_array is given, this is also the x-axis).

field line_label: str = None

Custom label for the line. If None, the respective item along linecolor_dim is used as label.

field linecolor_dim: str = None

Name of the dimension along which to split the array into several lines within each subplot. If None, only one line is plotted per subplot.

field subplot_dim: str = None

Name of the dimension by which to split the array into subplots. If None, the array is plotted in a single subplot.

field title: str = None

Title of the plot, if desired.

field x_array: FlodymArray = None

Array with x-values for each line. Must have the same dimensions as array, or a subset of them. If None, the intra_line_dim is used as x-axis.

field xlabel: str = None

Custom label for the x-axis. If None, the name of the x_array or intra_line_dim is used.

field ylabel: str = None

Custom label for the y-axis. If None, the name of the array is used.

add_line(i_subplot, x, y, label, i_line)
validator check_colors  »  all fields
validator check_dims  »  all fields
col(i_subplot)
display_name(name)
get_fig()
plot(save_path=None, do_show=False)
Parameters:
  • save_path (str | None)

  • do_show (bool)

plot_legend()
row(i_subplot)
save(save_path=None)
Parameters:

save_path (str | None)

set_subplot_title(index, title)
set_title()
set_xlabel(i_subplot, label)
set_ylabel(i_subplot, label)
show()
pydantic model flodym.export.PyplotArrayPlotter
Config:
  • arbitrary_types_allowed: bool = True

  • extra: str = allow

  • protected_namespaces: tuple = ()

Fields:
  • array (flodym.flodym_arrays.FlodymArray)

  • display_names (dict | None)

  • fig (matplotlib.figure.Figure)

  • intra_line_dim (str)

  • line_label (str)

  • linecolor_dim (str)

  • subplot_dim (str)

  • title (str)

  • x_array (flodym.flodym_arrays.FlodymArray)

  • xlabel (str)

  • ylabel (str)

Validators:
  • check_colors » all fields

  • check_dims » all fields

field array: FlodymArray [Required]

Values to plot, usually a Flow or Stock; sliced or summed along excess dimensions.

field display_names: dict | None = {}

Dictionary for string replacement in figures. Keys are strings to be replaced (like process names, etc.), values are strings to display instead. All strings not in this dictionary will be displayed as is.

field fig: Figure = None

A previously created pyplot figure object, for adding lines to an existing figure. If None, a new figure is created.

field intra_line_dim: str [Required]

Name of the dimension along which lines are plotted (if no x_array is given, this is also the x-axis).

field line_label: str = None

Custom label for the line. If None, the respective item along linecolor_dim is used as label.

field linecolor_dim: str = None

Name of the dimension along which to split the array into several lines within each subplot. If None, only one line is plotted per subplot.

field subplot_dim: str = None

Name of the dimension by which to split the array into subplots. If None, the array is plotted in a single subplot.

field title: str = None

Title of the plot, if desired.

field x_array: FlodymArray = None

Array with x-values for each line. Must have the same dimensions as array, or a subset of them. If None, the intra_line_dim is used as x-axis.

field xlabel: str = None

Custom label for the x-axis. If None, the name of the x_array or intra_line_dim is used.

field ylabel: str = None

Custom label for the y-axis. If None, the name of the array is used.

add_line(i_subplot, x, y, label, i_line)
validator check_colors  »  all fields
validator check_dims  »  all fields
display_name(name)
get_fig()
plot(save_path=None, do_show=False)
Parameters:
  • save_path (str | None)

  • do_show (bool)

plot_legend()
save(save_path=None)
Parameters:

save_path (str | None)

set_subplot_title(i_subplot, title)
set_title()
set_xlabel(i_subplot, label)
set_ylabel(i_subplot, label)
show()
property ax: Axes
pydantic model flodym.export.PlotlySankeyPlotter
Config:
  • arbitrary_types_allowed: bool = True

  • extra: str = allow

  • protected_namespaces: tuple = ()

Fields:
  • color_scheme (str | None)

  • display_names (dict | None)

  • exclude_flows (list[str] | None)

  • exclude_processes (list[str] | None)

  • flow_color (str | None)

  • mfa (flodym.mfa_system.MFASystem)

  • node_color (str | None)

  • slice_dict (dict | None)

  • split_flows_by (str | None)

Validators:
  • check_colors » all fields

  • check_dims » all fields

  • check_excluded » all fields

field color_scheme: str | None = 'blueish'

used if split_flows_by is not None and splitting dimension is in flow.

field display_names: dict | None = {}

Dictionary for string replacement in figures. Keys are strings to be replaced (like process names, etc.), values are strings to display instead. All strings not in this dictionary will be displayed as is.

field exclude_flows: list[str] | None = []

flows that won’t show up in the plot

field exclude_processes: list[str] | None = ['sysenv']

processes that won’t show up in the plot; neither will flows to and from them

field flow_color: str | None = 'hsl(230,20,70)'

used if split_flows_by is None or splitting dimension not in flow.

field mfa: MFASystem [Required]

MFA system to visualize.

field node_color: str | None = 'gray'

color of the nodes (processes and stocks)

field slice_dict: dict | None = {}

for selection of a subset of the data; all other dimensions are summed over

field split_flows_by: str | None = None

dimension name to split and color flows by; if None, all flows are colored the same

validator check_colors  »  all fields
validator check_dims  »  all fields
validator check_excluded  »  all fields
display_name(name)
plot()
flodym.export.export_mfa_flows_to_csv(mfa, export_directory)

export flows of an MFA system to csv files.

Parameters:
  • mfa (MFASystem) – The MFA system from which the flows should be exported.

  • export_directory (str) – The directory where the csv files should be saved.

flodym.export.export_mfa_stocks_to_csv(mfa, export_directory, with_in_and_out=False)

export stocks of an MFA system to csv files.

Parameters:
  • mfa (MFASystem) – The MFA system from which the stocks should be exported.

  • export_directory (str) – The directory where the csv files should be saved.

  • with_in_and_out (bool, optional) – If True, the inflow and outflow of the stocks are also exported. Defaults to False.

flodym.export.export_mfa_to_pickle(mfa, export_path)

Write an MFA system to a pickle file.

Parameters:
  • mfa (MFASystem) – The MFA system to be exported.

  • export_path (str) – The path to the file where the MFA system should be saved.

flodym.export.convert_to_dict(mfa, type='numpy')

Convert an MFA system to a dictionary which is readable without flodym.

Parameters:
  • mfa (MFASystem) – The MFA system to be converted.

  • type (str, optional) – The type of the values in the flows and stocks. Options are ‘numpy’ and ‘pandas’. Defaults to “numpy”.

Returns:

The MFA system as a dictionary. Contains the items ‘dimension_names’, ‘dimension_items’, ‘processes’, ‘flows’, ‘flow_dimensions’, ‘flow_processes’, ‘stocks’, ‘stock_dimensions’, ‘stock_processes’.

Return type:

dict