mirror of
https://github.com/netbymatt/nexrad-level-2-plot.git
synced 2026-11-29 02:38:05 -08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
847d4cbecc | ||
|
|
7731d64af6 | ||
|
|
96d3f36545 | ||
|
|
6a7f0868a5 | ||
|
|
bed3043ccd | ||
|
|
676c63dc1c | ||
|
|
e559ba1d9c | ||
|
|
febb902f15 | ||
|
|
aa307c44c0 | ||
|
|
a9fd62a513 |
No files matched your search
@@ -114,6 +114,9 @@ data|{canvas[palette]}|Typically the output of [plot()](#plotfile-options).\<pro
|
|||||||
|
|
||||||
# Notable and breaking changes
|
# Notable and breaking changes
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
|||||||
+5
-3
@@ -22,11 +22,12 @@ files.forEach((file) => {
|
|||||||
const radarData = Level2Radar.combineData(chunks);
|
const radarData = Level2Radar.combineData(chunks);
|
||||||
|
|
||||||
const size = 1800;
|
const size = 1800;
|
||||||
|
const iterations = 10;
|
||||||
|
|
||||||
// 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,
|
||||||
@@ -41,7 +42,8 @@ const size = 1800;
|
|||||||
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();
|
||||||
|
console.log(`Iteration: ${i + 1}/${iterations} Average time: ${(end - start) / 1000 / (i + 1)} s`);
|
||||||
}
|
}
|
||||||
const end = new Date();
|
|
||||||
console.log(`Total Time: ${(end - start) / 1000}`);
|
|
||||||
})();
|
})();
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"path": "."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"settings": {}
|
||||||
|
}
|
||||||
Generated
+3897
-3779
File diff suppressed because it is too large.
Load diff
+37
-37
@@ -1,39 +1,39 @@
|
|||||||
{
|
{
|
||||||
"name": "nexrad-level-2-plot",
|
"name": "nexrad-level-2-plot",
|
||||||
"version": "2.2.0",
|
"version": "2.5.0",
|
||||||
"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": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/netbymatt/nexrad-level-2-plot.git"
|
"url": "git+https://github.com/netbymatt/nexrad-level-2-plot.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"NEXRAD",
|
"NEXRAD",
|
||||||
"level",
|
"level",
|
||||||
"2",
|
"2",
|
||||||
"radar",
|
"radar",
|
||||||
"plot"
|
"plot"
|
||||||
],
|
],
|
||||||
"author": "Matt Walsh",
|
"author": "Matt Walsh",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/netbymatt/nexrad-level-2-plot/issues"
|
"url": "https://github.com/netbymatt/nexrad-level-2-plot/issues"
|
||||||
},
|
},
|
||||||
"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.1",
|
||||||
"nexrad-level-2-data": "^2.1.0"
|
"nexrad-level-2-data": "^2.3.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^8.0.0",
|
"eslint": "^8.0.0",
|
||||||
"eslint-config-airbnb-base": "^15.0.0",
|
"eslint-config-airbnb-base": "^15.0.0",
|
||||||
"eslint-plugin-import": "^2.23.4",
|
"eslint-plugin-import": "^2.23.4",
|
||||||
"glob": "^7.1.7"
|
"glob": "^7.1.7"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=13.0.0"
|
"node": ">=13.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+14
-3
@@ -73,7 +73,18 @@ 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
|
||||||
|
console.log('');
|
||||||
|
console.log(`ELEVATION: ${options.product} ${options.elevation}`);
|
||||||
|
console.log(`Gate size: ${data?.data?.[options.elevation]?.[0]?.record?.reflect?.gate_size}`);
|
||||||
|
console.log('Super Res:', data?.vcp?.record?.elevations?.[options.elevation]?.super_res_control?.super_res);
|
||||||
|
console.log(`Gate count: ${data?.data?.[options.elevation]?.[0]?.record?.reflect.gate_count}`);
|
||||||
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');
|
||||||
|
|
||||||
@@ -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);
|
||||||
|
|
||||||
@@ -141,11 +152,11 @@ const draw = (data, _options) => {
|
|||||||
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();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user