Compare commits

..
5 Commits
Author SHA1 Message Date
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
4 changed files with 20 additions and 9 deletions

No files matched your search

+5 -3
View File
@@ -22,11 +22,12 @@ files.forEach((file) => {
const radarData = Level2Radar.combineData(chunks);
const size = 1800;
const iterations = 10;
// plot for each elevation and size
(async () => {
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'], {
size,
palettize: true,
@@ -41,7 +42,8 @@ const size = 1800;
writePromises.push(writePngToFile(`./output/VEL-${elevation}-${size}.png`, p.VEL));
});
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}`);
})();
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "nexrad-level-2-plot",
"version": "2.2.1",
"version": "2.4.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "nexrad-level-2-plot",
"version": "2.2.1",
"version": "2.4.0",
"license": "MIT",
"dependencies": {
"canvas": "^2.9.1",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "nexrad-level-2-plot",
"version": "2.2.1",
"version": "2.4.0",
"description": "Plotting library for nexrad-level-2-data",
"main": "src/index.js",
"scripts": {
+12 -3
View File
@@ -73,6 +73,15 @@ 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
// 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 longRange = data?.vcp?.record?.elevations?.[options.elevation]?.super_res_control?.super_res?.['300km'];
const rangeDivider = longRange ? 2 : 1;
// calculate crop, adjust if necessary
const cropTo = Math.min(options.size, options.cropTo);
if (options.cropTo < 1) throw new Error('Provide options.cropTo > 0');
@@ -87,7 +96,7 @@ const draw = (data, _options) => {
// canvas settings
ctx.imageSmoothingEnabled = true;
ctx.lineWidth = options.lineWidth;
ctx.lineWidth = options.lineWidth * rangeDivider / gateSizeScaling;
ctx.translate(cropTo / 2, cropTo / 2);
ctx.rotate(-Math.PI / 2);
@@ -141,11 +150,11 @@ const draw = (data, _options) => {
if (bin.count) {
// rrle encoded
ctx.strokeStyle = palette.lookupRgba[bin.value];
ctx.arc(0, 0, (idx + deadZone), startAngle, endAngle + resolution * (bin.count - 1));
ctx.arc(0, 0, (idx + deadZone) * rangeDivider / gateSizeScaling, startAngle, endAngle + resolution * (bin.count - 1));
} else {
// plain data
ctx.strokeStyle = palette.lookupRgba[bin];
ctx.arc(0, 0, (idx + deadZone), startAngle, endAngle);
ctx.arc(0, 0, (idx + deadZone) * rangeDivider / gateSizeScaling, startAngle, endAngle);
}
ctx.stroke();
}