Package Exports
- @atmosx/event-product-parser
- @atmosx/event-product-parser/dist/cjs/index.cjs
- @atmosx/event-product-parser/dist/esm/index.mjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@atmosx/event-product-parser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
🌪️ AtmosphericX - Event Product Parser ⚠️
This repository contains the primary parser for AtmosphericX's NOAA Weather Wire Service (NWWS) and National Weather Service (NWS) API. It is designed to handle real time weather alerts and messages from the National Weather Service, using both XMPP (NWWS) and direct API access (Slower). This parser is intended for developers who want to integrate real time weather alerts, watches, warnings, and forecast data from the NWS seamlessly into their applications or services. It is not recommended for users without basic programming knowledge. If you wish to access NOAA weather data without programming, consider using our end-user project, which leverages this parser and provides an easy-to-use interface for tracking weather alerts.
Documentation written by @k3yomi
Installation (NPM)
npm install @atmosx/event-product-parser@latest # Latest
npm install @atmosx/event-product-parser@beta # BetaExample Usage
const { AlertManager } = require('@atmosx/product-parser'); // CJS
import { AlertManager } from '@atmosx/product-parser'; // ESM
const parser = new AlertManager({
database: `shapefiles.db`,
is_wire: true,
journal: true,
noaa_weather_wire_service_settings: {
reconnection_settings: {
enabled: true,
interval: 60,
},
credentials: {
username: `username_here`,
password: `password_here`,
nickname: "AtmosphericX Parser",
},
cache: {
enabled: false,
max_db_history: 5000,
max_db_cache_size: 1000,
},
preferences: {
disable_ugc: false,
disable_vtec: false,
disable_text: false,
cap_only: false,
}
},
national_weather_service_settings: {
interval: 15,
endpoint: `https://api.weather.gov/alerts/active`,
},
global_settings: {
parent_events_only: true,
better_event_parsing: true,
shapefile_coordinates: false,
shapefile_skip: 10,
filtering: {
events: [`Severe Thunderstorm Warning`],
filtered_icao: [`KLOT`],
ignored_icao: [],
ignored_events: [`Xx`, `Test Message`],
ugc_filter: [],
state_filter: [],
check_expired: true,
ignore_test_products: true,
},
eas_settings: {
directory: null,
intro_wav: null,
}
},
})NOAA Weather Wire Service (Getting Started)
To use the NOAA Weather Wire Service (NWWS). You would need to obtain credentials from the National Weather Service. Follow these steps:
- Visit the NOAA NWWS Registration Page.
- Fill out the registration form with the required information.
- Submit the form and wait for approval. You will receive your NWWS credentials via email.
Events and Listeners
All events are in GeoJSON.
Event onEvents
Triggered when a batch of new alerts are received and processed.
parser.on(`onEvents`, (alerts) => {
console.log(`Received ${alerts.length} new alerts.`);
alerts.forEach(alert => {
console.log(`${alert.properties.event} for ${alert.properties.locations}`);
});
});Alternatively, you can listen for single alert events using onSevereThunderstormWarning or onTornadoWarning, etc.
parser.on(`onTornadoWarning`, (alert) => {
console.log(`Tornado Warning issued for ${alert.properties.locations}`);
});Event onReconnection
Triggered when the parser attempts to reconnect to the NWWS service.
parser.on(`onReconnection`, (data) => {
console.log(`Reconnection attempt #${data.reconnects}`);
});Event onConnection
Triggered when the parser successfully connects to the NWWS service.
parser.on(`onConnection`, (nickname) => {
console.log(`Connected to NWWS service as ${nickname}`);
});Event onOccupant
Triggered when a new occupant is detected on the NWWS XMPP service.
parser.on(`onOccupant`, (data) => {
console.log(`New occupant detected: ${data.occupant}`);
});Event onMessage
Triggered when a stanza message is validated and received from the XMPP client.
parser.on(`onMessage`, (data) => {
console.log(`Message received from ${data.from}: ${data.message}`);
});Event onTest
Triggered when a test message comes in. Ex: Test Tsunami Warning
parser.on(`onTest`, (alert) => {
console.log(`Test alert received for ${alert.properties.locations}`);
});Event onExpired
Triggered when an alert expires.
parser.on(`onExpired`, (alert) => {
console.log(`Alert expired for ${alert.properties.event} for locations of ${alert.properties.locations}`);
});Event onFilteredEvent / onIgnoredEvent
Triggered when an alert is filtered out.
parser.on(`onFilteredEvent`, (alert) => {
console.log(`Alert filtered for ${alert.properties.event}`);
});
parser.on(`onIgnoredEvent`, (alert) => {
console.log(`Alert ignored for ${alert.properties.event}`);
});Event onFilteredICAO / (onIgnoredICAO)
Triggered when an alert is filtered out based on its ICAO code.
parser.on(`onFilteredICAO`, (alert) => {
console.log(`Alert filtered for ${alert.properties.event}`);
});
parser.on(`onIgnoredICAO`, (alert) => {
console.log(`Alert ignored for ${alert.properties.event}`);
});Event onFilteredUGC
Triggered when an alert is filtered out based on its UGC zone.
parser.on(`onFilteredUGC`, (alert) => {
console.log(`Alert filtered for ${alert.properties.event}`);
});Event onFilteredState
Triggered when an alert is filtered out based on its state (Abbreviation)
parser.on(`onFilteredState`, (alert) => {
console.log(`Alert filtered for ${alert.properties.event}`);
});Event log
Triggered for logging purposes, providing log level and message.
parser.on(`log`, (message) => {
console.log(data.message);
});Callbacks and Functions
Function setDisplayName(name)
Sets the display name for the XMPP client. This requires reconnection to take effect.
parser.setDisplayName(`My Weather Parser`);Function createEasAudio(description, header)
Generates an EAS audio file based on the provided description and header. Audio file will be located based on settings provided in the global_settings.eas_settings object. If you are running linux, festival is required to use this or it will error out.
parser.createEasAudio(`This is a test alert`, `EAS Header Info`);Function getAllAlertTypes()
Returns an array of all supported alert types by the parser.
const alertTypes = parser.getAllAlertTypes();
console.log(alertTypes);Function getEventPolygon(event)
Retrieves the geographical polygon for a given event based on its generated geocode and UGC zones. (Returns in GeoJSON format)
const polygon = await parser.getEventPolygon(event);
console.log(polygon);Function searchStanzaDatabase(query)
Searches the internal stanza database for messages matching the provided query.
const results = parser.searchStanzaDatabase(`Tornado Warning`);
console.log(results);Function setSettings({})
Dynamically updates the parser settings. Accepts the same configuration object as the constructor.
parser.setSettings({
global_settings: {
filtering: {
ignored_icao: [`KXYZ`],
}
}
});Function stop()
Stops the parser and disconnects from the NWWS service.
parser.stop();References
NOAA NWWS Information |
NWS API Documentation |
XMPP Protocol |
AtmosphericX |
Documentation |
Discord Server |
Project Board |
Code of Conduct |
Contributing |
License |
Security |
Changelogs |
Acknowledgements
- k3yomi
- Lead developer @ AtmosphericX and maintainer of this module.
- StarflightWx
- For testing and providing feedback (Co-Developer and Spotter @ AtmosphericX)