message_ix_models.model.transport.plot.ComparePDT

class message_ix_models.model.transport.plot.ComparePDT[source]

Bases: Plot

Passenger activity.

This plot is used in transport.build.debug_multi(), not in ordinary reporting. Rather than receiving data from computed quantities already in the graph, it reads them from files named pdt.csv (per kind) in the directories generated by the workflow steps like “SSP1 debug build” ( transport.build.debug()).

  • One page per \(n\).

  • 5 horizontal panels for |t| (=transport modes).

  • One line with points per scenario, coloured by scenario.

__init__()

Methods

__init__()

add_tasks(c, key, *inputs[, strict])

Use a custom output path.

generate(*paths)

Generate and return the plot.

ggtitle([extra])

Return plotnine.ggtitle including the current date & time.

groupby_plot(data, *args)

Combination of groupby and ggplot().

make_task(*inputs)

Return a task tuple to add to a Computer.

save(config, *args, **kwargs)

Prepare data, call generate(), and save to file.

Attributes

basename

File name base for saving the plot.

factor

Unit adjustment factor.

inputs

Keys referring to Quantities or other inputs accepted by generate().

kind

Base name for source data files, for instance pdt.csv.

path

Path for file output.

runs_on_solved_scenario

False for plots not intended to be run on a solved scenario.

save_args

Keyword arguments for plotnine.ggplot.save.

static

list of plotnine objects that are not dynamic

suffix

File extension; determines file format.

title

Fixed plot title string.

unit

Units of input files

classmethod add_tasks(c: Computer, key: KeyLike, *inputs, strict: bool = False) KeyLike

Use a custom output path.

basename = 'compare-pdt'

File name base for saving the plot.

factor = 1000000.0

Unit adjustment factor.

generate(*paths: Path)[source]

Generate and return the plot.

A subclass of Plot must implement this method.

Parameters:

args (Sequence of pandas.DataFrame or other) –

One argument is given corresponding to each of the inputs.

Because plotnine operates on pandas data structures, save() automatically converts any Quantity inputs to pandas.DataFrame before they are passed to generate().

ggtitle(extra: str | None = None)

Return plotnine.ggtitle including the current date & time.

groupby_plot(data: DataFrame, *args)

Combination of groupby and ggplot().

Groups by args and yields a series of plotnine.ggplot objects, one per group, with static geoms and ggtitle() appended to each.

inputs: Sequence[Hashable] = []

Keys referring to Quantities or other inputs accepted by generate().

kind = 'pdt'

Base name for source data files, for instance pdt.csv.

classmethod make_task(*inputs)

Return a task tuple to add to a Computer.

Deprecated since version 1.18.0: Use add_tasks() instead.

Parameters:

*inputs (.Key or str or hashable, optional) – If provided, overrides the inputs property of the class.

Returns:

  • The first, callable element of the task is save().

  • The second element is "config", to access the configuration of the Computer.

  • The third and following elements are the inputs.

Return type:

tuple

path: Path | None = None

Path for file output. If it is not set, save() will populate it with a value constructed from config["output_dir"], basename, and suffix. The implementation of generate() in a Plot sub-class may assign any other value, for instance one constructed at runtime from the inputs.

runs_on_solved_scenario: bool = False

False for plots not intended to be run on a solved scenario.

save(config, *args, **kwargs) Path | None

Prepare data, call generate(), and save to file.

This method is used as the callable in the task generated by add_tasks().

Added in version 1.24.1: This method uses disable_copy_on_write() to work around has2k1/mizani#38. This may cause issues if other computations (for instance, of the inputs to the Plot) rely on Pandas’ copy-on-write behaviour being enabled.

save_args: dict[str, Any] = {'verbose': False}

Keyword arguments for plotnine.ggplot.save.

static: list['plotnine.typing.PlotAddable'] = [<plotnine.themes.theme.theme object>, {'color': 'scenario', 'x': 'y', 'y': 'value'}, <plotnine.facets.facet_wrap.facet_wrap object>, <plotnine.geoms.geom_line.geom_line object>, <plotnine.geoms.geom_point.geom_point object>, scale_y_log10(name=None, breaks=True, limits=None, labels=True, expand=None, guide=None, na_value=nan, aesthetics=['y', 'ymin', 'ymax', 'yend', 'yintercept', 'ymin_final', 'ymax_final', 'lower', 'middle', 'upper'], rescaler=<function rescale>, oob=<function censor>, minor_breaks=True, trans='log10'), labs(x=None, y='Activity', alpha=None, color=None, colour=None, fill=None, linetype=None, shape=None, size=None, stroke=None, title=None, subtitle=None, caption=None)]

list of plotnine objects that are not dynamic

Type:

‘Static’ geoms

suffix = '.pdf'

File extension; determines file format.

title: str | None = None

Fixed plot title string. If not given, the first line of the class docstring is used.

unit: str | None = 'km/a'

Units of input files