otoole.results package

Submodules

otoole.results.result_package module

class otoole.results.result_package.ResultsPackage(data: Dict[str, pandas.core.frame.DataFrame], input_data: Optional[Dict[str, pandas.core.frame.DataFrame]] = None)[source]

Bases: collections.abc.Mapping

A package of OSeMOSYS results

Internal data structure is a dictionary of pandas DataFrames

A crude caching function is implemented whereby calculated results are stored in the internal data structure so that each result is only calculated once.

Parameters:
  • data (dict) – A dictionary of results data
  • input_data (dict, default=None) – Dictionary of input data
accumulated_new_capacity() → pandas.core.frame.DataFrame[source]

AccumulatedNewCapacity

Parameters:

Notes

From the formulation:

r~REGION, t~TECHNOLOGY, y~YEAR,
sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0}
    NewCapacity[r,t,yy] ~VALUE;
annual_emissions() → pandas.core.frame.DataFrame[source]

Calculates the annual emissions

Annual Emission are found by multiplying the emission activity ratio (emissions per unit activity) by the rate of activity and the yearsplit

Notes

From the formulation:

sum{t in TECHNOLOGY, l in TIMESLICE, m in MODE_OF_OPERATION:
        EmissionActivityRatio[r,t,e,m,y]<>0}
    RateOfActivity[r,l,t,m,y] * EmissionActivityRatio[r,t,e,m,y]
        * YearSplit[l,y]~VALUE;
annual_fixed_operating_cost() → pandas.core.frame.DataFrame[source]

Compute AnnualFixedOperatingCost result

Notes

From the formulation:

r~REGION, t~TECHNOLOGY, y~YEAR,
FixedCost[r,t,y] *
((sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0}
    NewCapacity[r,t,yy]) + ResidualCapacity[r,t,y]) ~VALUE;
annual_technology_emission_by_mode() → pandas.core.frame.DataFrame[source]

Notes

From the formulation:

r~REGION, t~TECHNOLOGY, e~EMISSION, m~MODE_OF_OPERATION, y~YEAR,
sum{l in TIMESLICE: EmissionActivityRatio[r,t,e,m,y] <> 0}
    EmissionActivityRatio[r,t,e,m,y] * RateOfActivity[r,l,t,m,y]
        * YearSplit[l,y]
annual_technology_emissions() → pandas.core.frame.DataFrame[source]

Calculates results AnnualTechnologyEmission

Notes

From the formulation:

REGION, TECHNOLOGY, EMISSION, YEAR,
sum{l in TIMESLICE, m in MODE_OF_OPERATION:
    EmissionActivityRatio[r,t,e,m,y]<>0}
EmissionActivityRatio[r,t,e,m,y] * RateOfActivity[r,l,t,m,y]
    * YearSplit[l,y];
annual_variable_operating_cost() → pandas.core.frame.DataFrame[source]

AnnualVariableOperatingCost

Notes

From the formulation:

r~REGION, t~TECHNOLOGY, y~YEAR,
sum{m in MODE_OF_OPERATION, l in TIMESLICE}
    RateOfActivity[r,l,t,m,y]
    * YearSplit[l,y]
    * VariableCost[r,t,m,y] ~VALUE;
capital_investment() → pandas.core.frame.DataFrame[source]

CapitalInvestment

Notes

From the formulation:

r~REGION, t~TECHNOLOGY, y~YEAR,
CapitalCost[r,t,y] * NewCapacity[r,t,y] ~VALUE;
data

View the results dictionary

demand() → pandas.core.frame.DataFrame[source]

Demand

Notes

From the formulation:

r~REGION, l~TIMESLICE, f~FUEL, y~YEAR,
SpecifiedAnnualDemand[r,f,y] * SpecifiedDemandProfile[r,f,l,y] ~VALUE;
discounted_tech_emis_pen() → pandas.core.frame.DataFrame[source]

Notes

From the formulation:

DiscountedTechnologyEmissionsPenalty[r,t,y] :=

EmissionActivityRatio[r,t,e,m,y] * RateOfActivity[r,l,t,m,y] *
YearSplit[l,y] * EmissionsPenalty[r,e,y] /
((1+DiscountRate[r, t]) ^ (y - min{yy in YEAR} min(yy) + 0.5))
get_unique_values_from_index(dataframes: List[T], name: str) → List[T][source]

Utility function to extract list of unique values

Extract unique values from the same index of the passed dataframes

production_by_technology() → pandas.core.frame.DataFrame[source]

Compute production by technology

ProductionByTechnology

Notes

From the formulation:

