mirror of
https://github.com/netbymatt/nexrad-level-2-data.git
synced 2026-11-28 18:58:05 -08:00
46 lines
992 B
JavaScript
46 lines
992 B
JavaScript
/* eslint-disable no-console */
|
|
import fs from 'node:fs';
|
|
import { writeFile } from 'node:fs/promises';
|
|
import { glob } from 'glob';
|
|
import Level2Radar from '../src/index.mjs';
|
|
|
|
// const files = [
|
|
// // './data/chunks/230/20210729-123848-001-S',
|
|
// './data/chunks/230/20210729-123848-002-I',
|
|
// ];
|
|
|
|
const files = glob.sync('./data/chunks/230/*');
|
|
|
|
const chunks = [];
|
|
|
|
files.forEach((fileToLoad) => {
|
|
console.log(`**** ${fileToLoad}`);
|
|
|
|
// load file
|
|
let data;
|
|
try {
|
|
// eslint-disable-next-line n/no-sync
|
|
data = fs.readFileSync(fileToLoad);
|
|
} catch (e) {
|
|
console.error('Unable to read file');
|
|
console.error(e.stack);
|
|
return false;
|
|
}
|
|
|
|
let radar;
|
|
try {
|
|
radar = new Level2Radar(data);
|
|
} catch (e) {
|
|
console.error('Error parsing data');
|
|
console.error(e.stack);
|
|
return false;
|
|
}
|
|
|
|
chunks.push(radar);
|
|
return true;
|
|
});
|
|
const full = Level2Radar.combineData(chunks);
|
|
|
|
console.log(full);
|
|
await writeFile('test/output/test-chunks.json', JSON.stringify(chunks[1], null, 2));
|