xl2times

Open source tool to convert TIMES models specified in Excel

https://github.com/etsap-times/xl2times

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 9 committers (11.1%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.6%) to scientific vocabulary

Keywords

data-processing energy-systems-modelling open-science open-source times-model

Keywords from Contributors

large-language-model
Last synced: 6 months ago · JSON representation

Repository

Open source tool to convert TIMES models specified in Excel

Basic Info
Statistics
  • Stars: 18
  • Watchers: 4
  • Forks: 9
  • Open Issues: 39
  • Releases: 6
Topics
data-processing energy-systems-modelling open-science open-source times-model
Created about 3 years ago · Last pushed 6 months ago
Metadata Files
Readme Contributing License Code of conduct Support Authors

README.md

xl2times

xl2times is an open source tool to convert TIMES models specified in Excel to a format ready for processing by GAMS. Development of the tool originally started in a Microsoft repository with an intention to make it easier for anyone to reproduce research results on TIMES models.

TIMES is an open source energy systems model generator developed by the Energy Technology Systems Analysis Program (ETSAP) of the International Energy Agency (IEA) that is used around the world to inform energy policy. It is fully explained in the TIMES Model Documentation.

Multiple approaches to using spreadsheets for specifying TIMES models have been developed, e.g. ANSWER-TIMES and VEDA-TIMES. At present, xl2times implements partial support of the Veda approach described in the TIMES Model Documentation PART IV and Veda Documentation. Support of other approaches may be added over time.

Installation and Basic Usage

You can install the latest published version of the tool from PyPI using pip (preferably in a virtual environment): bash pip install xl2times

You can also install the latest development version by cloning this repository and running the following command in the root directory: bash pip install .

After installation, run the following command to see the basic usage and available options: bash xl2times --help

Here is an example invocation to convert the Demo 1 model into DD (you need to have the benchmarks set up, see the "Running Benchmarks" section below): sh xl2times benchmarks/xlsx/DemoS_001/ Note that by default, the tool puts the produced output DD files into a directory called output/ in the current working directory. This behavior can be changed using the --output_dir /path/to/desired/output/ argument.

Note: If you are running a huge model, and it looks like nothing is happening, try adding a -v or --verbose argument to see more detailed logs, inlcuding a message when each intermediate transform is completed.

If the tool is installed on Windows, the above commands should be prefixed by python -m.

Documentation

The tool's documentation is at http://xl2times.readthedocs.io/ and the source is in the docs/ directory.

The documentation is generated by Sphinx and hosted on ReadTheDocs. We use the following extensions: - myst-parser: to be able to write documentation in markdown - sphinx-book-theme: the theme - sphinx-copybutton: to add copy buttons to code blocks - sphinxcontrib-apidoc: to automatically generate API documentation from the Python package

Documentation can be generated locally (after setting up your development environment as described below) by: bash cd docs make html

Testing on an existing model

If you have an existing TIMES model in Excel (e.g. developed using Veda) and would like to use the tool with it, we recommend to conduct bulk testing first. Bulk testing will allow understanding how much of the syntax used in the model is supported by the tool.

Start by generating *.dd files based on AllScenario scenario group (i.e. in Veda).

Afterwards, execute the following command from the root of the tool (assumes My_Bulk_Test case name) to extract all the data from the *.dd files: bash python xl2times/dd_to_csv.py "C:\VEDA\GAMS_WrkTIMES\My_Bulk_Test" ground_truth

Finally, execute the tool on the model (e.g. My_TIMES-Model) and compare the results to the previously extracted data (assumes activated virtual environment): bash xl2times "C:\VEDA\VEDA_Models\My_TIMES-Model" --ground_truth_dir=ground_truth -v

The tool will summarise any differences between the data it generates and the extracted data.

Development

Setup

We recommend installing the tool in editable mode (-e) in a Python virtual environment: bash python3 -m venv .venv source .venv/bin/activate pip install -U pip pip install -e .[dev]

On Windows: bash python -m venv .venv ".venv/Scripts/python" -m pip install -U pip ".venv/Scripts/activate" pip install -e .[dev]

We use the black code formatter. The pip command above will install it along with other requirements.

We also use the pyright type checker -- our GitHub Actions check will fail if pyright detects any type errors in your code. You can install pyright in your virtual environment and check your code by running these commands in the root of the repository: bash pip install pyright==1.1.304 pyright Additionally, you can install a git pre-commit that will ensure that your changes are formatted and pyright detects no issues before creating new commits: bash pre-commit install If you want to skip these pre-commit steps for a particular commit, if for instance pyright has issues but you still want to commit your changes to your branch, you can run: bash git commit --no-verify

Running Benchmarks

We use the TIMES DemoS models and some public TIMES models as benchmarks. See our GitHub Actions CI .github/workflows/ci.yml and the utility script utils/run_benchmarks.py to see how to we benchmark the tool and check PRs automatically for regression. If you are a developer, you can use the below instructions to set up and run the benchmarks locally on Linux/WSL:

