winds#

Vectors and Components#

struct WindVector#

A simple structure of two named floats that represent a wind vector.

Author

Kelton Halbert - NWS Storm Prediction Center

Public Members

float speed#

The magntidue of a wind vector.

float direction#

The direction (degrees from North) of a wind vector.

struct WindComponents#

A simple structure of two names floats that represent the components of a wind vector.

Author

Kelton Halbert - NWS Storm Prediction Center

Public Members

float u#

The zonal (U) component of a wind vector.

float v#

The meridional (V) component of a wind vector.

WindVector sharp::components_to_vector(WindComponents comp)#

Conveniance function to compute wind speed and direction from components.

Author

Kelton Halbert - NWS Storm Prediction Center

Given the components of a vector via sharp::WindComponents, compute and return the wind speed (m/s) and direction (degrees from North) and return them as sharp::WindVector.

Parameters:

comp – {u_comp, v_comp}

Returns:

{wind_speed, wind_direction}

WindVector sharp::components_to_vector(float u_comp, float v_comp)#

Conveniance function to compute wind speed and direction from components.

Author

Kelton Halbert - NWS Storm Prediction Center

Given the zonal (U) and meridional (V) components of a vector, compute and return the wind speed (m/s) and direction (degrees from North) from the components as a struct.

Parameters:
  • u_comp – (m/s)

  • v_comp – (m/s)

Returns:

{wind_speed, wind_direction}

WindComponents sharp::vector_to_components(WindVector vect)#

Conveniance function to compute the U and V components of a wind vector.

Author

Kelton Halbert - NWS Storm Prediction Center

Given the wind speed and direction of a vector via sharp::WindVector, compute and return the zonal and meridional vector components as a struct.

Parameters:

vect – {speed, direction}

Returns:

{u_comp, v_comp}

WindComponents sharp::vector_to_components(float wind_speed, float wind_direction)#

Conveniance function to compute the U and V components of a wind vector.

Author

Kelton Halbert - NWS Storm Prediction Center

Given the wind speed and direction of a vector, compute and return the zonal and meridional vector components as a struct.

Parameters:
  • wind_speed – (m/s)

  • wind_direction – (degrees from North)

Returns:

{u_comp, v_comp}

float sharp::vector_magnitude(float u_comp, float v_comp)#

Computes the magnitude of a vector given its components.

Author

John Hart - NSSFC KCMO / NWSSPC OUN

Given the zonal (U) and meridional (V) components of a vector, compute and return the magnitude (m/s) of the vector.

Parameters:
  • u_comp – (m/s)

  • v_comp – (m/s)

Returns:

wind_speed (m/s)

float sharp::vector_magnitude_precise(float u_comp, float v_comp)#

Precisely computes the magnitude of a vector given its components.

Author

John Hart - NSSFC KCMO / NWSSPC OUN

Given the zonal (U) and meridional (V) components of a vector, compute and return the magnitude (distance / time) of the vector. Instead of using a standard sqrt(u*u + v*v) approach, this uses the c++ Standard Template Library implementation of std::hypot. Using std::hypot is ~20 times slower, but ensures a higher accuracy and checks for overflow/underflow when using extremely large or extremely small values. Chances are, you are fine using the imprecise version as long as values are in the range of 1e-100 < values < 1e100.

Parameters:
  • u_comp – (m/s)

  • v_comp – (m/s)

Returns:

wind_speed (m/s)

float sharp::vector_angle(float u_comp, float v_comp)#

Computes the direction (degrees from North) a vector points to.

Author

John Hart - NSSFC KCMO / NWSSPC OUN

Given the zonal (U) and meridional (V) components of a vector, compute and return the direction (degrees from North) the vector points to.

Parameters:
  • u_comp – (m/s)

  • v_comp – (m/s)

Returns:

wind_direction (degrees from North)

float sharp::u_component(float wind_speed, float wind_direction)#

Computes the zonal (U) wind component from a wind vector.

Author

John Hart - NSSFC KCMO / NWSSPC OUN

Given the wind speed and direction, compute and return the zonal (U) wind component.

Parameters:
  • wind_speed – (m/s)

  • wind_direction – (degrees from North)

Returns:

u_component (m/s)

float sharp::v_component(float wind_speed, float wind_direction)#

Computes the meridional (V) wind component from a wind vector.

Author

John Hart - NSSFC KCMO / NWSSPC OUN

Given the wind speed and direction, compute and return the meridional (V) wind component.

Parameters:
  • wind_speed – (m/s)

  • wind_direction – (degrees from North)

Returns:

v_component (m/s)

Kinematic Variables#

template<typename L>
float sharp::helicity(L layer, WindComponents storm_motion, const float coord[], const float u_wind[], const float v_wind[], const std::ptrdiff_t N)#

Computes the Storm Relative Helicity (SRH) over a given layer.

Author

Kelton Halbert - NWS Storm Prediction Center

Computes the Storm Relative Helicity (SRH) over a given layer using storm motion vector components stored in sharp::WindComponents. This tempalte is the generalized form that will fill in the appropriate interpolation calls and coordinate arrays depending on whether a sharp::PressureLayer or sharp::HeightLayer gets passed to this template. The other API instances are just static instantiations of this template.

This integration occurs over the given arrays of coord, u_wind, and v_wind, with N elements in each. The integration only uses interpolation for the top and bottom of the specified layer.

If using a sharp::HeightLayer, units are expected in above-ground-level (AGL), and gets converted to above-mean-sea-level (MSL) during the computation.

Parameters:
  • layer – {bottom, top}

  • storm_motion – {storm_u, storm_v}

  • coord – (meters or Pa)

  • u_wind – (m/s)

  • v_wind – (m/s)

  • N – (length of arrays)

Returns:

storm_relative_helicity

template<typename L>
constexpr WindComponents sharp::wind_shear(L layer, const float coord[], const float u_wind[], const float v_wind[], const std::ptrdiff_t N)#

Compue the wind shear for a given layer.

Author

Kelton Halbert - NWS Storm Prediction Center

Computes the U and V components of the wind shear over a layer given the vertical sounding arrays of pressure/height, u_wind, v_wind, and their length.

This generic template handles the logic at compike time on whether or not this is a sharp::HeightLayer or a sharp::PressureLayer, and calls the interpolation routines accordingly

Parameters:
  • layer – {bottom, top}

  • coord – (meters or Pa)

  • u_wind – (m/s)

  • v_wind – (m/s)

  • N – (length of arrays)

Returns:

{shear_u, shear_v}

WindComponents sharp::mean_wind(PressureLayer layer, const float pres[], const float u_wind[], const float v_wind[], const std::ptrdiff_t N, const bool weighted)#

Compute the mean wind over the given sharp::PressureLayer.

Author

Kelton Halbert - NWS Storm Prediction Center

Computes the mean wind over the given sharp::PressureLayer and arrays of pressure and wind components with a length of N.

Parameters:
  • layer – {bottom, top}

  • pres – (Pa)

  • u_wind – (m/s)

  • v_wind – (m/s)

  • N – (length of arrays)

  • weighted – (whether to weight by pressure level)

Returns:

{mean_u, mean_v}