muse.sectors package

Submodules

muse.sectors.abstract module

class AbstractSector[source]

Bases: ABC

Abstract base class for sectors.

Sectors are part of type hierarchy with AbstractSector at the apex: all sectors should derive from AbstractSector directly or indirectly.

MUSE only requires two things of a sector. Sector should be instanstiable via a factory() function. And they should be callable via next().

AbstractSector declares an interface with these two functions. Sectors which derive from it will be warned if either method is not implemented.

abstract classmethod factory(name, settings)[source]

Creates class from settings named-tuple.

abstract next(mca_market)[source]

Advance sector by one time period.

muse.sectors.preset_sector module

Sector with preset behaviours.

class PresetSector(presets, interpolation_mode='linear', name='preset')[source]

Bases: AbstractSector

Sector with outcomes fixed from the start.

classmethod factory(name, settings)[source]

Constructs a PresetSectors from input data.

interpolation_mode

Interpolation method

name

Name by which to identify a sector

next(mca_market)[source]

Advance sector by one time period.

presets

Market across time and space.

muse.sectors.register module

SECTORS_REGISTERED = {'default': <bound method Sector.factory of <class 'muse.sectors.sector.Sector'>>, 'preset': <bound method PresetSector.factory of <class 'muse.sectors.preset_sector.PresetSector'>>, 'presets': <bound method PresetSector.factory of <class 'muse.sectors.preset_sector.PresetSector'>>}

Dictionary of sectors.

register_sector(sector_class=None, name=None)[source]

Registers a sector so it is available MUSE-wide.

Example

>>> from muse.sectors import AbstractSector, register_sector
>>> @register_sector(name="MyResidence")
... class ResidentialSector(AbstractSector):
...     pass

muse.sectors.sector module

class Sector(name, technologies, supply_prod, subsectors=[], interactions=None, outputs=None, timeslice_level=None)[source]

Bases: AbstractSector

Base class for all sectors.

property agents

Iterator over all agents in the sector.

property capacity

Aggregates capacity across agents.

The capacities are aggregated leaving only two dimensions: asset (technology, installation date, region), year.

convert_to_global_timeslicing(market)[source]

Converts market data to global timeslicing.

convert_to_sector_timeslicing(market)[source]

Converts market data to sector timeslicing.

classmethod factory(name, settings)[source]

Creates class from settings named-tuple.

interactions

A function for outputting data for post-mortem analysis.

market_variables(market, technologies)[source]

Computes resulting market: production, consumption, and costs.

name

Timeslice level for the sector (e.g. “month”).

next(mca_market)[source]

Advance sector by one time period.

Parameters:

mca_market – Market with demand, supply, and prices.

Returns:

A market containing the supply offered by the sector, it’s attendant consumption of fuels and materials and the associated costs.

output_data
outputs

Computes production as used to return the supply to the MCA.

It can be anything registered with @register_production.

save_outputs(year)[source]

Calls the outputs function with the current output data.

subsectors

Parameters describing the sector’s technologies.

supply_prod

Full supply, consumption and costs data for the most recent year.

technologies
timeslice_level

Subsectors controlled by this object.

muse.sectors.subsector module

class Subsector(agents, commodities, demand_share=None, constraints=None, investment=None, name='subsector', expand_market_prices=False, timeslice_level=None)[source]

Bases: object

Agent group servicing a subset of the sectorial commodities.

aggregate_lp(technologies, market)[source]
classmethod factory(settings, technologies, regions=None, current_year=None, name='subsector', timeslice_level=None)[source]
invest(technologies, market)[source]
timeslice_level

Whether to expand prices to include destination region.

If True, the input market prices are expanded of the missing “dst_region” dimension by setting them to the maximum between the source and destination region.

aggregate_enduses(technologies)[source]

Aggregate enduse commodities for a set of technologies.

Returns a list of all enduse commodities associated with the technologies in the input dataset. Enduse commodities are determined using based on the comm_usage attribute of the technologies, using the is_enduse function from the muse.commodities module.

Module contents

Define a sector, e.g. aggregation of agents.

There are three main kinds of sectors classes, encompassing three use cases:

  • Sector: The main workhorse sector of the model. It contains only on kind of data, namely the agents responsible for holding assets and investing in new assets.

  • PresetSector: A sector that is meant to generate demand for the sectors above using a fixed formula or schedule.

All the sectors derive from AbstractSector. The AbstractSector defines two abstract functions which should be declared by derived sectors. Abstract here means a common programming practice where some concept in the code (e.g. a sector) is given an explicit interface, with the goal of making it easier for other programmers to use and implement the concept.

  • AbstractSector.factory(): Creates a sector from input data

  • AbstractSector.next(): A function which takes a market (demand, supply, prices) and returns a market. What happens within could be anything, though it will likely consists of dispatch and investment.

New sectors can be registered with the MUSE input files using muse.sectors.register.register_sector().

class AbstractSector[source]

Bases: ABC

Abstract base class for sectors.

Sectors are part of type hierarchy with AbstractSector at the apex: all sectors should derive from AbstractSector directly or indirectly.

MUSE only requires two things of a sector. Sector should be instanstiable via a factory() function. And they should be callable via next().

AbstractSector declares an interface with these two functions. Sectors which derive from it will be warned if either method is not implemented.

abstract classmethod factory(name, settings)[source]

Creates class from settings named-tuple.

abstract next(mca_market)[source]

Advance sector by one time period.

class PresetSector(presets, interpolation_mode='linear', name='preset')[source]

Bases: AbstractSector

Sector with outcomes fixed from the start.

classmethod factory(name, settings)[source]

Constructs a PresetSectors from input data.

interpolation_mode

Interpolation method

name

Name by which to identify a sector

next(mca_market)[source]

Advance sector by one time period.

presets

Market across time and space.

class Sector(name, technologies, supply_prod, subsectors=[], interactions=None, outputs=None, timeslice_level=None)[source]

Bases: AbstractSector

Base class for all sectors.

property agents

Iterator over all agents in the sector.

property capacity

Aggregates capacity across agents.

The capacities are aggregated leaving only two dimensions: asset (technology, installation date, region), year.

convert_to_global_timeslicing(market)[source]

Converts market data to global timeslicing.

convert_to_sector_timeslicing(market)[source]

Converts market data to sector timeslicing.

classmethod factory(name, settings)[source]

Creates class from settings named-tuple.

interactions

A function for outputting data for post-mortem analysis.

market_variables(market, technologies)[source]

Computes resulting market: production, consumption, and costs.

name

Timeslice level for the sector (e.g. “month”).

next(mca_market)[source]

Advance sector by one time period.

Parameters:

mca_market – Market with demand, supply, and prices.

Returns:

A market containing the supply offered by the sector, it’s attendant consumption of fuels and materials and the associated costs.

output_data
outputs

Computes production as used to return the supply to the MCA.

It can be anything registered with @register_production.

save_outputs(year)[source]

Calls the outputs function with the current output data.

subsectors

Parameters describing the sector’s technologies.

supply_prod

Full supply, consumption and costs data for the most recent year.

technologies
timeslice_level

Subsectors controlled by this object.

register_sector(sector_class=None, name=None)[source]

Registers a sector so it is available MUSE-wide.

Example

>>> from muse.sectors import AbstractSector, register_sector
>>> @register_sector(name="MyResidence")
... class ResidentialSector(AbstractSector):
...     pass