Time series =========== This page shows how to load time series data. All examples below expects you to have an initialized instance of the client called ``eq``. Operations described here are available under ``eq.timeseries.*``. **Requirements:** Use these operations for curves with ``curve_type`` set to any of the following: * ``TIMESERIES`` * ``SCENARIO_TIMESERIES`` Load time series data --------------------- Method reference: :py:meth:`eq.timeseries.load() ` Loading time series data is quite straight-forward. You must at least specify these three parameters: **curve**, **begin** and **end**. So, let's load data for a curve called ``DE Wind Power Production MWh/h 15min Actual`` from 1 January 2020 at 00:00 (inclusive) to 6 January 2020 at 00:00 (exclusive). In the example below, we specified the curve as a string. You can either supply the **curve name** or a **Curve** object. The same goes for the date parameters, where the allowed types are: **date**, **datetime** or an *ISO-8601*-formatted **string**. (Keep in mind that if you do not have a paid subscription on Energy Quantified, you will only be able to load data 30 days back from *today*. So, in that case, you should adjust the begin and end dates accordingly.) >>> from datetime import date >>> timeseries = eq.timeseries.load( >>> 'DE Wind Power Production MWh/h 15min Actual', >>> begin=date(2020, 1, 1), # or begin='2020-01-01' >>> end=date(2020, 1, 6) # or end='2020-01-06' >>> ) The response is an :class:`energyquantified.data.Timeseries` instance: >>> timeseries.curve >>> timeseries.resolution >>> timeseries.begin() datetime.datetime(2020, 1, 1, 0, 0, tzinfo=) >>> timeseries.end() datetime.datetime(2020, 1, 6, 0, 0, tzinfo=) >>> timeseries.data [, , ... Aggregation ^^^^^^^^^^^ Notice that the actual wind curve in the above examples is in a 15-minute resolution. Energy Quantified do not a copy of that curve in hourly, daily or any other resolution. If you would like to get the data in, say, daily resolution, supply an extra argument, ``frequency``, when loading the time series data: >>> from energyquantified.time import Frequency >>> timeseries = eq.timeseries.load( >>> 'DE Wind Power Production MWh/h 15min Actual', >>> begin=date(2020, 1, 1), >>> end=date(2020, 1, 6), >>> frequency=Frequency.P1D # daily resolution >>> ) >>> timeseries.resolution >>> timeseries.data [, , , , ] You can also decide on the aggregation method. Let's load the maximum wind production per day: >>> from energyquantified.time import Frequency >>> from energyquantified.metadata import Aggregation >>> timeseries = eq.timeseries.load( >>> 'DE Wind Power Production MWh/h 15min Actual', >>> begin=date(2020, 1, 1), >>> end=date(2020, 1, 6), >>> frequency=Frequency.P1D, >>> aggregation=Aggregation.MAX # Max value per day >>> ) >>> timeseries.data [, , , , ] There is also support for hourly filters, such as ``BASE`` and ``PEAK``. So, to load the daily *mean* wind production during *peak hours*, you can do like so: >>> from energyquantified.time import Frequency >>> from energyquantified.metadata import Aggregation, Filter >>> timeseries = eq.timeseries.load( >>> 'DE Wind Power Production MWh/h 15min Actual', >>> begin=date(2020, 1, 1), >>> end=date(2020, 1, 6), >>> frequency=Frequency.P1D, >>> aggregation=Aggregation.AVERAGE, >>> hour_filter=Filter.PEAK >>> ) >>> timeseries.data [, , , , ] When you specify a weekly, monthly, quarterly or yearly frequency, the API will automatically use futures peak (8-20 on workdays only) in the aggregation. Load time series scenarios -------------------------- Energy Quantified provides climate data, where we run the weather data for different years through our models (as of this writing, the weather years 1980-2019). By using the same method as above, ``eq.timeseries.load()``, we can load this data. For the scenario-based time series, the values in ``timeseries.data[]`` are slightly different: It will consist of ``ScenarioValue`` items instead of ``Value`` items. These ``ScenarioValue`` items contain a **scenarios** attribute instead of a **value**. The **scenarios** attribute is a tuple of the scenario values: >>> from energyquantified.time import Frequency >>> timeseries = eq.timeseries.load( >>> 'DE Wind Power Production MWh/h 15min Climate', >>> begin=date(2020, 1, 1), >>> end=date(2020, 1, 6), >>> frequency=Frequency.P1D, >>> ) >>> timeseries.data [, , ... ----- Next steps ^^^^^^^^^^ Learn how to load :doc:`time series instances <../userguide/instances>`, :doc:`period-based series <../userguide/periods>`, and :doc:`period-based series instances <../userguide/period-instances>`.