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 fromAbstractSector
directly or indirectly.MUSE only requires two things of a sector. Sector should be instanstiable via a
factory()
function. And they should be callable vianext()
.AbstractSector
declares an interface with these two functions. Sectors which derive from it will be warned if either method is not implemented.
muse.sectors.legacy_sector module¶
This module defines the LegacySector class.
This is needed to interface the new MCA with the old MUSE sectors. It can be deleted once accessing those sectors is no longer needed.
- class LegacyMarket(BaseYear: int, EndYear: int, Foresight: numpy.ndarray, TimeFramework: numpy.ndarray, YearlyTimeFramework: numpy.ndarray, NYears: list, GlobalCommoditiesAttributes: numpy.ndarray, CommoditiesBudget: list, macro_drivers: pandas.core.frame.DataFrame, dfRegions: pandas.core.frame.DataFrame, Regions: numpy.ndarray, interpolation_mode: str)[source]¶
Bases:
object
- BaseYear¶
- CommoditiesBudget¶
- EndYear¶
- Foresight¶
- GlobalCommoditiesAttributes¶
- NYears¶
- Regions¶
- TimeFramework¶
- YearlyTimeFramework¶
- dfRegions¶
- interpolation_mode¶
- macro_drivers¶
- class LegacySector(name, old_sector, timeslices, commodities, commodity_price, static_trade, regions, time_framework, mode, excess, market_iterative, sectors_dir, output_dir)[source]¶
Bases:
AbstractSector
- calibrated¶
Flag if the sector has gone through the calibration process.
- commodities¶
Commodities for each sector, as well as global commodities.
- commodity_price¶
Initial price of all the commodities.
- dims¶
Order of the input and output dimensions.
- excess¶
Allowed excess of capacity.
- property global_commodities¶
List of all commodities used by the MCA.
- static load_timeslices_and_aggregation(timeslices, sectors)[source]¶
Loads all sector timeslices and finds the finest one.
- market_iterative¶
—–> TODO what’s this parameter?
- mode¶
If ‘Calibration’, the sector runs in calibration mode
- name¶
Name of the sector
- old_sector¶
Legacy sector method to run the calculation
- output_dir¶
Outputs directory.
- regions¶
Regions taking part in the simulation.
- property sector_commodities¶
List of all commodities used by the Sector.
- property sector_timeslices¶
List of all commodities used by the MCA.
- sectors_dir¶
Sectors directory.
- static_trade¶
Static trade needed for the conversion and supply sectors.
- time_framework¶
Time framework of the complete simulation.
- timeslices¶
Timeslices for sectors and mca.
- commodities_idx(sector, comm)[source]¶
Gets the indices of the commodities involved in the processes of the sector.
- Parameters:
sector – The old MUSE sector of interest
comm – Either “OUT”, “IN” or “NotENV”
- Returns:
A list with the indexes
muse.sectors.preset_sector module¶
Sector with preset behaviours.
muse.sectors.register module¶
- SECTORS_REGISTERED = {'default': <bound method Sector.factory of <class 'muse.sectors.sector.Sector'>>, 'legacy': <bound method LegacySector.factory of <class 'muse.sectors.legacy_sector.LegacySector'>>, '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.
muse.sectors.sector module¶
- class Sector(name, technologies, subsectors=[], timeslices=None, technodata_timeslices=None, interactions=None, interpolation='linear', outputs=None, supply_prod=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.
- static convert_market_timeslice(market, timeslice, intensive='prices')[source]¶
Converts market from one to another timeslice.
- property forecast¶
Maximum forecast horizon across agents.
If no agents with a “forecast” attribute are found, defaults to 5. It cannot be lower than 1 year.
- interactions¶
Interactions between agents.
Called right before computing new investments, this function should manage any interactions between agents, e.g. passing assets from new agents to retro agents, and maket make-up from retro to new.
Defaults to doing nothing.
The function takes the sequence of agents as input, and returns nothing. It is expected to modify the agents in-place.
See also
- interpolation¶
Interpolation method and arguments when computing years.
- market_variables(market, technologies)[source]¶
Computes resulting market: production, consumption, and costs.
- name¶
Name of the sector.
- next(mca_market, time_period=None, current_year=None)[source]¶
Advance sector by one time period.
- Parameters:
mca_market – Market with
demand
,supply
, andprices
.time_period – Length of the time period in the framework. Defaults to the range of
mca_market.year
.current_year – Current year of the simulation
- Returns:
A market containing the
supply
offered by the sector, it’s attendantconsumption
of fuels and materials and the associatedcosts
.
- outputs¶
A function for outputting data for post-mortem analysis.
- subsectors¶
Subsectors controlled by this object.
- supply_prod¶
Computes production as used to return the supply to the MCA.
It can be anything registered with
@register_production
.
- technologies¶
Parameters describing the sector’s technologies.
- timeslices¶
Timeslice at which this sector operates.
If None, it will operate using the timeslice of the input market.
muse.sectors.subsector module¶
- class Subsector(agents, commodities, demand_share=None, constraints=None, investment=None, name='subsector', forecast=5, expand_market_prices=False)[source]¶
Bases:
object
Agent group servicing a subset of the sectorial commodities.
- expand_market_prices¶
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.
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.LegacySector
: A wrapper around the original MUSE sectors.
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 dataAbstractSector.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 fromAbstractSector
directly or indirectly.MUSE only requires two things of a sector. Sector should be instanstiable via a
factory()
function. And they should be callable vianext()
.AbstractSector
declares an interface with these two functions. Sectors which derive from it will be warned if either method is not implemented.
- class LegacySector(name, old_sector, timeslices, commodities, commodity_price, static_trade, regions, time_framework, mode, excess, market_iterative, sectors_dir, output_dir)[source]¶
Bases:
AbstractSector
- calibrated¶
Flag if the sector has gone through the calibration process.
- commodities¶
Commodities for each sector, as well as global commodities.
- commodity_price¶
Initial price of all the commodities.
- dims¶
Order of the input and output dimensions.
- excess¶
Allowed excess of capacity.
- property global_commodities¶
List of all commodities used by the MCA.
- static load_timeslices_and_aggregation(timeslices, sectors)[source]¶
Loads all sector timeslices and finds the finest one.
- market_iterative¶
—–> TODO what’s this parameter?
- mode¶
If ‘Calibration’, the sector runs in calibration mode
- name¶
Name of the sector
- old_sector¶
Legacy sector method to run the calculation
- output_dir¶
Outputs directory.
- regions¶
Regions taking part in the simulation.
- property sector_commodities¶
List of all commodities used by the Sector.
- property sector_timeslices¶
List of all commodities used by the MCA.
- sectors_dir¶
Sectors directory.
- static_trade¶
Static trade needed for the conversion and supply sectors.
- time_framework¶
Time framework of the complete simulation.
- timeslices¶
Timeslices for sectors and mca.
- class PresetSector(presets, interpolation_mode='linear', name='preset')[source]¶
Bases:
AbstractSector
Sector with outcomes fixed from the start.
- interpolation_mode¶
Interpolation method
- name¶
Name by which to identify a sector
- presets¶
Market across time and space.
- class Sector(name, technologies, subsectors=[], timeslices=None, technodata_timeslices=None, interactions=None, interpolation='linear', outputs=None, supply_prod=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.
- static convert_market_timeslice(market, timeslice, intensive='prices')[source]¶
Converts market from one to another timeslice.
- property forecast¶
Maximum forecast horizon across agents.
If no agents with a “forecast” attribute are found, defaults to 5. It cannot be lower than 1 year.
- interactions¶
Interactions between agents.
Called right before computing new investments, this function should manage any interactions between agents, e.g. passing assets from new agents to retro agents, and maket make-up from retro to new.
Defaults to doing nothing.
The function takes the sequence of agents as input, and returns nothing. It is expected to modify the agents in-place.
See also
- interpolation¶
Interpolation method and arguments when computing years.
- market_variables(market, technologies)[source]¶
Computes resulting market: production, consumption, and costs.
- name¶
Name of the sector.
- next(mca_market, time_period=None, current_year=None)[source]¶
Advance sector by one time period.
- Parameters:
mca_market – Market with
demand
,supply
, andprices
.time_period – Length of the time period in the framework. Defaults to the range of
mca_market.year
.current_year – Current year of the simulation
- Returns:
A market containing the
supply
offered by the sector, it’s attendantconsumption
of fuels and materials and the associatedcosts
.
- outputs¶
A function for outputting data for post-mortem analysis.
- subsectors¶
Subsectors controlled by this object.
- supply_prod¶
Computes production as used to return the supply to the MCA.
It can be anything registered with
@register_production
.
- technologies¶
Parameters describing the sector’s technologies.
- timeslices¶
Timeslice at which this sector operates.
If None, it will operate using the timeslice of the input market.