OMIEData


NameOMIEData JSON
Version 0.2.0.0 PyPI version JSON
download
home_pagehttps://github.com/acruzgarcia/OMIEData
SummaryPackage to download electricity time series from https://www.omie.es/
upload_time2023-05-02 21:44:50
maintainer
docs_urlNone
authorAlberto Cruz and Mirel Mora
requires_python>=3.11
license
keywords omie electricity prices
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # OMIEData: 

[![made-with-python](https://img.shields.io/badge/Made%20with-Python-1f425f.svg)](https://www.python.org/)
[![PyPI version fury.io](https://img.shields.io/pypi/v/OMIEData.svg)](https://pypi.org/project/OMIEData/)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/OMIEData.svg)](https://www.python.org/)

Python package to import data from OMIE (Iberian Peninsula's Electricity Market Operator): https://www.omie.es/

Concretely, you can easily access to data for the following markets:

- Daily market: hourly prices in Spain and Portugal, total hourly energy after auction (with/without billateral contracts), breakdown of the total hourly energy by technology and bid/ask curves.
- Intra-day market: hourly prices for the different sessions and total hourly energy.
- Additional data in next releases.


## Installation 

The package is uploaded at https://pypi.org/project/OMIEData/, so

```python
python -m pip install OMIEData

```
from the command line will install the last version uploaded to pypi. 

Aternatively, to install it from GitHub repository, type:

```python
python -m pip install git+https://github.com/acruzgarcia/OMIEData

```

in the command line. You can also install the .whl or .tar.gz files within [dist](https://github.com/acruzgarcia/OMIEData/tree/dev/dist) as:

```python
python -m pip install OMIEData-VERSION-py3-none-any.whl

```
or

```python
python -m pip install OMIEData-VERSION.tar.gz

```

or to install a previous version from [dist_old](https://github.com/acruzgarcia/OMIEData/tree/dev/dist_old).

## Examples:

A very simple example to download hourly electricity prices and demand:

```python
import datetime as dt
import matplotlib.pyplot as plt

from OMIEData.DataImport.omie_marginalprice_importer import OMIEMarginalPriceFileImporter
from OMIEData.Enums.all_enums import DataTypeInMarginalPriceFile

dateIni = dt.datetime(2020, 1, 1)
dateEnd = dt.datetime(2022, 3, 22)

# This can take time, it is downloading the files from the website..
df = OMIEMarginalPriceFileImporter(date_ini=dateIni, date_end=dateEnd).read_to_dataframe(verbose=True)
df.sort_values(by='DATE', axis=0, inplace=True)
print(df)
```
The code will generate a data-frame like the following one:

```python
            DATE         CONCEPT        H1  ...       H22       H23       H24
0     2020-01-01        PRICE_SP     41.88  ...     45.60     42.90     37.55
1     2020-01-01        PRICE_PT     41.88  ...     45.60     42.90     37.55
2     2020-01-01         ENER_IB  18132.30  ...  22492.60  21800.90  19946.30
3     2020-01-01  ENER_IB_BILLAT  26488.50  ...  32611.70  31523.70  29088.30
4     2020-01-02        PRICE_SP     35.40  ...     42.00     38.60     33.39
          ...             ...       ...  ...       ...       ...       ...
3241  2022-03-21        PRICE_PT    218.69  ...    261.44    240.29    228.88
3245  2022-03-22        PRICE_PT    223.00  ...    256.00    242.18    212.99
3246  2022-03-22         ENER_IB  20652.20  ...  27113.50  24167.60  21841.50
3244  2022-03-22        PRICE_SP    223.00  ...    256.00    242.18    212.99
3247  2022-03-22  ENER_IB_BILLAT  29840.30  ...  38281.20  34781.90  31872.50
[3248 rows x 26 columns]
```

You can filter the data-frame to have only the prices in spain, and then plot

```python
# Just prices in spain
str_price_spain = str(DataTypeInMarginalPriceFile.PRICE_SPAIN)
dfPrices = df[df.CONCEPT == str_price_spain]

# Plotting
plt.figure()
plt.plot(dfPrices.DATE, dfPrices.H12, label='H12')
plt.plot(dfPrices.DATE, dfPrices.H23, label='H23')
plt.legend()
plt.show()
```

which will produce the following plot:

![alt text](https://github.com/acruzgarcia/OMIEData/blob/dev/images/PricesSP_H12_23.png)

Another example to download hourly demand resulting of the daily market auction, breakdown by technologies:

```python
import datetime as dt
from OMIEData.Enums.all_enums import SystemType
from OMIEData.DataImport.omie_energy_by_technology_importer import OMIEEnergyByTechnologyImporter

dateIni = dt.datetime(2020, 6, 1)
dateEnd = dt.datetime(2020, 7, 30)
system_type = SystemType.SPAIN

# This can take time, it is downloading the files from the website..
df = OMIEEnergyByTechnologyImporter(date_ini=dateIni,
                                    date_end=dateEnd,
                                    system_type=system_type).read_to_dataframe(verbose=True)
df.sort_values(by=['DATE', 'HOUR'], axis=0, inplace=True)
print(df)
```

Another example to download supply/demand curves:

```python
import datetime as dt
from OMIEData.DataImport.omie_supply_demand_curve_importer import OMIESupplyDemandCurvesImporter

dateIni = dt.datetime(2020, 6, 1)
dateEnd = dt.datetime(2020, 6, 1)
hour = 1

# This can take time, it is downloading the files from the website..
df = OMIESupplyDemandCurvesImporter(date_ini=dateIni, date_end=dateEnd, hour=hour).read_to_dataframe(verbose=True)
df.sort_values(by=['DATE', 'HOUR'], axis=0, inplace=True)
print(df)
```

Other examples that illustrate the use of the package in here:

- [examples folder](https://github.com/acruzgarcia/OMIEData/tree/dev/examples)

Enjoy!.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/acruzgarcia/OMIEData",
    "name": "OMIEData",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": "",
    "keywords": "OMIE,Electricity prices",
    "author": "Alberto Cruz and Mirel Mora",
    "author_email": "a.cruz.garcia@gmail.com, mirel.mora@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/0d/9c/a635fef71e5ffe3a2a00070997b597323bf1c6d5bb6c7c3cb7e6ce75d28a/OMIEData-0.2.0.0.tar.gz",
    "platform": null,
    "description": "# OMIEData: \r\n\r\n[![made-with-python](https://img.shields.io/badge/Made%20with-Python-1f425f.svg)](https://www.python.org/)\r\n[![PyPI version fury.io](https://img.shields.io/pypi/v/OMIEData.svg)](https://pypi.org/project/OMIEData/)\r\n[![PyPI pyversions](https://img.shields.io/pypi/pyversions/OMIEData.svg)](https://www.python.org/)\r\n\r\nPython package to import data from OMIE (Iberian Peninsula's Electricity Market Operator): https://www.omie.es/\r\n\r\nConcretely, you can easily access to data for the following markets:\r\n\r\n- Daily market: hourly prices in Spain and Portugal, total hourly energy after auction (with/without billateral contracts), breakdown of the total hourly energy by technology and bid/ask curves.\r\n- Intra-day market: hourly prices for the different sessions and total hourly energy.\r\n- Additional data in next releases.\r\n\r\n\r\n## Installation \r\n\r\nThe package is uploaded at https://pypi.org/project/OMIEData/, so\r\n\r\n```python\r\npython -m pip install OMIEData\r\n\r\n```\r\nfrom the command line will install the last version uploaded to pypi. \r\n\r\nAternatively, to install it from GitHub repository, type:\r\n\r\n```python\r\npython -m pip install git+https://github.com/acruzgarcia/OMIEData\r\n\r\n```\r\n\r\nin the command line. You can also install the .whl or .tar.gz files within [dist](https://github.com/acruzgarcia/OMIEData/tree/dev/dist) as:\r\n\r\n```python\r\npython -m pip install OMIEData-VERSION-py3-none-any.whl\r\n\r\n```\r\nor\r\n\r\n```python\r\npython -m pip install OMIEData-VERSION.tar.gz\r\n\r\n```\r\n\r\nor to install a previous version from [dist_old](https://github.com/acruzgarcia/OMIEData/tree/dev/dist_old).\r\n\r\n## Examples:\r\n\r\nA very simple example to download hourly electricity prices and demand:\r\n\r\n```python\r\nimport datetime as dt\r\nimport matplotlib.pyplot as plt\r\n\r\nfrom OMIEData.DataImport.omie_marginalprice_importer import OMIEMarginalPriceFileImporter\r\nfrom OMIEData.Enums.all_enums import DataTypeInMarginalPriceFile\r\n\r\ndateIni = dt.datetime(2020, 1, 1)\r\ndateEnd = dt.datetime(2022, 3, 22)\r\n\r\n# This can take time, it is downloading the files from the website..\r\ndf = OMIEMarginalPriceFileImporter(date_ini=dateIni, date_end=dateEnd).read_to_dataframe(verbose=True)\r\ndf.sort_values(by='DATE', axis=0, inplace=True)\r\nprint(df)\r\n```\r\nThe code will generate a data-frame like the following one:\r\n\r\n```python\r\n            DATE         CONCEPT        H1  ...       H22       H23       H24\r\n0     2020-01-01        PRICE_SP     41.88  ...     45.60     42.90     37.55\r\n1     2020-01-01        PRICE_PT     41.88  ...     45.60     42.90     37.55\r\n2     2020-01-01         ENER_IB  18132.30  ...  22492.60  21800.90  19946.30\r\n3     2020-01-01  ENER_IB_BILLAT  26488.50  ...  32611.70  31523.70  29088.30\r\n4     2020-01-02        PRICE_SP     35.40  ...     42.00     38.60     33.39\r\n          ...             ...       ...  ...       ...       ...       ...\r\n3241  2022-03-21        PRICE_PT    218.69  ...    261.44    240.29    228.88\r\n3245  2022-03-22        PRICE_PT    223.00  ...    256.00    242.18    212.99\r\n3246  2022-03-22         ENER_IB  20652.20  ...  27113.50  24167.60  21841.50\r\n3244  2022-03-22        PRICE_SP    223.00  ...    256.00    242.18    212.99\r\n3247  2022-03-22  ENER_IB_BILLAT  29840.30  ...  38281.20  34781.90  31872.50\r\n[3248 rows x 26 columns]\r\n```\r\n\r\nYou can filter the data-frame to have only the prices in spain, and then plot\r\n\r\n```python\r\n# Just prices in spain\r\nstr_price_spain = str(DataTypeInMarginalPriceFile.PRICE_SPAIN)\r\ndfPrices = df[df.CONCEPT == str_price_spain]\r\n\r\n# Plotting\r\nplt.figure()\r\nplt.plot(dfPrices.DATE, dfPrices.H12, label='H12')\r\nplt.plot(dfPrices.DATE, dfPrices.H23, label='H23')\r\nplt.legend()\r\nplt.show()\r\n```\r\n\r\nwhich will produce the following plot:\r\n\r\n![alt text](https://github.com/acruzgarcia/OMIEData/blob/dev/images/PricesSP_H12_23.png)\r\n\r\nAnother example to download hourly demand resulting of the daily market auction, breakdown by technologies:\r\n\r\n```python\r\nimport datetime as dt\r\nfrom OMIEData.Enums.all_enums import SystemType\r\nfrom OMIEData.DataImport.omie_energy_by_technology_importer import OMIEEnergyByTechnologyImporter\r\n\r\ndateIni = dt.datetime(2020, 6, 1)\r\ndateEnd = dt.datetime(2020, 7, 30)\r\nsystem_type = SystemType.SPAIN\r\n\r\n# This can take time, it is downloading the files from the website..\r\ndf = OMIEEnergyByTechnologyImporter(date_ini=dateIni,\r\n                                    date_end=dateEnd,\r\n                                    system_type=system_type).read_to_dataframe(verbose=True)\r\ndf.sort_values(by=['DATE', 'HOUR'], axis=0, inplace=True)\r\nprint(df)\r\n```\r\n\r\nAnother example to download supply/demand curves:\r\n\r\n```python\r\nimport datetime as dt\r\nfrom OMIEData.DataImport.omie_supply_demand_curve_importer import OMIESupplyDemandCurvesImporter\r\n\r\ndateIni = dt.datetime(2020, 6, 1)\r\ndateEnd = dt.datetime(2020, 6, 1)\r\nhour = 1\r\n\r\n# This can take time, it is downloading the files from the website..\r\ndf = OMIESupplyDemandCurvesImporter(date_ini=dateIni, date_end=dateEnd, hour=hour).read_to_dataframe(verbose=True)\r\ndf.sort_values(by=['DATE', 'HOUR'], axis=0, inplace=True)\r\nprint(df)\r\n```\r\n\r\nOther examples that illustrate the use of the package in here:\r\n\r\n- [examples folder](https://github.com/acruzgarcia/OMIEData/tree/dev/examples)\r\n\r\nEnjoy!.\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Package to download electricity time series from https://www.omie.es/",
    "version": "0.2.0.0",
    "project_urls": {
        "Homepage": "https://github.com/acruzgarcia/OMIEData"
    },
    "split_keywords": [
        "omie",
        "electricity prices"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "284a1f267a58cb66884b4009f3d795f1ed47117a14980fabf24e64bc1670db05",
                "md5": "37c4ec2c376df9fd729d00be6c3e8f22",
                "sha256": "33cb32ceb129858a2cc7e16e51f58c2595312e4ee032317a57a696fe80bff390"
            },
            "downloads": -1,
            "filename": "OMIEData-0.2.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "37c4ec2c376df9fd729d00be6c3e8f22",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 20714,
            "upload_time": "2023-05-02T21:44:48",
            "upload_time_iso_8601": "2023-05-02T21:44:48.270771Z",
            "url": "https://files.pythonhosted.org/packages/28/4a/1f267a58cb66884b4009f3d795f1ed47117a14980fabf24e64bc1670db05/OMIEData-0.2.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0d9ca635fef71e5ffe3a2a00070997b597323bf1c6d5bb6c7c3cb7e6ce75d28a",
                "md5": "c750b66da43246ae40ead40db55a6193",
                "sha256": "ba4d550b2e99d7388faa8f967580248fd269c25825ba7aaec2f4c2f2fab38577"
            },
            "downloads": -1,
            "filename": "OMIEData-0.2.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "c750b66da43246ae40ead40db55a6193",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 12644,
            "upload_time": "2023-05-02T21:44:50",
            "upload_time_iso_8601": "2023-05-02T21:44:50.711717Z",
            "url": "https://files.pythonhosted.org/packages/0d/9c/a635fef71e5ffe3a2a00070997b597323bf1c6d5bb6c7c3cb7e6ce75d28a/OMIEData-0.2.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-02 21:44:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "acruzgarcia",
    "github_project": "OMIEData",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "omiedata"
}
        
Elapsed time: 0.06361s