Compare commits

..
3 Commits
Author SHA1 Message Date
Matt Walsh 2b8fbbc3b5 2.1.1 2022-03-11 13:31:01 -06:00
Matt Walsh cab1556cc4 disable preferred products for chunk mode 2022-03-11 13:30:51 -06:00
Matt Walsh 2017a6f4ff fix benchmark code 2022-03-11 09:53:14 -06:00
4 changed files with 18 additions and 16 deletions

No files matched your search

+9 -10
View File
@@ -1,3 +1,4 @@
/* eslint-disable no-await-in-loop */
const { Level2Radar } = require('nexrad-level-2-data');
// eslint-disable-next-line import/no-extraneous-dependencies
const glob = require('glob');
@@ -20,28 +21,26 @@ files.forEach((file) => {
// combine data
const radarData = Level2Radar.combineData(chunks);
// result array by elevations
const plots = [];
const size = 1800;
const elevation = 1;
// plot for each elevation and size
(async () => {
const start = new Date();
for (let i = 0; i < 100; i += 1) {
plots[elevation] = plot(radarData, ['REF', 'VEL'], {
elevation,
const plots = plot(radarData, ['REF', 'VEL'], {
size,
palettize: true,
cropTo: size / 2,
});
// write files to disk
await Promise.allSettled([
writePngToFile(`./output/REF-${elevation}-${size}--${i}.png`, plots[elevation].REF),
writePngToFile(`./output/VEL-${elevation}-${size}--${i}.png`, plots[elevation].VEL),
]);
const writePromises = [];
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));
});
await Promise.allSettled(writePromises);
}
const end = new Date();
console.log(`Total Time: ${(end - start) / 1000}`);
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "nexrad-level-2-plot",
"version": "2.1.0",
"version": "2.1.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "nexrad-level-2-plot",
"version": "2.1.0",
"version": "2.1.1",
"license": "MIT",
"dependencies": {
"canvas": "^2.8.0",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "nexrad-level-2-plot",
"version": "2.1.0",
"version": "2.1.1",
"description": "Plotting library for nexrad-level-2-data",
"main": "src/index.js",
"scripts": {
+6 -3
View File
@@ -61,9 +61,12 @@ const draw = (data, _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;
const elevationInfo = data?.vcp?.record?.elevations?.[options?.elevation];
// elevation info is not available in chunks mode, so preferred waveforms cannot be processed
if (elevationInfo) {
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}`);