mirror of
https://github.com/netbymatt/nexrad-level-2-plot.git
synced 2026-11-28 18:28:05 -08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d108e96cea | ||
|
|
ba885085d2 |
No files matched your search
+4
-1
@@ -22,7 +22,7 @@ files.forEach((file) => {
|
||||
const radarData = Level2Radar.combineData(chunks);
|
||||
|
||||
const size = 1800;
|
||||
const iterations = 10;
|
||||
const iterations = 5;
|
||||
|
||||
// plot for each elevation and size
|
||||
(async () => {
|
||||
@@ -32,6 +32,9 @@ const iterations = 10;
|
||||
size,
|
||||
palettize: true,
|
||||
cropTo: size / 2,
|
||||
alpha: false,
|
||||
imageSmoothingEnabled: false,
|
||||
antialias: 'none',
|
||||
});
|
||||
|
||||
// write files to disk
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "nexrad-level-2-plot",
|
||||
"version": "2.6.1",
|
||||
"version": "2.6.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "nexrad-level-2-plot",
|
||||
"version": "2.6.1",
|
||||
"version": "2.6.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"canvas": "^2.9.1",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nexrad-level-2-plot",
|
||||
"version": "2.6.1",
|
||||
"version": "2.6.2",
|
||||
"description": "Plotting library for nexrad-level-2-data",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
|
||||
+14
-14
@@ -146,20 +146,20 @@ const draw = (data, _options) => {
|
||||
|
||||
// plot each bin
|
||||
radial.moment_data.forEach((bin, idx) => {
|
||||
if (bin !== null) {
|
||||
ctx.beginPath();
|
||||
// different methods for rrle encoded or not
|
||||
if (bin.count) {
|
||||
// rrle encoded
|
||||
ctx.strokeStyle = palette.lookupRgba[bin.value];
|
||||
ctx.arc(0, 0, (idx + deadZone) * gateSizeScaling, startAngle, endAngle + resolution * (bin.count - 1));
|
||||
} else {
|
||||
// plain data
|
||||
ctx.strokeStyle = palette.lookupRgba[bin];
|
||||
ctx.arc(0, 0, (idx + deadZone) * gateSizeScaling, startAngle, endAngle);
|
||||
}
|
||||
ctx.stroke();
|
||||
if (bin === null) return;
|
||||
|
||||
ctx.beginPath();
|
||||
// different methods for rrle encoded or not
|
||||
if (bin.count) {
|
||||
// rrle encoded
|
||||
ctx.strokeStyle = palette.lookupRgba[bin.value];
|
||||
ctx.arc(0, 0, (idx + deadZone) * gateSizeScaling, startAngle, endAngle + resolution * (bin.count - 1));
|
||||
} else {
|
||||
// plain data
|
||||
ctx.strokeStyle = palette.lookupRgba[bin];
|
||||
ctx.arc(0, 0, (idx + deadZone) * gateSizeScaling, startAngle, endAngle);
|
||||
}
|
||||
ctx.stroke();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -171,7 +171,7 @@ const draw = (data, _options) => {
|
||||
}
|
||||
|
||||
// palettize image
|
||||
const palettized = palettizeImage(canvas.getContext('2d'), palette);
|
||||
const palettized = palettizeImage(ctx, palette);
|
||||
|
||||
// return palettized image
|
||||
return {
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
const findTotalMatches = (radials, startI, binIdx, resolutionThreshold) => {
|
||||
// get the target value
|
||||
const target = radials[startI].moment_data[binIdx];
|
||||
// check for null
|
||||
if (target === null) return false;
|
||||
|
||||
// start a counter for matches
|
||||
let count = 1;
|
||||
@@ -23,7 +21,7 @@ const findTotalMatches = (radials, startI, binIdx, resolutionThreshold) => {
|
||||
// end condition is the number of radials available
|
||||
// a radial not within the resolution threshold
|
||||
// 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
|
||||
checkNext = false;
|
||||
const nextAzimuth = radials[nextI].azimuth;
|
||||
@@ -60,13 +58,14 @@ const rrle = (radials, resolutionRad) => {
|
||||
|
||||
// look at each bin on the radial
|
||||
radial.moment_data.forEach((bin, binIdx) => {
|
||||
if (radials[i].moment_data[binIdx] === null) return;
|
||||
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 (totalMatches) {
|
||||
radial.moment_data[binIdx] = { value: bin, count: totalMatches };
|
||||
for (let clearI = i + 1; clearI <= i + totalMatches - 1; clearI += 1) {
|
||||
sorted[clearI].moment_data[binIdx] = null;
|
||||
}
|
||||
if (!totalMatches) return;
|
||||
radial.moment_data[binIdx] = { value: bin, count: totalMatches };
|
||||
const loopEnd = i + totalMatches - 1;
|
||||
for (let clearI = i + 1; clearI <= loopEnd; clearI += 1) {
|
||||
sorted[clearI].moment_data[binIdx] = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user