OSUKED / ElexonDataPortal

Python wrapper for the Elexon/BMRS API
https://osuked.github.io/ElexonDataPortal
MIT License
52 stars 14 forks source link

RFE: Option to get times in UTC #17

Closed swaldman3 closed 2 years ago

swaldman3 commented 2 years ago

It would be useful to have an option to have the date/time in UTC rather than UK local time. When dealing with long timeseries this would give a monotonically increasing timestamp throughout the year, without the need to handle the "missing" times at the start of DST or the duplicate ones at its end.

Thanks for considering.

AyrtonB commented 2 years ago

Hi @swaldman3, thanks for the request - I'll roll it into the next version. I'm assuming this would be something that you'd want set globally rather than on a per request basis?

I'd look to implement with something like client = api.Client(tz_out='UTC').

swaldman3 commented 2 years ago

That would be fantastic. Thanks!

AyrtonB commented 2 years ago

With the latest 2.0.15 release you should be able to use the following code to achieve this goal. @swaldman3 let me know if this achieves what you intended and I'll close the issue.

start_date = '2020-10-25 00:30'
end_date = '2020-10-25 02:00'

client = api.Client(non_local_tz='UTC')

df_B1610_no_clock_change = client.get_B1610(start_date, end_date)

df_B1610_no_clock_change[['datetime', 'settlementDate', 'settlementPeriod']].drop_duplicates()
datetime settlementDate settlementPeriod
2020-10-24 23:30:00+00:00 2020-10-25 2
2020-10-25 00:00:00+00:00 2020-10-25 3
2020-10-25 00:30:00+00:00 2020-10-25 4
2020-10-25 01:00:00+00:00 2020-10-25 5
2020-10-25 01:30:00+00:00 2020-10-25 6
AyrtonB commented 2 years ago

Closing this as I believe it has been addressed, please reopen and clarify @swaldman3 if you think it hasn't been

swaldman3 commented 2 years ago

Reopening (possibly? commenting anyway) to say YES, thank you, that's exactly what I was hoping for although I haven't had a chance to test it, and sorry for not responding before - it's marking season.....

AyrtonB commented 2 years ago

No worries, thanks for clarifying. Hope there's not too much marking left!