OSeMOSYS / otoole

OSeMOSYS Tools for Energy
https://otoole.readthedocs.io
MIT License
23 stars 17 forks source link

[Bug]: Error in calculation of `DiscountedTechnologyEmissionsPenalty` #178

Open trevorb1 opened 1 year ago

trevorb1 commented 1 year ago

The Issue

If there is no emissions penalty, and you try to calculate results for a single year model, the calculation of DiscountedTechnologyEmissionsPenalty fails, and the following error is thrown:

TypeError: '<' not supported between instances of 'str' and 'int'

I have replicated the issue on two different models, and provided simplicity as an example below. I think I have isolated it to having to be a single year model with no emissions penalty. A single year model with an emissions penalty works fine, and a multi-year model without an emissions penalty works fine

Expected Behavior

I would expect the conversion to happen correctly

Steps To Reproduce

  1. Copy over the model, data, and config files supplied. These are the simplicity files with the emission penalty removed, and all years except 2014 removed
  2. Run otoole -v results cbc csv model.sol results/ config.yaml --input_datafile data.txt

Log output

otoole -v results cbc csv model.sol results/ config.
yaml --input_datafile simplicity.txt 
INFO:otoole.cli:Reading config from config.yaml
INFO:otoole.cli:Validating config from config.yaml
INFO:otoole.preprocess.validate_config:AnnualEmissions -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:AccumulatedNewCapacity -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:AnnualFixedOperatingCost -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:AnnualTechnologyEmission -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:AnnualTechnologyEmissionByMode -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:AnnualVariableOperatingCost -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:CapitalInvestment -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:Demand -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:DiscountedSalvageValue -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:DiscountedTechnologyEmissionsPenalty -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:NewCapacity -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:NewStorageCapacity -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:NumberOfNewTechnologyUnits -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:ProductionByTechnology -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:ProductionByTechnologyAnnual -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:RateOfActivity -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:RateOfProductionByTechnology -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:RateOfProductionByTechnologyByMode -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:RateOfUseByTechnology -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:RateOfUseByTechnologyByMode -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:SalvageValue -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:SalvageValueStorage -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:StorageLevelDayTypeFinish -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:StorageLevelDayTypeStart -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:StorageLevelSeasonStart -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:StorageLevelYearStart -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:StorageLevelYearFinish -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:TotalAnnualTechnologyActivityByMode -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:TotalCapacityAnnual -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:TotalDiscountedCost -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:TotalTechnologyAnnualActivity -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:TotalTechnologyModelPeriodActivity -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:Trade -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:otoole.preprocess.validate_config:UseByTechnology -> Config file field of 'calculated' is deprecated. Remove 'calculated' to suppress this warning.
INFO:root:Checking datatypes for AccumulatedAnnualDemand
INFO:root:dtype of column REGION does not match str for parameter AccumulatedAnnualDemand
INFO:root:dtype of column FUEL does not match str for parameter AccumulatedAnnualDemand
INFO:root:dtype of column YEAR does not match int for parameter AccumulatedAnnualDemand
INFO:root:Checking datatypes for AnnualEmissionLimit
INFO:root:dtype of column REGION does not match str for parameter AnnualEmissionLimit
INFO:root:dtype of column EMISSION does not match str for parameter AnnualEmissionLimit
INFO:root:dtype of column YEAR does not match int for parameter AnnualEmissionLimit
INFO:root:Checking datatypes for AnnualExogenousEmission
INFO:root:dtype of column REGION does not match str for parameter AnnualExogenousEmission
INFO:root:dtype of column EMISSION does not match str for parameter AnnualExogenousEmission
INFO:root:dtype of column YEAR does not match int for parameter AnnualExogenousEmission
INFO:root:Checking datatypes for AvailabilityFactor
INFO:root:dtype of column REGION does not match str for parameter AvailabilityFactor
INFO:root:dtype of column TECHNOLOGY does not match str for parameter AvailabilityFactor
INFO:root:dtype of column YEAR does not match int for parameter AvailabilityFactor
INFO:root:dtype of column VALUE does not match float for parameter AvailabilityFactor
INFO:root:Checking datatypes for CapacityFactor
INFO:root:dtype of column REGION does not match str for parameter CapacityFactor
INFO:root:dtype of column TECHNOLOGY does not match str for parameter CapacityFactor
INFO:root:dtype of column TIMESLICE does not match str for parameter CapacityFactor
INFO:root:dtype of column YEAR does not match int for parameter CapacityFactor
INFO:root:Checking datatypes for CapacityOfOneTechnologyUnit
INFO:root:dtype of column REGION does not match str for parameter CapacityOfOneTechnologyUnit
INFO:root:dtype of column TECHNOLOGY does not match str for parameter CapacityOfOneTechnologyUnit
INFO:root:dtype of column YEAR does not match int for parameter CapacityOfOneTechnologyUnit
INFO:root:dtype of column VALUE does not match float for parameter CapacityOfOneTechnologyUnit
INFO:root:Checking datatypes for CapacityToActivityUnit
INFO:root:dtype of column REGION does not match str for parameter CapacityToActivityUnit
INFO:root:dtype of column TECHNOLOGY does not match str for parameter CapacityToActivityUnit
INFO:root:Checking datatypes for CapitalCost
INFO:root:dtype of column REGION does not match str for parameter CapitalCost
INFO:root:dtype of column TECHNOLOGY does not match str for parameter CapitalCost
INFO:root:dtype of column YEAR does not match int for parameter CapitalCost
INFO:root:Checking datatypes for CapitalCostStorage
INFO:root:dtype of column REGION does not match str for parameter CapitalCostStorage
INFO:root:dtype of column STORAGE does not match str for parameter CapitalCostStorage
INFO:root:dtype of column YEAR does not match int for parameter CapitalCostStorage
INFO:root:dtype of column VALUE does not match float for parameter CapitalCostStorage
INFO:root:Checking datatypes for Conversionld
INFO:root:dtype of column TIMESLICE does not match str for parameter Conversionld
INFO:root:dtype of column DAYTYPE does not match int for parameter Conversionld
INFO:root:Checking datatypes for Conversionlh
INFO:root:dtype of column TIMESLICE does not match str for parameter Conversionlh
INFO:root:dtype of column DAILYTIMEBRACKET does not match int for parameter Conversionlh
INFO:root:Checking datatypes for Conversionls
INFO:root:dtype of column TIMESLICE does not match str for parameter Conversionls
INFO:root:dtype of column SEASON does not match int for parameter Conversionls
INFO:root:Checking datatypes for DaysInDayType
INFO:root:dtype of column SEASON does not match int for parameter DaysInDayType
INFO:root:dtype of column DAYTYPE does not match int for parameter DaysInDayType
INFO:root:dtype of column YEAR does not match int for parameter DaysInDayType
INFO:root:dtype of column VALUE does not match float for parameter DaysInDayType
INFO:root:Checking datatypes for DaySplit
INFO:root:dtype of column DAILYTIMEBRACKET does not match int for parameter DaySplit
INFO:root:dtype of column YEAR does not match int for parameter DaySplit
INFO:root:dtype of column VALUE does not match float for parameter DaySplit
INFO:root:Checking datatypes for DepreciationMethod
INFO:root:dtype of column REGION does not match str for parameter DepreciationMethod
INFO:root:dtype of column VALUE does not match float for parameter DepreciationMethod
INFO:root:Checking datatypes for DiscountRate
INFO:root:dtype of column REGION does not match str for parameter DiscountRate
INFO:root:dtype of column VALUE does not match float for parameter DiscountRate
INFO:root:Checking datatypes for DiscountRateStorage
INFO:root:dtype of column REGION does not match str for parameter DiscountRateStorage
INFO:root:dtype of column STORAGE does not match str for parameter DiscountRateStorage
INFO:root:dtype of column VALUE does not match float for parameter DiscountRateStorage
INFO:root:dtype does not match str for set EMISSION
INFO:root:Checking datatypes for EmissionActivityRatio
INFO:root:dtype of column REGION does not match str for parameter EmissionActivityRatio
INFO:root:dtype of column TECHNOLOGY does not match str for parameter EmissionActivityRatio
INFO:root:dtype of column EMISSION does not match str for parameter EmissionActivityRatio
INFO:root:dtype of column MODE_OF_OPERATION does not match int for parameter EmissionActivityRatio
INFO:root:dtype of column YEAR does not match int for parameter EmissionActivityRatio
INFO:root:Checking datatypes for EmissionsPenalty
INFO:root:dtype of column REGION does not match str for parameter EmissionsPenalty
INFO:root:dtype of column EMISSION does not match str for parameter EmissionsPenalty
INFO:root:dtype of column YEAR does not match int for parameter EmissionsPenalty
INFO:root:dtype of column VALUE does not match float for parameter EmissionsPenalty
INFO:root:Checking datatypes for FixedCost
INFO:root:dtype of column REGION does not match str for parameter FixedCost
INFO:root:dtype of column TECHNOLOGY does not match str for parameter FixedCost
INFO:root:dtype of column YEAR does not match int for parameter FixedCost
INFO:root:dtype does not match str for set FUEL
INFO:root:Checking datatypes for InputActivityRatio
INFO:root:dtype of column REGION does not match str for parameter InputActivityRatio
INFO:root:dtype of column TECHNOLOGY does not match str for parameter InputActivityRatio
INFO:root:dtype of column FUEL does not match str for parameter InputActivityRatio
INFO:root:dtype of column MODE_OF_OPERATION does not match int for parameter InputActivityRatio
INFO:root:dtype of column YEAR does not match int for parameter InputActivityRatio
INFO:root:Checking datatypes for MinStorageCharge
INFO:root:dtype of column REGION does not match str for parameter MinStorageCharge
INFO:root:dtype of column STORAGE does not match str for parameter MinStorageCharge
INFO:root:dtype of column YEAR does not match int for parameter MinStorageCharge
INFO:root:dtype of column VALUE does not match float for parameter MinStorageCharge
INFO:root:Checking datatypes for ModelPeriodEmissionLimit
INFO:root:dtype of column REGION does not match str for parameter ModelPeriodEmissionLimit
INFO:root:dtype of column EMISSION does not match str for parameter ModelPeriodEmissionLimit
INFO:root:dtype of column VALUE does not match float for parameter ModelPeriodEmissionLimit
INFO:root:Checking datatypes for ModelPeriodExogenousEmission
INFO:root:dtype of column REGION does not match str for parameter ModelPeriodExogenousEmission
INFO:root:dtype of column EMISSION does not match str for parameter ModelPeriodExogenousEmission
INFO:root:dtype of column VALUE does not match float for parameter ModelPeriodExogenousEmission
INFO:root:Checking datatypes for OperationalLife
INFO:root:dtype of column REGION does not match str for parameter OperationalLife
INFO:root:dtype of column TECHNOLOGY does not match str for parameter OperationalLife
INFO:root:Checking datatypes for OperationalLifeStorage
INFO:root:dtype of column REGION does not match str for parameter OperationalLifeStorage
INFO:root:dtype of column STORAGE does not match str for parameter OperationalLifeStorage
INFO:root:dtype of column VALUE does not match float for parameter OperationalLifeStorage
INFO:root:Checking datatypes for OutputActivityRatio
INFO:root:dtype of column REGION does not match str for parameter OutputActivityRatio
INFO:root:dtype of column TECHNOLOGY does not match str for parameter OutputActivityRatio
INFO:root:dtype of column FUEL does not match str for parameter OutputActivityRatio
INFO:root:dtype of column MODE_OF_OPERATION does not match int for parameter OutputActivityRatio
INFO:root:dtype of column YEAR does not match int for parameter OutputActivityRatio
INFO:root:dtype does not match str for set REGION
INFO:root:Checking datatypes for REMinProductionTarget
INFO:root:dtype of column REGION does not match str for parameter REMinProductionTarget
INFO:root:dtype of column YEAR does not match int for parameter REMinProductionTarget
INFO:root:dtype of column VALUE does not match float for parameter REMinProductionTarget
INFO:root:Checking datatypes for ReserveMargin
INFO:root:dtype of column REGION does not match str for parameter ReserveMargin
INFO:root:dtype of column YEAR does not match int for parameter ReserveMargin
INFO:root:dtype of column VALUE does not match float for parameter ReserveMargin
INFO:root:Checking datatypes for ReserveMarginTagFuel
INFO:root:dtype of column REGION does not match str for parameter ReserveMarginTagFuel
INFO:root:dtype of column FUEL does not match str for parameter ReserveMarginTagFuel
INFO:root:dtype of column YEAR does not match int for parameter ReserveMarginTagFuel
INFO:root:dtype of column VALUE does not match float for parameter ReserveMarginTagFuel
INFO:root:Checking datatypes for ReserveMarginTagTechnology
INFO:root:dtype of column REGION does not match str for parameter ReserveMarginTagTechnology
INFO:root:dtype of column TECHNOLOGY does not match str for parameter ReserveMarginTagTechnology
INFO:root:dtype of column YEAR does not match int for parameter ReserveMarginTagTechnology
INFO:root:dtype of column VALUE does not match float for parameter ReserveMarginTagTechnology
INFO:root:Checking datatypes for ResidualCapacity
INFO:root:dtype of column REGION does not match str for parameter ResidualCapacity
INFO:root:dtype of column TECHNOLOGY does not match str for parameter ResidualCapacity
INFO:root:dtype of column YEAR does not match int for parameter ResidualCapacity
INFO:root:Checking datatypes for ResidualStorageCapacity
INFO:root:dtype of column REGION does not match str for parameter ResidualStorageCapacity
INFO:root:dtype of column STORAGE does not match str for parameter ResidualStorageCapacity
INFO:root:dtype of column YEAR does not match int for parameter ResidualStorageCapacity
INFO:root:dtype of column VALUE does not match float for parameter ResidualStorageCapacity
INFO:root:Checking datatypes for RETagFuel
INFO:root:dtype of column REGION does not match str for parameter RETagFuel
INFO:root:dtype of column FUEL does not match str for parameter RETagFuel
INFO:root:dtype of column YEAR does not match int for parameter RETagFuel
INFO:root:dtype of column VALUE does not match float for parameter RETagFuel
INFO:root:Checking datatypes for RETagTechnology
INFO:root:dtype of column REGION does not match str for parameter RETagTechnology
INFO:root:dtype of column TECHNOLOGY does not match str for parameter RETagTechnology
INFO:root:dtype of column YEAR does not match int for parameter RETagTechnology
INFO:root:Checking datatypes for SpecifiedAnnualDemand
INFO:root:dtype of column REGION does not match str for parameter SpecifiedAnnualDemand
INFO:root:dtype of column FUEL does not match str for parameter SpecifiedAnnualDemand
INFO:root:dtype of column YEAR does not match int for parameter SpecifiedAnnualDemand
INFO:root:Checking datatypes for SpecifiedDemandProfile
INFO:root:dtype of column REGION does not match str for parameter SpecifiedDemandProfile
INFO:root:dtype of column FUEL does not match str for parameter SpecifiedDemandProfile
INFO:root:dtype of column TIMESLICE does not match str for parameter SpecifiedDemandProfile
INFO:root:dtype of column YEAR does not match int for parameter SpecifiedDemandProfile
INFO:root:dtype does not match str for set STORAGE
INFO:root:Checking datatypes for StorageLevelStart
INFO:root:dtype of column REGION does not match str for parameter StorageLevelStart
INFO:root:dtype of column STORAGE does not match str for parameter StorageLevelStart
INFO:root:dtype of column VALUE does not match float for parameter StorageLevelStart
INFO:root:Checking datatypes for StorageMaxChargeRate
INFO:root:dtype of column REGION does not match str for parameter StorageMaxChargeRate
INFO:root:dtype of column STORAGE does not match str for parameter StorageMaxChargeRate
INFO:root:dtype of column VALUE does not match float for parameter StorageMaxChargeRate
INFO:root:Checking datatypes for StorageMaxDischargeRate
INFO:root:dtype of column REGION does not match str for parameter StorageMaxDischargeRate
INFO:root:dtype of column STORAGE does not match str for parameter StorageMaxDischargeRate
INFO:root:dtype of column VALUE does not match float for parameter StorageMaxDischargeRate
INFO:root:dtype does not match str for set TECHNOLOGY
INFO:root:Checking datatypes for TechnologyFromStorage
INFO:root:dtype of column REGION does not match str for parameter TechnologyFromStorage
INFO:root:dtype of column TECHNOLOGY does not match str for parameter TechnologyFromStorage
INFO:root:dtype of column STORAGE does not match str for parameter TechnologyFromStorage
INFO:root:dtype of column MODE_OF_OPERATION does not match int for parameter TechnologyFromStorage
INFO:root:Checking datatypes for TechnologyToStorage
INFO:root:dtype of column REGION does not match str for parameter TechnologyToStorage
INFO:root:dtype of column TECHNOLOGY does not match str for parameter TechnologyToStorage
INFO:root:dtype of column STORAGE does not match str for parameter TechnologyToStorage
INFO:root:dtype of column MODE_OF_OPERATION does not match int for parameter TechnologyToStorage
INFO:root:dtype does not match str for set TIMESLICE
INFO:root:Checking datatypes for TotalAnnualMaxCapacity
INFO:root:dtype of column REGION does not match str for parameter TotalAnnualMaxCapacity
INFO:root:dtype of column TECHNOLOGY does not match str for parameter TotalAnnualMaxCapacity
INFO:root:dtype of column YEAR does not match int for parameter TotalAnnualMaxCapacity
INFO:root:Checking datatypes for TotalAnnualMaxCapacityInvestment
INFO:root:dtype of column REGION does not match str for parameter TotalAnnualMaxCapacityInvestment
INFO:root:dtype of column TECHNOLOGY does not match str for parameter TotalAnnualMaxCapacityInvestment
INFO:root:dtype of column YEAR does not match int for parameter TotalAnnualMaxCapacityInvestment
INFO:root:Checking datatypes for TotalAnnualMinCapacity
INFO:root:dtype of column REGION does not match str for parameter TotalAnnualMinCapacity
INFO:root:dtype of column TECHNOLOGY does not match str for parameter TotalAnnualMinCapacity
INFO:root:dtype of column YEAR does not match int for parameter TotalAnnualMinCapacity
INFO:root:dtype of column VALUE does not match float for parameter TotalAnnualMinCapacity
INFO:root:Checking datatypes for TotalAnnualMinCapacityInvestment
INFO:root:dtype of column REGION does not match str for parameter TotalAnnualMinCapacityInvestment
INFO:root:dtype of column TECHNOLOGY does not match str for parameter TotalAnnualMinCapacityInvestment
INFO:root:dtype of column YEAR does not match int for parameter TotalAnnualMinCapacityInvestment
INFO:root:dtype of column VALUE does not match float for parameter TotalAnnualMinCapacityInvestment
INFO:root:Checking datatypes for TotalTechnologyAnnualActivityLowerLimit
INFO:root:dtype of column REGION does not match str for parameter TotalTechnologyAnnualActivityLowerLimit
INFO:root:dtype of column TECHNOLOGY does not match str for parameter TotalTechnologyAnnualActivityLowerLimit
INFO:root:dtype of column YEAR does not match int for parameter TotalTechnologyAnnualActivityLowerLimit
INFO:root:Checking datatypes for TotalTechnologyAnnualActivityUpperLimit
INFO:root:dtype of column REGION does not match str for parameter TotalTechnologyAnnualActivityUpperLimit
INFO:root:dtype of column TECHNOLOGY does not match str for parameter TotalTechnologyAnnualActivityUpperLimit
INFO:root:dtype of column YEAR does not match int for parameter TotalTechnologyAnnualActivityUpperLimit
INFO:root:Checking datatypes for TotalTechnologyModelPeriodActivityLowerLimit
INFO:root:dtype of column REGION does not match str for parameter TotalTechnologyModelPeriodActivityLowerLimit
INFO:root:dtype of column TECHNOLOGY does not match str for parameter TotalTechnologyModelPeriodActivityLowerLimit
INFO:root:dtype of column VALUE does not match float for parameter TotalTechnologyModelPeriodActivityLowerLimit
INFO:root:Checking datatypes for TotalTechnologyModelPeriodActivityUpperLimit
INFO:root:dtype of column REGION does not match str for parameter TotalTechnologyModelPeriodActivityUpperLimit
INFO:root:dtype of column TECHNOLOGY does not match str for parameter TotalTechnologyModelPeriodActivityUpperLimit
INFO:root:dtype of column VALUE does not match float for parameter TotalTechnologyModelPeriodActivityUpperLimit
INFO:root:Checking datatypes for TradeRoute
INFO:root:dtype of column REGION does not match str for parameter TradeRoute
INFO:root:dtype of column FUEL does not match str for parameter TradeRoute
INFO:root:dtype of column YEAR does not match int for parameter TradeRoute
INFO:root:dtype of column VALUE does not match float for parameter TradeRoute
INFO:root:Checking datatypes for VariableCost
INFO:root:dtype of column REGION does not match str for parameter VariableCost
INFO:root:dtype of column TECHNOLOGY does not match str for parameter VariableCost
INFO:root:dtype of column MODE_OF_OPERATION does not match int for parameter VariableCost
INFO:root:dtype of column YEAR does not match int for parameter VariableCost
INFO:root:Checking datatypes for YearSplit
INFO:root:dtype of column TIMESLICE does not match str for parameter YearSplit
INFO:root:dtype of column YEAR does not match int for parameter YearSplit
INFO:otoole.results.results:Looking for AccumulatedNewCapacity
INFO:otoole.results.results:Looking for AnnualEmissions
INFO:otoole.results.results:Looking for AnnualFixedOperatingCost
INFO:otoole.results.results:Looking for AnnualTechnologyEmission
INFO:otoole.results.results:Looking for AnnualTechnologyEmissionByMode
INFO:otoole.results.results:Looking for AnnualVariableOperatingCost
INFO:otoole.results.results:Looking for CapitalInvestment
INFO:otoole.results.results:No calculation method available for CapitalInvestment
INFO:otoole.results.results:Looking for Demand
INFO:otoole.results.results:Looking for DiscountedSalvageValue
INFO:otoole.results.results:Looking for DiscountedTechnologyEmissionsPenalty
                                                              VALUE
