Decode Nexrad Level II radar archive files
npm install nexrad-level-2-datas3://unidata-nexrad-level2-chunks/
s3://noaa-nexrad-level2
bash
$ npm i nexrad-level-2-data
`
Usage
` javascript
const { Level2Radar } = require('nexrad-level-2-data')
const fs = require('fs');
const file_to_load = "./data/KTLX20130420_205120_V06" // The radar archive file to load
const rawData = fs.readFileSync(file_to_load);
new Level2Radar(rawData).then(radar => {
console.log(radar.getHighresReflectivity())
})
`
API
Complete API documentation
Testing
A formal testing suite is not provided. Several test-*.js are provided with matching data in the ./data folder. These can be run individually as shown below.
` bash
node test.js
node test-chunks.js
node test-error.js
`
The output of each test script is sent to the console.
Error recovery and handling
This library will throw on many errors including:
- Buffer not provided for parsing
- Calling a data accessor on non-existant data such as invalid elevations or azimuths
- A successfully parsed file that did not contain any data
- A cursory check on data validity is done by checking the ICAO identifier of each record in the file before further parsing occurs.
- Basic file length checks against offsets and block lengths listed in the file.
The Nexrad archives and chunks do contain errors when read from the Unidata archives in s3 buckets s3://noaa-nexrad-level2 and s3://unidata-nexrad-level2-chunks/. A very basic attempt is made to detect these errors, discard the affected record and find the begining of the next record. This does not always succeeded. The following are the possible outcomes:
- Successful error detection and skipping to a known good block.
- Logs to console Invlaid record id or Invalid block type
- Returns as much data that could be parsed with some gaps in data. The actual gaps are not logged. A manual scan of the Level2Radar.data[] arrays looking at Azimuths would need to be performed to find the gaps in data. However any program calling this routine should be considering the Level2Radar.data[].azimuth data for further processing and thus should be unaffected.
- Level2Data.hasGaps is set to true
- Error detection with no skipping to a known good block
- Logs to console Invalid record id or Invalid block id
- Later logs to console Unable to recover message
- Returns as much data that could be parsed.
- Level2Data.isTruncated is set to true
test-error.js can be run to test some of this functionality. It parses data in ./data/messagesizeerror.