Compare commits

...
22 Commits
Author SHA1 Message Date
Matt Walsh 4a1f29cfae change to piscina 2022-07-13 23:21:58 -05:00
Matt Walsh 8b244a41a6 testing 2022-07-13 21:42:07 -05:00
Matt Walsh 97b07611e8 initial threading tests 2022-07-13 16:36:43 -05:00
Matt Walsh d108e96cea 2.6.2 2022-07-13 15:52:52 -05:00
Matt Walsh ba885085d2 minor performance optimization 2022-07-13 15:52:44 -05:00
Matt Walsh 2b6e0ba3fd 2.6.1 2022-07-13 12:01:03 -05:00
Matt Walsh 347c530edd improve hex lookup during paletizing 2022-07-13 12:00:55 -05:00
Matt Walsh a6f27875e9 2.6.0 2022-07-13 10:34:43 -05:00
Matt Walsh 1ef5053ca0 add canvas options 2022-07-13 10:34:29 -05:00
Matt Walsh ea4cb9de74 update documentation close #3 2022-07-10 21:11:07 -05:00
Matt Walsh e3c882a57c 2.5.1 2022-06-21 11:17:10 -05:00
Matt Walsh aa4b02236a remove debug logging 2022-06-21 11:17:05 -05:00
Matt Walsh 847d4cbecc 2.5.0 2022-06-21 11:13:18 -05:00
Matt Walsh 7731d64af6 fix interpertation of 300km flag 2022-06-21 11:13:11 -05:00
Matt Walsh 96d3f36545 2.4.0 2022-06-01 13:01:32 -05:00
Matt Walsh 6a7f0868a5 handle gate sizing properly for tdwr 2022-06-01 13:01:16 -05:00
Matt Walsh bed3043ccd 2.3.0 2022-05-25 23:52:30 -05:00
Matt Walsh 676c63dc1c handle super-res long range scaling properly 2022-05-25 23:51:53 -05:00
Matt Walsh e559ba1d9c better benchmark statistics 2022-05-13 10:28:26 -05:00
Matt Walsh febb902f15 2.2.1 2022-05-12 22:02:18 -05:00
Matt Walsh aa307c44c0 update nexrad-level-2-data version 2022-05-12 22:01:57 -05:00
Matt Walsh a9fd62a513 update dependencies 2022-05-12 16:02:22 -05:00
15 changed files with 663 additions and 326 deletions

No files matched your search

