Compare commits

..
5 Commits
Author SHA1 Message Date
Matt Walsh 86c2f9e8ee 2.6.4 2024-05-30 11:33:53 -05:00
Matt Walsh f881493aa4 update and test for node 20 2024-05-30 11:33:49 -05:00
Matt Walsh 5767f2a10e 2.6.3 2023-01-16 12:36:21 -06:00
Matt Walsh a718f5c3e3 correct tdwr gate size scaling 2023-01-16 12:36:09 -06:00
Matt Walsh 20c4552d0a add demo to readme 2023-01-04 22:35:15 -06:00
79 changed files with 1932 additions and 2320 deletions

No files matched your search

+1 -2
View File
@@ -11,8 +11,7 @@
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/demos/test.js",
"outputCapture": "std",
"program": "${workspaceFolder}/demos/test.js"
},
{
"type": "pwa-node",
+3
View File
@@ -2,6 +2,9 @@
> A javascript implementation for plotting Nexrad Level II data parsed via [nexrad-level-2-data](https://github.com/netbymatt/nexrad-level-2-data/).
# Demo
A live demo showing the output of this library (via [nexrad-level-2-data](https://www.github.com/netbymatt/nexrad-level-2-data)) for select radar sites is available at https://nexrad-demo.netbymatt.com/
# Use
## Install
```bash
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -39,7 +39,7 @@ const iterations = 5;
// write files to disk
const writePromises = [];
(await plots).forEach((p) => {
plots.forEach((p) => {
const { elevation } = p;
writePromises.push(writePngToFile(`./output/REF-${elevation}-${size}.png`, p.REF));
writePromises.push(writePngToFile(`./output/VEL-${elevation}-${size}.png`, p.VEL));
+4 -5
View File
@@ -10,9 +10,9 @@ const { plot, writePngToFile } = require('../src');
// const files = glob.sync('./data/KLOT/381/*');
// const files = glob.sync('./data/KLOT/548/*');
// const files = glob.sync('./data/KLOT/940/*');
// const files = glob.sync('./data/KSRX/804/*');
// const files = glob.sync('./data/TORD/767/*');
const files = glob.sync('./data/KLOT/KLOT20210812_171451_V*'); // ref palette tuning
const files = glob.sync('./data/KSRX/804/*');
// const files = glob.sync('./data/TORD/168/*');
// const files = glob.sync('./data/KLOT/KLOT20210812_171451_V*'); // ref palette tuning
// const files = glob.sync('./data/KLOT/KLOT20210621_041151_V06'); // vel palette tuning
// const store each file's data
@@ -43,11 +43,10 @@ if (single) {
// plot for each elevation and size
(async () => {
await Promise.allSettled(sizes.map(async (size) => {
const plots = await plot(radarData, ['REF', 'VEL'], {
const plots = plot(radarData, ['REF', 'VEL'], {
elevations,
size,
palettize: true,
elevations: 1,
cropTo: size / 2,
});
+1905 -2278
View File
File diff suppressed because it is too large. Load diff
+4 -5
View File
@@ -1,6 +1,6 @@
{
"name": "nexrad-level-2-plot",
"version": "2.6.2",
"version": "2.6.4",
"description": "Plotting library for nexrad-level-2-data",
"main": "src/index.js",
"scripts": {
@@ -24,15 +24,14 @@
},
"homepage": "https://github.com/netbymatt/nexrad-level-2-plot#readme",
"dependencies": {
"canvas": "^2.9.3",
"nexrad-level-2-data": "../nexrad-level-2-data",
"piscina": "^3.2.0"
"canvas": "^2.11.2",
"nexrad-level-2-data": "^2.3.5"
},
"devDependencies": {
"eslint": "^8.0.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.23.4",
"glob": "^7.1.7"
"glob": "^10.0.0"
},
"engines": {
"node": ">=13.0.0"
+2 -3
View File
@@ -76,11 +76,10 @@ const draw = (data, _options) => {
if (options.size < 1) throw new Error('Provide options.size > 0');
const scale = DEFAULT_OPTIONS.size / options.size;
// wsr88d uses a gate size of 0.25km, tdwr uses a gate size of 0.15km, although it is reported as 0.3km for processing reasons
// wsr88d uses a gate size of 0.25km, tdwr uses a gate size of 0.15km or 0.30km
// this calculation scales the plot accordingly to the nominal 0.25km so all generated plots are at the same scale
const rawGateSize = data?.data?.[options.elevation]?.[0]?.record?.reflect?.gate_size ?? 0.25;
const realGateSize = rawGateSize !== 0.3 ? rawGateSize : rawGateSize / 2;
const gateSizeScaling = 0.25 / realGateSize;
const gateSizeScaling = rawGateSize / 0.25;
// calculate crop, adjust if necessary
const cropTo = Math.min(options.size, options.cropTo);
-9
View File
@@ -1,9 +0,0 @@
const { Level2Radar } = require('nexrad-level-2-data');
const { workerData } = require('piscina');
const { draw } = require('./index');
module.exports = (options) => {
const level2Radar = Level2Radar(workerData);
const plot = draw(level2Radar, options);
return plot;
};
+12 -17
View File
@@ -1,8 +1,5 @@
const { Piscina } = require('piscina');
const path = require('path');
const { canvas } = require('./draw');
const { draw, canvas } = require('./draw');
const { writePngToFile } = require('./utils/file');
/**
* Plot level 2 data
* @param {Level2Data} data output from the nexrad-level-2-data library
@@ -20,7 +17,10 @@ const { writePngToFile } = require('./utils/file');
* @param {string} [options.antialias = 'default'] Control antialias. Passed directly to ctx.antialias (part of node-canvas)
* @returns Canvas
*/
const plot = async (data, _products, options) => {
const plot = (data, _products, options) => {
// store result
const result = [];
let products;
// make product list into an array
if (_products && Array.isArray(_products)) {
@@ -41,24 +41,19 @@ const plot = async (data, _products, options) => {
if (!elevations) elevations = availableElevations;
if (typeof elevations === 'number') elevations = [elevations];
const staticPool = new Piscina({
filename: path.resolve(__dirname, './draw/thread.js'),
workerData: data.toObject(),
});
const result = await Promise.all(elevations.map(async (elevation) => {
elevations.forEach((elevation) => {
const elevationResult = { elevation };
await Promise.all(products.map(async (product) => {
products.forEach((product) => {
// parse and store result
elevationResult[product] = await staticPool.run({
elevationResult[product] = draw(data, {
...options,
elevation,
product,
});
}));
return elevationResult;
}));
staticPool.destroy();
});
result.push(elevationResult);
});
return result;
};