r~REGION, l~TIMESLICE, t~TECHNOLOGY, f~FUEL, y~YEAR,
sum{m in MODE_OF_OPERATION: OutputActivityRatio[r,t,f,m,y] <> 0}
    RateOfActivity[r,l,t,m,y] * OutputActivityRatio[r,t,f,m,y]
    * YearSplit[l,y] ~VALUE;
production_by_technology_annual() → pandas.core.frame.DataFrame[source]

Aggregates production by technology to the annual level

rate_of_product_technology() → pandas.core.frame.DataFrame[source]

Sums up mode of operation for rate of production

Notes

From the formulation:

r~REGION, l~TIMESLICE, t~TECHNOLOGY, f~FUEL, y~YEAR,
sum{m in MODE_OF_OPERATION: OutputActivityRatio[r,t,f,m,y] <> 0}
    RateOfActivity[r,l,t,m,y] * OutputActivityRatio[r,t,f,m,y]~VALUE;
rate_of_production_tech_mode() → pandas.core.frame.DataFrame[source]

RateOfProductionByTechnologyByMode

Notes

From the formulation:

r~REGION, l~TIMESLICE, t~TECHNOLOGY, m~MODE_OF_OPERATION, f~FUEL, y~YEAR,
RateOfActivity[r,l,t,m,y] * OutputActivityRatio[r,t,f,m,y]~VALUE;
rate_of_use_by_technology() → pandas.core.frame.DataFrame[source]

RateOfUseByTechnology

Notes

From the formulation:

r~REGION, l~TIMESLICE, t~TECHNOLOGY, f~FUEL, y~YEAR,
sum{m in MODE_OF_OPERATION: InputActivityRatio[r,t,f,m,y]<>0}
    RateOfActivity[r,l,t,m,y] * InputActivityRatio[r,t,f,m,y]~VALUE;
rate_of_use_by_technology_by_mode() → pandas.core.frame.DataFrame[source]

RateOfUseByTechnologyByMode

Notes

From the formulation:

r~REGION, l~TIMESLICE, t~TECHNOLOGY, m~MODE_OF_OPERATION, f~FUEL, y~YEAR,
RateOfActivity[r,l,t,m,y] * InputActivityRatio[r,t,f,m,y]~VALUE;
result_cache
result_mapper
total_annual_tech_activity_mode() → pandas.core.frame.DataFrame[source]

TotalAnnualTechnologyActivityByMode

Notes

From the formulation:

r~REGION, t~TECHNOLOGY, m~MODE_OF_OPERATION, y~YEAR,
sum{l in TIMESLICE}
    RateOfActivity[r,l,t,m,y] * YearSplit[l,y]~VALUE;
total_capacity_annual() → pandas.core.frame.DataFrame[source]

Compute TotalCapacityAnnual result

Notes

From the formulation:

r~REGION, t~TECHNOLOGY, y~YEAR,
ResidualCapacity[r,t,y] +
(sum{yy in YEAR: y-yy < OperationalLife[r,t] && y-yy>=0}
    NewCapacity[r,t,yy])~VALUE;
total_discounted_cost() → pandas.core.frame.DataFrame[source]

TotalDiscountedCost

Notes

From the formulation:

r~REGION, y~YEAR,
sum{t in TECHNOLOGY}
((((    (sum{yy in YEAR: y-yy
             < OperationalLife[r,t]
             && y-yy>=0}
            NewCapacity[r,t,yy])
            + ResidualCapacity[r,t,y])
        * FixedCost[r,t,y]
        + sum{m in MODE_OF_OPERATION, l in TIMESLICE}
            RateOfActivity[r,l,t,m,y] * YearSplit[l,y]
            * VariableCost[r,t,m,y])
    / ((1+DiscountRate[r,t])^(y-min{yy in YEAR} min(yy)+0.5))
    + CapitalCost[r,t,y] * NewCapacity[r,t,y]
    / ((1+DiscountRate[r,t])^(y-min{yy in YEAR} min(yy)))
    + DiscountedTechnologyEmissionsPenalty[r,t,y]
    - DiscountedSalvageValue[r,t,y]
)    )
+ sum{r in REGION, s in STORAGE, y in YEAR}
    (CapitalCostStorage[r,s,y] * NewStorageCapacity[r,s,y]
    / ((1+DiscountRate[r,t])^(y-min{yy in YEAR} min(yy)))
        - SalvageValueStorage[r,s,y]
        / ((1+DiscountRate[r,t])^(max{yy in YEAR}
            max(yy)-min{yy in YEAR} min(yy)+1))
    )~VALUE;
total_tech_model_period_activity() → pandas.core.frame.DataFrame[source]

TotalTechnologyModelPeriodActivity

Notes

From the formulation:

