0.03
Low commit activity in last 3 years
No release in over a year
metar-parser is a ruby gem that downloads weather reports, parses them and formats reports. It also provides weather station listings and info (e.g. country, latitude and longitude). Reports can be fully localized (currently Brazilian Portuguese, English, German and Italian are available).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
~> 3.2
>= 12.3.3

Runtime

~> 0.3.5
>= 0.8.0
 Project Readme

Build Status

metar-parser

Get latest weather reports from weather stations worldwide

The information comes from the National Oceanic and Atmospheric Association's raw data source.

Installation

require 'metar'

Examples

Hello World

This prints the latest weather report for Portland International Airport:

station = Metar::Station.find_by_cccc('KPDX')
puts station.report.to_s

Using Your Own Raw Data

The parser needs to know the full date when the reading was taken. Unfortunately, the METAR string itself only contains the day of the month.

When you know the date of the reading

Use Metar::Raw::Data and supply the date as the second parameter:

metar_string = "KHWD 280554Z AUTO 29007KT 10SM OVC008 14/12 A3002 RMK AO2 SLP176 T01390117 10211\n"
raw    = Metar::Raw::Data.new(metar_string, reading_date)
parser = Metar::Parser.new(raw)

When you do not know the date

Use Metar::Raw::Metar - the library will choose the date as the most recent day with the day of the month indicated in the METAR string:

I.e. on 11th April 2016:

metar_string = "KHWD 280554Z AUTO 29007KT 10SM OVC008 14/12 A3002 RMK AO2 SLP176 T01390117 10211\n"
raw    = Metar::Raw::Metar.new(metar_string)
raw.time.to_s                              # => "2016-03-28"
parser = Metar::Parser.new(raw)

Access Specific Data

station = Metar::Station.find_by_cccc('KPDX')
parser  = station.parser
puts parser.temperature.value

Countries

List countries:

puts Metar::Station.countries

Find a country's weather stations:

spanish = Metar::Station.find_all_by_country('Spain')

Translations

Translations are available for the following languages (and region):

  • :de
  • :en
  • :'en-US'
  • :it
  • :'pt-BR'

Thanks to the I18n gem's fallback mechanism, under regional locales, language generic translations will be used if a region-specific translation is not available. I.e.

I18n.locale = :'en-US'
I18n.t('metar.station_code.title') # station code

The METAR Format

See doc/metar_format.

Compliance

By default, the parser runs in 'loose' compliance mode. That means that it tries to accept non-standard input.

If you only want to accept standards-compliant METAR strings, do this:

Metar::Parse.compliance = :strict

Contributors