|
| 1 | +.. _weatherdata: |
| 2 | + |
| 3 | +Weather data |
| 4 | +============ |
| 5 | + |
| 6 | +Simulating the performance of a PV system requires irradiance and meteorological data |
| 7 | +as the inputs to a PV system model. Weather datasets are available |
| 8 | +from many sources and in many formats. The :py:mod:`pvlib.iotools` module |
| 9 | +contains functions to easily retrieve and import such datasets in a standardized |
| 10 | +form that is convenient to use with the rest of pvlib. |
| 11 | + |
| 12 | +The primary focus of :py:mod:`pvlib.iotools` is time series solar resource |
| 13 | +data like the irradiance datasets from PVGIS and the NSRDB, but it also provides |
| 14 | +functionality for other types of data useful for certain aspects of PV modeling. |
| 15 | +For example, precipitation data is available from :py:func:`~pvlib.iotools.get_acis_prism` |
| 16 | +for soiling modeling and horizon profiles can be retrieved from |
| 17 | +:py:func:`~pvlib.iotools.get_pvgis_horizon` for horizon shade modeling. |
| 18 | + |
| 19 | +For a complete list of functions related to retrieving and importing weather |
| 20 | +data, see :ref:`iotools`, and for a detailed comparison of the weather datasets |
| 21 | +available through pvlib, see [1]_. |
| 22 | + |
| 23 | + |
| 24 | +Types of weather data sources |
| 25 | +----------------------------- |
| 26 | + |
| 27 | +Weather data can be grouped into a few fundamental categories. Which |
| 28 | +type is most useful depends on the application. Here we provide a high-level |
| 29 | +overview of different types of weather data, and when you might want to use |
| 30 | +them. |
| 31 | + |
| 32 | +1. **Ground station measurements**: |
| 33 | + From in-situ monitoring equipment. If properly maintained and |
| 34 | + quality-controlled, these are the highest quality |
| 35 | + source of weather information. However, the coverage depends on |
| 36 | + a weather station having been set up in advance for the location and |
| 37 | + times of interest. Some ground station networks like the BSRN and SURFRAD |
| 38 | + make their measurement data publicly available. An global overview of ground |
| 39 | + stations is available at https://SolarStations.org. |
| 40 | + |
| 41 | + Data from public ground station measurement networks are useful if you |
| 42 | + want accurate, high-resolution data but have flexibility around the |
| 43 | + specific measurement location. |
| 44 | + |
| 45 | +2. **Satellite data**: |
| 46 | + These sources process satellite imagery (typically from geostationary |
| 47 | + satellites) to identify and classify clouds, and combine this with solar |
| 48 | + irradiance models and aerosol data to produce irradiance estimates. The |
| 49 | + quality is generally much higher than NWP, but still not as good as a well-maintained |
| 50 | + weather station. They have high spatial and temporal resolution |
| 51 | + corresponding to the source satellite imagery, and are generally |
| 52 | + optimised to estimate solar irradiance for PV applications. Free sources |
| 53 | + such as PVGIS, NSRDB, and CAMS are available, and commerical sources such |
| 54 | + as SolarAnywhere, Solcast, and Solargis provide paid options though often |
| 55 | + have free trials. |
| 56 | + |
| 57 | + Satellite data is useful when suitable ground measurements are |
| 58 | + not available for the location and/or times of interest. |
| 59 | + |
| 60 | +3. **Numerical Weather Prediction (NWP)**: |
| 61 | + These are mathematical simulations of weather systems. |
| 62 | + The data quality is much lower than that of measurements and |
| 63 | + satellite data, owing in part to coarser spatial and temporal |
| 64 | + resolution, as well as many models not being optimised for solar |
| 65 | + irradiance for PV applications. On the plus side, these models typically |
| 66 | + have worldwide coverage, with some regional models (e.g. HRRR) sacrifice |
| 67 | + global coverage for somewhat higher spatial and temporal resolution. |
| 68 | + Various forecast (e.g. GFS, ECMWF, ICON) and reanalysis sources (ERA5, |
| 69 | + MERRA2) exist. |
| 70 | + |
| 71 | + NWP datasets are primarily useful for parts of the world not covered |
| 72 | + by satellite-based datasets (e.g. polar regions) or if extremely long time |
| 73 | + ranges are needed. |
| 74 | + |
| 75 | + |
| 76 | +Usage |
| 77 | +----- |
| 78 | + |
| 79 | +With some exceptions, the :py:mod:`pvlib.iotools` functions |
| 80 | +provide a uniform interface for accessing data across many formats. |
| 81 | +Specifically, :py:mod:`pvlib.iotools` functions usually return two objects: |
| 82 | +a :py:class:`pandas.DataFrame` of the actual dataset, plus a metadata |
| 83 | +dictionary. Most :py:mod:`pvlib.iotools` functions also have |
| 84 | +a ``map_variables`` parameter to automatically translate |
| 85 | +the column names used in the data file (which vary widely from dataset to dataset) |
| 86 | +into standard pvlib names (see :ref:`variables_style_rules`). |
| 87 | + |
| 88 | +Typical usage looks something like this: |
| 89 | + |
| 90 | +.. code-block:: python |
| 91 | +
|
| 92 | + # get_pvgis_tmy returns two additional values besides df and metadata |
| 93 | + df, _, _, metadata = pvlib.iotools.get_pvgis_tmy(latitude, longitude, map_variables=True) |
| 94 | +
|
| 95 | +This code will fetch a Typical Meteorological Year (TMY) dataset from PVGIS, |
| 96 | +returning a :py:class:`pandas.DataFrame` containing the hourly weather data |
| 97 | +and a python dict with information about the dataset. |
| 98 | + |
| 99 | +Most :py:mod:`pvlib.iotools` functions work with time series datasets. |
| 100 | +In that case, the returned ``df`` DataFrame has a datetime index, localized |
| 101 | +to the appropriate time zone where possible. Make sure to understand each |
| 102 | +dataset's timestamping convention (e.g. center versus end of interval), as |
| 103 | +pvlib will use these timestamps for solar position calculations. |
| 104 | + |
| 105 | +The content of the metadata dictionary varies for each function/dataset. |
| 106 | + |
| 107 | + |
| 108 | +Data retrieval |
| 109 | +************** |
| 110 | + |
| 111 | +Several :py:mod:`pvlib.iotools` functions access the internet to fetch data from |
| 112 | +online web APIs. For example, :py:func:`~pvlib.iotools.get_pvgis_hourly` |
| 113 | +downloads data from PVGIS's webservers and returns it as a python variable. |
| 114 | +Functions that retrieve data from the internet are named ``get_``, followed |
| 115 | +by the name of the data source: :py:func:`~pvlib.iotools.get_bsrn`, |
| 116 | +:py:func:`~pvlib.iotools.get_psm3`, :py:func:`~pvlib.iotools.get_pvgis_tmy`, |
| 117 | +and so on. |
| 118 | + |
| 119 | +For satellite/reanalysis datasets, the location is specified by latitude and |
| 120 | +longitude in decimal degrees: |
| 121 | + |
| 122 | +.. code-block:: python |
| 123 | +
|
| 124 | + latitude, longitude = 33.75, -84.39 # Atlanta, Georgia, United States |
| 125 | + df, metadata = pvlib.iotools.get_psm3(latitude, longitude, map_variables=True, ...) |
| 126 | +
|
| 127 | +
|
| 128 | +For ground station networks, the location identifier is the station ID: |
| 129 | + |
| 130 | +.. code-block:: python |
| 131 | +
|
| 132 | + df, metadata = pvlib.iotools.get_bsrn(station='cab', start='2020-01-01', end='2020-01-31', ...) |
| 133 | +
|
| 134 | +Some of these data providers require registration. In those cases, your |
| 135 | +access credentials must be passed as parameters to the function. See the |
| 136 | +individual function documentation pages for details. |
| 137 | + |
| 138 | + |
| 139 | +Reading local files |
| 140 | +******************* |
| 141 | + |
| 142 | +:py:mod:`pvlib.iotools` also provides functions for parsing data files |
| 143 | +stored locally on your computer. |
| 144 | +Functions that read and parse local data files are named ``read_``, followed by |
| 145 | +the name of the file format they parse: :py:func:`~pvlib.iotools.read_tmy3`, |
| 146 | +:py:func:`~pvlib.iotools.read_epw`, and so on. |
| 147 | + |
| 148 | +For example, here is how to read a file in the TMY3 file format: |
| 149 | + |
| 150 | +.. code-block:: python |
| 151 | +
|
| 152 | + df, metadata = pvlib.iotools.read_tmy3(r"C:\path\to\file.csv", map_variables=True) |
| 153 | +
|
| 154 | +
|
| 155 | +References |
| 156 | +---------- |
| 157 | +.. [1] Jensen et al. "pvlib iotools—Open-source Python functions for seamless |
| 158 | + access to solar irradiance data". Solar Energy, 2023. |
| 159 | + :doi:`10.1016/j.solener.2023.112092`. |
0 commit comments