This mini-tutorial describes how to create DIRSIG-friendly formatted weather files (.wth) using weather data.
|   | The tool used in this tutorial ( makewth.py) is designed to do a
specific function and is not meant to be a robust tool. | 
Requirements
- 
Python 3 - 
Packages: numpy, pandas, os, sys, argparse, json 
 
- 
- 
A data source (2 options): - 
An API key from NREL’s NSRDB website 
- 
A "Properly formatted" weather data file (this very specific formatting is how weather data comes from the National Solar Radiation Database (NSRDB): - 
30-minute time resolution 
- 
Data with specific column names: - 
"Temperature" - temperature in Celcius 
- 
"Pressure" - pressure in mbar 
- 
"Relative Humidity" - relative humidity in % 
- 
"Wind Speed" - wind speed in m/s 
- 
"DNI" - direct normal irradiance in W/m^2 (direct sun) 
- 
"DHI" - diffuse horizontal irradiance in W/m^2 (diffuse sky) 
 
- 
 
- 
 
- 
- 
The makewth.pytool distributed with DIRSIG (can be found in theextra/makewthfolder inside the DIRSIG installation directory)
Overview
This tool has 2 "modes": CSV Mode and API Mode. In CSV Mode the user provides weather data in a Comma Separated Values (CSV) file with a very specific format. The formatting requirements are listed above. When weather data is downloaded from NSRDB it comes in this format.
In API Mode the user will supply an API key which can be obtained from
the NSRDB API signup page. Once the user
has an API key the rest of the setup can be done with the make_wth.py tool.
Setting up makewth.py by editing a local copy
One way to set the options in makewth.py is by creating and editing a local
copy of the script. Alternatively you can set all of these options via the
command line.
- 
❏ Make a copy of makewth.pythat you can edit. Using this setup requires that you edit this script with appropriate inputs. Making a copy of this file in your home directory or My Documents folder is the easiest, safest way to accomplish this step.
 
- 
❏ Edit the options section of the script. - 
❏ Set the outfilevariable to the filename you want your ouput .wth to be.
- 
❏ Set the daysoffsetto the number of days you want to skip from the beginning of the data file.
 
- 
 
make_wth.py. The General Options are used in both the CSV and API modes.|   | The output .wthfile contains 48 hours of data at 15-minute time
resolution. If your input data file contains, for example, 1 year of data,
use thedaysoffsetvariable to "select" which days you would like in your
output. | 
Using CSV Mode
After setting the General Options, the CSV mode option (infile) should be
set to run in CSV Mode.
 
makewth.py.- 
❏ Set the infilevariable to the file that contains your weather data (e.g. Miami.csv).
- 
❏ Double-check that api_modeis set toFalseto run in CSV Mode.
- 
❏ Run makewth.py. This can be done multiple ways. If you need help you can search online (eg. search "run python3 script in Windows 10"). Specific instructions for this step are not provided in this manual because this can vary system to system.
The output .wth file is ready to be used in your DIRSIG simulations.
Using API Mode
Using API Mode is recommended if you are planning on making weather files from more than 2 or 3 locations. The options available in this mode make it very easy to change time and location to quickly generate multiple weather files. Before proceeding, you will need an API key from the NSRDB API signup page.
|   | In API mode data is pulled from 3 possible sources. In order of preference these are: Physical Solar Model (PSM) v3, METEOSAT IODC Region: Physical Solar Model (PSM), and Himawari: PSM v3. If the data is successfully pulled from any of these sources, the script will continue without querying the remaining sources in the list. If all three queries fail you will see an error code 400. | 
Setting up your API Key
After receiving your API key from the
NSRDB API signup page, you need to set up makewth.py to use it. The
variables to do this are described below:
|   | If your require spaces in these fields, use the + symbol as spaces (e.g. John+Doe or Academic+Research). | 
- 
api_keyis your api key you received from NREL
- 
your_nameis your name (e.g. John+Doe)
- 
reason_for_useis the reason you are using the data
- 
your_affiliationis the company or organization you are affiliated with.
- 
your_emailis your email address
- 
mailing_listis set to true if you would like to sign up for updates about the NSRDB (otherwise is set to false).
These can be set and saved inside the script itself (they are located at the
bottom of the Options section), or you can leave these blank and run
makewth.py to have the script walk you through the setup. One benefit of
leaving the fields blank is that the tool will provide you with instructions
to set this information as an environment variable which will tie your
API key to your computer account without saving it inside the script.
Setting the API Mode options
 
makewth.py.- 
❏ Set the api_modevariable toTrueto enable API Mode.
- 
❏ Set the latitude ( lat) and longitude (lon) of the location of interest.
- 
❏ Set the yearto the year of interest.
- 
❏ Set the leap_yearvariable to true unless you want to ignore leap years.
- 
❏ Leave the time intervalas 30, which is the highest frequency data available from NSRDB at this time.
- 
❏ Setting utcto true will use UTC as the time zone. Otherwise, the data will use the time zone local to the data location.
- 
❏ Run makewth.py. This can be done multiple ways. If you need help you can search online (eg. search "run python3 script in Windows 10"). Specific instructions for this step are not provided in this manual because this can vary system to system.
Setting options with the command line
Running makewth.py with the -h argument (e.g. python3 makewth.py -h) will
display a list of the command line options. Note that in CSV Mode you only
need to set the --outfile, --nskipdays, and --infile options. In API
Mode the required arguments are --outfile, --nskipdays, --api_mode,
--lat, --lon, --year, and --utc.
Below are two example commands for running makewth.py. The first example
runs the tool in CSV Mode, and the second example runs it in API Mode.
|   | If some (or all) of the arguments are missing from the command, the script will fall back on the values stored inside the script as defaults. | 
python3 makewth.py --outfile=my_weather.wth --nskipdays=10 --infile=raw/Denver.csvpython3 makewth.py --api_mode --outfile=my_weather.wth --nskipdays=10 --lat=39.742043 --lon=-104.991531 --year=2019 --utc=falseBoth commands will save a weather file called my_weather.wth that is ready
to be used with DIRSIG.