smrf.distribute.wind package

Submodules

smrf.distribute.wind.wind module

class smrf.distribute.wind.wind.Wind(config)[source]

Bases: smrf.distribute.image_data.image_data

The wind class allows for variable specific distributions that go beyond the base class.

Three distribution methods are available for the Wind class:

  1. Winstral and Marks 2002 method for maximum upwind slope (maxus)

  2. Import WindNinja simulations

  3. Standard interpolation

Parameters

self.config – The full SMRF configuration file

config

configuration from [wind] section

wind_speed

numpy matrix of the wind speed

wind_direction

numpy matrix of the wind direction

veg_type

numpy array for the veg type, from smrf.data.loadTopo.Topo.veg_type

_maxus_file

the location of the maxus NetCDF file

maxus

the loaded library values from _maxus_file

maxus_direction

the directions associated with the maxus values

min

minimum value of wind is 0.447

max

maximum value of wind is 35

stations

stations to be used in alphabetical order

VARIABLE = 'wind'
distribute(data_speed, data_direction, t)[source]

Distribute given a Panda’s dataframe for a single time step. Calls smrf.distribute.image_data.image_data._distribute for the wind_model chosen.

Parameters
  • data_speed – Pandas dataframe for single time step from wind_speed

  • data_direction – Pandas dataframe for single time step from wind_direction

  • t – time stamp

distribute_thread(queue, data_speed, data_direction)[source]

Distribute the data using threading and queue. All data is provided and distribute_thread will go through each time step and call smrf.distribute.wind.wind.distribute then puts the distributed data into the queue for wind_speed.

Parameters
  • queue – queue dictionary for all variables

  • data – pandas dataframe for all data, indexed by date time

initialize(topo, data)[source]

Initialize the distribution, calls smrf.distribute.image_data.image_data._initialize. Checks for the enhancement factors for the stations and vegetation.

Parameters
output_variables = {'flatwind': {'long_name': 'Simulated wind on a flat surface', 'standard_name': 'flatwind_wind_speed', 'units': 'm/s'}, 'wind_direction': {'long_name': 'Wind direction', 'standard_name': 'wind_direction', 'units': 'degrees'}, 'wind_speed': {'long_name': 'Wind speed', 'standard_name': 'wind_speed', 'units': 'm/s'}}
post_process_variables = {}

smrf.distribute.wind.wind_ninja module

class smrf.distribute.wind.wind_ninja.WindNinjaModel(smrf_config)[source]

Bases: smrf.distribute.image_data.image_data

The WindNinjaModel loads data from a WindNinja simulation. The WindNinja is ran externally to SMRF and the configuration points to the location of the output ascii files. SMRF takes the files and interpolates to the model domain.

DATE_FORMAT = '%Y%m%d'
VARIABLE = 'wind'
WN_DATE_FORMAT = '%m-%d-%Y_%H%M'
convert_wind_ninja(t)[source]

Convert the WindNinja ascii grids back to the SMRF grids and into the SMRF data streamself.

Parameters

t – datetime of timestep

Returns

wind speed numpy array wd: wind direction numpy array

Return type

ws

distribute(data_speed, data_direction)[source]

Distribute the wind for the model

Parameters
  • {DataFrame} -- wind speed data frame (data_speed) –

  • {DataFrame} -- wind direction data frame (data_direction) –

fill_data(g_vel)[source]

Fill the WindNinja array that has NaN’s. This makes an assumption that all the NaN values are along the left and bottom edge. This will be the case in the Northern hemisphere. First fill the Y direction with 1d interpolation exprapolated to the edges, then do the same in the X direction. At the end, it will check to ensure that there are no NaN values left.

Parameters

{np.array} -- numpy array to fill (g_vel) –

Raises

ValueError – If there are still NaN values after filling

Returns

np.array – filled numpy array

initialize(topo, data=None)[source]

Initialize the model with data

Parameters
  • {topo class} -- Topo class (topo) –

  • {None} -- Not used but needs to be there (data) –

initialize_interp(t)[source]

Initialize the interpolation weights

Parameters

{datetime} -- initialize with this file (t) –

wind_ninja_path(dt, file_type)[source]

