From cbca39ffe34dd117bc2f3ae4d38a98eb58fc7bb2 Mon Sep 17 00:00:00 2001 From: Matt Walsh Date: Tue, 27 Apr 2021 16:25:38 -0500 Subject: [PATCH] add test-all --- README.md | 25 +++++++++++++++++++++---- demos/test-all.js | 22 ++++++++++++++++++++++ nexrad-level-3-plot.code-workspace | 9 ++++++++- 3 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 demos/test-all.js diff --git a/README.md b/README.md index c2fe21e..1c19268 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,28 @@ # nexrad-level-3-plot -### v0.1.0 -A javascript implementation for plotting Nexrad Level III data parsed via [nexrad-level-3-data](https://github.com/netbymatt/nexrad-level-3-data/). +> A javascript implementation for plotting Nexrad Level III data parsed via [nexrad-level-3-data](https://github.com/netbymatt/nexrad-level-3-data/). -## Acknowledgements +# Work in Progress +This package is currently incomplete. It will plot raster data created by the package mentioned above but there are several limitations that will be addressed in future releases. +- Color scales do not dynamically change when needed such as with total precipitation products. +- The size of the output image is hard coded to 1800x1800 +- Background color/transparency is hard coded +- Only some products are [supported](#supported-products) + +## Supported Products +|ID|Code|Description| +|---|---|---| +78|N1P|One-hour precipitation +80|NTP|Storm total precipitation +170|DAA|Digital One Hour Accumulation +172|DTA|Digital Total Accumulation + +# Demos +Test code and data is provided in the `./demo` folder. `test.js` can be used to test any one of the products by commenting/uncommenting the appropriate line in the file. All images will be output as PNG to `./output`. A `test-all.js` is also provided to plot all of the products provided in the `./data/` folder. + +# Acknowledgements The code for this project is based upon: - [nexrad-level-3-data](https://github.com/netbymatt/nexrad-level-3-data/) - [Unidata](https://github.com/Unidata/thredds/blob/master/cdm/src/main/java/ucar/nc2/iosp/nexrad2/) - [nexrad-radar-data](https://github.com/bartholomew91/nexrad-radar-data) -- And my own fork of the above [netbymatt/nexrad-radar-data](https://github.com/netbymatt/nexrad-radar-data) \ No newline at end of file +- And my own fork of the above [netbymatt/nexrad-level-2-data](https://github.com/netbymatt/nexrad-level-2-data) \ No newline at end of file diff --git a/demos/test-all.js b/demos/test-all.js new file mode 100644 index 0000000..a15a10b --- /dev/null +++ b/demos/test-all.js @@ -0,0 +1,22 @@ +const fs = require('fs'); +const { plot } = require('../src'); +const { writePngToFile } = require('../src/utils/file'); + +// get a list of all data files +const files = fs.readdirSync('./data/'); + +// plot each file +(async () => { + await Promise.allSettled(files.map(async (file) => { + console.log(file); + try { + const rawFile = fs.readFileSync(`./data/${file}`); + const level3Plot = plot(rawFile); + console.log(level3Plot); + // write to disk + await writePngToFile(`./output/${file}.png`, level3Plot); + } catch (e) { + console.error(e.message); + } + })); +})(); diff --git a/nexrad-level-3-plot.code-workspace b/nexrad-level-3-plot.code-workspace index 362d7c2..b5e2290 100644 --- a/nexrad-level-3-plot.code-workspace +++ b/nexrad-level-3-plot.code-workspace @@ -3,5 +3,12 @@ { "path": "." } - ] + ], + "settings": { + "files.exclude": { + "**/node_modules/": true, + "demos/output/**/*": true, + "demos/output/**/.gitignore": false + } + } } \ No newline at end of file