winds#
Sounding and Hodograph Analysis and Research Program Library (SHARPlib) :: Kinematic Routines
Vectors and Components#
Representations of atmospheric winds as vectors (speed, angle) or components (u, v), their magnitudes, and the various operatins to convert between representations.
- class nwsspc.sharp.calc.winds.WindVector(self)#
- class nwsspc.sharp.calc.winds.WindVector(self, speed: float, direction: float)
- property direction#
Wind Direction (degrees from North)
- property speed#
Wind Speed (m/s)
- class nwsspc.sharp.calc.winds.WindComponents(self)#
- class nwsspc.sharp.calc.winds.WindComponents(self, u_comp: float, v_comp: float)
- property u#
U wind component (m/s)
- property v#
V wind component (m/s)
- nwsspc.sharp.calc.winds.components_to_vector(u_comp: float, v_comp: float) nwsspc.sharp.calc.winds.WindVector #
- nwsspc.sharp.calc.winds.components_to_vector(wind_comp: nwsspc.sharp.calc.winds.WindComponents) nwsspc.sharp.calc.winds.WindVector
- nwsspc.sharp.calc.winds.components_to_vector(u_comp: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], v_comp: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False]) tuple[numpy.ndarray[dtype=float32, shape=(*), order='C'], numpy.ndarray[dtype=float32, shape=(*), order='C']]
Overloaded function.
components_to_vector(u_comp: float, v_comp: float) -> nwsspc.sharp.calc.winds.WindVector
Given the zonal (U) and meridional (V) components of a vector, compute and return the wind speed (m/s) and direction (degrees from North) as a WindVector type.
- Parameters:
u_comp (
float
) – The U-wind component (m/s)v_comp (
float
) – The V-wind component (m/s)
- Returns:
WindVector containing wind speed (m/s) and direction (degrees from North)
- Return type:
components_to_vector(wind_comp: nwsspc.sharp.calc.winds.WindComponents) -> nwsspc.sharp.calc.winds.WindVector
Given the components of a vector via a WindComponents object (m/s), compute and return the wind speed (m/s) and wind direction (degrees from North) as a WindVector type.
- Parameters:
wind_comp (
nwsspc.sharp.calc.winds.WindComponents
) – WindComponents (m/s)- Returns:
WindVector containing wind speed (m/s) and direction (degrees from North)
- Return type:
components_to_vector(u_comp: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], v_comp: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False]) -> tuple[numpy.ndarray[dtype=float32, shape=(*), order='C'], numpy.ndarray[dtype=float32, shape=(*), order='C']]
Given 1D NumPy arrays of zonal (U) and meridional (V) wind components, compute the wind speed (m/s) and direction (degrees from North).
- Parameters:
u_comp (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of U-wind component values (m/s)v_comp (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of V-wind component values (m/s)
- Returns:
wspd: 1D NumPy array of wind speeds (m/s)
wdir: 1D NumPy array of wind directiond (degrees from North)
- Return type:
tuple[numpy.ndarray[dtype=float32]
,numpy.ndarray[dtype=float32]]
- nwsspc.sharp.calc.winds.vector_to_components(wind_speed: float, wind_direction: float) nwsspc.sharp.calc.winds.WindComponents #
- nwsspc.sharp.calc.winds.vector_to_components(wind_vector: nwsspc.sharp.calc.winds.WindVector) nwsspc.sharp.calc.winds.WindComponents
- nwsspc.sharp.calc.winds.vector_to_components(wspd: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], wdir: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False]) tuple[numpy.ndarray[dtype=float32, shape=(*), order='C'], numpy.ndarray[dtype=float32, shape=(*), order='C']]
Overloaded function.
vector_to_components(wind_speed: float, wind_direction: float) -> nwsspc.sharp.calc.winds.WindComponents
Given the wind speed (m/s) and wind direction (degrees from North), compute and return the zonal and meridional vector components as WindComponents.
- Parameters:
wind_speed (
float
) – The magnitude/speed of the vector (m/s)wind_direction (
float
) – The direction of the vector (degrees from North)
- Returns:
The U-wind and V-wind components (m/s) as WindComponents
- Return type:
vector_to_components(wind_vector: nwsspc.sharp.calc.winds.WindVector) -> nwsspc.sharp.calc.winds.WindComponents
Given the wind speed (m/s) and direction (degrees from North), compute and return the zonal (U) and meridional (V) vector components as WindComponents.
- Parameters:
wind_vector (
nwsspc.sharp.calc.winds.WindVector
) – WindVector containing wind wpeed (m/s) and direction (degrees from North)- Returns:
U and V wind components (m/s) in a WindComponents object
- Return type:
vector_to_components(wspd: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], wdir: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False]) -> tuple[numpy.ndarray[dtype=float32, shape=(*), order='C'], numpy.ndarray[dtype=float32, shape=(*), order='C']]
Given 1D NumPy arrays of the wind speed (m/s) and direction (degrees from North), compute and return 1D NumPy arays of the zonal (U) and meridional (V) vector componenWindComponents.
- Parameters:
wspd (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of wind speeds (m/s)wdir (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of wind directions (degrees from North)
- Returns:
uwin: 1D NumPy array of U-wind components
vwin: 1D NumPy array of V-wind components
- Return type:
tuple[numpy.ndarray[dtype=float32]
,numpy.ndarray[dtype=float32]]
- nwsspc.sharp.calc.winds.vector_magnitude(u_comp: float, v_comp: float) float #
- nwsspc.sharp.calc.winds.vector_magnitude(u_comp: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], v_comp: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False]) numpy.ndarray[dtype=float32, shape=(*), order='C']
Overloaded function.
vector_magnitude(u_comp: float, v_comp: float) -> float
Given the zonal (U) and meridional (V) wind components of a vector, compute and return the magnitude (m/s) of the vector.
- Parameters:
u_comp (
float
) – U-wind component (m/s)v_comp (
float
) – V-wind component (m/s)
- Returns:
Wind speed (m/s)
- Return type:
float
vector_magnitude(u_comp: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], v_comp: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False]) -> numpy.ndarray[dtype=float32, shape=(*), order='C']
Given the zonal (U) and meridional (V) components of a vector, compute and return the magnitude (m/s) of the vector.
- Parameters:
u_comp (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of U-wind component (m/s)v_comp (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of V-wind component (m/s)
- Returns:
1D NumPy array of wind speed (m/s)
- Return type:
numpy.ndarray[dtype=float32]
- nwsspc.sharp.calc.winds.vector_angle(u_comp: float, v_comp: float) float #
- nwsspc.sharp.calc.winds.vector_angle(u_comp: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], v_comp: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False]) numpy.ndarray[dtype=float32, shape=(*), order='C']
Overloaded function.
vector_angle(u_comp: float, v_comp: float) -> float
Given the zonal (U) and meridional (V) components of a vector, compute and return the angle (from North) of the vector.
- Parameters:
u_comp (
float
) – The U-wind componentv_comp (
float
) – The V-wind component
- Returns:
Wind direction (degrees from North)
- Return type:
float
vector_angle(u_comp: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], v_comp: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False]) -> numpy.ndarray[dtype=float32, shape=(*), order='C']
Given the zonal (U) and meridional (V) components of a vector, compute and return the angle (from North) of the vector.
- Parameters:
u_comp (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of U-wind component (m/s)v_comp (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of V-wind component (m/s)
- Returns:
1D NumPy array of wind direction (degrees from North)
- Return type:
numpy.ndarray[dtype=float32]
- nwsspc.sharp.calc.winds.u_component(wind_speed: float, wind_direction: float) float #
- nwsspc.sharp.calc.winds.u_component(wind_speed: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], wind_direction: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False]) numpy.ndarray[dtype=float32, shape=(*), order='C']
Overloaded function.
u_component(wind_speed: float, wind_direction: float) -> float
Computes the zonal (U) wind component from a wind vector.
- Parameters:
wind_speed (
float
) – The vector speed (m/s)wind_direction (
float
) – The vector direction (degrees from North)
- Returns:
The U-wind component (m/s)
- Return type:
float
u_component(wind_speed: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], wind_direction: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False]) -> numpy.ndarray[dtype=float32, shape=(*), order='C']
Computes the zonal (U) wind component from a wind vector.
- Parameters:
wind_speed (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of wind speeds (m/s)wind_direction (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of wind direction (degrees)
- Returns:
1D NumPy array of U-wind component values (m/s)
- Return type:
numpy.ndarray[dtype=float32]
- nwsspc.sharp.calc.winds.v_component(wind_speed: float, wind_direction: float) float #
- nwsspc.sharp.calc.winds.v_component(wind_speed: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], wind_direction: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False]) numpy.ndarray[dtype=float32, shape=(*), order='C']
Overloaded function.
v_component(wind_speed: float, wind_direction: float) -> float
Computes the meridional (V) wind component from a wind vector.
- Parameters:
wind_speed (
float
) – Vector speed (m/s)wind_direction (
float
) – Vector angle (degrees from North)
- Returns:
The V-wind component
- Return type:
float
v_component(wind_speed: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], wind_direction: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False]) -> numpy.ndarray[dtype=float32, shape=(*), order='C']
Computes the meridional (V) wind component from a wind vector.
- Parameters:
wind_speed (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of wind speeds (m/s)wind_direction (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of wind direction (degrees)
- Returns:
1D NumPy array of V-wind component values (m/s)
- Return type:
numpy.ndarray[dtype=float32]
Kinematic Variables#
Calculations derived from wind vectors or components related to mean winds, shear, helicity, vorticity, and more.
- nwsspc.sharp.calc.winds.helicity(layer: nwsspc.sharp.calc.layer.HeightLayer, storm_motion: nwsspc.sharp.calc.winds.WindComponents, height: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], u_wind: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], v_wind: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False]) float #
- nwsspc.sharp.calc.winds.helicity(layer: nwsspc.sharp.calc.layer.PressureLayer, storm_motion: nwsspc.sharp.calc.winds.WindComponents, pressure: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], u_wind: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], v_wind: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False]) float
Overloaded function.
helicity(layer: nwsspc.sharp.calc.layer.HeightLayer, storm_motion: nwsspc.sharp.calc.winds.WindComponents, height: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], u_wind: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], v_wind: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False]) -> float
Computes the Storm Relative Helicity (SRH) over a given layer using storm motion vector components stored in a WindComponents object.
This integration occurs over the given arrays, using interpolation for the top and bottom of the integration layer, and native data levels in between.
- Parameters:
layer (
nwsspc.sharp.calc.layer.HeightLayer
) – A HeightLayer to integrate over (meters AGL)storm_motion (
nwsspc.sharp.calc.winds.WindComponents
) – A WindComponents object with the storm motion in m/sheight (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of height values (meters)u_wind (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of environment U-wind components (m/s)v_wind (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of environment V-wind components (m/s)
- Returns:
Storm Relative Helicity (m^2/s^2)
- Return type:
float
helicity(layer: nwsspc.sharp.calc.layer.PressureLayer, storm_motion: nwsspc.sharp.calc.winds.WindComponents, pressure: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], u_wind: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], v_wind: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False]) -> float
Computes the Storm Relative Helicity (SRH) over a given layer using storm motion vector components stored in a WindComponents object.
This integration occurs over the given arrays, using interpolation for the top and bottom of the integration layer, and native data levels in between.
- Parameters:
layer (
nwsspc.sharp.calc.layer.PressureLayer
) – A PressureLayer to integrate over (Pa)storm_motion (
nwsspc.sharp.calc.winds.WindComponents
) – A WindComponents object with the storm motion in m/sheight (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of height values (meters)u_wind (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of environment U-wind components (m/s)v_wind (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of environment V-wind components (m/s)
- Returns:
Storm Relative Helicity (m^2/s^2)
- Return type:
float
- nwsspc.sharp.calc.winds.wind_shear(layer: nwsspc.sharp.calc.layer.HeightLayer, height: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], u_wind: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], v_wind: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False]) nwsspc.sharp.calc.winds.WindComponents #
- nwsspc.sharp.calc.winds.wind_shear(layer: nwsspc.sharp.calc.layer.PressureLayer, pressure: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], u_wind: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], v_wind: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False]) nwsspc.sharp.calc.winds.WindComponents
Overloaded function.
wind_shear(layer: nwsspc.sharp.calc.layer.HeightLayer, height: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], u_wind: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], v_wind: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False]) -> nwsspc.sharp.calc.winds.WindComponents
Computes the U and V components of the wind shear over a layer given the vertical sounding arrays of height, u_wind, and v_wind.
- Parameters:
layer (
nwsspc.sharp.calc.layer.HeightLayer
) – HeightLayer for which to compute wind shearheight (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of height values (meters)u_wind (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of U-wind components (m/s)v_wind (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of V-wind components (m/s)
- Returns:
WindComponents of U and V wind shear components (m/s)
- Return type:
wind_shear(layer: nwsspc.sharp.calc.layer.PressureLayer, pressure: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], u_wind: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], v_wind: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False]) -> nwsspc.sharp.calc.winds.WindComponents
Computes the U and V components of the wind shear over a layer given the vertical sounding arrays of height, u_wind, and v_wind.
- Parameters:
layer (
nwsspc.sharp.calc.layer.PressureLayer
) – PressureLayer for which to compute wind shearheight (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of height values (meters)u_wind (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of U-wind components (m/s)v_wind (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of V-wind components (m/s)
- Returns:
WindComponents of U and V wind shear components (m/s)
- Return type:
- nwsspc.sharp.calc.winds.mean_wind(layer: nwsspc.sharp.calc.layer.PressureLayer, pressure: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], u_wind: ndarray[dtype=float32, shape=(*), order='C', device='cpu', writable=False], v_wind: ndarray[dtype=float32, shape=(*), order='C', device='cpu'], weighted: bool = False) nwsspc.sharp.calc.winds.WindComponents #
Computes the mean wind over the given PressureLayer and input profile arrays of pressure, U-wind, and V-wind components.
- Parameters:
layer (
nwsspc.sharp.calc.layer.PressureLayer
) – PressureLayer over which to compute meanpressure (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of pressure coordinate values (Pa)u_wind (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of U-wind component values (m/s)v_wind (
numpy.ndarray[dtype=float32]
) – 1D NumPy array of V-wind component values (m/s)weighted (
bool
) – Boolean flag to compute pressure-weighted mean wind (default: False)
- Returns:
WindComponents of U anf V mean wind components (m/s)
- Return type: