Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

noaa_weather_client

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

noaa_weather_client

  • 0.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Build Status

NoaaWeatherClient

Ruby wrapper for the NOAA weather API.

Installation

Add this line to your application's Gemfile:

gem 'noaa_weather_client'

And then execute:

$ bundle

Or install it yourself as:

$ gem install noaa_weather_client

Notes

Weather Station Caching

It is important to cache a copy of the available stations for frequent use as the stations response is quite large NOAA does not appreciate repeated calls.

# cache a copy of stations and store in memory, file, etc.
stations = client.weather_stations

# current_observations
client.current_observations(some_lat, some_lon, stations: stations)

# nearest_weather_station
client.nearest_weather_station(some_lat, some_lon, stations: stations)

Filtering Weather Stations

In my experience, the best observations tend to come from the ICAO(mostly airports) stations. There are many other stations - typically in cities and near the coast, but the observations tend to be partial and intermittent.

# filter by station type
filter = NoaaWeatherClient::StationFilters.icao
client.nearest_weather_station(some_lat, some_lon, stations: stations, filter: filter)

Postal Codes

NOAA provides a service to resolve postal codes to a coordinate.

# convert postal code to coordinate
coordinate = client.postal_code_to_coordinate(90210)
coordinate.latitude #=> 34.0995
coordinate.longitude #=> -118.414

Usage

# create a client instance
client = NoaaWeatherClient.build_client

# all weather stations
client.weather_stations

# locate the nearest weather station
client.nearest_weather_station(34.0995, -118.414)

# 7 day forecast
client.forecast_by_day(34.0995, -118.414)

# current observations
client.current_observations(34.0995, -118.414)

CLI

$ noaa_weather_client -p 65804
 #=> 34.0995 -118.414

# current observations 
$ noaa_weather_client 34.0995 -118.414

# include 7 day forecast
$ noaa_weather_client -f 34.0995 -118.414
 
# resolve postal code and pipe args
$ noaa_weather_client -p 90210 | xargs noaa_weather_client -f

Contributing

Contributions are always welcome. A few notes:

  • Keep changes small and on topic.
  • Stay consistent with existing code conventions.
  • Break changes into smaller logical commits.

To propose a change or fix a bug:

FAQs

Package last updated on 03 Mar 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc