### Install OMIEData Source: https://context7.com/acruzgarcia/omiedata/llms.txt Use pip to install the package. ```bash pip install OMIEData ``` -------------------------------- ### Install OMIEData from GitHub Source: https://github.com/acruzgarcia/omiedata/blob/dev/README.md Install the OMIEData package directly from its GitHub repository. ```bash python -m pip install git+https://github.com/acruzgarcia/OMIEData ``` -------------------------------- ### Install OMIEData from Wheel file Source: https://github.com/acruzgarcia/omiedata/blob/dev/README.md Install OMIEData using a downloaded wheel (.whl) file. ```bash python -m pip install OMIEData-VERSION-py3-none-any.whl ``` -------------------------------- ### Install OMIEData from Tarball Source: https://github.com/acruzgarcia/omiedata/blob/dev/README.md Install OMIEData using a downloaded source tarball (.tar.gz) file. ```bash python -m pip install OMIEData-VERSION.tar.gz ``` -------------------------------- ### Install OMIEData from PyPI Source: https://github.com/acruzgarcia/omiedata/blob/dev/README.md Install the latest version of the OMIEData package from the Python Package Index. ```bash python -m pip install OMIEData ``` -------------------------------- ### Download and Plot Spanish Electricity Prices Source: https://context7.com/acruzgarcia/omiedata/llms.txt Imports OMIE marginal price data for a specified date range, filters for Spanish prices, and plots hourly price data for peak and off-peak hours using matplotlib. Ensure matplotlib is installed for visualization. ```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 # Download price data date_ini = dt.datetime(2023, 1, 1) date_end = dt.datetime(2023, 6, 30) df = OMIEMarginalPriceFileImporter( date_ini=date_ini, date_end=date_end ).read_to_dataframe(verbose=True) df.sort_values(by='DATE', axis=0, inplace=True) # Filter Spanish prices df_prices = df[df.CONCEPT == str(DataTypeInMarginalPriceFile.PRICE_SPAIN)] # Plot hourly prices (comparing peak hour 12 with off-peak hour 23) plt.figure(figsize=(12, 6)) plt.plot(df_prices.DATE, df_prices.H12, label='Hour 12 (Peak)') plt.plot(df_prices.DATE, df_prices.H23, label='Hour 23 (Off-Peak)') plt.xlabel('Date') plt.ylabel('Price (€/MWh)') plt.title('Spanish Electricity Prices') plt.legend() plt.grid(True) plt.show() ``` -------------------------------- ### Two-Step Workflow: Download Energy by Technology then Read Source: https://context7.com/acruzgarcia/omiedata/llms.txt Downloads energy by technology data files to a local folder and then reads them into a DataFrame. Allows filtering by specific technologies. ```python import datetime as dt from OMIEData.DataImport.omie_data_importer_from_folder import OMIEDataImporterFromFolder from OMIEData.Downloaders.energy_by_technology_downloader import EnergyByTechnologyDownloader from OMIEData.FileReaders.energy_by_technology_files_reader import EnergyByTechnologyHourlyFileReader from OMIEData.Enums.all_enums import SystemType, TechnologyType # Step 1: Download energy by technology files working_folder = '/tmp/omie_energy' date_ini = dt.datetime(2023, 6, 1) date_end = dt.datetime(2023, 10, 31) # Download for Iberian system downloader = EnergyByTechnologyDownloader(system=SystemType.IBERIAN) errors = downloader.download_data( date_ini=date_ini, date_end=date_end, output_folder=working_folder ) # Step 2: Read with technology filter (only nuclear and combined cycle) data_types = [TechnologyType.NUCLEAR, TechnologyType.COMBINED_CYCLE] file_reader = EnergyByTechnologyHourlyFileReader(types=data_types) df = OMIEDataImporterFromFolder( absolute_path=working_folder, file_reader=file_reader ).read_to_dataframe(verbose=True) df.sort_values(by=['DATE', 'HOUR'], axis=0, inplace=True) print(df) ``` -------------------------------- ### Two-Step Workflow: Download Marginal Prices then Read Source: https://context7.com/acruzgarcia/omiedata/llms.txt Downloads marginal price data files to a local folder and then reads them into a DataFrame. Useful for caching or repeated analysis. You can filter by specific data types. ```python import datetime as dt from OMIEData.DataImport.omie_data_importer_from_folder import OMIEDataImporterFromFolder from OMIEData.Downloaders.marginal_price_downloader import MarginalPriceDownloader from OMIEData.FileReaders.marginal_price_file_reader import MarginalPriceFileReader from OMIEData.Enums.all_enums import DataTypeInMarginalPriceFile # Step 1: Download files to local folder working_folder = '/tmp/omie_data' date_ini = dt.datetime(2023, 1, 1) date_end = dt.datetime(2023, 12, 31) # Download marginal price data files downloader = MarginalPriceDownloader() errors = downloader.download_data( date_ini=date_ini, date_end=date_end, output_folder=working_folder ) # Step 2: Read from local folder (can filter specific data types) data_types = [ DataTypeInMarginalPriceFile.PRICE_SPAIN, DataTypeInMarginalPriceFile.ENERGY_IBERIAN ] file_reader = MarginalPriceFileReader(types=data_types) df = OMIEDataImporterFromFolder( absolute_path=working_folder, file_reader=file_reader ).read_to_dataframe(verbose=True) df.sort_values(by='DATE', axis=0, inplace=True) print(df) ``` -------------------------------- ### Download Supply/Demand Curves Source: https://github.com/acruzgarcia/omiedata/blob/dev/README.md Initializes an importer for OMIE supply and demand curves within a specified date range and hour. Further implementation is needed to retrieve the data. ```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 ``` -------------------------------- ### Import Marginal Prices with OMIEMarginalPriceFileImporter Source: https://context7.com/acruzgarcia/omiedata/llms.txt Retrieves daily market marginal prices and energy volumes. Use the DataTypeInMarginalPriceFile enum to filter for specific metrics like Spanish or Portuguese prices. ```python import datetime as dt import pandas as pd from OMIEData.DataImport.omie_marginalprice_importer import OMIEMarginalPriceFileImporter from OMIEData.Enums.all_enums import DataTypeInMarginalPriceFile # Define date range for data retrieval date_ini = dt.datetime(2023, 1, 1) date_end = dt.datetime(2023, 1, 31) # Download and import marginal prices (downloads from OMIE website) df = OMIEMarginalPriceFileImporter( date_ini=date_ini, date_end=date_end ).read_to_dataframe(verbose=True) # Sort by date for chronological order df.sort_values(by='DATE', axis=0, inplace=True) # Filter for Spanish prices only price_spain_str = str(DataTypeInMarginalPriceFile.PRICE_SPAIN) df_prices = df[df.CONCEPT == price_spain_str] # Access hourly columns (H1-H24) print(df_prices[['DATE', 'CONCEPT', 'H1', 'H12', 'H24']]) ``` -------------------------------- ### Download Hourly Electricity Prices and Demand Source: https://github.com/acruzgarcia/omiedata/blob/dev/README.md Imports hourly electricity prices and demand data for Spain and Portugal within a specified date range. This operation may take time as it downloads files from the OMIE website. The resulting DataFrame is sorted by date. ```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) ``` -------------------------------- ### Import Energy by Technology with OMIEEnergyByTechnologyImporter Source: https://context7.com/acruzgarcia/omiedata/llms.txt Retrieves hourly energy generation data broken down by technology. Specify the system type using the SystemType enum to target Spain, Portugal, or the Iberian system. ```python import datetime as dt from OMIEData.DataImport.omie_energy_by_technology_importer import OMIEEnergyByTechnologyImporter from OMIEData.Enums.all_enums import SystemType, TechnologyType # Define date range date_ini = dt.datetime(2023, 6, 1) date_end = dt.datetime(2023, 6, 30) # Choose system type: SPAIN, PORTUGAL, or IBERIAN system_type = SystemType.SPAIN # Download and import energy by technology data df = OMIEEnergyByTechnologyImporter( date_ini=date_ini, date_end=date_end, system_type=system_type ).read_to_dataframe(verbose=True) # Sort by date and hour df.sort_values(by=['DATE', 'HOUR'], axis=0, inplace=True) print(df) ``` -------------------------------- ### Import Supply and Demand Curves with OMIESupplyDemandCurvesImporter Source: https://context7.com/acruzgarcia/omiedata/llms.txt Retrieves price-volume pairs for aggregated supply and demand curves for a specific hour. ```python import datetime as dt from OMIEData.DataImport.omie_supply_demand_curve_importer import OMIESupplyDemandCurvesImporter # Define date range and hour (1-24) date_ini = dt.datetime(2023, 6, 15) date_end = dt.datetime(2023, 6, 15) hour = 12 # Hour 12 (noon) # Download and import supply/demand curves df = OMIESupplyDemandCurvesImporter( date_ini=date_ini, date_end=date_end, hour=hour ).read_to_dataframe(verbose=True) # Sort by date and hour df.sort_values(by=['DATE', 'HOUR'], axis=0, inplace=True) print(df) ``` -------------------------------- ### Download Hourly Energy by Technology Source: https://github.com/acruzgarcia/omiedata/blob/dev/README.md Imports hourly energy demand data, broken down by technology, for a specified system type (e.g., Spain) and date range. This operation may take time as it downloads files from the OMIE website. The resulting DataFrame is sorted by date and hour. ```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) ``` -------------------------------- ### Download Intra-Day Market Prices Source: https://context7.com/acruzgarcia/omiedata/llms.txt Downloads intra-day market prices for a specified trading session and date range. Files are saved with a naming convention indicating the session and date. ```python import datetime as dt from OMIEData.Downloaders.intra_day_price_downloader import IntraDayPriceDownloader # Define date range date_ini = dt.datetime(2023, 5, 1) date_end = dt.datetime(2023, 5, 31) working_folder = '/tmp/omie_intraday' # Download intra-day prices for session 2 session_number = 2 # Sessions typically range from 1-6 downloader = IntraDayPriceDownloader(session=session_number) errors = downloader.download_data( date_ini=date_ini, date_end=date_end, output_folder=working_folder ) # Files saved as: PrecioIntra_2_YYYYMMDD.txt ``` -------------------------------- ### Import OMIE Adjustment Prices to DataFrame Source: https://context7.com/acruzgarcia/omiedata/llms.txt Imports hourly adjustment prices directly into a pandas DataFrame. Specify the date range for the data you need. ```python import datetime as dt from OMIEData.DataImport.omie_adjustmentprice_importer import OMIEAdjustmentPriceFileImporter # Define date range date_ini = dt.datetime(2023, 3, 1) date_end = dt.datetime(2023, 3, 31) # Download and import adjustment prices df = OMIEAdjustmentPriceFileImporter( date_ini=date_ini, date_end=date_end ).read_to_dataframe(verbose=True) print(df) # Output: # DATE H1 H2 ... H23 H24 # 0 2023-03-01 5.2 4.8 ... 6.1 5.5 # ... ``` -------------------------------- ### Import and Process OMIE Supply Demand Data Source: https://github.com/acruzgarcia/omiedata/blob/dev/README.md Use this snippet to download supply and demand curve data for a specified date range and hour. The data is then processed into a pandas DataFrame and sorted by date and hour. Set verbose=True for detailed output during download. ```python 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) ``` -------------------------------- ### DataTypeInMarginalPriceFile Enum Usage Source: https://context7.com/acruzgarcia/omiedata/llms.txt Demonstrates how to use the DataTypeInMarginalPriceFile enumeration for filtering marginal price data when reading files. Shows available types and how to filter a DataFrame. ```python from OMIEData.Enums.all_enums import DataTypeInMarginalPriceFile # Available data types and their string representations print(str(DataTypeInMarginalPriceFile.PRICE_SPAIN)) # 'PRICE_SP' print(str(DataTypeInMarginalPriceFile.PRICE_PORTUGAL)) # 'PRICE_PT' print(str(DataTypeInMarginalPriceFile.ENERGY_IBERIAN)) # 'ENER_IB' print(str(DataTypeInMarginalPriceFile.ENERGY_IBERIAN_WITH_BILLATERAL)) # 'ENER_IB_BILLAT' # Use for filtering DataFrame results df_spain_prices = df[df.CONCEPT == str(DataTypeInMarginalPriceFile.PRICE_SPAIN)] df_portugal_prices = df[df.CONCEPT == str(DataTypeInMarginalPriceFile.PRICE_PORTUGAL)] df_energy = df[df.CONCEPT == str(DataTypeInMarginalPriceFile.ENERGY_IBERIAN)] ``` -------------------------------- ### Filter and Plot Spain Prices Source: https://github.com/acruzgarcia/omiedata/blob/dev/README.md Filters the previously imported DataFrame to include only prices in Spain and then plots the prices for hours H12 and H23. ```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() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.