From 1f0dacae8daf30dc16b3ca6b1510a716a9e07f29 Mon Sep 17 00:00:00 2001 From: maoji-y <255648417+maoji-y@users.noreply.github.com> Date: Thu, 26 Nov 2026 09:01:44 +0100 Subject: [PATCH] Document time index conventions for irradiance data readers --- docs/sphinx/source/whatsnew/v0.16.2.rst | 3 +++ pvlib/iotools/bsrn.py | 5 +++-- pvlib/iotools/midc.py | 5 +++-- pvlib/iotools/psm4.py | 24 +++++++++++++++++------- pvlib/iotools/pvgis.py | 17 +++++++++++++---- pvlib/iotools/sodapro.py | 7 +++++-- pvlib/iotools/solargis.py | 4 +++- pvlib/iotools/solrad.py | 3 ++- pvlib/iotools/surfrad.py | 7 +++++-- 9 files changed, 54 insertions(+), 21 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.16.2.rst b/docs/sphinx/source/whatsnew/v0.16.2.rst index b9a54f6c26..b579fb0a6d 100644 --- a/docs/sphinx/source/whatsnew/v0.16.2.rst +++ b/docs/sphinx/source/whatsnew/v0.16.2.rst @@ -52,6 +52,8 @@ Documentation * Note deprecation of ``king`` model in :py:func:`~pvlib.irradiance.get_total_irradiance` and :py:func:`~pvlib.irradiance.get_sky_diffuse` docstrings. (:issue:`2897`, :pull:`2904`) +* Document time index conventions for NSRDB PSM4, PVGIS, CAMS, Solargis, + BSRN, SURFRAD, SOLRAD, and MIDC readers. (:issue:`2963`) Testing @@ -87,3 +89,4 @@ Contributors * :ghuser:`xiajiahang` * Jakub Krasuski (:ghuser:`Blizzeq`) * Dylan Pulver (:ghuser:`dylanpulver`) +* :ghuser:`maoji-y` diff --git a/pvlib/iotools/bsrn.py b/pvlib/iotools/bsrn.py index 7c02866e1c..30e9c54ec8 100644 --- a/pvlib/iotools/bsrn.py +++ b/pvlib/iotools/bsrn.py @@ -95,8 +95,9 @@ def get_bsrn(station, start, end, username, password, ------- data: DataFrame timeseries data from the BSRN archive, see - :func:`pvlib.iotools.read_bsrn` for fields. An empty DataFrame is - returned if no data was found for the time period. + :func:`pvlib.iotools.read_bsrn` for fields. The UTC index labels the + start of each measurement interval. An empty DataFrame is returned if + no data was found for the requested dates. metadata: dict metadata for the last available monthly file. diff --git a/pvlib/iotools/midc.py b/pvlib/iotools/midc.py index e2fe435125..730382b1be 100644 --- a/pvlib/iotools/midc.py +++ b/pvlib/iotools/midc.py @@ -234,8 +234,9 @@ def read_midc_raw_data_from_nrel(site, start, end, variable_map={}, Returns ------- - data: - Dataframe with DatetimeIndex localized to the station location. + data : pandas.DataFrame + DataFrame indexed by the timestamps in the raw data, localized to + the time zone specified in the file header. Raises ------ diff --git a/pvlib/iotools/psm4.py b/pvlib/iotools/psm4.py index e9e7ef9f0d..d08c962b28 100644 --- a/pvlib/iotools/psm4.py +++ b/pvlib/iotools/psm4.py @@ -137,7 +137,8 @@ def get_nsrdb_psm4_aggregated(latitude, longitude, api_key, email, Returns ------- data : pandas.DataFrame - timeseries data from NLR PSM4 + Time series indexed by the timestamps supplied by NSRDB. See + :func:`~pvlib.iotools.read_nsrdb_psm4` for how the index is built. metadata : dict metadata from NLR PSM4 about the record, see :func:`pvlib.iotools.read_nsrdb_psm4` for fields @@ -269,7 +270,8 @@ def get_nsrdb_psm4_tmy(latitude, longitude, api_key, email, year='tmy', Returns ------- data : pandas.DataFrame - timeseries data from NLR PSM4 + Time series indexed by the timestamps supplied by NSRDB. See + :func:`~pvlib.iotools.read_nsrdb_psm4` for how the index is built. metadata : dict metadata from NLR PSM4 about the record, see :func:`pvlib.iotools.read_nsrdb_psm4` for fields @@ -401,7 +403,8 @@ def get_nsrdb_psm4_conus(latitude, longitude, api_key, email, year, Returns ------- data : pandas.DataFrame - timeseries data from NLR PSM4 + Time series indexed by the timestamps supplied by NSRDB. See + :func:`~pvlib.iotools.read_nsrdb_psm4` for how the index is built. metadata : dict metadata from NLR PSM4 about the record, see :func:`pvlib.iotools.read_nsrdb_psm4` for fields @@ -534,7 +537,8 @@ def get_nsrdb_psm4_full_disc(latitude, longitude, api_key, email, Returns ------- data : pandas.DataFrame - timeseries data from NLR PSM4 + Time series indexed by the timestamps supplied by NSRDB. See + :func:`~pvlib.iotools.read_nsrdb_psm4` for how the index is built. metadata : dict metadata from NLR PSM4 about the record, see :func:`pvlib.iotools.read_nsrdb_psm4` for fields @@ -674,7 +678,8 @@ def get_nsrdb_psm4_polar(latitude, longitude, api_key, email, Returns ------- data : pandas.DataFrame - timeseries data from NLR PSM4 Polar + Time series indexed by the timestamps supplied by NSRDB. See + :func:`~pvlib.iotools.read_nsrdb_psm4` for how the index is built. metadata : dict metadata from NLR PSM4 about the record, see :func:`pvlib.iotools.read_nsrdb_psm4` for fields @@ -817,7 +822,8 @@ def get_nsrdb_psm4_polar_tmy(latitude, longitude, api_key, email, year='tmy', Returns ------- data : pandas.DataFrame - timeseries data from NLR PSM4 Polar TMY + Time series indexed by the timestamps supplied by NSRDB. See + :func:`~pvlib.iotools.read_nsrdb_psm4` for how the index is built. metadata : dict metadata from NLR PSM4, see :func:`pvlib.iotools.read_nsrdb_psm4` for fields @@ -912,7 +918,11 @@ def read_nsrdb_psm4(filename, map_variables=True): Returns ------- data : pandas.DataFrame - timeseries data from NLR PSM4 + Time series indexed by the file's ``Year``, ``Month``, ``Day``, + ``Hour``, and ``Minute`` columns, localized using its ``Time Zone`` + metadata. The positions of these timestamps within the hour can vary + with dataset and resolution. For example, hourly Polar single-year + files can use ``HH:00`` and hourly Polar TMY files can use ``HH:30``. metadata : dict metadata from NLR PSM4 about the record, see notes for fields diff --git a/pvlib/iotools/pvgis.py b/pvlib/iotools/pvgis.py index 74b044abad..3fc27f0140 100644 --- a/pvlib/iotools/pvgis.py +++ b/pvlib/iotools/pvgis.py @@ -135,7 +135,11 @@ def get_pvgis_hourly(latitude, longitude, start=None, end=None, Returns ------- data : pandas.DataFrame - Time-series of hourly data, see Notes for fields + Hourly data indexed by the PVGIS timestamps in UTC. The irradiance + timestamp depends on the radiation database. For PVGIS-SARAH it + is the time of the satellite observation at the site. For PVGIS-ERA5 + the irradiance is averaged over the hour and labeled at ``HH:30`` + [5]_. See Notes for fields. metadata : dict Dictionary containing metadata @@ -205,6 +209,8 @@ def get_pvgis_hourly(latitude, longitude, start=None, end=None, `_ .. [4] `PVGIS horizon profile tool `_ + .. [5] `PVGIS 5 user manual, hourly radiation data + `_ """ # noqa: E501 # use requests to format the query string by passing params dictionary params = {'lat': latitude, 'lon': longitude, 'outputformat': outputformat, @@ -486,7 +492,9 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True, Returns ------- data : pandas.DataFrame - the weather data + Hourly weather data. CSV and JSON use ``HH:00`` index labels. See the + irradiance time offset [2]_ for the underlying irradiance timestamp. + For EPW, see :func:`~pvlib.iotools.read_epw` for index parsing. metadata : list or dict file metadata @@ -504,10 +512,11 @@ def get_pvgis_tmy(latitude, longitude, outputformat='json', usehorizon=True, References ---------- .. [1] `PVGIS `_ - .. [2] `PVGIS TMY tool `_ + .. [2] `PVGIS TMY tool + `_ .. [3] `PVGIS horizon profile tool `_ - """ + """ # noqa: E501 # use requests to format the query string by passing params dictionary params = {'lat': latitude, 'lon': longitude, 'outputformat': outputformat} # pvgis only likes 0 for False, and 1 for True, not strings, also the diff --git a/pvlib/iotools/sodapro.py b/pvlib/iotools/sodapro.py index 2e88590ddd..65a19b2036 100644 --- a/pvlib/iotools/sodapro.py +++ b/pvlib/iotools/sodapro.py @@ -104,7 +104,10 @@ def get_cams(latitude, longitude, start, end, email, identifier='mcclear', Returns ------- data: pandas.DataFrame - Timeseries data, see Notes for columns + Time series data indexed by the start (``label='left'``) or end + (``label='right'``) of the observation interval. Daily and monthly + data use dates without a timezone. For monthly data, ``label='right'`` + (the default) uses the last day of the month. See Notes for columns. metadata: dict Metadata of the requested time-series @@ -120,7 +123,7 @@ def get_cams(latitude, longitude, start, end, email, identifier='mcclear', ======================== ====== ========================================= **Mapped field names are returned when the map_variables argument is True** --------------------------------------------------------------------------- - Observation period str Beginning/end of time period + Observation period str Start and end of the observation interval TOA, ghi_extra float Horizontal radiation at top of atmosphere Clear sky GHI, ghi_clear float Clear sky global radiation on horizontal Clear sky BHI, bhi_clear float Clear sky beam radiation on horizontal diff --git a/pvlib/iotools/solargis.py b/pvlib/iotools/solargis.py index 2792011c2e..57841ca5af 100644 --- a/pvlib/iotools/solargis.py +++ b/pvlib/iotools/solargis.py @@ -106,7 +106,9 @@ def get_solargis(latitude, longitude, start, end, variables, api_key, Returns ------- data : DataFrame - DataFrame containing time series data. + Time series indexed by timestamps from the Solargis API. + ``timestamp_type`` selects the start, center (default), or end of + each interval. meta : dict Dictionary containing metadata. diff --git a/pvlib/iotools/solrad.py b/pvlib/iotools/solrad.py index 8e661b74ad..40f6fc9383 100644 --- a/pvlib/iotools/solrad.py +++ b/pvlib/iotools/solrad.py @@ -166,7 +166,8 @@ def get_solrad(station, start, end, Returns ------- data : pd.DataFrame - Dataframe with data from SOLRAD. + Time series with a UTC index. Each timestamp marks the end of the + averaging interval [2]_. meta : dict Metadata. diff --git a/pvlib/iotools/surfrad.py b/pvlib/iotools/surfrad.py index d25651e19a..d5a6f9fe58 100644 --- a/pvlib/iotools/surfrad.py +++ b/pvlib/iotools/surfrad.py @@ -215,7 +215,8 @@ def get_surfrad(station, start, end, map_variables=True, Returns ------- data : pd.DataFrame - Dataframe with data from SURFRAD. + Time series with a UTC index. Each timestamp marks the end of the + averaging interval [4]_. meta : dict Metadata. @@ -242,7 +243,9 @@ def get_surfrad(station, start, end, map_variables=True, `SURFRAD Archive `_ .. [3] `NOAA SURFRAD HTTP Index `_ - """ + .. [4] `NOAA SURFRAD data format + `_ + """ # noqa: E501 start = pd.to_datetime(start) end = pd.to_datetime(end)