tesp_support.weather package
TESP is the Transactive Energy Simulation Platform tesp_support for Weather
Submodules
tesp_support.weather.PSM_download module
Simple script to download PSM weather files and convert them to DAT files.
In the name of expediency, this script contains two functions that were copy and pasted from dsot_solar.py. I wish that those functions had been better abstracted when I wrote them but, it’s not worth the time and effort to do so now. This script will likely ever only be run a few times as it is just creating input files and is not a part of the co-sim runtime.
The script does make use of PSMvstoDAT.py as a function, though. I had to make minor edits to that function as it was slightly non-abstracted and not completely stand-alone.
- tesp_support.weather.PSM_download.download_nsrdb_data(dso_meta, output_path)
This function queries the NSRDB database over the web and pulls down and does a conversion.
Function pulls down the solar data down calls PSMv3toDAT to convert them to appropriate format.
- Parameters:
dso_meta (list) – List of dicts with metadata associated with each DSO, specifically the site information
output_path (str)
- tesp_support.weather.PSM_download.parse_DSO_location(dso_metadata_path, worksheet_name)
This function parses the DSO metadata which is contained in an Excel spreadsheet
- Parameters:
dso_metadata_path (str) – Path to the Excel file containing the metadata to be parsed.
worksheet_name (str) – Name of the worksheet in the Excel file containing the metadata
- Returns:
One dictionary per DSO with appropriate metadata captured.
- Return type:
list<dict>
tesp_support.weather.PSMv3toDAT module
This code reads in PSM v3 csv files obtained from https://maps.nrel.gov/nsrdb-viewer/.
The csv file includes 6 columns for the following, in addition to date and time information: temperature, humidity, DNI, DHI, pressure and wind_speed
- tesp_support.weather.PSMv3toDAT.weatherdat(psmv3csvfile, bus_str, location_str)
Takes a weather csv file name obtained from NREL PSM v3 and does a conversion.
The function reads the file, converts the data to the desired units, and outputs dat file with the desired format
- Parameters:
psmv3csvfile (str) – name of the file to be converted, without ext ‘.csv’
bus_str (str) – id of the bus
location_str (str)
tesp_support.weather.TMY3toCSV module
Convert typical meteorological year version 3 (TMY3) data to comma separated values (CSV)
For common use by TESP agents.
- Public Functions:
- readtmy3:
Read a TMY3 file in to a pandas dataframe, using python tkinter.
- weathercsv:
Converts TMY3 weather data to CSV in the requested time range.
- weathercsv_cloudy_day:
Converts weather data to cloudy days CSV in the requested time range.
- tesp_support.weather.TMY3toCSV.readtmy3(filename=None, coerce_year=None, recolumn=True)
Read a TMY3 file in to a pandas dataframe.
- Parameters:
filename (object)
coerce_year
recolumn
- Return type:
dict, dict
- tesp_support.weather.TMY3toCSV.weathercsv(tmyfile, output_file, start_time, end_time, year)
Converts TMY3 weather data to CSV in the requested time range
- Parameters:
tmyfile (str) – the input TMY3 data file
output_file (str) – the output CSV data file
start_time (str) – the starting date and time of interest, like 2013-07-01 00:00:00
end_time (str) – the ending date and time of interest, like 2013-07-08 00:00:00
year (int) – the year of interest
- tesp_support.weather.TMY3toCSV.weathercsv_cloudy_day(start_time, end_time, output_file)
Converts weather data to cloudy days CSV in the requested time range
- Parameters:
start_time (str) – the starting date and time of interest, like 2013-07-01 00:00:00
end_time (str) – the ending date and time of interest, like 2013-07-08 00:00:00
output_file (str) – the output CSV data file
tesp_support.weather.TMYtoEPW module
Functions to convert Typical Meteorological Year data for EnergyPlus
The input must be in TMY2 format. If only TMY3 files are available, see the TMY3toTMY2_ansi.c program distributed with TESP under the [weather_path]/TMY2EPW/source_code directory.
- Public Functions:
- convert_tmy2_to_epw:
Converts TMY2 file to EPW.
- convert_tmy3_to_epw:
Converts TMY3 file to EPW.
- tesp_support.weather.TMYtoEPW.convert_tmy2_to_epw(in_file_root, out_file_root=None)
Converts TMY2 to EPW
Reads in_file_root.tmy2 and writes in_file_root.epw
- Parameters:
in_file_root (str) – The input path and base file name, without extension
out_file_root (str) – The output path and base file name, without extension
- tesp_support.weather.TMYtoEPW.convert_tmy3_to_epw(in_file_root, out_file_root=None)
Converts TMY3 to EPW
Reads in_file_root.tmy3 and writes out_file_root.epw
- Parameters:
in_file_root (str) – The input path and base file name, without extension
out_file_root (str) – The output path and base file name, without extension
- tesp_support.weather.TMYtoEPW.removeZero(x)
Helper function to strip leading ‘0’ from a string
tesp_support.weather.forecast module
- tesp_support.weather.forecast.convertTimeToSeconds(time)
Convert time string with unit to integer in seconds
Parses the unit in day, hour, minute and second. It will not recognize week, month, year, millisecond, microsecond or nanosecond, they can be added if needed.
- Parameters:
time (str) – time with unit
- Returns:
represent the input time in second
- Return type:
int
- tesp_support.weather.forecast.deltaTimeToResampleFreq(time)
Convert time unit to a resampling frequency that can be recognized by pandas.DataFrame.resample()
Parses unit in day, hour, minute and second. It won’t recognize week, month, year, millisecond, microsecond or nanosecond, they can be added if needed.
- Parameters:
time (str) – time with unit
- Returns:
time with resample frequency
- Return type:
str
- tesp_support.weather.forecast.findDeltaTimeMultiplier(time)
Find the multiplier to convert delta_time to seconds
Parses unit in day, hour, minute and second. It won’t recognize week, month, year, millisecond, microsecond or nanosecond, they can be added if needed.
- Parameters:
time (str) – time with unit
- Returns:
the multiplier to convert delta_time to seconds
- Return type:
int
- class tesp_support.weather.forecast.weather_forecast(variable, period, W_dict)
Bases:
object
This object includes the error to a weather variable
- Parameters:
variable (str) – Type of weather variable being forecasted
period (int) – period of the sinusoidal bias
W_dict (dict) – dictionary for specifying the generation of the error envelope
- weather_variable
Type of weather variable being forecasted
- Type:
str
- # Type of error insertion
- distribution
type of distribution –> 0 uniform;1 triangular;2 truncated normal the standard deviation is computed for 95% of values to be within bounds in a conventional normal distribution
- Type:
int
- P_e_bias
pu maximum bias at first hour –> [0 to 1]
- Type:
float
- P_e_envelope
pu maximum error from mean values –> [0 to 1]
- Type:
float
- Lower_e_bound
pu of the maximum error at the first hour –> [0 to 1]
- Type:
float
- # Bias variable
- biasM
sinusoidal bias for altering the error envelope
- Type:
float) (1 X period
- Period_bias
period of the sinusoidal bias
- Type:
int
- get_truncated_normal(EL, EH)
Truncated normal distribution
- make_forecast(weather, t=0)
Include error to a known weather variable
- Parameters:
weather (float) (1 x desired number of hours ahead) – known weather variable
t (int) – time in hours
- Returns:
weather variable with included error ENV_U (float) (1 x desired number of hours ahead): envelope with bias upper bound ENV_l (float) (1 x desired number of hours ahead): envelope with bias lower bound
- Return type:
weather_f (float) (1 x desired number of hours ahead)
tesp_support.weather.weather_agent module
Weather Agent
This weather agent needs an WEATHER_CONFIG environment variable to be set, which is a json file.
- tesp_support.weather.weather_agent.startWeatherAgent(file)
The weather agent publishes weather data as configured by the json file
- Parameters:
file (str) – the weather data file
- tesp_support.weather.weather_agent.usage()
tesp_support.weather.weather_agent_f module
Weather Agent
This weather agent needs an WEATHER_CONFIG environment variable to be set, which is a json file.
- tesp_support.weather.weather_agent_f.startWeatherAgent(file)
The weather agent publishes weather data as configured by the json file
- Parameters:
file (str) – the weather data file
- tesp_support.weather.weather_agent_f.usage()