The goal of this lesson is to introduce the various ways of getting and using weather data in a GridLAB-D simulation. The specific learning objectives are the following.
- How to change from using TMY data to CSV data.
- How to obtain historical data from NSRDB.
- How to obtain realtime data from METAR.
- How to obtain a weather forecast from NOAA.
Normally TMY data is loaded from a TMY3 file using a climate object. This data can be used to provide typical weather data for any year past, present, or future. If you want to provide alternative TMY data, you can either generate you own TMY3 file (which can be difficult) or you can define a CSV reader to load a more generic data file as TMY.
Historical data can be retrieved from the National Solar Radiation Database (NSRDB) using the Python nsrdb_weather
module. The tool only allows access to historical weather records in North America, so you have to specify the year using -y=YEAR
and geographic location using -p=LAT,LON
. You also have to specify the name of the GLM file in which the historical weather object is stored using -g=FILENAME.glm
.
The NSRDB database requires access credentials. In GitHub, you must use the Settings/Secrets/Actions tab to create an actions secret. Click the New repository secret button and add your NSRDB credentials, giving it a name of your choice. If you have forked this repository, you can use the name NSRDB_CREDENTIAL
. To get your NSRDB credential, you should visit the NSRDB website. You should save the credentials in the format {"YOUR_EMAIL": "YOUR_API_KEY"}
. Once you have the credentials, you can add them to the workflow file.
Realtime weather data can be accessed using the FAA's METAR system. The Python module metar2glm
can retrieve the weather at any airport in North America and generates a GLM file that can be saved and loaded. Since the METAR object's default class name weather
is the same as a climate
module's class name, we have to rename the class using the option -c CLASSNAME
.
Weather forecasts are downloaded from NOAA. Here too, you must specify the location using the -p=LAT,LON
option. You can also specify the name of the CSV file using the -c=FILENAME.csv
option, the name of the forecast object using the -n=OBJECTNAME
, and the name of the GLM file using the -g=FILENAME.glm
option.
The GLM file contains some helpful global variables you can use to identify what time range is provided by the forecast:
NOAA_FORECAST_TIMEZONE
, e.g.,PST+8PDT
NOAA_FORECAST_STARTTIME
, e.g.,2023-06-26T11:00:00-07:00
NOAA_FORECAST_STOPTIME
, e.g.,2023-07-09T09:00:00-07:00
- Load
sample.csv
file as TMY weather data (main.glm@6
)- Load the climate module (see
main.glm@7
) - Add a CSV reader to read the file (see
main.glm@8
). - Add a climate object to use the data from the CSV reader (see
main.glm@13
).
- Load the climate module (see
- Get and load the historical weather for Redwood City, CA (37.5N,122.4W) for the year 2020.
- Get the historical weather object (see
main.glm@21
). (Hint: the data doesn't change each time you run the command, so you have test for the existence of the file and avoid downloading the data more than once.) - Load the historical data object (see
main.glm@23
) - Add the credentials to your workflow file (see
.github/workflows/main.yml@17
).
- Get the historical weather object (see
- Get and load the realtime weather for San Francisco International Airport (KSFO).
- Get the realtime weather (see
main.glm@26
) - Load the realtime weather (see
main.glm@27
)
- Get the realtime weather (see
- Get and load the weather forecast for Redwood City, CA, and set the simulation time to the forecast time.
- Get the forecast (see
main.glm@30
) - Load the forecast (see
main.glm@31
)) - Set the clock (see
main.glm@32
))
- Get the forecast (see
- Change the weather history, realtime, and forecast to run in Seattle, Washington.