forked from bartholomew91/nexrad-radar-data
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest-chunks.js
42 lines (34 loc) · 820 Bytes
/
test-chunks.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* eslint-disable no-console */
const fs = require('fs');
const glob = require('glob');
const { Level2Radar } = require('./src');
// 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 {
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);