SheffieldSolar / PV_Live-API

A Python implementation of the PV_Live web API.
16 stars 4 forks source link

Get Install capacity #7

Closed peterdudfield closed 2 years ago

peterdudfield commented 3 years ago

It would be great if there was an endpoint that got the "install capacity". Perhaps this would be time dependent.

** if there is already, and just not the python code, then let me know, and I can add the (try) code

p.s. I live have you have used units in the variable names, i.e" installed_capacity_mw" or maybe it 'mwp'?

JamieTaylor-TUOS commented 2 years ago

@peterdudfield It's already possible, both via the API directly and via this lib...

As you suggest, it's time dependent, so goes hand-in-hand with downloading the outturn data.

Via the API, it's a case of adding extra_fields=installed_capacity_mwp to the URL params.

Via the Python lib, it's a case of specifying the extra_fields arg when calling one of the download methods e.g.

from datetime import datetime
import pytz

from pvlive_api import PV_Live

pvl = PVLive()

data = pvl.between(
    start=datetime(2015, 1, 1, 0, 30, tzinfo=pytz.utc),
    end=datetime(2021, 1, 1, tzinfo=pytz.utc),
    extra_fields="installedcapacity_mwp",
    dataframe=True
)

data.sort_values("datetime_gmt") then looks like:

        pes_id              datetime_gmt  generation_mw  installedcapacity_mwp
1440         0 2015-01-01 00:30:00+00:00            0.0                 5309.0
1439         0 2015-01-01 01:00:00+00:00            0.0                 5309.0
1438         0 2015-01-01 01:30:00+00:00            0.0                 5309.0
1437         0 2015-01-01 02:00:00+00:00            0.0                 5309.0
1436         0 2015-01-01 02:30:00+00:00            0.0                 5309.0
...        ...                       ...            ...                    ...
105179       0 2020-12-31 22:00:00+00:00            0.0                13080.0
105178       0 2020-12-31 22:30:00+00:00            0.0                13080.0
105177       0 2020-12-31 23:00:00+00:00            0.0                13080.0
105176       0 2020-12-31 23:30:00+00:00            0.0                13080.0
105175       0 2021-01-01 00:00:00+00:00            0.0                13080.0

[105198 rows x 4 columns]

N.B. data is not sorted by default, hence calling .sort_values("datetime_gmt")

A full list of "extra fields" that are available is in the API docs, see here.

peterdudfield commented 2 years ago

Amazing, thank you very much