smrf.data package¶
smrf.data.csv_data module¶
smrf.data.loadData module¶
-
class
smrf.data.loadData.wxdata(dataConfig, start_date, end_date, time_zone='UTC', stations=None, dataType=None)[source]¶ Bases:
objectClass 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= ['user', 'password', 'host', 'database', 'port', 'metadata', 'data_table', 'station_table']¶
-
load_from_csv()[source]¶ 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
-
variables= ['air_temp', 'vapor_pressure', 'precip', 'wind_speed', 'wind_direction', 'cloud_factor']¶
-
smrf.data.loadGrid module¶
-
smrf.data.loadGrid.apply_utm(s, force_zone_number)[source]¶ Calculate the utm from lat/lon for a series
Parameters: - s – pandas series with fields latitude and longitude
- force_zone_number – default None, zone number to force to
Returns: pandas series with fields ‘X’ and ‘Y’ filled
Return type: s
-
class
smrf.data.loadGrid.grid(dataConfig, topo, start_date, end_date, time_zone='UTC', dataType='wrf', tempDir=None, forecast_flag=False, day_hour=0, n_forecast_hours=18)[source]¶ Bases:
objectClass 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
-
load_from_hrrr()[source]¶ 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
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()[source]¶ Load the data from a generic netcdf file
Parameters: - 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
-
smrf.data.loadTopo module¶
-
class
smrf.data.loadTopo.topo(topoConfig, calcInput=True, tempDir=None)[source]¶ Bases:
objectClass 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= ['dem', 'mask', 'veg_type', 'veg_height', 'veg_k', 'veg_tau']¶
-
smrf.data.mysql_data module¶
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
-
class
smrf.data.mysql_data.database(user, password, host, db, port)[source]¶ Bases:
objectDatabase class for querying metadata and station data
-
get_data(table, station_ids, start_date, end_date, variables)[source]¶ Get data from the database, either for the specified stations or for the specific group of stations in client
Parameters: - 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
-
metadata(table, station_ids=None, client=None, station_table=None)[source]¶ 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
Parameters: - 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
Returns: Pandas DataFrame of station information
Return type: d
-