REGION     TECHNOLOGY     EMISSION MODE_OF_OPERATION YEAR          
SIMPLICITY GAS_EXTRACTION CO2      1                 2014  0.236102
           IMPDSL         CO2      1                 2014  0.099056
Empty DataFrame
Columns: [VALUE]
Index: []
['SIMPLICITY']
[2014]
Empty DataFrame
Columns: [VALUE]
Index: []
Traceback (most recent call last):
  File "/home/trevorb1/miniconda3/envs/step/bin/otoole", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/trevorb1/miniconda3/envs/step/lib/python3.11/site-packages/otoole/cli.py", line 470, in main
    args.func(args)
  File "/home/trevorb1/miniconda3/envs/step/lib/python3.11/site-packages/otoole/cli.py", line 165, in result_matrix
    context.convert(args.from_path, args.to_path, input_data=input_data)
  File "/home/trevorb1/miniconda3/envs/step/lib/python3.11/site-packages/otoole/input.py", line 113, in convert
    inputs, default_values = self._read(input_filepath, **kwargs)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trevorb1/miniconda3/envs/step/lib/python3.11/site-packages/otoole/input.py", line 95, in _read
    return self._read_strategy.read(filepath, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trevorb1/miniconda3/envs/step/lib/python3.11/site-packages/otoole/results/results.py", line 45, in read
    results = self.calculate_results(
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trevorb1/miniconda3/envs/step/lib/python3.11/site-packages/otoole/results/results.py", line 70, in calculate_results
    results[name] = results_package[name]
                    ~~~~~~~~~~~~~~~^^^^^^
  File "/home/trevorb1/miniconda3/envs/step/lib/python3.11/site-packages/otoole/results/result_package.py", line 96, in __getitem__
    results = self.result_mapper[name]()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trevorb1/miniconda3/envs/step/lib/python3.11/site-packages/otoole/results/result_package.py", line 394, in discounted_tech_emis_pen
    data = emissions_penalty.div(discount_factor_mid, fill_value=0.0)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trevorb1/miniconda3/envs/step/lib/python3.11/site-packages/pandas/core/ops/__init__.py", line 436, in f
    self, other = align_method_FRAME(self, other, axis, flex=True, level=level)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trevorb1/miniconda3/envs/step/lib/python3.11/site-packages/pandas/core/ops/__init__.py", line 287, in align_method_FRAME
    left, right = left.align(right, join="outer", level=level, copy=False)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trevorb1/miniconda3/envs/step/lib/python3.11/site-packages/pandas/core/frame.py", line 5090, in align
    return super().align(
           ^^^^^^^^^^^^^^
  File "/home/trevorb1/miniconda3/envs/step/lib/python3.11/site-packages/pandas/core/generic.py", line 9440, in align
    return self._align_frame(
           ^^^^^^^^^^^^^^^^^^
  File "/home/trevorb1/miniconda3/envs/step/lib/python3.11/site-packages/pandas/core/generic.py", line 9487, in _align_frame
    join_index, ilidx, iridx = self.index.join(
                               ^^^^^^^^^^^^^^^^
  File "/home/trevorb1/miniconda3/envs/step/lib/python3.11/site-packages/pandas/util/_decorators.py", line 331, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/trevorb1/miniconda3/envs/step/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 228, in join
    join_index, lidx, ridx = meth(self, other, how=how, level=level, sort=sort)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trevorb1/miniconda3/envs/step/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 4615, in join
    return self._join_multi(other, how=how)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trevorb1/miniconda3/envs/step/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 4757, in _join_multi
    join_idx, lidx, ridx = self_jnlevels.join(
                           ^^^^^^^^^^^^^^^^^^^
  File "/home/trevorb1/miniconda3/envs/step/lib/python3.11/site-packages/pandas/util/_decorators.py", line 331, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/trevorb1/miniconda3/envs/step/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 228, in join
    join_index, lidx, ridx = meth(self, other, how=how, level=level, sort=sort)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trevorb1/miniconda3/envs/step/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 4665, in join
    return self._join_monotonic(other, how=how)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trevorb1/miniconda3/envs/step/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 5023, in _join_monotonic
    join_array, lidx, ridx = self._outer_indexer(other)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trevorb1/miniconda3/envs/step/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 387, in _outer_indexer
    joined_ndarray, lidx, ridx = libjoin.outer_join_indexer(sv, ov)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "pandas/_libs/join.pyx", line 580, in pandas._libs.join.outer_join_indexer
TypeError: '<' not supported between instances of 'str' and 'int'

Operating System

Linux

What version of otoole are you running?

1.0.3

Possible Solution

The error points to this location in the code with line 389 throwing the actual error.

https://github.com/OSeMOSYS/otoole/blob/56baf80da81b03f13ff772cab5664cc7967d1fa8/src/otoole/results/result_package.py#L363-L394

If you print out the variables is the try block, these are them below:

INFO:otoole.results.results:Looking for DiscountedTechnologyEmissionsPenalty
# annual_technology_emission_by_mode
                                                              VALUE
REGION     TECHNOLOGY     EMISSION MODE_OF_OPERATION YEAR          
SIMPLICITY GAS_EXTRACTION CO2      1                 2014  0.236102
           IMPDSL         CO2      1                 2014  0.099056

# emission_penalty
Empty DataFrame
Columns: [VALUE]
Index: []

# regions
['UTOPIA']

# years
[2010]

# discount_rate
Empty DataFrame
Columns: [VALUE]
Index: []

This seems correct, so idk whats going on 😅

Anything else?

OSeMOSYS.txt simplicity.txt

config.yaml

AccumulatedAnnualDemand:
    indices: [REGION,FUEL,YEAR]
    type: param
    dtype: float
    default: 0
AnnualEmissionLimit:
    indices: [REGION,EMISSION,YEAR]
    type: param
    dtype: float
    default: -1
AnnualExogenousEmission:
    indices: [REGION,EMISSION,YEAR]
    type: param
    dtype: float
    default: 0
AvailabilityFactor:
    indices: [REGION,TECHNOLOGY,YEAR]
    type: param
    dtype: float
    default: 1
CapacityFactor:
    indices: [REGION,TECHNOLOGY,TIMESLICE,YEAR]
    type: param
    dtype: float
    default: 1
CapacityOfOneTechnologyUnit:
    indices: [REGION,TECHNOLOGY,YEAR]
    type: param
    dtype: float
    default: 0
CapacityToActivityUnit:
    indices: [REGION,TECHNOLOGY]
    type: param
    dtype: float
    default: 1
CapitalCost:
    indices: [REGION,TECHNOLOGY,YEAR]
    type: param
    dtype: float
    default: 0
CapitalCostStorage:
    indices: [REGION,STORAGE,YEAR]
    type: param
    dtype: float
    default: 0
Conversionld:
    indices: [TIMESLICE,DAYTYPE]
    type: param
    dtype: float
    default: 0
Conversionlh:
    indices: [TIMESLICE,DAILYTIMEBRACKET]
    type: param
    dtype: float
    default: 0
Conversionls:
    indices: [TIMESLICE,SEASON]
    type: param
    dtype: float
    default: 0
DAILYTIMEBRACKET:
    dtype: int
    type: set
DaysInDayType:
    indices: [SEASON,DAYTYPE,YEAR]
    type: param
    dtype: float
    default: 7
DaySplit:
    indices: [DAILYTIMEBRACKET,YEAR]
    type: param
    dtype: float
    default: 0.00137
DAYTYPE:
    dtype: int
    type: set
DepreciationMethod:
    indices: [REGION]
    type: param
    dtype: float
    default: 1
DiscountRate:
    indices: [REGION]
    type: param
    dtype: float
    default: 0.05
DiscountRateStorage:
    indices: [REGION,STORAGE]
    type: param
    dtype: float
    default: 0.05
EMISSION:
    dtype: str
    type: set
EmissionActivityRatio:
    indices: [REGION,TECHNOLOGY,EMISSION,MODE_OF_OPERATION,YEAR]
    type: param
    dtype: float
    default: 0
EmissionsPenalty:
    indices: [REGION,EMISSION,YEAR]
    type: param
    dtype: float
    default: 0
FixedCost:
    indices: [REGION,TECHNOLOGY,YEAR]
    type: param
    dtype: float
    default: 0
FUEL:
    dtype: str
    type: set
InputActivityRatio:
    indices: [REGION,TECHNOLOGY,FUEL,MODE_OF_OPERATION,YEAR]
    type: param
    dtype: float
    default: 0
MinStorageCharge:
    indices: [REGION,STORAGE,YEAR]
    type: param
    dtype: float
    default: 0
MODE_OF_OPERATION:
    dtype: int
    type: set
ModelPeriodEmissionLimit:
    indices: [REGION,EMISSION]
    type: param
    dtype: float
    default: -1
ModelPeriodExogenousEmission:
    indices: [REGION,EMISSION]
    type: param
    dtype: float
    default: 0
OperationalLife:
    indices: [REGION,TECHNOLOGY]
    type: param
    dtype: float
    default: 1
OperationalLifeStorage:
    indices: [REGION,STORAGE]
    type: param
    dtype: float
    default: 0
OutputActivityRatio:
    indices: [REGION,TECHNOLOGY,FUEL,MODE_OF_OPERATION,YEAR]
    type: param
    dtype: float
    default: 0
REGION:
    dtype: str
    type: set
REMinProductionTarget:
    indices: [REGION,YEAR]
    type: param
    dtype: float
    default: 0
ReserveMargin:
    indices: [REGION,YEAR]
    type: param
    dtype: float
    default: 1
ReserveMarginTagFuel:
    indices: [REGION,FUEL,YEAR]
    type: param
    dtype: float
    default: 0
ReserveMarginTagTechnology:
    indices: [REGION,TECHNOLOGY,YEAR]
    type: param
    dtype: float
    default: 0
ResidualCapacity:
    indices: [REGION,TECHNOLOGY,YEAR]
    type: param
    dtype: float
    default: 0
ResidualStorageCapacity:
    indices: [REGION,STORAGE,YEAR]
    type: param
    dtype: float
    default: 999
RETagFuel:
    indices: [REGION,FUEL,YEAR]
    type: param
    dtype: float
    default: 0
RETagTechnology:
    indices: [REGION,TECHNOLOGY,YEAR]
    type: param
    dtype: float
    default: 0
SEASON:
    dtype: int
    type: set
SpecifiedAnnualDemand:
    indices: [REGION,FUEL,YEAR]
    type: param
    dtype: float
    default: 0
SpecifiedDemandProfile:
    indices: [REGION,FUEL,TIMESLICE,YEAR]
    type: param
    dtype: float
    default: 0
STORAGE:
    dtype: str
    type: set
StorageLevelStart:
    indices: [REGION,STORAGE]
    type: param
    dtype: float
    default: 0
StorageMaxChargeRate:
    indices: [REGION,STORAGE]
    type: param
    dtype: float
    default: 0
StorageMaxDischargeRate:
    indices: [REGION,STORAGE]
    type: param
    dtype: float
    default: 0
TECHNOLOGY:
    dtype: str
    type: set
TechnologyFromStorage:
    indices: [REGION,TECHNOLOGY,STORAGE,MODE_OF_OPERATION]
    type: param
    dtype: float
    default: 0
TechnologyToStorage:
    indices: [REGION,TECHNOLOGY,STORAGE,MODE_OF_OPERATION]
    type: param
    dtype: float
    default: 0
TIMESLICE:
    dtype: str
    type: set
TotalAnnualMaxCapacity:
    indices: [REGION,TECHNOLOGY,YEAR]
    type: param
    dtype: float
    default: -1
TotalAnnualMaxCapacityInvestment:
    short_name: TotalAnnualMaxCapacityInvestmen
    indices: [REGION,TECHNOLOGY,YEAR]
    type: param
    dtype: float
    default: -1
TotalAnnualMinCapacity:
    indices: [REGION,TECHNOLOGY,YEAR]
    type: param
    dtype: float
    default: 0
TotalAnnualMinCapacityInvestment:
    short_name: TotalAnnualMinCapacityInvestmen
    indices: [REGION,TECHNOLOGY,YEAR]
    type: param
    dtype: float
    default: 0
TotalTechnologyAnnualActivityLowerLimit:
    short_name: TotalTechnologyAnnualActivityLo
    indices: [REGION,TECHNOLOGY,YEAR]
    type: param
    dtype: float
    default: 0
TotalTechnologyAnnualActivityUpperLimit:
    short_name: TotalTechnologyAnnualActivityUp
    indices: [REGION,TECHNOLOGY,YEAR]
    type: param
    dtype: float
    default: -1
TotalTechnologyModelPeriodActivityLowerLimit:
    short_name: TotalTechnologyModelPeriodActLo
    indices: [REGION,TECHNOLOGY]
    type: param
    dtype: float
    default: 0
TotalTechnologyModelPeriodActivityUpperLimit:
    short_name: TotalTechnologyModelPeriodActUp
    indices: [REGION,TECHNOLOGY]
    type: param
    dtype: float
    default: -1
TradeRoute:
    indices: [REGION,FUEL,YEAR]
    type: param
    dtype: float
    default: 0
VariableCost:
    indices: [REGION,TECHNOLOGY,MODE_OF_OPERATION,YEAR]
    type: param
    dtype: float
    default: 0
YEAR:
    dtype: int
    type: set
YearSplit:
    indices: [TIMESLICE,YEAR]
    type: param
    dtype: float
    default: 0
AnnualEmissions:
    indices: [REGION,EMISSION,YEAR]
    type: result
    dtype: float
    default: 0
    calculated: True
AccumulatedNewCapacity:
    indices: [REGION, TECHNOLOGY, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: True
AnnualFixedOperatingCost:
    indices: [REGION, TECHNOLOGY, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: True
AnnualTechnologyEmission:
    indices: [REGION, TECHNOLOGY, EMISSION, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: True
AnnualTechnologyEmissionByMode:
    indices: [REGION, TECHNOLOGY, EMISSION, MODE_OF_OPERATION, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: True
AnnualVariableOperatingCost:
    indices: [REGION, TECHNOLOGY, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: True
CapitalInvestment:
    indices: [REGION, TECHNOLOGY, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: True
Demand:
    indices: [REGION, TIMESLICE, FUEL, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: True
DiscountedSalvageValue:
    indices: [REGION, TECHNOLOGY, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: False
DiscountedTechnologyEmissionsPenalty:
    short_name: DiscountedTechEmissionsPenalty
    indices: [REGION, TECHNOLOGY, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: False
NewCapacity:
    indices: [REGION, TECHNOLOGY, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: False
NewStorageCapacity:
    indices: [REGION, STORAGE, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: False
NumberOfNewTechnologyUnits:
    indices: [REGION, TECHNOLOGY, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: False
ProductionByTechnology:
    indices: [REGION, TIMESLICE, TECHNOLOGY, FUEL, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: True
ProductionByTechnologyAnnual:
    indices: [REGION, TECHNOLOGY, FUEL, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: True
RateOfActivity:
    indices: [REGION, TIMESLICE, TECHNOLOGY, MODE_OF_OPERATION, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: False
RateOfProductionByTechnology:
    indices: [REGION, TIMESLICE, TECHNOLOGY, FUEL, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: True
RateOfProductionByTechnologyByMode:
    short_name: RateOfProductionByTechByMode
    indices: [REGION, TIMESLICE, TECHNOLOGY, MODE_OF_OPERATION, FUEL, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: True
RateOfUseByTechnology:
    indices: [REGION, TIMESLICE, TECHNOLOGY, FUEL, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: True
RateOfUseByTechnologyByMode:
    indices: [REGION, TIMESLICE, TECHNOLOGY, MODE_OF_OPERATION, FUEL, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: True
SalvageValue:
    indices: [REGION, TECHNOLOGY, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: False
SalvageValueStorage:
    indices: [REGION, STORAGE, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: False
StorageLevelDayTypeFinish:
    indices: [REGION, STORAGE, SEASON, DAYTYPE, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: False
StorageLevelDayTypeStart:
    indices: [REGION, STORAGE, SEASON, DAYTYPE, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: False
StorageLevelSeasonStart:
    indices: [REGION, STORAGE, SEASON, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: False
StorageLevelYearStart:
    indices: [REGION, STORAGE, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: False
StorageLevelYearFinish:
    indices: [REGION, STORAGE, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: False
TotalAnnualTechnologyActivityByMode:
    short_name: TotalAnnualTechActivityByMode
    indices: [REGION, TECHNOLOGY, MODE_OF_OPERATION, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: True
TotalCapacityAnnual:
    indices: [REGION, TECHNOLOGY, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: True
TotalDiscountedCost:
    indices: [REGION,YEAR]
    type: result
    dtype: float
    default: 0
    calculated: True
TotalTechnologyAnnualActivity:
    indices: [REGION, TECHNOLOGY, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: True
TotalTechnologyModelPeriodActivity:
    short_name: TotalTechModelPeriodActivity
    indices: [REGION, TECHNOLOGY]
    type: result
    dtype: float
    default: 0
    calculated: True
Trade:
    indices: [REGION, REGION, TIMESLICE, FUEL, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: False
UseByTechnology:
    indices: [REGION, TIMESLICE, TECHNOLOGY, FUEL, YEAR]
    type: result
    dtype: float
    default: 0
    calculated: False
willu47 commented 1 year ago

Perhaps it is due to the fill_value=0.0 in line 389 data = emissions_penalty.div(discount_factor_mid, fill_value=0.0). The fill_value argument replaces missing data with the given value. I guess this is causing a divide by 0 error when no discount_factor_mid is computed.