Jump to content

LuaDoc

Modules

  • metar

Files


Module metar

Lua class to parse METAR coded weather reports and fetch current METAR reports from NOAA Internet Weather Service. The parser is pretty simple and by no means claims to support every feature one might find in METAR coded weather reports. For example, weather forecasts and automatic weather reports are not detected. Unsupported features in the weather reports are silently dropped.

Author:

  • Tuomas Jormola

Copyright: © 2011-2016 Tuomas Jormola tj@solitudo.net http://solitudo.net Licensed under the terms of the GNU General Public License Version 2.0.

Functions summary

metatable. index:get metar data (*`*)` Return parsed METAR data as a table
new (args) Create a new METAR object

Tables summary

CLOUD COVERAGE Could coverage table.
CLOUD TYPE Could type table.
SKY STATUS Could type table.
WEATHER DESCRIPTOR Weather descriptor table.
WEATHER INTENSITY Weather intensity table.
WEATHER PHENOMENA Weather phenomena table.
WIND DIRECTION Wind direction table.

Functions


metatable.index:getmetardata ()

Return parsed METAR data as a table

Usage

  • var m = metar.new('EFHF') -- Weather station Helsinki/Malmi
  • var md = m:get_metar_data() -- metardata.temperature contains the temperature etc.
  • if md.temperature >= 30 then print("It's hot!") end
  • if md.weather.intensity and md.weather.intensity == m.WEATHER_INTENSITY.HEAVY and md.weather.phenomena and md.weather.phenomena == m.WEATHER_PHENOMENA.RAIN then print("It's raining a lot!") end

Return values:

  1. Table containing the data parsed from the METAR data. If an error occurs, returns nil as the first return value. The table may contain following entries
    • timestamp os.time table which represents the timestamp when the METAR data was generated. Time is in UTC. Always included.
    • wind A table representing the wind phenomena with the following keys. Optional, but usually included.
      • direction Wind direction as a value of the WIND_DIRECTION table.
      • speed Wind speed in knots.
      • gust Gust speed in knots, optional.
    • visibility A list of tables that represent the visibility towards different directions. Tables contain the following keys. Optional, but if defined, at least one visibility entry exists in the list. Usually included.
      • direction Direction as a value of the WIND_DIRECTION table. Optional.
      • distance Visibility distance in meters
    • vertical_visibility Vertical visibility in meters. Optional.
    • runway_visual_range A table representing runway visual range with the following keys. Optional.
      • runway Runway code
      • visibility Visibility in meters
    • clouds A list of tables that represent clouds at different altitudes. Tables contain the following keys. Optional, but if defined, at least one cloud entry exists in the list. Usually included.
      • coverage Cloud coverate as a value of the CLOUD_COVERAGE table.
      • altitude Altitude of the clouds in feet.
      • type Cloud type as a value of the CLOUD_TYPE table.
    • weather A table representing weather conditions with the following keys. Optional, but usually included.
    • descriptor Weather descriptor as a value of the WEATHER_DESCRIPTOR table. Optional.
    • phenomena Weather phenomena as a value of the WEATHER_PHENOMENA table. Always included.
  2. sky Sky status as a value of the SKY_STATUS table. Always included.
  3. temperature Temperature in Celcius. Always included.
  4. dewpoint Dewpoint temperature in Celcius. Always included.
  5. pressure Pressure in hectopascals. Optional, but usually included.
  6. Error string in case an error occurred and nil METAR table is returned

new (args)

Create a new METAR object

Parameters

  • args: String that is either the METAR data string (one line) to parse or the four-letter, upper-case ICAO code for the weather station. If weather station code is given, the current METAR data for the station is downloaded from IWS.

Return value:

A table which is the metar object for METAR data given or downloaded from IWS for the given weather station code

Tables


CLOUD_COVERAGE

Could coverage table. Values from this table are used in the result table with key clouds[n].coverage returned by get_metar_data().

Fields

  • CLEAR: Clear
  • FEW: Few clouds
  • SCATTERED: Scattered clouds
  • BROKEN_SKY: Broken sky
  • OVERCAST: Overcast

CLOUD_TYPE

Could type table. Values from this table are used in the result table with key clouds[n].type returned by get_metar_data().

Fields

  • CUMULONIMBUS: Cumulonimbus clouds
  • TOWERING_CUMULUS: Towering Cumulus clouds

SKY_STATUS

Could type table. Values from this table are used in the result table with key sky returned by get_metar_data().

Fields

  • UNKNOWN: Sky type is unknown
  • OBSCURE: Obscured sky
  • CLOUDS: Clouds in the sky
  • CLEAR: Clear sky
  • NO_SIGNIFICANT_CLOUDS: No significant clouds detected
  • NO_CLOUDS_DETECTED: No clouds detected

WEATHER_DESCRIPTOR

Weather descriptor table. Values from this table are used in the result table with key weather.descriptor returned by get_metar_data().

Fields

  • SHALLOW: Shallow phenomena
  • PARTIAL: Partial phenomena
  • PATCHES: Patches phenomena
  • DRIFTING: Drifring phenomena
  • BLOWING: Blowing phenomena
  • SHOWERS: Showers phenomena
  • THUNDERSTORM: Thunderstorm phenomena
  • FREEZING: Freezing phenomena

WEATHER_INTENSITY

Weather intensity table. Values from this table are used in the result table with key weather.intensity returned by get_metar_data().

Fields

  • MODERATE: Moderate phenomena
  • LIGHT: Light phenomena
  • HEAVY: Heavy phenomena
  • VICINITY: In the vicinity of the weather observation point

WEATHER_PHENOMENA

Weather phenomena table. Values from this table are used in the result table with key weather.phenomena returned by get_metar_data().

Fields

  • DRIZZLE: Drizzle
  • RAIN: Rain
  • SNOW: Snow
  • SNOW_GRAINS: Snow grains
  • ICE_CRYSTALS: Ice crystals
  • ICE_PELLETS: Ice pellets
  • HAIL: Hail
  • SMALL_HAIL: Small hail
  • UNKNOWN: Unknown phenomena
  • MIST: Mist
  • FOG: Fog
  • SMOKE: Smoke
  • VOLCANIC_ASH: Volcanic ash
  • WIDESPREAD_DUST: Widespread dust
  • SAND: Sand
  • HAZE: Haze
  • SPRAY: Spray
  • DUST_WHIRLS: Dust whirls
  • SQUALLS: Squalls
  • FUNNEL_CLOUD: Funnel cloud
  • SAND_STORM: Sand storm
  • DUST_STORM: Dust storm

WIND_DIRECTION

Wind direction table. Values from this table are used in the result table with key wind.direction returned by get_metar_data().

Fields

  • VRB: Index value for variable speed direction
  • N: Index value for North
  • NNE: Index value for North - North East
  • NE: Index value for Nort - East
  • ENE: Index value for East - North East
  • E: Index value for East
  • ESE: Index value for East - South East
  • SE: Index value for South East
  • SSE: Index value for South - South Est
  • S: Index value for South
  • SSW: Index value for South - South West
  • SW: Index value for South West
  • WSW: Index value for West - South West
  • W: Index value for West
  • WNW: Index value for West - North West
  • NW: Index value for North West
  • NNW: Index value for North - North West