A Wind instance represents surface wind conditions. The conditions are set using a METAR-style wind direction string (e.g. "180V210") and wind speed string (e.g. "10G15"). These can be set using the setDirection() or setSpeed() methods. These strings can also be retrieved directly from an airport-related page using the setFromPage() method. Other instance methods will return the windo components with respect to a particular runway magnetic heading. Here are some examples:
// create a Wind instance from the departure page settings.
const wind = new Wind('dep');
// find the crosswind on runway 7
const crosswind = wind.crosswind(70);
// find the headwind on runway 7
const headwind = wind.headwind(70);
The computed headwind and crosswind are worst-case: The higher wind gust speed is used, if present and if the winds are variable, the direction that produces the lowest headwind or largest crosswind is used.
Remember that METAR wind directions are always relative to true north and that a local magnetic variance value must be supplied.
If the Wind instance is set from a METAR-style wind specification string that is invalid, the instance has a dirErrorMsg and a speedErrorMsg property that each contains a message string explaining the reason for the error.
new Wind()
new Wind(pageId)
Constructs a new Wind instance. If a pageId string is provided, the instance is initialized from the information on the Page specified by pageId. See the setFromPage() method.
pageIdclone()clone()
Return a new Wind instance that has the same wind settings as this instance.
A Wind instance.
crosswind()crosswind(magHeading)
Returns the worst-case (highest) crosswind component for this runway. Positive numbers are from the right, negative numbers are from the left.
magHeadingA crosswind speed in knots, or INVALID if the wind is not valid (see isValid()).
components()components(magHeading)
Returns the wind components for this runway magnetic heading. The returned value is an object with min and max properties, each containing an array with four elements, with the following values in clockwise order: headwind, right crosswind, tailwind, and left crosswind. The max property is computed using the gust speed, and the min property is computed using the base wind speed.
All four components are zero or positive. If the wind comes from a steady direction, then only one of the headwind and tailwind values is non-zero, and similarly, only one of the right and left crosswind values is non-zero.
If the wind is not valid (see isValid()), then all components are zero.
If the wind direction is variable ('VRB'), then all min values are the base wind speed value, and all max values are the gust wind speed value.
If the wind is shifting between two directions (e.g., 010V040), then it's a bit more complicated. The min values are the minimum wind speed possible in that quadrant for a wind direction within the angular limits and the base wind speed. The max values are the maximum wind speed possible in that quadrant for a wind direction within the angular limits and the gust wind speed.
magHeadingAn object containing min and max properties. Each property contains an array of four numeric values, ordered clockwise around the four quadrants, as follows:
headwind()headwind(magHeading)
Returns the worst-case (lowest) headwind component for this runway. Positive numbers are headwinds, and negative numbers are tailwinds. A positive result is computed using the smaller base wind speed, while a negative result uses the equal or higher gust wind speed.
magHeadingA headwind speed in knots, or INVALID if the wind is not valid (see isValid()).
isValid()isValid()
Return true if both the wind speed and direction are valid.
A Booleans.
setDirection()setDirection(spec)
setDirection(spec, magVar)
Sets the instance's wind direction from the spec string. If the spec is invalid or magVar is outside the range -180 to 180, then dir and dir2 are INVALID. The string may be relative to magnetic north (an ATIS value) or true north (a METAR value). If the value is relative to true north, then a local magnetic variance must be provided.
specmagVar (optional)setFromPage()setFromPage(pageId)
Sets the instance's wind direction and speed from an airport page specified by pageId. The values are retrieved from the following page state variables:
${pageId}_windSpeed_wkt: The wind speed spec string in knots.${pageId}_windDir_M: The wind direction spec string relative to magnetic north.pageId'alt': The alternate airport page'dep': The departure airport page'depRtn': The departure return airport page'dest': The destination airport pagesetSpeed()setSpeed(spec)
setSpeed(spec, units)
Sets the instance's wind speed from the spec string. If the wind speed is in units other than knots (e.g., 'wmps') then the units string must be provided and the wind speed values are converted to knots internally. If units is neither 'wkt' nor 'wmps', then min and max are INVALID.
specunits (optional)'wkt' (knots) or 'wmps' (meters per second). The default value is 'wkt', if not provided.dirA wind direction in degrees relative to magnetic north. If the winds are variable without a range, then the value is the string 'VRB'. Read-only.
dir2A wind direction in degrees relative to magnetic north. If the winds are variable without a range, then the value is the string 'VRB'. dir2 is the second wind direction of a variable range (e.g., the 270 of 240V270), converted to magnetic north like dir. If the winds are not variable, then dir2 equals dir. Read-only.
dirErrorMsgAn error message string for errors in the wind direction specification string. Read-only.
dirSpecThe wind direction string used to set the direction values. Read-only.
maxThe maximum (gust) wind speed in knots. Read-only.
magVarThe magnetic variance in degrees. The magVar value is added to a magnetic north direction to convert to true north. Read-only.
minThe base wind speed in knots. Read-only.
speedErrorMsgAn error message string for errors in the wind speed specification string. Read-only.
speedSpecThe wind speed string used to set the speed values. Read-only.
speedUnitsThe wind speed units string for the speedSpec. Read-only.
The Wind class also registers two units string conversions, 'wkt' to 'wmps' and 'wmps' to 'wkt', that convert a wind speed spec string using Wind.convertSpeed().
Wind.convertDir()Wind.convertDir(spec, from, to, magVar)
Convert a wind direction spec string between magnetic and true north.
specfromspec: 'M' (magnetic) or 'T' (true).to'M' or 'T'.magVarA direction spec string with each direction padded to three digits (e.g., '190V220'). If from equals to, then spec is returned unchanged. 'VRB' is returned unchanged, and an empty string is returned if spec is invalid.
Wind.convertSpeed()Wind.convertSpeed(spec, from, to)
Convert a wind speed spec string between knots and meters per second. The conversion is keyed by the concatenation of the units strings: 'wktwmps' converts knots to meters per second, and any other combination converts meters per second to knots.
specfromspec: 'wkt' or 'wmps'.to'wkt' or 'wmps'.A rounded speed spec string. If the converted gust equals the converted wind speed, then the gust is increased by one so that the gust remains greater than the wind speed. An empty string is returned if spec is invalid.
Wind.decodeDir()Wind.decodeDir(spec)
Decode a wind direction spec string.
specAn object with the following properties:
d1: The first direction (a number from 1 to 360) or 'VRB'.d2: The second direction of a variable range, or undefined.valid: True if the spec is valid. Directions must be from 1 to 360 and the variable directions must differ.errorMsg: An error message string, or '' if the spec is valid.Wind.decodeSpeed()Wind.decodeSpeed(spec)
Decode a wind speed spec string.
specAn object with the following properties:
wind: The base wind speed number.gust: The gust speed number, or undefined.valid: True if the spec is valid. A gust must be greater than the wind speed.errorMsg: An error message string, or '' if the spec is valid.Wind.isValidDir()Wind.isValidDir(spec)
Return true if spec is a valid wind direction spec string. See Wind.decodeDir().
A Boolean.
Wind.isValidSpeed()Wind.isValidSpeed(spec)
Return true if spec is a string that is a valid wind speed spec. See Wind.decodeSpeed().
A Boolean.