Model database utilities

Common code for data input.

class item.model.common.ModelInfo(id: str, format: str, versions: tuple[int, ...]=<factory>, name: str | None = None, citation: str | None = None, model_url: str | None = None, org: str | None = None, org_url: str | None = None)[source]

Information about a model.

This dataclass replaces entries previously in data/model/models.yaml.

model_url: str | None = None

URL for model documentation.

org: str | None = None

Organization name.

org_url: str | None = None

Organization contact URL.

item.model.common.concat_versions(dataframes={})[source]

Convert a dict of dataframes to a single pd.DataFrame.

The keys of dataframes are saved in a new column ‘version’.

item.model.common.data_columns(df)[source]

Return a sorted list of non-index columns in pandas.Dataframe df.

item.model.common.drop_empty(df, columns=None)[source]

Drop rows in df where the data columns are all empty.

The number of dropped rows is logged. If columns, an iterable of column names, is given, drop on these columns instead.

item.model.common.load()[source]

Load model & scenario data.

item.model.common.select(data, *args, **kwargs)[source]

Select from data.

item.model.common.to_wide(data, dimension='year')[source]

Convert data to wide format, one column per year.