bash ./setup-benchmarks.sh Note that this script assumes you have access to all the relevant repositories (some are private and you'll have to request access) - if not, comment out the inaccessible benchmarks from benchmarks.yml before running.

Then to run the benchmarks: ```bash

Run a only a single benchmark by name (see benchmarks.yml for name list)

python utils/runbenchmarks.py benchmarks.yml --run DemoS001-all

To see the full output logs, and save it in a file for convenience

python utils/runbenchmarks.py benchmarks.yml --run DemoS001-all --verbose | tee out.txt

Run all benchmarks (without GAMS run, just comparing CSV data for regressions)

Note: if you have multiple remotes, set etsap-TIMES/xl2times as the origin, as it is used for speed/correctness comparisons.

python utils/run_benchmarks.py benchmarks.yml

Run benchmarks with regression tests vs main branch

git branch feature/yournewchanges --checkout

... make your code changes here ...

git commit -a -m "your commit message" # code must be committed for comparison to main branch to run. python utils/run_benchmarks.py benchmarks.yml At this point, if you haven't broken anything you should see something like: Change in runtime: +2.97s Change in correct rows: +0 Change in additional rows: +0 No regressions. You're awesome! ``` If you have a large increase in runtime, a decrease in correct rows or fewer rows being produced, then you've broken something and will need to figure out how to fix it.

Debugging Regressions

If your change is causing regressions on one of the benchmarks, a useful way to debug and find the difference is to run the tool in verbose mode and compare the intermediate tables. For example, if your branch has regressions on Demo 1: ```bash

First, on the main branch:

xl2times benchmarks/xlsx/DemoS001 --outputdir benchmarks/out/DemoS001-all --groundtruthdir benchmarks/csv/DemoS001-all -v -v > before 2>&1

Then, on your branch:

git checkout my-branch-name xl2times benchmarks/xlsx/DemoS001 --outputdir benchmarks/out/DemoS001-all --groundtruthdir benchmarks/csv/DemoS001-all -v -v > after 2>&1

And then compare the files before and after

code -d before after ``` VS Code will highlight the changes in the two files, which should correspond to any differences in the intermediate tables.

Publishing the Tool

Follow these steps to release a new version of xl2times and publish it on PyPI: - Bump the version number in pyproject.toml and xl2times/__init__.py (use Semantic Versioning) - Open a PR with this change titled "Release vX.Y.Z" - When the PR is merged, create a new release titled "vX.Y.Z". Select "Create a new tag: on publish" and click "Generate release notes" to generate the notes automatically. - Click "Publish release" to publish the release on GitHub. A GitHub Actions workflow will automatically upload the distribution to PyPI.

Contributing

This project welcomes contributions and suggestions. See Code of Conduct and Contributing for more details.

Owner

  • Name: IEA-ETSAP
  • Login: etsap-TIMES
  • Kind: organization

GitHub Events

Total
  • Create event: 80
  • Release event: 4
  • Issues event: 41
  • Watch event: 7
  • Delete event: 77
  • Issue comment event: 184
  • Push event: 427
  • Pull request review event: 145
  • Pull request review comment event: 94
  • Pull request event: 147
  • Fork event: 1
Last Year
  • Create event: 80
  • Release event: 4
  • Issues event: 41
  • Watch event: 7
  • Delete event: 77
  • Issue comment event: 184
  • Push event: 427
  • Pull request review event: 145
  • Pull request review comment event: 94
  • Pull request event: 147
  • Fork event: 1

Committers

Last synced: 6 months ago

All Time
  • Total Commits: 365
  • Total Committers: 9
  • Avg Commits per committer: 40.556
  • Development Distribution Score (DDS): 0.595
Past Year
  • Commits: 78
  • Committers: 3
  • Avg Commits per committer: 26.0
  • Development Distribution Score (DDS): 0.205
Top Committers
Name Email Commits
Olexandr Balyk ob@f****y 148
Sam Webster 1****r 104
Siddharth Krishna s****a 83
Tom Minka 8****a 13
Sam West s****t@c****u 7
Microsoft Open Source m****e 5
Niloy n****t 3
microsoft-github-operations[bot] 5****] 1
AlexRomeroPrieto 1****o 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 71
  • Total pull requests: 221
  • Average time to close issues: 4 months
  • Average time to close pull requests: 10 days
  • Total issue authors: 4
  • Total pull request authors: 4
  • Average comments per issue: 2.21
  • Average comments per pull request: 1.95
  • Merged pull requests: 189
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 21
  • Pull requests: 103
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 3 days
  • Issue authors: 3
  • Pull request authors: 2
  • Average comments per issue: 1.1
  • Average comments per pull request: 1.75
  • Merged pull requests: 87
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • olejandro (50)
  • siddharth-krishna (12)
  • samwebster (7)
  • Antti-L (2)
Pull Request Authors
  • olejandro (133)
  • siddharth-krishna (63)
  • SamRWest (14)
  • samwebster (11)
Top Labels
Issue Labels
bug (2) documentation (1) question (1)
Pull Request Labels

Packages

  • Total packages: 3
  • Total downloads:
    • pypi 36 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 0
    (may contain duplicates)
  • Total versions: 18
  • Total maintainers: 2
proxy.golang.org: github.com/etsap-times/xl2times
  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago
proxy.golang.org: github.com/etsap-TIMES/xl2times
  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago
pypi.org: xl2times

An open source tool to convert TIMES models specified in Excel to a format ready for processing by GAMS

  • Documentation: https://xl2times.readthedocs.io
  • License: MIT License Copyright (c) 2022-2023 Microsoft Corporation. Copyright (c) 2023-2024 IEA Energy Technology Systems Analysis Programme. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
  • Latest release: 0.3.0
    published 9 months ago
  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 36 Last month
Rankings
Dependent packages count: 10.1%
Average: 38.6%
Dependent repos count: 67.1%
Maintainers (2)
Last synced: 6 months ago