Compare commits

..
1 Commits
Author SHA1 Message Date
Matt Walsh dcc07e5bf7 add non-hi-res plot 2022-01-30 16:53:19 -06:00
6 changed files with 88 additions and 86 deletions

No files matched your search

Binary file not shown.
+1
View File
@@ -14,6 +14,7 @@ const { plot, writePngToFile } = require('../src');
// const files = glob.sync('./data/TORD/767/*');
const files = glob.sync('./data/KLOT/KLOT20210812_171451_V*'); // ref palette tuning
// const files = glob.sync('./data/KLOT/KLOT20210621_041151_V06'); // vel palette tuning
// const files = glob.sync('./data/non-hi-res/*');
// const store each file's data
const chunks = [];
+44 -66
View File
@@ -1,16 +1,16 @@
{
"name": "nexrad-level-2-plot",
"version": "1.1.2",
"version": "1.1.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "nexrad-level-2-plot",
"version": "1.1.2",
"version": "1.1.1",
"license": "MIT",
"dependencies": {
"canvas": "^2.8.0",
"nexrad-level-2-data": "^2.1.0"
"nexrad-level-2-data": "file:../nexrad-level-2-data"
},
"devDependencies": {
"eslint": "^8.0.0",
@@ -22,6 +22,22 @@
"node": ">=13.0.0"
}
},
"../nexrad-level-2-data": {
"version": "2.1.0",
"license": "MIT",
"dependencies": {
"seek-bzip": "^2.0.0"
},
"devDependencies": {
"eslint": "^8.0.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.22.1",
"glob": "^7.1.7"
},
"engines": {
"node": ">=13.0.0"
}
},
"node_modules/@eslint/eslintrc": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.0.5.tgz",
@@ -52,9 +68,9 @@
}
},
"node_modules/@humanwhocodes/config-array": {
"version": "0.9.3",
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.3.tgz",
"integrity": "sha512-3xSMlXHh03hCcCmFc0rbKp3Ivt2PFEJnQUJDDMTJQ2wkECZWdq4GePs2ctc5H8zV+cHPaq8k2vU8mrQjA6iHdQ==",
"version": "0.9.2",
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.2.tgz",
"integrity": "sha512-UXOuFCGcwciWckOpmfKDq/GyhlTf9pN/BzG//x8p8zTOFEcGuA68ANXheFS0AGvy3qgZqLBUkMs7hqzqCKOVwA==",
"dev": true,
"dependencies": {
"@humanwhocodes/object-schema": "^1.2.1",
@@ -331,14 +347,6 @@
"color-support": "bin.js"
}
},
"node_modules/commander": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz",
"integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==",
"engines": {
"node": ">= 6"
}
},
"node_modules/concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
@@ -511,9 +519,9 @@
}
},
"node_modules/eslint": {
"version": "8.8.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.8.0.tgz",
"integrity": "sha512-H3KXAzQGBH1plhYS3okDix2ZthuYJlQQEGE5k0IKuEqUSiyu4AmxxlJ2MtTYeJ3xB4jDhcYCwGOg2TXYdnDXlQ==",
"version": "8.7.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.7.0.tgz",
"integrity": "sha512-ifHYzkBGrzS2iDU7KjhCAVMGCvF6M3Xfs8X8b37cgrUlDt6bWRTpRh6T/gtSXv1HJ/BUGgmjvNvOEGu85Iif7w==",
"dev": true,
"dependencies": {
"@eslint/eslintrc": "^1.0.5",
@@ -610,9 +618,9 @@
}
},
"node_modules/eslint-module-utils": {
"version": "2.7.3",
"resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.3.tgz",
"integrity": "sha512-088JEC7O3lDZM9xGe0RerkOMd0EjFl+Yvd1jPWIkMT5u3H9+HC34mWWPnqPrN13gieT9pBOO+Qt07Nb/6TresQ==",
"version": "2.7.2",
"resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.2.tgz",
"integrity": "sha512-zquepFnWCY2ISMFwD/DqzaM++H+7PDzOpUvotJWm/y1BAFt5R4oeULgdrTejKqLkz7MA/tgstsUMNYc7wNdTrg==",
"dev": true,
"dependencies": {
"debug": "^3.2.7",
@@ -1486,15 +1494,8 @@
"dev": true
},
"node_modules/nexrad-level-2-data": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/nexrad-level-2-data/-/nexrad-level-2-data-2.1.0.tgz",
"integrity": "sha512-jfHbUtlx6Ky3Hiv2sVKuxCBy50vziVfs3AWdC84ARAx7xUOe4sXE0TLFsU+bK9skqHgCm2vfjWxURmLKnzNSzw==",
"dependencies": {
"seek-bzip": "^2.0.0"
},
"engines": {
"node": ">=13.0.0"
}
"resolved": "../nexrad-level-2-data",
"link": true
},
"node_modules/node-fetch": {
"version": "2.6.7",
@@ -1819,18 +1820,6 @@
}
]
},
"node_modules/seek-bzip": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/seek-bzip/-/seek-bzip-2.0.0.tgz",
"integrity": "sha512-SMguiTnYrhpLdk3PwfzHeotrcwi8bNV4iemL9tx9poR/yeaMYwB9VzR1w7b57DuWpuqR8n6oZboi0hj3AxZxQg==",
"dependencies": {
"commander": "^6.0.0"
},
"bin": {
"seek-bunzip": "bin/seek-bunzip",
"seek-table": "bin/seek-bzip-table"
}
},
"node_modules/semver": {
"version": "7.3.5",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
@@ -2220,9 +2209,9 @@
}
},
"@humanwhocodes/config-array": {
"version": "0.9.3",
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.3.tgz",
"integrity": "sha512-3xSMlXHh03hCcCmFc0rbKp3Ivt2PFEJnQUJDDMTJQ2wkECZWdq4GePs2ctc5H8zV+cHPaq8k2vU8mrQjA6iHdQ==",
"version": "0.9.2",
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.2.tgz",
"integrity": "sha512-UXOuFCGcwciWckOpmfKDq/GyhlTf9pN/BzG//x8p8zTOFEcGuA68ANXheFS0AGvy3qgZqLBUkMs7hqzqCKOVwA==",
"dev": true,
"requires": {
"@humanwhocodes/object-schema": "^1.2.1",
@@ -2429,11 +2418,6 @@
"resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz",
"integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg=="
},
"commander": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz",
"integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA=="
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
@@ -2562,9 +2546,9 @@
"dev": true
},
"eslint": {
"version": "8.8.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.8.0.tgz",
"integrity": "sha512-H3KXAzQGBH1plhYS3okDix2ZthuYJlQQEGE5k0IKuEqUSiyu4AmxxlJ2MtTYeJ3xB4jDhcYCwGOg2TXYdnDXlQ==",
"version": "8.7.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.7.0.tgz",
"integrity": "sha512-ifHYzkBGrzS2iDU7KjhCAVMGCvF6M3Xfs8X8b37cgrUlDt6bWRTpRh6T/gtSXv1HJ/BUGgmjvNvOEGu85Iif7w==",
"dev": true,
"requires": {
"@eslint/eslintrc": "^1.0.5",
@@ -2646,9 +2630,9 @@
}
},
"eslint-module-utils": {
"version": "2.7.3",
"resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.3.tgz",
"integrity": "sha512-088JEC7O3lDZM9xGe0RerkOMd0EjFl+Yvd1jPWIkMT5u3H9+HC34mWWPnqPrN13gieT9pBOO+Qt07Nb/6TresQ==",
"version": "2.7.2",
"resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.2.tgz",
"integrity": "sha512-zquepFnWCY2ISMFwD/DqzaM++H+7PDzOpUvotJWm/y1BAFt5R4oeULgdrTejKqLkz7MA/tgstsUMNYc7wNdTrg==",
"dev": true,
"requires": {
"debug": "^3.2.7",
@@ -3293,10 +3277,12 @@
"dev": true
},
"nexrad-level-2-data": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/nexrad-level-2-data/-/nexrad-level-2-data-2.1.0.tgz",
"integrity": "sha512-jfHbUtlx6Ky3Hiv2sVKuxCBy50vziVfs3AWdC84ARAx7xUOe4sXE0TLFsU+bK9skqHgCm2vfjWxURmLKnzNSzw==",
"version": "file:../nexrad-level-2-data",
"requires": {
"eslint": "^8.0.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.22.1",
"glob": "^7.1.7",
"seek-bzip": "^2.0.0"
}
},
@@ -3514,14 +3500,6 @@
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
},
"seek-bzip": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/seek-bzip/-/seek-bzip-2.0.0.tgz",
"integrity": "sha512-SMguiTnYrhpLdk3PwfzHeotrcwi8bNV4iemL9tx9poR/yeaMYwB9VzR1w7b57DuWpuqR8n6oZboi0hj3AxZxQg==",
"requires": {
"commander": "^6.0.0"
}
},
"semver": {
"version": "7.3.5",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "nexrad-level-2-plot",
"version": "1.1.2",
"version": "1.1.1",
"description": "Plotting library for nexrad-level-2-data",
"main": "src/index.js",
"scripts": {
@@ -25,7 +25,7 @@
"homepage": "https://github.com/netbymatt/nexrad-level-2-plot#readme",
"dependencies": {
"canvas": "^2.8.0",
"nexrad-level-2-data": "^2.1.0"
"nexrad-level-2-data": "file:../nexrad-level-2-data"
},
"devDependencies": {
"eslint": "^8.0.0",
+20 -17
View File
@@ -60,20 +60,6 @@ const draw = (data, _options) => {
const cropTo = Math.min(options.size, options.cropTo);
if (options.cropTo < 1) throw new Error('Provide options.cropTo > 0');
// create the canvas and context
const canvas = createCanvas(cropTo, cropTo);
const ctx = canvas.getContext('2d');
// fill background with black
ctx.fillStyle = options.background;
ctx.fillRect(0, 0, cropTo, cropTo);
// canvas settings
ctx.imageSmoothingEnabled = true;
ctx.lineWidth = options.lineWidth;
ctx.translate(cropTo / 2, cropTo / 2);
ctx.rotate(-Math.PI / 2);
// get the palette
const palette = palettes[options.product];
// test for valid palette
@@ -107,10 +93,27 @@ const draw = (data, _options) => {
const indexedProduct = indexProduct(downSampledProduct, palette);
const rrlEncoded = rrle(indexedProduct, resolution);
// create the canvas and context
const canvas = createCanvas(cropTo, cropTo);
const ctx = canvas.getContext('2d');
// fill background with black
ctx.fillStyle = options.background;
ctx.fillRect(0, 0, cropTo, cropTo);
// calculate a gate size against the nominal size
const gateScale = rrlEncoded[0].gate_size / 0.25;
// canvas settings
ctx.imageSmoothingEnabled = true;
ctx.lineWidth = options.lineWidth * gateScale;
ctx.translate(cropTo / 2, cropTo / 2);
ctx.rotate(-Math.PI / 2);
// loop through data
rrlEncoded.forEach((radial) => {
// calculate plotting parameters
const deadZone = radial.first_gate / radial.gate_size / scale;
const deadZone = radial.first_gate / radial.gate_size / scale * gateScale;
// 10% is added to the arc to ensure that each arc bleeds into the next just slightly to avoid radial empty spaces at further distances
const startAngle = radial.azimuth * (Math.PI / 180) - halfResolution * 1.1;
@@ -124,11 +127,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) * gateScale, 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) * gateScale, startAngle, endAngle);
}
ctx.stroke();
}
+21 -1
View File
@@ -5,7 +5,27 @@
const filterProduct = (data, product) => data.map((header) => {
// get correct data
const thisRadial = header[product];
let thisRadial = header[product];
// special case for non-hi-res data
// re-formats data to expected format
if (!thisRadial.moment_data && thisRadial) {
thisRadial = {
...header,
moment_data: header[product],
};
if (product === 'refelect') {
thisRadial.gate_size = header.surveillance_range_sample_interval;
thisRadial.gate_count = header.number_of_surveillance_bins;
} else {
thisRadial.gate_size = header.doppler_range_sample_interval;
thisRadial.gate_count = header.number_of_doppler_bins;
}
thisRadial.first_gate = 2;
}
// skip if this radial isn't found
if (thisRadial === undefined) return false;
thisRadial.azimuth = header.azimuth;