ResultsPath & "/TotalTechnologyModelPeriodActivity.csv":
r~REGION, t~TECHNOLOGY,
sum{l in TIMESLICE, m in MODE_OF_OPERATION, y in YEAR}
    RateOfActivity[r,l,t,m,y]*YearSplit[l,y]~VALUE;
total_technology_annual_activity() → pandas.core.frame.DataFrame[source]

TotalTechnologyAnnualActivity

Notes

From the formulation:

ResultsPath & "/TotalTechnologyAnnualActivity.csv":
r~REGION, t~TECHNOLOGY, y~YEAR,
sum{l in TIMESLICE, m in MODE_OF_OPERATION}
    RateOfActivity[r,l,t,m,y] * YearSplit[l,y]~VALUE;
use_by_technology() → pandas.core.frame.DataFrame[source]

UseByTechnology

Notes

From the formulation:

r~REGION, l~TIMESLICE, t~TECHNOLOGY, f~FUEL, y~YEAR,
sum{m in MODE_OF_OPERATION}
    RateOfActivity[r,l,t,m,y]
    * InputActivityRatio[r,t,f,m,y]
    * YearSplit[l,y]~VALUE;
otoole.results.result_package.capital_recovery_factor(regions: List[T], technologies: List[T], years: List[T], discount_rate: pandas.core.frame.DataFrame, adj: float = 0.0) → pandas.core.frame.DataFrame[source]

Calculates the capital recovery factor

Parameters:
  • regions (list) –
  • years (list) –
  • discount_rate (pd.DataFrame) –
  • adj (float, default=0.0) – Adjust to beginning of the year (default), mid year (0.5) or end year (1.0)

otoole.results.results module

class otoole.results.results.ReadCbc(user_config: Optional[Dict[KT, VT]] = None, results_config: Optional[Dict[KT, VT]] = None)[source]

Bases: otoole.results.results.ReadResultsCBC

Read a CBC solution file into memory

Parameters:
  • user_config
  • results_config
class otoole.results.results.ReadCplex(user_config: Optional[Dict[KT, VT]] = None, results_config: Optional[Dict[KT, VT]] = None)[source]

Bases: otoole.results.results.ReadResults

convert_df(data: List[List[str]], variable: str, start_year: int, end_year: int) → pandas.core.frame.DataFrame[source]

Read the cplex lines into a pandas DataFrame

extract_rows(sol_file: TextIO, start_year: int, end_year: int) → Dict[str, List[List[str]]][source]
extract_variable_dimensions_values(data: List[T]) → Tuple[str, Tuple, List[T]][source]

Extracts useful information from a line of a results file

get_results_from_file(filepath: Union[str, TextIO], input_data) → Dict[str, pandas.core.frame.DataFrame][source]
class otoole.results.results.ReadGurobi(user_config: Optional[Dict[KT, VT]] = None, results_config: Optional[Dict[KT, VT]] = None)[source]

Bases: otoole.results.results.ReadResultsCBC

Read a Gurobi solution file into memory

class otoole.results.results.ReadResults(user_config: Optional[Dict[KT, VT]] = None, results_config: Optional[Dict[KT, VT]] = None)[source]

Bases: otoole.input.ReadStrategy

calculate_results(available_results: Dict[str, pandas.core.frame.DataFrame], input_data: Dict[str, pandas.core.frame.DataFrame]) → Dict[str, pandas.core.frame.DataFrame][source]

Populates the results with calculated values using input data

get_results_from_file(filepath, input_data)[source]
read(filepath: Union[str, TextIO], **kwargs) → Tuple[Dict[str, pandas.core.frame.DataFrame], Dict[str, Any]][source]

Read a solution file from filepath and process using input_data

Parameters:
  • filepath (str, TextIO) – A path name or file buffer pointing to the CBC solution file
  • input_data (dict, default=None) – dict of dataframes
Returns:

A tuple containing dict of pandas.DataFrames and a dict of default_values

Return type:

tuple

class otoole.results.results.ReadResultsCBC(user_config: Optional[Dict[KT, VT]] = None, results_config: Optional[Dict[KT, VT]] = None)[source]

Bases: otoole.results.results.ReadResults

get_results_from_file(filepath, input_data)[source]
otoole.results.results.check_duplicate_index(df: pandas.core.frame.DataFrame, columns: List[T], index: List[T]) → pandas.core.frame.DataFrame[source]

Catches pandas error when there are duplicate column indices

otoole.results.results.check_for_duplicates(index: List[T]) → bool[source]
otoole.results.results.identify_duplicate(index: List[T]) → Union[int, bool][source]
otoole.results.results.rename_duplicate_column(index: List[T]) → List[T][source]

Module contents