Skip to content

Commit

Permalink
Merge branch 'master' into joss
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorb1 committed Aug 29, 2023
2 parents 115532c + 89baeed commit b15c807
Show file tree
Hide file tree
Showing 97 changed files with 3,253 additions and 825 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/python-publish.yml
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 }}
6 changes: 2 additions & 4 deletions .github/workflows/python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
Expand All @@ -20,12 +20,10 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install tox
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install -e .
- name: Lint with flake8
run: |
tox -e lint
- name: Test with pytest
- name: Run tests using tox
run: |
tox
- name: Upload coverage data to converalls.io
Expand Down
10 changes: 5 additions & 5 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ version: 2
sphinx:
configuration: docs/conf.py

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF
formats:
- pdf

python:
version: 3.8
install:
- requirements: docs/requirements.txt
- {path: ., method: pip}

build:
os: ubuntu-22.04
tools:
python: "3.11"
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Changelog
=========

Version 1.0.4
=============
- Fixed issue with pydantic v2.0.0
- Dropped support for Python 3.8. Otoole now requires Python 3.9 or later

Version 1.0.3
=============
- Improved error message for multiple names mismatches
Expand Down
202 changes: 202 additions & 0 deletions docs/_static/validation-data.txt
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;
10 changes: 5 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@
"path_to_docs": "docs",
"use_repository_button": True,
"use_edit_page_button": True,
"extra_navbar":
"""
<p>Theme by the <a href="https://executablebooks.org/en/latest/">Executable Book Project</a></p>
<p>Logo by <a href="https://looka.com/">looka.com</a></p>
""",
# "extra_navbar":
# """
# <p>Theme by the <a href="https://executablebooks.org/en/latest/">Executable Book Project</a></p>
# <p>Logo by <a href="https://looka.com/">looka.com</a></p>
# """,
"icon_links": [],
}

Expand Down
70 changes: 70 additions & 0 deletions docs/convert.rst
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/
Loading

0 comments on commit b15c807

Please sign in to comment.