+
+
+
+## Level2Radar
+**Kind**: global class
+
+* [Level2Radar](#Level2Radar)
+ * [new Level2Radar(file, [options])](#new_Level2Radar_new)
+ * _instance_
+ * _Configuration_
+ * [.setElevation(elevation)](#Level2Radar+setElevation)
+ * _Data_
+ * [.getAzimuth([scan])](#Level2Radar+getAzimuth) ⇒ number \| Array.<number>
+ * [.getHighresReflectivity([scan])](#Level2Radar+getHighresReflectivity) ⇒ [HighResData](#HighResData) \| [Array.<HighResData>](#HighResData)
+ * [.getHighresVelocity([scan])](#Level2Radar+getHighresVelocity) ⇒ [HighResData](#HighResData) \| [Array.<HighResData>](#HighResData)
+ * [.getHighresSpectrum([scan])](#Level2Radar+getHighresSpectrum) ⇒ [HighResData](#HighResData) \| [Array.<HighResData>](#HighResData)
+ * [.getHighresDiffReflectivity([scan])](#Level2Radar+getHighresDiffReflectivity) ⇒ [HighResData](#HighResData) \| [Array.<HighResData>](#HighResData)
+ * [.getHighresDiffPhase([scan])](#Level2Radar+getHighresDiffPhase) ⇒ [HighResData](#HighResData) \| [Array.<HighResData>](#HighResData)
+ * [.getHighresCorrelationCoefficient([scan])](#Level2Radar+getHighresCorrelationCoefficient) ⇒ [HighResData](#HighResData) \| [Array.<HighResData>](#HighResData)
+ * _Metadata_
+ * [.getScans()](#Level2Radar+getScans) ⇒ number
+ * [.getHeader([scan])](#Level2Radar+getHeader) ⇒ [MessageHeader](#MessageHeader)
+ * [.listElevations()](#Level2Radar+listElevations) ⇒ Array.<number>
+ * _static_
+ * [.combineData(...data)](#Level2Radar.combineData) ⇒ [Level2Radar](#Level2Radar)
+
+
+
+### new Level2Radar(file, [options])
+Parses a Nexrad Level 2 Data archive or chunk. Provide `rawData` as a `Buffer`. Returns an object formatted per the [ICD FOR RDA/RPG - Build RDA 20.0/RPG 20.0 (PDF)](https://www.roc.noaa.gov/wsr88d/PublicDocs/ICDs/2620002U.pdf), or as close as can reasonably be represented in a javascript object. Additional data accessors are provided in the returned object to pull out typical data in a format ready for processing.
+
+
+| Param | Type | Default | Description |
+| --- | --- | --- | --- |
+| file | Buffer \| [Level2Radar](#Level2Radar) | | Buffer with Nexrad Level 2 data. Alternatively a Level2Radar object, typically used internally when combining data. |
+| [options] | object | | Parser options |
+| [options.logger] | object \| boolean | console | By default error and information messages will be written to the console. These can be suppressed by passing false, or a custom logger can be provided. A custom logger must provide the log() and error() function. |
+
+
+
+### level2Radar.setElevation(elevation)
+Sets the elevation in use for get* methods
+
+**Kind**: instance method of [Level2Radar](#Level2Radar)
+**Category**: Configuration
+
+| Param | Type | Description |
+| --- | --- | --- |
+| elevation | number | Selected elevation number |
+
+
+
+### level2Radar.getAzimuth([scan]) ⇒ number \| Array.<number>
+Returns an single azimuth value or array of azimuth values for the current elevation and scan (or all scans if not provided).
The order of azimuths in the returned array matches the order of the data in other get* functions.
+
+**Kind**: instance method of [Level2Radar](#Level2Radar)
+**Returns**: number \| Array.<number> - Azimuth angle
+**Category**: Data
+
+| Param | Type | Description |
+| --- | --- | --- |
+| [scan] | number | Selected scan |
+
+
+
+### level2Radar.getHighresReflectivity([scan]) ⇒ [HighResData](#HighResData) \| [Array.<HighResData>](#HighResData)
+Returns an Object of radar reflectivity data for the current elevation and scan (or all scans if not provided)
+
+**Kind**: instance method of [Level2Radar](#Level2Radar)
+**Returns**: [HighResData](#HighResData) \| [Array.<HighResData>](#HighResData) - Scan's high res reflectivity data, or an array of the data.
+**Category**: Data
+
+| Param | Type | Description |
+| --- | --- | --- |
+| [scan] | number | Selected scan or null for all scans in elevation |
+
+
+
+### level2Radar.getHighresVelocity([scan]) ⇒ [HighResData](#HighResData) \| [Array.<HighResData>](#HighResData)
+Returns an Object of radar velocity data for the current elevation and scan (or all scans if not provided)
+
+**Kind**: instance method of [Level2Radar](#Level2Radar)
+**Returns**: [HighResData](#HighResData) \| [Array.<HighResData>](#HighResData) - Scan's high res velocity data, or an array of the data.
+**Category**: Data
+
+| Param | Type | Description |
+| --- | --- | --- |
+| [scan] | number | Selected scan, or null for all scans in this elevation |
+
+
+
+### level2Radar.getHighresSpectrum([scan]) ⇒ [HighResData](#HighResData) \| [Array.<HighResData>](#HighResData)
+Returns an Object of radar spectrum data for the current elevation and scan (or all scans if not provided)
+
+**Kind**: instance method of [Level2Radar](#Level2Radar)
+**Returns**: [HighResData](#HighResData) \| [Array.<HighResData>](#HighResData) - Scan's high res spectrum data, or an array of the data.
+**Category**: Data
+
+| Param | Type | Description |
+| --- | --- | --- |
+| [scan] | number | Selected scan, or null for all scans in this elevation |
+
+
+
+### level2Radar.getHighresDiffReflectivity([scan]) ⇒ [HighResData](#HighResData) \| [Array.<HighResData>](#HighResData)
+Returns an Object of radar differential reflectivity data for the current elevation and scan (or all scans if not provided)
+
+**Kind**: instance method of [Level2Radar](#Level2Radar)
+**Returns**: [HighResData](#HighResData) \| [Array.<HighResData>](#HighResData) - Scan's high res differential reflectivity data, or an array of the data.
+**Category**: Data
+
+| Param | Type | Description |
+| --- | --- | --- |
+| [scan] | number | Selected scan or null for all scans in elevation |
+
+
+
+### level2Radar.getHighresDiffPhase([scan]) ⇒ [HighResData](#HighResData) \| [Array.<HighResData>](#HighResData)
+Returns an Object of radar differential phase data for the current elevation and scan (or all scans if not provided)
+
+**Kind**: instance method of [Level2Radar](#Level2Radar)
+**Returns**: [HighResData](#HighResData) \| [Array.<HighResData>](#HighResData) - Scan's high res differential phase data, or an array of the data.
+**Category**: Data
+
+| Param | Type | Description |
+| --- | --- | --- |
+| [scan] | number | Selected scan or null for all scans in elevation |
+
+
+
+### level2Radar.getHighresCorrelationCoefficient([scan]) ⇒ [HighResData](#HighResData) \| [Array.<HighResData>](#HighResData)
+Returns an Object of radar correlation coefficient data for the current elevation and scan (or all scans if not provided)
+
+**Kind**: instance method of [Level2Radar](#Level2Radar)
+**Returns**: [HighResData](#HighResData) \| [Array.<HighResData>](#HighResData) - Scan's high res correlation coefficient data, or an array of the data.
+**Category**: Data
+
+| Param | Type | Description |
+| --- | --- | --- |
+| [scan] | number | Selected scan or null for all scans in elevation |
+
+
+
+### level2Radar.getScans() ⇒ number
+Return the number of scans in the current elevation
+
+**Kind**: instance method of [Level2Radar](#Level2Radar)
+**Category**: Metadata
+
+
+### level2Radar.getHeader([scan]) ⇒ [MessageHeader](#MessageHeader)
+Return message_header information for all scans or a specific scan for the selected elevation
+
+**Kind**: instance method of [Level2Radar](#Level2Radar)
+**Category**: Metadata
+
+| Param | Type | Description |
+| --- | --- | --- |
+| [scan] | number | Selected scan, omit to return all scans for this elevation |
+
+
+
+### level2Radar.listElevations() ⇒ Array.<number>
+List all available elevations
+
+**Kind**: instance method of [Level2Radar](#Level2Radar)
+**Category**: Metadata
+
+
+### Level2Radar.combineData(...data) ⇒ [Level2Radar](#Level2Radar)
+Combines the data returned by multiple runs of the Level2Data constructor. This is typically used in "chunks" mode to combine all azimuths from one revolution into a single data set. data can be provided as an array of Level2Radar objects, individual Level2Data parameters or any combination thereof.
The combine function blindly combines data and the right-most argument will overwrite any previously provided data. Individual azimuths located in Level2Radar.data[] will be appended. It is up to the calling routine to properly manage the parsing of related chunks and send it in to this routine.
+
+**Kind**: static method of [Level2Radar](#Level2Radar)
+**Returns**: [Level2Radar](#Level2Radar) - Combined data
+
+| Param | Type | Description |
+| --- | --- | --- |
+| ...data | [Level2Radar](#Level2Radar) | Data to combine |
+
+
+
+## HighResData : object
+See NOAA documentation for detailed meanings of these values.
+
+**Kind**: global typedef
+**Properties**
+
+| Name | Type | Description |
+| --- | --- | --- |
+| gate_count | number | |
+| gate_size | number | |
+| first_gate | number | |
+| rf_threshold | number | |
+| snr_threshold | number | |
+| scale | number | |
+| offset | number | |
+| block_type | string | 'D' |
+| control_flags | number | |
+| data_size | number | |
+| name | string | 'REF', 'VEL', 'SW ', 'ZDR', 'PHI', 'RHO' |
+| spare | Array.<Buffer> | Spare data per the documentation |
+| moment_data | Array.<number> | Scaled data |
+
+
+
+## MessageHeader : object
+See NOAA documentation for detailed meanings of these values.
+
+**Kind**: global typedef
+**Properties**
+
+| Name | Type |
+| --- | --- |
+| aim | number |
+| ars | number |
+| compress_idx | number |
+| cut | number |
+| dcount | number |
+| elevation_angle | number |
+| elevation_number | number |
+| id | string |
+| julian_date | number |
+| mseconds | number |
+| phi | [HighResData](#HighResData) |
+| radial | [Radial](#Radial) |
+| radial_length | number |
+| radial_number | number |
+| [reflect] | [HighResData](#HighResData) |
+| [rho] | [HighResData](#HighResData) |
+| rs | number |
+| rsbs | number |
+| spectrum | [HighResData](#HighResData) |
+| sp | number |
+| volume | [Volume](#Volume) |
+| [velocity] | [HighResData](#HighResData) |
+| [zdr] | [HighResData](#HighResData) |
+
+
+
+## Radial
+**Kind**: global typedef
+**Properties**
+
+| Name | Type | Description |
+| --- | --- | --- |
+| block_type | string | 'R' |
+| horizontal_calibration | number | |
+| horizontal_noise_level | number | |
+| name | string | 'RAD' |
+| nyquist_velocity | number | |
+| radial_flags | number | |
+| size | number | |
+| unambiguous_range | number | |
+| vertical_calibration | number | |
+| vertical_noise_level | number | |
+
+
+
+## Volume
+**Kind**: global typedef
+**Properties**
+
+| Name | Type | Description |
+| --- | --- | --- |
+| block_type | string | 'R' |
+| calibration | number | |
+| differential_phase | number | |
+| differential_reflectivity | number | |
+| elevation | number | |
+| feedhorn_height | number | |
+| latitude | number | |
+| longitude | number | |
+| name | string | 'VOL' |
+| processing_status | number | |
+| size | number | |
+| tx_horizontal | number | |
+| tx_vertical | number | |
+| version_major | number | |
+| version_minor | number | |
+| volume_coverage_pattern | number | |
+| zdr_bias_estimate | number | |
+
diff --git a/README.md b/README.md
index d51ce6e..da558bd 100644
--- a/README.md
+++ b/README.md
@@ -49,11 +49,13 @@ new Level2Radar(rawData).then(radar => {
## API
### Constructor(rawData, options)
-Parses a Nexrad Level 2 Data archive or chunk. Provide `rawData` as a `Buffer`. Returns an object formatted per the [ICD FOR RDA/RPG - Build RDA 20.0/RPG 20.0 (PDF)](https://www.roc.noaa.gov/wsr88d/PublicDocs/ICDs/2620002U.pdf), or as close as can reasonably be represented in a javascript object. Additional data accessors are provided in the returned object to pull out typical data in a format ready for processing. These are detailed below.
+
+Complete [API documentation](API.md)
+
|option|Description|
|--|--|
-|options.logger|By default error and information messages will be written to the console. These can be supressed by passing false, or a custom logger can be provided. A custom logger must provide the ``log()`` and ``error()`` function.|
+|options.logger|By default error and information messages will be written to the console. These can be suppressed by passing false, or a custom logger can be provided. A custom logger must provide the ``log()`` and ``error()`` function.|
## Level2Data.combineData(data, [data, data], ...)
Combines the data returned by multiple runs of the Level2Data constructor. This is typically used in "chunks" mode to combine all azimuths from one revolution into a single data set. `data` can be provided as an array of Level2Radar objects, individual Level2Data parameters or any combination thereof.
diff --git a/docs/Level2Radar.html b/docs/Level2Radar.html
new file mode 100644
index 0000000..0ff4781
--- /dev/null
+++ b/docs/Level2Radar.html
@@ -0,0 +1,2314 @@
+
+
+
+
+
+
+ Documentation Class: Level2Radar
+
+
+
+
+
+
+
+
+
+
+
+ Parses a Nexrad Level 2 Data archive or chunk. Provide `rawData` as a `Buffer`. Returns an object formatted per the [ICD FOR RDA/RPG - Build RDA 20.0/RPG 20.0 (PDF)](https://www.roc.noaa.gov/wsr88d/PublicDocs/ICDs/2620002U.pdf), or as close as can reasonably be represented in a javascript object. Additional data accessors are provided in the returned object to pull out typical data in a format ready for processing.
+
Buffer with Nexrad Level 2 data. Alternatively a Level2Radar object, typically used internally when combining data.
+
+
+
+
+
+
+
options
+
+
+
+
+
+object
+
+
+
+
+
+
+
+
+
+ <optional>
+
+
+
+
+
+
+
+
+
+
+
Parser options
+
Properties
+
+
+
+
+
+
+
Name
+
+
+
Type
+
+
+
Argument
+
+
+
+
Default
+
+
+
Description
+
+
+
+
+
+
+
+
+
logger
+
+
+
+
+
+object
+|
+
+boolean
+
+
+
+
+
+
+
+
+
+ <optional>
+
+
+
+
+
+
+
+
+
+
+
+ console
+
+
+
+
+
By default error and information messages will be written to the console. These can be suppressed by passing false, or a custom logger can be provided. A custom logger must provide the log() and error() function.
+ Combines the data returned by multiple runs of the Level2Data constructor. This is typically used in "chunks" mode to combine all azimuths from one revolution into a single data set. data can be provided as an array of Level2Radar objects, individual Level2Data parameters or any combination thereof.
The combine function blindly combines data and the right-most argument will overwrite any previously provided data. Individual azimuths located in Level2Radar.data[] will be appended. It is up to the calling routine to properly manage the parsing of related chunks and send it in to this routine.
+
+ Returns an single azimuth value or array of azimuth values for the current elevation and scan (or all scans if not provided).
The order of azimuths in the returned array matches the order of the data in other get* functions.
+
By default error and information messages will be written to the console. These can be suppressed by passing false, or a custom logger can be provided. A custom logger must provide the log() and error() function.
+
+
+
+
Level2Data.combineData(data, [data, data], ...)
+
Combines the data returned by multiple runs of the Level2Data constructor. This is typically used in "chunks" mode to combine all azimuths from one revolution into a single data set. data can be provided as an array of Level2Radar objects, individual Level2Data parameters or any combination thereof.
+
The combine function blindly combines data and the right-most argument will overwrite any previously provided data. Individual azimuths located in Level2Radar.data[] will be appended. It is up to the calling routine to properly manage the parsing of related chunks and send it in to this routine.
+
setElevation(Number elevation)
+
Sets the elevation you want to grab the data from
+
getHighresReflectivity([scan])
+
Returns an Object of radar reflectivity data for the current elevation and scan (or all scans if not provided) in the following format
Returns an single azimuth value or array of azimuth values forthe current elevation and scan (or all scans if not provided). The order of azimuths in the returned array matches the order of the data in other get* functions above.
+
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.
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 trueThe scripttest-error.jscan be run to test some of this functionality. It parses data in./data/messagesizeerror`.
+
+
+
+
Supported Messages
+
Nexrad data is stored as message types. This package currently processes the following messages.
+
+
+
+
Message
+
Title
+
Description
+
+
+
+
+
1
+
Digital Radar Data
+
Reflectivity and velocity data. Replaced by message 31 in 2008 which supports a higher resolution.