Metadata-Version: 2.1
Name: pybalmorel
Version: 0.1.0
Summary: A package for convenient python functions when processing Balmorel data or results
Author-email: Mathias Berg Rosendal <mathiasros@gmail.com>
Project-URL: Homepage, https://github.com/Mathias157
Project-URL: Issues, https://github.com/Mathias157/balmorel-preprocessing/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas>=2.1.4
Requires-Dist: matplotlib>=3.9.0
Requires-Dist: geopandas>=0.14.4
Requires-Dist: gamsapi[transfer]>=45.0.0
Requires-Dist: ipywidgets>=8.1.3

Convenient python functions for pre- or post-processing the GAMS framework Balmorel 

### Example of creating an .inc file
```
from pybalmorel.functions import IncFile
import pandas as pd


# Initiate .inc file class
DE = IncFile(name='DE',
            prefix="TABLE   DE1(RRR,DEUSER,YYY)   'Annual electricity consumption (MWh)'\n",
            suffix="\n;\nDE(YYY,RRR,DEUSER) = DE1(RRR,DEUSER,YYY);",
            path='Balmorel/sc1/data')


# Create annual electricity demand 
DE.body = pd.DataFrame(index=['DK1', 'DK2'], columns=[2030, 2040, 2050],
                       data=[[17e6, 20e6, 25e6],
                            [14e6, 17e6, 20e6]])

# Fix the index format (in this case, append the DEUSER set to RRR)
DE.body.index += ' . RESE'

# Save .inc file to path (will save as ./Balmorel/sc1/data/DE.inc)
DE.save()
```

### Example of loading results from a .gdx file
```
import gams
import os
from pybalmorel.functions import symbol_to_df
import pandas as pd


# Load .gdx file
ws = gams.GamsWorkspace()
db = ws.add_database_from_gdx(os.path.abspath('Balmorel/base/model/MainResults_Base.gdx'))

# Load the annual production into a pandas DataFrame
pro = symbol_to_df(db, 'PRO_YCRAGF', cols=['Y', 'C', 'R', 'A', 'G', 'F', 
                                           'Commodity', 'Tech', 'Unit', 'Value'])
```
