Units

class ixmp4.core.unit.UnitServiceFacade(backend: Backend)
create(name: str) Unit

Creates a unit.

platform.units.create("MtCO2/yr")
#> <Unit 1 name='MtCO2/yr'>
Parameters:

name (str) – The name of the model.

Raises:

UnitNotUnique – If the unit with name is not unique.

Returns:

The created unit.

Return type:

ixmp4.core.unit.Unit

delete(ref: Unit | int | str) None

Deletes a unit.

platform.units.delete("MtCO2/yr")
Parameters:

ref (ixmp4.core.unit.Unit | int | str) – Unit object, unit id or unit name.

Raises:
  • UnitNotFound – If no region matching ref exists.

  • UnitDeletionPrevented – If the region matching ref is used in the database, preventing its deletion.

  • Unauthorized – If the current user is not authorized to perform this action.

get_by_name(name: str) Unit

Retrieves a unit by its name.

platform.units.get_by_name("MtCO2/yr")
#> <Unit 1 name='MtCO2/yr'>
Parameters:

name (str) – The unique name of the unit.

Raises:

UnitNotFound – If the unit with name does not exist.

Returns:

The retrieved unit.

Return type:

ixmp4.core.unit.Unit

list(**kwargs: Unpack[FacadeUnitFilter]) list[Unit]

Lists units by specified criteria.

platform.units.list()
#> [<Unit 1 name='MtCO2/yr'>]
Parameters:

**kwargs (any) – Filter parameters as specified in UnitFilter.

Returns:

List of units.

Return type:

list[ixmp4.core.unit.Unit]

tabulate(**kwargs: Unpack[FacadeUnitFilter]) DataFrame

Tabulates units by specified criteria.

platform.units.tabulate()
#>     name      id
# 0  MtCO2/yr   1
Parameters:

**kwargs (any) – Filter parameters as specified in UnitFilter.

Returns:

A data frame with the columns:
  • id

  • name

Return type:

pandas.DataFrame

class ixmp4.core.unit.Unit(backend: Backend, dto: DtoT)
Filter

alias of FacadeUnitFilter

NotUnique

alias of UnitNotUnique

NotFound

alias of UnitNotFound

DeletionPrevented

alias of UnitDeletionPrevented

docs: DocsDescriptor[UnitService, Unit]

Unit docs.

property id: int

Unique id.

property name: str

Unit name.

delete() None

Deletes this unit.