Time Series Plots

This module holds time-series plotting functions.

These plotting functions have in common, that they represent some kind of time series. The time may be visualized on the x-axis or in some other way, e.g. via the color of scatter points.

utopya.plot_funcs.time_series.density(dm: utopya.datamanager.DataManager, *, uni: utopya.datagroup.UniverseGroup, hlpr: utopya.plotting.PlotHelper, model_name: str, path_to_data: str, mean_of: Tuple[str], preprocess: Optional[Tuple[Union[dict, str]]] = None, transformations_log_level: int = 10, sizes_from: Optional[str] = None, size_factor: float = 1.0, **plot_kwargs) None[source]

Plot the density of a mask, i.e. of a dataset holding booleans.

This plotting function is useful when creating a plot from data that is encoded in a binary fashion, e.g.: arrays containing True to denote the existence of some entity or some value and False to denote its absence.

If the dataset chosen via path_to_data is not already of boolean data type, the preprocess argument is to be used to generate the array-like boolean. By means of this argument, a binary operation of form data <operator> rhs_value is carried out, which results in the desired mask.

Another feature of this plotting function is that it can include another data source to use for the sizes of the plots; in that case, a scatter plot rather than a line plot is carried out.

Parameters
  • dm (DataManager) – The data manager from which to retrieve the data

  • uni (UniverseGroup) – The selected universe data

  • hlpr (PlotHelper) – The PlotHelper that instantiates the figure and takes care of plot aesthetics (labels, title, …) and saving

  • model_name (str) – The name of the model the data resides in, i.e. the base path within the UniverseGroup.

  • path_to_data (str) – Which data to use as the mask

  • mean_of (Tuple[str], optional) – which data dimensions to calculate the density over. If this evaluates to False, the operation will be skipped

  • preprocess (Tuple[Union[str, dict]], optional) – Apply pre-processing transformations to the selected data. With the parameters specified here, multiple transformations can be applied to the data. This can be used for dimensionality reduction of the data, but also for other operations, e.g. to select only a slice of the data. See utopya.dataprocessing.transform() for more info. NOTE The operations are carried out _before_ calculating the density over the parameters specified in mean_of. The preprocess ing should not be used for calculating the mean.

  • transformations_log_level (int, optional) – With which log level to perform the preprocess. Useful for debugging.

  • sizes_from (str, optional) – If given, this is expected to be the path to a dataset that contains size values for a scatter plot. This leads to a scatter rather than a line-plot. The sizes are not used directly but are normalized by dividing with the maximum size; this makes configuration via the size_factor parameter feasible.

  • size_factor (float, optional) – The factor by which to scale the sizes given in the sizes_from argument.

  • **plot_kwargs – Passed on to plt.plot or plt.scatter

Raises

ValueError – If the selected data is not a boolean mask. This error can be alleviated by providing the preprocess argument.

Returns

Description

Return type

None

utopya.plot_funcs.time_series.densities(dm: utopya.datamanager.DataManager, *, uni: utopya.datagroup.UniverseGroup, hlpr: utopya.plotting.PlotHelper, model_name: str, to_plot: dict, **common_plot_kwargs)[source]

Like density, but for several specifications given by the to_plot argument.

Parameters
  • dm (DataManager) – The data manager from which to retrieve the data

  • uni (UniverseGroup) – The selected universe data

  • hlpr (PlotHelper) – The PlotHelper that instantiates the figure and takes care of plot aesthetics (labels, title, …) and saving

  • model_name (str) – The name of the model the data resides in, i.e. the base path within the UniverseGroup.

  • to_plot (dict) – Which data to plot the densities of. The keys of this dict are used as path_to_data for the density function. The values are unpacked and passed to density

  • **common_plot_kwargs – Passed along to the density plot function for all calls. Note that this may not contain any keys that are given within to_plot!

utopya.plot_funcs.time_series.phase_space(dm: utopya.datamanager.DataManager, *, uni: utopya.datagroup.UniverseGroup, hlpr: utopya.plotting.PlotHelper, model_name: str, x: str, y: str, cmap: Optional[str] = None, **scatter_kwargs)[source]

Plots x and y data in a phase space plot. If cmap is given, the time development will be colour coded.

Note

This automatically calculates the mean over all but the time dimension of the data.

Parameters
  • dm (DataManager) – The data manager from which to retrieve the data

  • uni (UniverseGroup) – The universe from which to plot the data

  • hlpr (PlotHelper) – The PlotHelper instance

  • model_name (str) – The model name from which to take the data

  • x (str) – The path to the data relative to the model_name which to plot on the x axis of the phase space plot.

  • y (str) – The path to the data relative to the model_name which to plot on the x axis of the phase space plot

  • cmap (str, optional) – The cmap which is used to color-code the time development. If not given, will not color-code it.

  • **scatter_kwargs – Passed on to plt.scatter


