mirror of
https://github.com/netbymatt/nexrad-level-2-plot.git
synced 2026-11-28 18:28:05 -08:00
attempt ad not plotting outside crop area
This commit is contained in:
1 parent
8f25b5beee
commit
3fa526c96a
2 files changed
+5
-8
No files matched your search
+2
-4
@@ -6,8 +6,8 @@ const { plot, writePngToFile } = require('../src');
|
||||
|
||||
// list files
|
||||
// const files = glob.sync('./data/KLOT/34/*');
|
||||
// const files = glob.sync('./data/KLOT/381/*');
|
||||
const files = glob.sync('./data/KLOT/548/*');
|
||||
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/*');
|
||||
@@ -44,7 +44,5 @@ const plots = [];
|
||||
writePngToFile(`./output/VEL-${elevation}-${size}.png`, plots[elevation].VEL),
|
||||
]);
|
||||
}));
|
||||
console.log(plots);
|
||||
console.log();
|
||||
}));
|
||||
})();
|
||||
+3
-4
@@ -53,9 +53,6 @@ const draw = (data, _options) => {
|
||||
// calculate crop, adjust if necessary
|
||||
const cropTo = Math.min(options.size, options.cropTo);
|
||||
if (options.cropTo < 1) throw new Error('Provide options.cropTo > 0');
|
||||
// calculate highest bin number to plot, diagonal distance from center of plot area to corner
|
||||
// TODO improve plotting time by calculating the max bin for each azimuth
|
||||
const cropMaxBin = Math.ceil((Math.sqrt(2) * (cropTo / 2)) * scale);
|
||||
|
||||
// create the canvas and context
|
||||
const canvas = createCanvas(cropTo, cropTo);
|
||||
@@ -115,7 +112,9 @@ const draw = (data, _options) => {
|
||||
let downsampled = 0;
|
||||
let lastRemainder = 0;
|
||||
|
||||
// calculate maximum bin to plot
|
||||
// calculate maximum bin to plot based on azimuth
|
||||
const azWrap = startAngle % (Math.PI / 2);
|
||||
const cropMaxBin = Math.ceil(Math.abs(cropTo / Math.cos(azWrap)) - 50);
|
||||
const maxBin = Math.min(cropMaxBin, thisRadial.moment_data.length);
|
||||
// plot each bin
|
||||
for (let idx = 0; idx < maxBin; idx += 1) {
|
||||
|
||||
Reference in new issue
Block a user