+1
View File
@@ -1 +1,2 @@
node_modules node_modules
*.cpuprofile
+9
View File
@@ -0,0 +1,9 @@
{
"words": [
"nexrad",
"KSRX",
"TORD",
"palettizing",
"tdwr"
]
}
+2 -1
View File
@@ -11,7 +11,8 @@
"skipFiles": [ "skipFiles": [
"<node_internals>/**" "<node_internals>/**"
], ],
"program": "${workspaceFolder}/demos/test.js" "program": "${workspaceFolder}/demos/test.js",
"outputCapture": "std",
}, },
{ {
"type": "pwa-node", "type": "pwa-node",
+11 -2
View File
@@ -16,10 +16,10 @@ const { plot, writeToPngFile } = require('nexrad-level-3-plot');
// read a file // read a file
const file = fs.readFileSync('<path to data>'); const file = fs.readFileSync('<path to data>');
// parse and plot // parse and plot
const level2Plot = plot(file, {elevation: 1, product: 'REF'}); const level2Plot = plot(file, 'REF', {elevations: 1});
// use bundled utility to write to disk // use bundled utility to write to disk
(async () => { (async () => {
await writePngToFile('<path to output>.png', level2Plot.REF.canvas); await writePngToFile('<path to output>.png', level2Plot[0].REF);
})(); })();
``` ```
# Data # Data
@@ -79,6 +79,9 @@ options.lineWidth|integer|2|The raster image is created by drawing several arcs
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.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.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. 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.
options.alpha|boolean|true|Draw on a 32-bit canvas. Passed directly to getContext('2d', {alpha}).
options.imageSmoothingEnabled|boolean|true|Enable image smoothing. Passed directly to ctx.imageSmoothingEnabled.
options.antialias|string|'default'|Enable antialias. Passed directly to ctx.antialias (part of node-canvas)
### Downsampling ### 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). 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).
@@ -114,6 +117,12 @@ data|{canvas[palette]}|Typically the output of [plot()](#plotfile-options).\<pro
# Notable and breaking changes # Notable and breaking changes
## v2.6.0 Notable, Additional canvas configuration options
The options antialias, imageSmoothingEnabled, and alpha were added and passed directly to the canvas context when creating it before plotting. Disabling these options (which were previously defaulted to on) can speed up plotting by about 5% and reduce output image size by up to 10% at a very slight cost of visual appearance.
## v2.5.0 Notable, 300km range now interperted correctly
Prior to this version, if the data had the ```super_res_control.300km``` flag set the resulting image would effectively be "zoomed in by 2x". Upon examing the results of this flag on the plot, reference plots and the ```gate_count``` values it was determined no scaling needed to be performed if this flag was present. Instead, the ```gate_count``` already reflects the additional data the flag indicates. This mainly affects VEL plots and some REF plots at higher elevations, depending on the VCP the radar is using.
## v2.0.0 Breaking, returns an array of objects ## v2.0.0 Breaking, returns an array of objects
Previously, a single elevation would be plotted by the routine. The elevation was selected by ```options.elevation```. ```options.elevation``` has been renamed to ```options.elevations``` and will still take a single integer as an input, but in this configuration an array is still returned. The simplest way to return to the functionality of v1.1.0 is ```plot(data,products,{elevation: <integer>})[0]``` which will return only the first object in the array. Previously, a single elevation would be plotted by the routine. The elevation was selected by ```options.elevation```. ```options.elevation``` has been renamed to ```options.elevations``` and will still take a single integer as an input, but in this configuration an array is still returned. The simplest way to return to the functionality of v1.1.0 is ```plot(data,products,{elevation: <integer>})[0]``` which will return only the first object in the array.
+9 -4
View File
@@ -22,26 +22,31 @@ files.forEach((file) => {
const radarData = Level2Radar.combineData(chunks); const radarData = Level2Radar.combineData(chunks);
const size = 1800; const size = 1800;
const iterations = 5;
// plot for each elevation and size // plot for each elevation and size
(async () => { (async () => {
const start = new Date(); const start = new Date();
for (let i = 0; i < 100; i += 1) { for (let i = 0; i < iterations; i += 1) {
const plots = plot(radarData, ['REF', 'VEL'], { const plots = plot(radarData, ['REF', 'VEL'], {
size, size,
palettize: true, palettize: true,
cropTo: size / 2, cropTo: size / 2,
alpha: false,
imageSmoothingEnabled: false,
antialias: 'none',
}); });
// write files to disk // write files to disk
const writePromises = []; const writePromises = [];
plots.forEach((p) => { (await plots).forEach((p) => {
const { elevation } = p; const { elevation } = p;
writePromises.push(writePngToFile(`./output/REF-${elevation}-${size}.png`, p.REF)); writePromises.push(writePngToFile(`./output/REF-${elevation}-${size}.png`, p.REF));
writePromises.push(writePngToFile(`./output/VEL-${elevation}-${size}.png`, p.VEL)); writePromises.push(writePngToFile(`./output/VEL-${elevation}-${size}.png`, p.VEL));
}); });
await Promise.allSettled(writePromises); await Promise.allSettled(writePromises);
}
const end = new Date(); const end = new Date();
console.log(`Total Time: ${(end - start) / 1000}`); console.log(`Iteration: ${i + 1}/${iterations} Average time: ${(end - start) / 1000 / (i + 1)} s`);
}
})(); })();
+2 -1
View File
@@ -43,10 +43,11 @@ if (single) {
// plot for each elevation and size // plot for each elevation and size
(async () => { (async () => {
await Promise.allSettled(sizes.map(async (size) => { await Promise.allSettled(sizes.map(async (size) => {
const plots = plot(radarData, ['REF', 'VEL'], { const plots = await plot(radarData, ['REF', 'VEL'], {
elevations, elevations,
size, size,
palettize: true, palettize: true,
elevations: 1,
cropTo: size / 2, cropTo: size / 2,
}); });
+8
View File
@@ -0,0 +1,8 @@
{
"folders": [
{
"path": "."
}
],
"settings": {}
}
+559 -289
View File
File diff suppressed because it is too large. Load diff
+4 -3
View File
@@ -1,6 +1,6 @@
{ {
"name": "nexrad-level-2-plot", "name": "nexrad-level-2-plot",
"version": "2.2.0", "version": "2.6.2",
"description": "Plotting library for nexrad-level-2-data", "description": "Plotting library for nexrad-level-2-data",
"main": "src/index.js", "main": "src/index.js",
"scripts": { "scripts": {
@@ -24,8 +24,9 @@
}, },
"homepage": "https://github.com/netbymatt/nexrad-level-2-plot#readme", "homepage": "https://github.com/netbymatt/nexrad-level-2-plot#readme",
"dependencies": { "dependencies": {
"canvas": "^2.8.0", "canvas": "^2.9.3",
"nexrad-level-2-data": "^2.1.0" "nexrad-level-2-data": "../nexrad-level-2-data",
"piscina": "^3.2.0"
}, },
"devDependencies": { "devDependencies": {
"eslint": "^8.0.0", "eslint": "^8.0.0",
+18 -7
View File
@@ -51,6 +51,9 @@ const DEFAULT_OPTIONS = {
background: 'black', background: 'black',
lineWidth: 2, lineWidth: 2,
usePreferredWaveforms: true, usePreferredWaveforms: true,
alpha: true,
imageSmoothingEnabled: true,
antialias: 'default',
}; };
const draw = (data, _options) => { const draw = (data, _options) => {
@@ -73,13 +76,21 @@ const draw = (data, _options) => {
if (options.size < 1) throw new Error('Provide options.size > 0'); if (options.size < 1) throw new Error('Provide options.size > 0');
const scale = DEFAULT_OPTIONS.size / options.size; 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
// 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;
// calculate crop, adjust if necessary // calculate crop, adjust if necessary
const cropTo = Math.min(options.size, options.cropTo); const cropTo = Math.min(options.size, options.cropTo);
if (options.cropTo < 1) throw new Error('Provide options.cropTo > 0'); if (options.cropTo < 1) throw new Error('Provide options.cropTo > 0');
// create the canvas and context // create the canvas and context
const canvas = createCanvas(cropTo, cropTo); const canvas = createCanvas(cropTo, cropTo);
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d', { alpha: options.alpha });
ctx.antialias = options.antialias;
ctx.imageSmoothingEnabled = options.imageSmoothingEnabled;
// fill background with black // fill background with black
ctx.fillStyle = options.background; ctx.fillStyle = options.background;
@@ -87,7 +98,7 @@ const draw = (data, _options) => {
// canvas settings // canvas settings
ctx.imageSmoothingEnabled = true; ctx.imageSmoothingEnabled = true;
ctx.lineWidth = options.lineWidth; ctx.lineWidth = options.lineWidth / gateSizeScaling;
ctx.translate(cropTo / 2, cropTo / 2); ctx.translate(cropTo / 2, cropTo / 2);
ctx.rotate(-Math.PI / 2); ctx.rotate(-Math.PI / 2);
@@ -135,20 +146,20 @@ const draw = (data, _options) => {
// plot each bin // plot each bin
radial.moment_data.forEach((bin, idx) => { radial.moment_data.forEach((bin, idx) => {
if (bin !== null) { if (bin === null) return;
ctx.beginPath(); ctx.beginPath();
// different methods for rrle encoded or not // different methods for rrle encoded or not
if (bin.count) { if (bin.count) {
// rrle encoded // rrle encoded
ctx.strokeStyle = palette.lookupRgba[bin.value]; ctx.strokeStyle = palette.lookupRgba[bin.value];
ctx.arc(0, 0, (idx + deadZone), startAngle, endAngle + resolution * (bin.count - 1)); ctx.arc(0, 0, (idx + deadZone) * gateSizeScaling, startAngle, endAngle + resolution * (bin.count - 1));
} else { } else {
// plain data // plain data
ctx.strokeStyle = palette.lookupRgba[bin]; ctx.strokeStyle = palette.lookupRgba[bin];
ctx.arc(0, 0, (idx + deadZone), startAngle, endAngle); ctx.arc(0, 0, (idx + deadZone) * gateSizeScaling, startAngle, endAngle);
} }
ctx.stroke(); ctx.stroke();
}
}); });
}); });
@@ -160,7 +171,7 @@ const draw = (data, _options) => {
} }
// palettize image // palettize image
const palettized = palettizeImage(canvas.getContext('2d'), palette); const palettized = palettizeImage(ctx, palette);
// return palettized image // return palettized image
return { return {
+1
View File
@@ -0,0 +1 @@
module.exports = ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '0a', '0b', '0c', '0d', '0e', '0f', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '1a', '1b', '1c', '1d', '1e', '1f', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '2a', '2b', '2c', '2d', '2e', '2f', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '3a', '3b', '3c', '3d', '3e', '3f', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '4a', '4b', '4c', '4d', '4e', '4f', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '5a', '5b', '5c', '5d', '5e', '5f', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '6a', '6b', '6c', '6d', '6e', '6f', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '7a', '7b', '7c', '7d', '7e', '7f', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '8a', '8b', '8c', '8d', '8e', '8f', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '9a', '9b', '9c', '9d', '9e', '9f', 'a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'aa', 'ab', 'ac', 'ad', 'ae', 'af', 'b0', 'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'b7', 'b8', 'b9', 'ba', 'bb', 'bc', 'bd', 'be', 'bf', 'c0', 'c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8', 'c9', 'ca', 'cb', 'cc', 'cd', 'ce', 'cf', 'd0', 'd1', 'd2', 'd3', 'd4', 'd5', 'd6', 'd7', 'd8', 'd9', 'da', 'db', 'dc', 'dd', 'de', 'df', 'e0', 'e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7', 'e8', 'e9', 'ea', 'eb', 'ec', 'ed', 'ee', 'ef', 'f0', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'fa', 'fb', 'fc', 'fd', 'fe', 'ff'];
+5 -1
View File
@@ -4,6 +4,8 @@
// this ensures that the colors are not blended because the index should be returned in the a position // this ensures that the colors are not blended because the index should be returned in the a position
// after the entire image is drawn the index information must be shifted from g to a // after the entire image is drawn the index information must be shifted from g to a
const hexLookup = require('./hexlookup');
const rgbaLookupSize = 200; const rgbaLookupSize = 200;
class Palette { class Palette {
@@ -59,7 +61,8 @@ class Palette {
// short circuit for transparent (black) // short circuit for transparent (black)
if (match[0] <= 2 && match[1] <= 2 && match[2] <= 2) return this.transparentIndex; if (match[0] <= 2 && match[1] <= 2 && match[2] <= 2) return this.transparentIndex;
// short circuit previously calculated matches // short circuit previously calculated matches
const asHex = match[0].toString(16).padStart(2, '0') + match[1].toString(16).padStart(2, '0') + match[2].toString(16).padStart(2, '0'); const asHex = hexLookup[match[0]] + hexLookup[match[1]] + hexLookup[match[2]];
// const asHex = match[0].toString(16).padStart(2, '0') + match[1].toString(16).padStart(2, '0') + match[2].toString(16).padStart(2, '0');
if (this.closest[asHex]) return this.closest[asHex]; if (this.closest[asHex]) return this.closest[asHex];
// initial conditions // initial conditions
let closestIndex = 0; let closestIndex = 0;
@@ -80,6 +83,7 @@ class Palette {
} }
// geometric distance // geometric distance
// square root is intentionally not taken for performance reasons
static geometricDistance(a, b) { static geometricDistance(a, b) {
return a.reduce((acc, val, idx) => acc + (val - b[idx]) ** 2, 0); return a.reduce((acc, val, idx) => acc + (val - b[idx]) ** 2, 0);
} }
+5 -6
View File
@@ -4,8 +4,6 @@
const findTotalMatches = (radials, startI, binIdx, resolutionThreshold) => { const findTotalMatches = (radials, startI, binIdx, resolutionThreshold) => {
// get the target value // get the target value
const target = radials[startI].moment_data[binIdx]; const target = radials[startI].moment_data[binIdx];
// check for null
if (target === null) return false;
// start a counter for matches // start a counter for matches
let count = 1; let count = 1;
@@ -23,7 +21,7 @@ const findTotalMatches = (radials, startI, binIdx, resolutionThreshold) => {
// end condition is the number of radials available // end condition is the number of radials available
// a radial not within the resolution threshold // a radial not within the resolution threshold
// or the binIdx under test not present in one of the next radials // or the binIdx under test not present in one of the next radials
while (nextI < radials.length && checkNext) { while (checkNext && nextI < radials.length) {
// reset flag // reset flag
checkNext = false; checkNext = false;
const nextAzimuth = radials[nextI].azimuth; const nextAzimuth = radials[nextI].azimuth;
@@ -60,14 +58,15 @@ const rrle = (radials, resolutionRad) => {
// look at each bin on the radial // look at each bin on the radial
radial.moment_data.forEach((bin, binIdx) => { radial.moment_data.forEach((bin, binIdx) => {
if (radials[i].moment_data[binIdx] === null) return;
const totalMatches = findTotalMatches(radials, i, binIdx, resolutionThreshold); const totalMatches = findTotalMatches(radials, i, binIdx, resolutionThreshold);
// if a total match was found update the bin data and null out the remaining bins in the run // if a total match was found update the bin data and null out the remaining bins in the run
if (totalMatches) { if (!totalMatches) return;
radial.moment_data[binIdx] = { value: bin, count: totalMatches }; radial.moment_data[binIdx] = { value: bin, count: totalMatches };
for (let clearI = i + 1; clearI <= i + totalMatches - 1; clearI += 1) { const loopEnd = i + totalMatches - 1;
for (let clearI = i + 1; clearI <= loopEnd; clearI += 1) {
sorted[clearI].moment_data[binIdx] = null; sorted[clearI].moment_data[binIdx] = null;
} }
}
}); });
} }
+9
View File
@@ -0,0 +1,9 @@
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;
};
+20 -12
View File
@@ -1,5 +1,8 @@
const { draw, canvas } = require('./draw'); const { Piscina } = require('piscina');
const path = require('path');
const { canvas } = require('./draw');
const { writePngToFile } = require('./utils/file'); const { writePngToFile } = require('./utils/file');
/** /**
* Plot level 2 data * Plot level 2 data
* @param {Level2Data} data output from the nexrad-level-2-data library * @param {Level2Data} data output from the nexrad-level-2-data library
@@ -12,12 +15,12 @@ const { writePngToFile } = require('./utils/file');
* @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 {(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 {(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. * @param {boolean} [options.usePreferredWaveforms = true] Limit the plotted data to the preferred use of waveforms 1 and 2.
* @param {boolean} [options.alpha = true] Draw on a 32-bit canvas. Passed directly to getContext('2d', {alpha}).
* @param {boolean} [options.imageSmoothingEnabled = true] Control image smoothing. Passed directly to ctx.imageSmoothingEnabled.
* @param {string} [options.antialias = 'default'] Control antialias. Passed directly to ctx.antialias (part of node-canvas)
* @returns Canvas * @returns Canvas
*/ */
const plot = (data, _products, options) => { const plot = async (data, _products, options) => {
// store result
const result = [];
let products; let products;
// make product list into an array // make product list into an array
if (_products && Array.isArray(_products)) { if (_products && Array.isArray(_products)) {
@@ -38,19 +41,24 @@ const plot = (data, _products, options) => {
if (!elevations) elevations = availableElevations; if (!elevations) elevations = availableElevations;
if (typeof elevations === 'number') elevations = [elevations]; if (typeof elevations === 'number') elevations = [elevations];
elevations.forEach((elevation) => { const staticPool = new Piscina({
filename: path.resolve(__dirname, './draw/thread.js'),
workerData: data.toObject(),
});
const result = await Promise.all(elevations.map(async (elevation) => {
const elevationResult = { elevation }; const elevationResult = { elevation };
products.forEach((product) => { await Promise.all(products.map(async (product) => {
// parse and store result // parse and store result
elevationResult[product] = draw(data, { elevationResult[product] = await staticPool.run({
...options, ...options,
elevation, elevation,
product, product,
}); });
}); }));
result.push(elevationResult); return elevationResult;
}); }));
staticPool.destroy();
return result; return result;
}; };