smrf.data.loadData.
wxdata
Bases: object
object
Class for loading and storing the data, either from - CSV file - MySQL database - Add other sources here
Inputs to data() are: - dataConfig, either the [csv] or [mysql] section - start_date, datetime object - end_date, datetime object - dataType, either ‘csv’ or ‘mysql’
The data will be loaded into a Pandas dataframe
db_config_vars
load_from_csv
Load the data from a csv file Fields that are operated on - metadata -> dictionary, one for each station, must have at least the following: primary_id, X, Y, elevation - csv data files -> dictionary, one for each time step, must have at least the following columns: date_time, column names matching metadata.primary_id
load_from_mysql
Load the data from a mysql database
variables
smrf.data.loadGrid.
apply_utm
Calculate the utm from lat/lon for a series
s – pandas series with fields latitude and longitude
force_zone_number – default None, zone number to force to
pandas series with fields ‘X’ and ‘Y’ filled
s
grid
Class for loading and storing the data, either from a gridded dataset in: - NetCDF format - other format
Inputs to data() are: - dataConfig, from the [gridded] section - start_date, datetime object - end_date, datetime object
get_latlon
Convert UTM coords to Latitude and longitude
utm_x – UTM easting in meters in the same zone/letter as the topo
utm_y – UTM Northing in meters in the same zone/letter as the topo
coordinates
tuple
load_from_hrrr
Load the data from the High Resolution Rapid Refresh (HRRR) model The variables returned from the HRRR class in dataframes are
metadata air_temp relative_humidity precip_int cloud_factor wind_u wind_v
metadata
air_temp
relative_humidity
precip_int
cloud_factor
wind_u
wind_v
The function will take the keys and load them into the appropriate objects within the grid class. The vapor pressure will be calculated from the air_temp and relative_humidity. The wind_speed and wind_direction will be calculated from wind_u and wind_v
load_from_netcdf
Load the data from a generic netcdf file
lat – latitude field in file, 1D array
lon – longitude field in file, 1D array
elev – elevation field in file, 2D array
variable – variable name in file, 3D array
load_from_wrf
Load the data from a netcdf file. This was setup to work with a WRF output file, i.e. wrf_out so it’s going to look for the following variables: - Times - XLAT - XLONG - HGT - T2 - DWPT - GLW - RAINNC - CLDFRA - UGRD - VGRD
Each cell will be identified by grid_IX_IY
model_domain_grid
Retrieve the bounding box for the gridded data by adding a buffer to the extents of the topo domain.
(dlat, dlon) Domain latitude and longitude extents
smrf.data.loadTopo.
Topo
Class for topo images and processing those images. Images are: - DEM - Mask - veg type - veg height - veg k - veg tau
Inputs to topo are the topo section of the config file topo will guess the location of the WORKDIR env variable and should work for unix systems.
topoConfig
configuration for topo
tempDir
location of temporary working directory
dem
numpy array for the DEM
mask
numpy array for the mask
veg_type
numpy array for the veg type
veg_height
numpy array for the veg height
veg_k
numpy array for the veg K
veg_tau
numpy array for the veg transmissivity
sky_view
ny
number of columns in DEM
nx
number of rows in DEM
u,v
location of upper left corner
du, dv
step size of grid
unit
geo header units of grid
coord_sys_ID
coordinate syste,
x,y
position vectors
X,Y
position grid
stoporad_in
numpy array for the sky view factor
IMAGES
get_center
Function returns the basin center in the native coordinates of the a netcdf object.
The incoming data set must contain at least and x, y and optionally whatever mask name the user would like to use for calculating . If no mask name is provided then the entire domain is used.
ds – netCDF4.Dataset object containing at least x,y, optionally a mask variable name
mask_name – variable name in the dataset that is a mask where 1 is in the mask
x,y of the data center in the datas native coordinates
gradient
Calculate the gradient and aspect
gfile – IPW file to write the results to
readNetCDF
Read in the images from the config file where the file listed is in netcdf format
stoporadInput
Calculate the necessary input file for stoporad The IPW and WORKDIR environment variables must be set
Created on Dec 22, 2015
Read in metadata and data from a MySQL database The table columns will most likely be hardcoded for ease of development and users will require the specific table setup
smrf.data.mysql_data.
database
Database class for querying metadata and station data
get_data
Get data from the database, either for the specified stations or for the specific group of stations in client
table – table to load data from
station_ids – list of station ids to get
start_date – start of time period
end_date – end of time period
variable – string for variable to get
time_zone – String timezone to set the data in
Similar to the CorrectWxData database call Get the metadata from the database for either the specified stations or for the specific group of stations in client
table – metadata table in the database
station_id – list of stations to read, default None
client – client to read from the station_table, default None
station_table – table name that contains the clients and list of stations, default None
Pandas DataFrame of station information
d
query
date_range
Calculate a list between start and end date with an increment