-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
97 changed files
with
3,253 additions
and
825 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# This workflow will upload a Python Package using Twine when a release is created | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries | ||
|
||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
|
||
name: Upload Python Package | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
deploy: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.x' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install tox | ||
- name: Build package | ||
run: tox -e build | ||
- name: Publish package | ||
run: tox -e publish | ||
env: | ||
TWINE_USERNAME: ${{ vars.TWINE_USERNAME }} | ||
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} | ||
TWINE_REPOSITORY: ${{ vars.TWINE_REPOSITORY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
# Model file written by *otoole* | ||
param default 0 : AccumulatedAnnualDemand := | ||
; | ||
param default -1 : AnnualEmissionLimit := | ||
; | ||
param default 0 : AnnualExogenousEmission := | ||
; | ||
param default 1 : AvailabilityFactor := | ||
; | ||
param default 1 : CapacityFactor := | ||
; | ||
param default 0 : CapacityOfOneTechnologyUnit := | ||
; | ||
param default 1 : CapacityToActivityUnit := | ||
R PWRWND 31.536 | ||
R PWRCOA 31.536 | ||
R TRNELC 31.536 | ||
; | ||
param default 0 : CapitalCost := | ||
R PWRWND 2020 1500 | ||
R PWRWND 2021 1500 | ||
R PWRWND 2022 1500 | ||
R PWRCOA 2020 5000 | ||
R PWRCOA 2021 5000 | ||
R PWRCOA 2022 5000 | ||
; | ||
param default 0 : CapitalCostStorage := | ||
; | ||
param default 0 : Conversionld := | ||
; | ||
param default 0 : Conversionlh := | ||
; | ||
param default 0 : Conversionls := | ||
; | ||
set DAILYTIMEBRACKET := | ||
; | ||
set DAYTYPE := | ||
; | ||
param default 0.00137 : DaySplit := | ||
; | ||
param default 7 : DaysInDayType := | ||
; | ||
param default 1 : DepreciationMethod := | ||
; | ||
param default 0.05 : DiscountRate := | ||
; | ||
param default 0.05 : DiscountRateStorage := | ||
; | ||
set EMISSION := | ||
; | ||
param default 0 : EmissionActivityRatio := | ||
; | ||
param default 0 : EmissionsPenalty := | ||
; | ||
set FUEL := | ||
WND00 | ||
COA00 | ||
ELC01 | ||
ELC02 | ||
; | ||
param default 0 : FixedCost := | ||
; | ||
param default 0 : InputActivityRatio := | ||
R PWRWND WND00 1 2020 1 | ||
R PWRWND WND00 1 2021 1 | ||
R PWRWND WND00 1 2022 1 | ||
R PWRCOA COA00 1 2020 1 | ||
R PWRCOA COA00 1 2021 1 | ||
R PWRCOA COA00 1 2022 1 | ||
R TRNELC ELC01 1 2020 1 | ||
R TRNELC ELC01 1 2021 1 | ||
R TRNELC ELC01 1 2022 1 | ||
; | ||
set MODE_OF_OPERATION := | ||
1 | ||
; | ||
param default 0 : MinStorageCharge := | ||
; | ||
param default -1 : ModelPeriodEmissionLimit := | ||
; | ||
param default 0 : ModelPeriodExogenousEmission := | ||
; | ||
param default 1 : OperationalLife := | ||
R PWRWND 20 | ||
R PWRCOA 30 | ||
; | ||
param default 0 : OperationalLifeStorage := | ||
; | ||
param default 0 : OutputActivityRatio := | ||
R MINWND WND00 1 2020 1 | ||
R MINWND WND00 1 2021 1 | ||
R MINWND WND00 1 2022 1 | ||
R MINCOA COA00 1 2020 1 | ||
R MINCOA COA00 1 2021 1 | ||
R MINCOA COA00 1 2022 1 | ||
R PWRWND ELC01 1 2020 1 | ||
R PWRWND ELC01 1 2021 1 | ||
R PWRWND ELC01 1 2022 1 | ||
R PWRCOA ELC01 1 2020 1 | ||
R PWRCOA ELC01 1 2021 1 | ||
R PWRCOA ELC01 1 2022 1 | ||
R TRNELC ELC02 1 2020 1 | ||
R TRNELC ELC02 1 2021 1 | ||
R TRNELC ELC02 1 2022 1 | ||
; | ||
set REGION := | ||
R | ||
; | ||
param default 0 : REMinProductionTarget := | ||
; | ||
param default 0 : RETagFuel := | ||
; | ||
param default 0 : RETagTechnology := | ||
; | ||
param default 1 : ReserveMargin := | ||
; | ||
param default 0 : ReserveMarginTagFuel := | ||
; | ||
param default 0 : ReserveMarginTagTechnology := | ||
; | ||
param default 0 : ResidualCapacity := | ||
R PWRCOA 2020 0.25 | ||
R PWRCOA 2021 0.25 | ||
R PWRCOA 2022 0.25 | ||
; | ||
param default 999 : ResidualStorageCapacity := | ||
; | ||
set SEASON := | ||
; | ||
set STORAGE := | ||
; | ||
param default 0 : SpecifiedAnnualDemand := | ||
R ELC02 2020 10 | ||
R ELC02 2021 15 | ||
R ELC02 2022 20 | ||
; | ||
param default 0 : SpecifiedDemandProfile := | ||
R ELC02 S 2020 0.5 | ||
R ELC02 W 2020 0.5 | ||
R ELC02 S 2021 0.5 | ||
R ELC02 W 2021 0.5 | ||
R ELC02 S 2022 0.5 | ||
R ELC02 W 2022 0.5 | ||
; | ||
param default 0 : StorageLevelStart := | ||
; | ||
param default 0 : StorageMaxChargeRate := | ||
; | ||
param default 0 : StorageMaxDischargeRate := | ||
; | ||
set TECHNOLOGY := | ||
MINWND | ||
MINCOA | ||
PWRWND | ||
PWRCOA | ||
TRNELC | ||
; | ||
set TIMESLICE := | ||
S | ||
W | ||
; | ||
param default 0 : TechnologyFromStorage := | ||
; | ||
param default 0 : TechnologyToStorage := | ||
; | ||
param default -1 : TotalAnnualMaxCapacity := | ||
; | ||
param default -1 : TotalAnnualMaxCapacityInvestment := | ||
; | ||
param default 0 : TotalAnnualMinCapacity := | ||
; | ||
param default 0 : TotalAnnualMinCapacityInvestment := | ||
; | ||
param default 0 : TotalTechnologyAnnualActivityLowerLimit := | ||
; | ||
param default -1 : TotalTechnologyAnnualActivityUpperLimit := | ||
; | ||
param default 0 : TotalTechnologyModelPeriodActivityLowerLimit := | ||
; | ||
param default -1 : TotalTechnologyModelPeriodActivityUpperLimit := | ||
; | ||
param default 0 : TradeRoute := | ||
; | ||
param default 0 : VariableCost := | ||
R MINCOA 1 2020 5 | ||
R MINCOA 1 2021 5 | ||
R MINCOA 1 2022 5 | ||
; | ||
set YEAR := | ||
2020 | ||
2021 | ||
2022 | ||
; | ||
param default 0 : YearSplit := | ||
S 2020 0.5 | ||
W 2020 0.5 | ||
S 2021 0.5 | ||
W 2021 0.5 | ||
S 2022 0.5 | ||
W 2022 0.5 | ||
; | ||
end; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
.. _convert: | ||
|
||
========== | ||
Python API | ||
========== | ||
|
||
otoole also provides a Python API to access all the features available from the command line tool. | ||
|
||
Converting between formats | ||
-------------------------- | ||
|
||
``otoole`` currently supports conversion between the following formats: | ||
|
||
- Excel | ||
- A folder of CSV files | ||
- GNU MathProg datafile | ||
|
||
>>> from otoole import convert | ||
>>> convert('my_model.yaml', 'excel', 'csv', 'my_model.xlsx', 'my_model_csvs') | ||
|
||
See :py:func:`otoole.convert.convert` for more details | ||
|
||
Converting solver results to a folder of CSV files | ||
-------------------------------------------------- | ||
|
||
The ``convert_results`` function creates a folder of CSV result files from a CBC_, CLP_, | ||
Gurobi_ or CPLEX_ solution file:: | ||
|
||
>>> from otoole import convert_results | ||
>>> convert_results('my_model.yaml', 'cbc', 'csv', 'my_model.sol', 'my_model_csvs', input_datafile='my_model.dat') | ||
|
||
See :func:`otoole.convert.convert_results` for more details | ||
|
||
Reading solver results into a dict of Pandas DataFrames | ||
------------------------------------------------------- | ||
|
||
The ``read_results`` function reads a CBC_, CLP_, | ||
Gurobi_ or CPLEX_ solution file into memory:: | ||
|
||
>>> from otoole import read_results | ||
>>> read_results('my_model.yaml', 'cbc', 'csv', 'my_model.sol', 'my_model_csvs', 'datafile', 'my_model.dat') | ||
|
||
See :func:`otoole.convert.read_results` for more details | ||
|
||
Read in data from different Formats | ||
----------------------------------- | ||
|
||
You can use the :py:func:`otoole.convert.read` function to read data in from different formats to a Python object. | ||
This allows you to then use all the features offered by Python to manipulate the data. | ||
|
||
>>> from otoole import read | ||
>>> data, defaults = read('my_model.yaml', 'csv', 'my_model_csvs') # read from a folder of csv files | ||
>>> data, defaults = read('my_model.yaml', 'excel', 'my_model.xlsx') # read from an Excel file | ||
>>> data, defaults = read('my_model.yaml', 'datafile', 'my_model.dat') # read from a GNU MathProg datafile | ||
|
||
Write out data to different Formats | ||
----------------------------------- | ||
|
||
You can use the :py:func:`otoole.convert.write` function to write data out to different formats from a Python object. | ||
|
||
>>> from otoole import read, write | ||
>>> data, defaults = read('my_model.yaml', 'csv', 'my_model_csvs') # read from a folder of csv files | ||
>>> write('my_model.yaml', 'excel', 'my_model.xlsx', data, defaults) # write to an Excel file | ||
>>> write('my_model.yaml', 'datafile', 'my_model.dat', data, defaults) # write to a GNU MathProg datafile | ||
|
||
|
||
.. _CBC: https://github.com/coin-or/Cbc | ||
.. _CLP: https://github.com/coin-or/Clp | ||
.. _CPLEX: https://www.ibm.com/products/ilog-cplex-optimization-studio/cplex-optimizer | ||
.. _Gurobi: https://www.gurobi.com/ |
Oops, something went wrong.