Properly scale 170, 172

This commit is contained in:
Matt Walsh committed 2021-03-02 16:58:56 -06:00
1 parent d84e1d203d
commit cd5bfc64b9
7 files changed
+54 -9

No files matched your search

+9
View File
@@ -23,6 +23,15 @@
],
"program": "${workspaceFolder}/demos/80-ntp-storm-total-accumulation.js",
},
{
"type": "pwa-node",
"request": "launch",
"name": "170 DAA",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/demos/170-dta-digital-one-hour",
},
{
"type": "pwa-node",
"request": "launch",
+17
View File
@@ -0,0 +1,17 @@
const fs = require('fs');
const { plot } = require('../src');
const { writePngToFile } = require('../src/utils/file');
// read file
const fileName = 'LOT_DAA_2021_02_28_12_14_47';
const file = fs.readFileSync(`./demos/data/${fileName}`);
// pass to plotting engine as a string or buffer
const level3Plot = plot(file);
(async () => {
writePngToFile(`./demos/output/${fileName}.png`, level3Plot);
})();
console.log(level3Plot);
console.log();
Binary file not shown.
+6 -8
View File
@@ -22,22 +22,20 @@ const draw = (data, product) => {
ctx.translate(dim.x / 2, dim.y / 2);
ctx.rotate(-Math.PI / 2);
// get scaling from product or use default
const scaling = {
scale: data?.productDescription?.plot?.scale ?? 1,
offset: data?.productDescription?.plot?.offset ?? 0,
};
// generate a palette
const palette = Palette.generate(product.palette);
// calculate scaling paramater with respect to pallet's designed criteria
const paletteScale = (data?.productDescription?.plot?.maxDataValue ?? 255) / (product.palette.baseScale ?? data?.productDescription?.plot?.maxDataValue ?? 1);
// use the raw values to avoid scaling and un-scaling
data.radialPackets[0].radials.forEach((radial) => {
const startAngle = radial.startAngle * (Math.PI / 180);
const endAngle = startAngle + radial.angleDelta * (Math.PI / 180);
// for each bin
radial.bins.forEach((bin, idx) => {
// skip null values
if (bin === null) return;
ctx.beginPath();
ctx.strokeStyle = palette[Math.round((bin - scaling.offset) / scaling.scale)];
ctx.strokeStyle = palette[Math.round(bin * paletteScale)];
ctx.arc(0, 0, idx + data.radialPackets[0].firstBin, startAngle, endAngle);
ctx.stroke();
});
+20
View File
@@ -0,0 +1,20 @@
const code = 170;
const abbreviation = 'DAA';
const description = 'Digital One Hour Accumulation';
// same colors as 172
const { colors } = require('../172').palette;
const palette = {
colors,
thresholds: [1, 2, 4, 6, 9, 11, 21, 32, 43, 64, 58, 128, 170, 213, 255],
baseScale: 6.0,
};
module.exports = {
code,
abbreviation,
description,
palette,
};
+1
View File
@@ -26,6 +26,7 @@ const palette = {
255, 255, 255,
],
thresholds: [8, 16, 24, 32, 40, 56, 72, 88, 104, 120, 136, 152, 168, 184, 200, 208, 216, 224, 232],
baseScale: 2.56,
};
module.exports = {