mirror of
https://github.com/netbymatt/nexrad-level-2-plot.git
synced 2026-11-28 18:28:05 -08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8389de11f | ||
|
|
dc02fe5f50 |
No files matched your search
@@ -78,6 +78,7 @@ options.background|string|#000000|Background color of the image. This can be tra
|
||||
options.lineWidth|integer|2|The raster image is created by drawing several arcs at the locations and colors specified in the data file. When scaling down you may get a better looking image by adjusting this value to something large than the default.
|
||||
options.palettize|boolean\|object|false|After drawing the image convert the image from RGBA to a palettized image. When true the same palette as the product is used. Additional options are described in [palettizing](#palettizing). This can significantly reduce the size of the resulting image with minimal loss of clarity.
|
||||
options.elevations|undefined\|integer\|Array of integers|undefined|The specific elevations to plot. If undefined (default) all available elevations will be plotted. If an integer is provided a single elevation will be plotted with all the selected ```products```. If an array of integers are provided each ```products``` in each elevation will be plotted. Note that when a product and elevation combination do not exist the returned object will have false in the missing location. This is common where elevation 1 will have reflectivity data and elevation 2 (altough at the same angle as elevation 1) will contain velocity data.
|
||||
options.usePreferredWaveforms|boolean|true|Waveform types of 1, 2, 3, 4 and 5 are produced by the radar. Type 1 is typically exclusive to reflectivity, Type 2 is typically exclusive to velocity however it also produces reflectivity data. Types 3, 4 and 5 all produce both velocity and reflectivity. When set to true type 1 waveforms will not plot velocity data, and type 2 waveforms will not plot reflectivity data. If you must see all information set this to false.
|
||||
|
||||
### Downsampling
|
||||
A full size plot is 3600 x 3600 pixels. This corresponds to the maximum range of the radar 460km (~250 mi) * maximum resolution 0.25 mi/bin * 2 (east and west side of radar).
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "nexrad-level-2-plot",
|
||||
"version": "2.0.0",
|
||||
"version": "2.1.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "nexrad-level-2-plot",
|
||||
"version": "2.0.0",
|
||||
"version": "2.1.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"canvas": "^2.8.0",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nexrad-level-2-plot",
|
||||
"version": "2.0.0",
|
||||
"version": "2.1.0",
|
||||
"description": "Plotting library for nexrad-level-2-data",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -35,6 +35,14 @@ const palettes = {
|
||||
};
|
||||
/* eslint-enable global-require */
|
||||
|
||||
const preferredWaveformUsage = {
|
||||
1: ['REF', 'SW ', 'ZDR', 'PHI', 'RHO'],
|
||||
2: ['VEL'],
|
||||
3: ['REF', 'VEL', 'SW ', 'ZDR', 'PHI', 'RHO'],
|
||||
4: ['REF', 'VEL', 'SW ', 'ZDR', 'PHI', 'RHO'],
|
||||
5: ['REF', 'VEL', 'SW ', 'ZDR', 'PHI', 'RHO'],
|
||||
};
|
||||
|
||||
// default options
|
||||
const DEFAULT_OPTIONS = {
|
||||
// must be a square image
|
||||
@@ -42,6 +50,7 @@ const DEFAULT_OPTIONS = {
|
||||
cropTo: 3600,
|
||||
background: 'black',
|
||||
lineWidth: 2,
|
||||
usePreferredWaveforms: true,
|
||||
};
|
||||
|
||||
const draw = (data, _options) => {
|
||||
@@ -51,6 +60,11 @@ const draw = (data, _options) => {
|
||||
..._options,
|
||||
};
|
||||
|
||||
// check preferred waveforms
|
||||
const elevationInfo = data.vcp.record.elevations[options.elevation];
|
||||
const preferredProducts = preferredWaveformUsage[elevationInfo.waveform_type];
|
||||
if (options.usePreferredWaveforms && !preferredProducts.includes(options.product)) return false;
|
||||
|
||||
// calculate scale
|
||||
if (options.size > DEFAULT_OPTIONS.size) throw new Error(`Upsampling is not supported. Provide a size <= ${DEFAULT_OPTIONS.size}`);
|
||||
if (options.size < 1) throw new Error('Provide options.size > 0');
|
||||
|
||||
@@ -10,6 +10,8 @@ const { writePngToFile } = require('./utils/file');
|
||||
* @param {string} [options.background=#000000] Background color of the image. This can be transparent by using #RGBA notation.
|
||||
* @param {number} [options.lineWidth=2] The raster image is created by drawing several arcs at the locations and colors specified in the data file. When scaling down you may get a better looking image by adjusting this value to something large than the default.
|
||||
* @param {(boolean|object)} [options.palettize] After drawing the image convert the image from RGBA to a palettized image. When true the same palette as the product is used.
|
||||
* @param {(undefined|number|number[])} [options.elevations=undefined] List of elevations to plot.
|
||||
* @param {boolean} [options.usePreferredWaveforms = true] Limit the plotted data to the preferred use of waveforms 1 and 2.
|
||||
* @returns Canvas
|
||||
*/
|
||||
const plot = (data, _products, options) => {
|
||||
|
||||
Reference in new issue
Block a user