Time and time zones¶
Dealing with time and time zones can be a frustrating experience in any
programming language and for any application. pvlib-python relies on
pandas
and pytz to handle
time and time zones. Therefore, the vast majority of the information in
this document applies to any time series analysis using pandas and is
not specific to pvlib-python.
General functionality¶
pvlib makes extensive use of pandas due to its excellent time series
functionality. Take the time to become familiar with pandas’ Time
Series / Date functionality page.
It is also worthwhile to become familiar with pure Python’s
datetime
module, although we usually recommend
using the corresponding pandas functionality where possible.
First, we’ll import the libraries that we’ll use to explore the basic time and time zone functionality in python and pvlib.
In [1]: import datetime
In [2]: import pandas as pd
In [3]: import pytz
Finding a time zone¶
pytz is based on the Olson time zone database. You can obtain a list of
all valid time zone strings with pytz.all_timezones
. It’s a long
list, so we only print every 20th time zone.
In [4]: len(pytz.all_timezones)
Out[4]: 593
In [5]: pytz.all_timezones[::20]