Generate the path to the wind ninja data and ensure it exists.

Parameters

{str} -- type of file to get (file_type) –

smrf.distribute.wind.wind_ninja.interpx(yi, xi, x)[source]

Interpolate in on direction

Parameters
  • {array} -- y data to fit (yi) –

  • {array} -- x data to fit (xi) –

  • {array} -- x data to interpolate over (x) –

Returns

array – y values evaluated at x

smrf.distribute.wind.winstral module

class smrf.distribute.wind.winstral.WinstralWindModel(smrf_config)[source]

Bases: smrf.distribute.image_data.image_data

Estimating wind speed and direction is complex terrain can be difficult due to the interaction of the local topography with the wind. The methods described here follow the work developed by Winstral and Marks (2002) and Winstral et al. (2009) [19] [20] which parameterizes the terrain based on the upwind direction. The underlying method calulates the maximum upwind slope (maxus) within a search distance to determine if a cell is sheltered or exposed. See smrf.utils.wind.model for a more in depth description. A maxus file (library) is used to load the upwind direction and maxus values over the dem. The following steps are performed when estimating the wind speed:

  1. Adjust measured wind speeds at the stations and determine the wind direction componenets

  2. Distribute the flat wind speed

  3. Distribute the wind direction components

  4. Simulate the wind speeds based on the distribute flat wind, wind direction, and maxus values

After the maxus is calculated for multiple wind directions over the entire DEM, the measured wind speed and direction can be distirbuted. The first step is to adjust the measured wind speeds to estimate the wind speed if the site were on a flat surface. The adjustment uses the maxus value at the station location and an enhancement factor for the site based on the sheltering of that site to wind. A special consideration is performed when the station is on a peak, as artificially high wind speeds can be calcualted. Therefore, if the station is on a peak, the minimum maxus value is choosen for all wind directions. The wind direction is also broken up into the u,v componenets.

Next the flat wind speed, u wind direction component, and v wind direction compoenent are distributed using the underlying distribution methods. With the distributed flat wind speed and wind direction, the simulated wind speeds can be estimated. The distributed wind direction is binned into the upwind directions in the maxus library. This determines which maxus value to use for each pixel in the DEM. Each cell’s maxus value is further enhanced for vegetation, with larger, more dense vegetation increasing the maxus value (more sheltering) and bare ground not enhancing the maxus value (exposed). With the adjusted maxus values, wind speed is estimated using the relationships in Winstral and Marks (2002) and Winstral et al. (2009) [19] [20] based on the distributed flat wind speed and each cell’s maxus value.

VARIABLE = 'wind'
distribute(data_speed, data_direction)[source]

Distribute the wind for the model

Follows the following steps for station measurements:

  1. Adjust measured wind speeds at the stations and determine the wind

    direction componenets

  2. Distribute the flat wind speed

  3. Distribute the wind direction components

  4. Simulate the wind speeds based on the distribute flat wind, wind

    direction, and maxus values

Parameters
  • {DataFrame} -- wind speed data frame (data_speed) –

  • {DataFrame} -- wind direction data frame (data_direction) –

initialize(topo, data)[source]

Initialize the model with data

Parameters
  • {topo class} -- Topo class (topo) –

  • {data object} -- SMRF data object (data) –

simulateWind(data_speed)[source]

Calculate the simulated wind speed at each cell from flatwind and the distributed directions. Each cell’s maxus value is pulled from the maxus library based on the distributed wind direction. The cell’s maxus is further adjusted based on the vegetation type and the factors provided in the [wind] section of the configuration file.

Parameters

data_speed – Pandas dataframe for a single time step of wind speed to make the pixel locations same as the measured values

stationMaxus(data_speed, data_direction)[source]

Determine the maxus value at the station given the wind direction. Can specify the enhancemet for each station or use the default, along with whether or not the station is on a peak which will ensure that the station cannot be sheltered. The station enhancement and peak stations are specified in the [wind] section of the configuration file. Calculates the following for each station:

  • flatwind

  • u_direction

  • v_direction

Parameters
  • data_speed – wind_speed data frame for single time step

  • data_direction – wind_direction data frame for single time step

Module contents