Density

utopya.plot_funcs.time_series.density(dm: utopya.datamanager.DataManager, *, uni: utopya.datagroup.UniverseGroup, hlpr: utopya.plotting.PlotHelper, model_name: str, path_to_data: str, mean_of: Tuple[str], preprocess: Optional[Tuple[Union[dict, str]]] = None, transformations_log_level: int = 10, sizes_from: Optional[str] = None, size_factor: float = 1.0, **plot_kwargs) None[source]

Plot the density of a mask, i.e. of a dataset holding booleans.

This plotting function is useful when creating a plot from data that is encoded in a binary fashion, e.g.: arrays containing True to denote the existence of some entity or some value and False to denote its absence.

If the dataset chosen via path_to_data is not already of boolean data type, the preprocess argument is to be used to generate the array-like boolean. By means of this argument, a binary operation of form data <operator> rhs_value is carried out, which results in the desired mask.

Another feature of this plotting function is that it can include another data source to use for the sizes of the plots; in that case, a scatter plot rather than a line plot is carried out.

Parameters
  • dm (DataManager) – The data manager from which to retrieve the data

  • uni (UniverseGroup) – The selected universe data

  • hlpr (PlotHelper) – The PlotHelper that instantiates the figure and takes care of plot aesthetics (labels, title, …) and saving

  • model_name (str) – The name of the model the data resides in, i.e. the base path within the UniverseGroup.

  • path_to_data (str) – Which data to use as the mask

  • mean_of (Tuple[str], optional) – which data dimensions to calculate the density over. If this evaluates to False, the operation will be skipped

  • preprocess (Tuple[Union[str, dict]], optional) – Apply pre-processing transformations to the selected data. With the parameters specified here, multiple transformations can be applied to the data. This can be used for dimensionality reduction of the data, but also for other operations, e.g. to select only a slice of the data. See utopya.dataprocessing.transform() for more info. NOTE The operations are carried out _before_ calculating the density over the parameters specified in mean_of. The preprocess ing should not be used for calculating the mean.

  • transformations_log_level (int, optional) – With which log level to perform the preprocess. Useful for debugging.

  • sizes_from (str, optional) – If given, this is expected to be the path to a dataset that contains size values for a scatter plot. This leads to a scatter rather than a line-plot. The sizes are not used directly but are normalized by dividing with the maximum size; this makes configuration via the size_factor parameter feasible.

  • size_factor (float, optional) – The factor by which to scale the sizes given in the sizes_from argument.

  • **plot_kwargs – Passed on to plt.plot or plt.scatter

Raises

ValueError – If the selected data is not a boolean mask. This error can be alleviated by providing the preprocess argument.

Returns

Description

Return type

None

Multiple Densities

utopya.plot_funcs.time_series.densities(dm: utopya.datamanager.DataManager, *, uni: utopya.datagroup.UniverseGroup, hlpr: utopya.plotting.PlotHelper, model_name: str, to_plot: dict, **common_plot_kwargs)[source]

Like density, but for several specifications given by the to_plot argument.

Parameters
  • dm (DataManager) – The data manager from which to retrieve the data

  • uni (UniverseGroup) – The selected universe data

  • hlpr (PlotHelper) – The PlotHelper that instantiates the figure and takes care of plot aesthetics (labels, title, …) and saving

  • model_name (str) – The name of the model the data resides in, i.e. the base path within the UniverseGroup.

  • to_plot (dict) – Which data to plot the densities of. The keys of this dict are used as path_to_data for the density function. The values are unpacked and passed to density

  • **common_plot_kwargs – Passed along to the density plot function for all calls. Note that this may not contain any keys that are given within to_plot!

Phase Space

utopya.plot_funcs.time_series.phase_space(dm: utopya.datamanager.DataManager, *, uni: utopya.datagroup.UniverseGroup, hlpr: utopya.plotting.PlotHelper, model_name: str, x: str, y: str, cmap: Optional[str] = None, **scatter_kwargs)[source]

Plots x and y data in a phase space plot. If cmap is given, the time development will be colour coded.

Note

This automatically calculates the mean over all but the time dimension of the data.

Parameters
  • dm (DataManager) – The data manager from which to retrieve the data

  • uni (UniverseGroup) – The universe from which to plot the data

  • hlpr (PlotHelper) – The PlotHelper instance

  • model_name (str) – The model name from which to take the data

  • x (str) – The path to the data relative to the model_name which to plot on the x axis of the phase space plot.

  • y (str) – The path to the data relative to the model_name which to plot on the x axis of the phase space plot

  • cmap (str, optional) – The cmap which is used to color-code the time development. If not given, will not color-code it.

  • **scatter_kwargs – Passed on to plt.scatter