Skip to content

jbuitt/nwws-php-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nwws-php-client

A simple client for the NWWS-2 OI (NOAA Weather Wire Service version 2 Open Interface) written in PHP. The NOAA Weather Wire Service is a satellite data collection and dissemination system operated by the National Weather Service, which was established in October 2000. Its purpose is to provide state and federal government, commercial users, media and private citizens with timely delivery of meteorological, hydrological, climatological and geophysical information.

This client uses an updated fork by zorn-v of Fabian Grutschus' popular XMPP PHP library.

How do I run it?

This script was developed and tested on Ubuntu 16.04. After downloading the latest release, run the following command to install the php dependencies. You need at least PHP 7.0+ with pcntl support and a recent version of Composer

    $ composer install

Now create a JSON config file with the following format:

{
  "server": "nwws-oi.weather.gov",
  "port": 5222,
  "username": "[username]",
  "password": "[paswword]",
  "resource": "[resource]",
  "logpath": "/path/to/log/dir",
  "logprefix": "logfile",
  "archivedir": "/path/to/archive/dir",
  "pan_run": "/path/to/executable_or_script"
}

Where [username] and [password] are your NWWS-2 credentials obtained by signing up on the NOAA Weather Wire Service website. You may use whatever you would like for [resource]. The "pan_run" variable is an optional Product Arrival Notification (PAN) script that you'd like to run on product arrival.

You can also filter products by their WMO header. For example, if you only wanted tornado warnings and severe thunderstorm warnings, you could add a 'wmofilter' section to your config file so it looks like this:

{
  "server": "nwws-oi.weather.gov",
  "port": 5222,
  "username": "[username]",
  "password": "[password]",
  "resource": "[resource]",
  "logpath": "/path/to/log/dir",
  "logprefix": "logfile",
  "archivedir": "/path/to/archive/dir",
  "pan_run": "/path/to/executable_or_script",
  "wmofilter": [
    "/^wf.+/",
    "/^wu.+/"
  ]
}

The wmofilter element should be a JSON array with regex patterns of the products you want.

Now run the script:

$ php ./nwws2.php /path/to/config/file

Provided that you're able to connect to the NWWS and your credentials are accepted, you will start to see products appear in the supplied archive directory in the following format:

[archive_dir]/
   [wfo]/
      [wfo]_[wmo_TTAAii]-[awips_id].[product_yearhour]_[product_id].txt

You can then type Ctrl+Z and then bg to send it to the background to continue downloading products. The client will automatically reconnect to NWWS if the connection is dropped. I have also provided a 'nwws2' bash script to take care of running the client using nohup. You'll need to copy the file 'contrib/etc/default/nwws2' to '/etc/default' before running the 'nwws2' script.

Author

License

See LICENSE file.

About

NOAA Weather Wire Service (NWWS) PHP Client

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published