Module: WrfLibrary::Measurand::Wind
- Defined in:
- lib/wrf_library/measurand/wind.rb
Overview
Helper module to calculate wind information from the wind vector components
Class Method Summary collapse
-
.calculate_winddirection(u_component, v_component) ⇒ Array
method to calculate the wind direction from its two dimenstional components.
-
.calculate_windspeed(u_component, v_component) ⇒ Array
method to calculate the wind speed from its two dimenstional components.
Class Method Details
.calculate_winddirection(u_component, v_component) ⇒ Array
method to calculate the wind direction from its two dimenstional components
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/wrf_library/measurand/wind.rb', line 26 def self.calculate_winddirection(u_component, v_component) r2d = 180.0 / (Math.atan(1) * 4.0) wind_direction = Array.new() u_component.zip(v_component).each { |u, v| if (u != 0.0 || v != 0.0) wind_direction << Math.atan2(u, v) * r2d + 180 else # normally atan2(0,0) is undefined, but implementation returns 0, so catch this edge case wind_direction << -1 end } wind_direction end |
.calculate_windspeed(u_component, v_component) ⇒ Array
method to calculate the wind speed from its two dimenstional components
13 14 15 16 17 18 19 20 |
# File 'lib/wrf_library/measurand/wind.rb', line 13 def self.calculate_windspeed(u_component, v_component) r2d = 180.0 / (Math.atan(1) * 4.0) wind_speed = Array.new() u_component.zip(v_component).each { |u, v| wind_speed << Math.sqrt(u**2+v**2) } wind_speed end |