diff --git a/README.md b/README.md
index a0971ee3..78e585d3 100644
--- a/README.md
+++ b/README.md
@@ -27,4 +27,8 @@ npm start
1. Install [ecCodes](https://confluence.ecmwf.int//display/ECC/ecCodes+Home) (e.g. `brew install eccodes`).
2. Edit constants in `data/download.sh` for desired date, time and resolution.
-3. Run `./data/download.sh
` to generate wind data files (`png` and `json`) for use with the library.
+3. Run `./data/download.sh demo/wind 20210627 00` to generate wind data files (`png` and `json`) for use with the library.
+4. Modify the `windFiles`, object in demo/index.js to reference the new dataset
+ 1. Object keys are offsets in hours from the first date/time
+ 2. The label for the GUI control is in the `meta` object
+ 3. The min, max, and interval for the GUI control are on the `gui.add(meta, ...)` line
diff --git a/data/download.sh b/data/download.sh
index 6feae97d..1d680f60 100755
--- a/data/download.sh
+++ b/data/download.sh
@@ -1,23 +1,49 @@
#!/bin/bash
-GFS_DATE="20161120"
-GFS_TIME="00"; # 00, 06, 12, 18
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
+
+function usage() {
+ cat < [ ]
+ e.g. download.sh demo/wind 20210701 00
+EOF
+}
+
+if ! [ -d "${1}" ]; then
+ echo "error: directory does not exist" >&2
+ usage >&2
+ exit 2
+fi
+cd "${1}"
+
+# Default date & time is 2021-07-01 at 00 hours
+GFS_DATE="${2:=20210701}"
+GFS_TIME="${3:=00}"; # 00, 06, 12, 18
+
+if ! echo "${GFS_DATE}${GFS_TIME}" | egrep -q '^[0-9]{10}$'; then
+ echo "error: incorrect date / time format" >&2
+ usage >&2
+ exit 2
+fi
+
RES="1p00" # 0p25, 0p50 or 1p00
BBOX="leftlon=0&rightlon=360&toplat=90&bottomlat=-90"
LEVEL="lev_10_m_above_ground=on"
-GFS_URL="http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_${RES}.pl?file=gfs.t${GFS_TIME}z.pgrb2.${RES}.f000&${LEVEL}&${BBOX}&dir=%2Fgfs.${GFS_DATE}${GFS_TIME}"
+GFS_URL="https://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_${RES}.pl?file=gfs.t${GFS_TIME}z.pgrb2.${RES}.anl&lev_max_wind=on&${BBOX}&dir=%2Fgfs.${GFS_DATE}%2F${GFS_TIME}%2Fatmos"
+
-curl "${GFS_URL}&var_UGRD=on" -o utmp.grib
-curl "${GFS_URL}&var_VGRD=on" -o vtmp.grib
+curl -L "${GFS_URL}&var_UGRD=on" -o utmp.grib
+curl -L "${GFS_URL}&var_VGRD=on" -o vtmp.grib
-grib_set -r -s packingType=grid_simple utmp.grib utmp.grib
-grib_set -r -s packingType=grid_simple vtmp.grib vtmp.grib
+grib_set -r -s packingType=grid_simple utmp.grib utmp.grib.new
+grib_set -r -s packingType=grid_simple vtmp.grib vtmp.grib.new
+mv utmp.grib.new utmp.grib
+mv vtmp.grib.new vtmp.grib
printf "{\"u\":`grib_dump -j utmp.grib`,\"v\":`grib_dump -j vtmp.grib`}" > tmp.json
rm utmp.grib vtmp.grib
-DIR=`dirname $0`
-node ${DIR}/prepare.js ${1}/${GFS_DATE}${GFS_TIME}
+node ${DIR}/prepare.js ./${GFS_DATE}${GFS_TIME}
rm tmp.json
diff --git a/data/prepare.js b/data/prepare.js
index 94cbd732..5f35181a 100644
--- a/data/prepare.js
+++ b/data/prepare.js
@@ -3,8 +3,19 @@ const fs = require('fs');
const data = JSON.parse(fs.readFileSync('tmp.json'));
const name = process.argv[2];
-const u = data.u;
-const v = data.v;
+
+
+
+const umessage = data.u.messages[0];
+const vmessage = data.v.messages[0];
+
+const unpack = (message) =>
+ message.reduce((acc, { key, value }) => ({ ...acc, [key]: value }), {});
+const u = unpack(umessage);
+const v = unpack(vmessage);
+
+
+
const width = u.Ni;
const height = u.Nj - 1;
@@ -29,7 +40,7 @@ for (let y = 0; y < height; y++) {
png.pack().pipe(fs.createWriteStream(name + '.png'));
-fs.writeFileSync(name + '.json', JSON.stringify({
+fs.writeFileSync('./' + name + '.json', JSON.stringify({
source: 'http://nomads.ncep.noaa.gov',
date: formatDate(u.dataDate + '', u.dataTime),
width: width,
diff --git a/demo/index.js b/demo/index.js
index 21e39c59..1b509a47 100644
--- a/demo/index.js
+++ b/demo/index.js
@@ -26,25 +26,21 @@ gui.add(wind, 'dropRate', 0, 0.1);
gui.add(wind, 'dropRateBump', 0, 0.2);
const windFiles = {
- 0: '2016112000',
- 6: '2016112006',
- 12: '2016112012',
- 18: '2016112018',
- 24: '2016112100',
- 30: '2016112106',
- 36: '2016112112',
- 42: '2016112118',
- 48: '2016112200'
+ 0: '2021062700',
+ 24: '2021062800',
+ 48: '2021062900',
+ 72: '2021063000',
+ 96: '2021070100'
};
const meta = {
- '2016-11-20+h': 0,
+ '2021-06-27+h': 0,
'retina resolution': true,
'github.com/mapbox/webgl-wind': function () {
window.location = 'https://github.com/mapbox/webgl-wind';
}
};
-gui.add(meta, '2016-11-20+h', 0, 48, 6).onFinishChange(updateWind);
+gui.add(meta, '2021-06-27+h', 0, 96, 24).onFinishChange(updateWind);
if (pxRatio !== 1) {
gui.add(meta, 'retina resolution').onFinishChange(updateRetina);
}
diff --git a/demo/wind/2016112000.json b/demo/wind/2016112000.json
deleted file mode 100644
index ec603122..00000000
--- a/demo/wind/2016112000.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "source": "http://nomads.ncep.noaa.gov",
- "date": "2016-11-20T00:00Z",
- "width": 360,
- "height": 180,
- "uMin": -21.32,
- "uMax": 26.8,
- "vMin": -21.57,
- "vMax": 21.42
-}
diff --git a/demo/wind/2016112000.png b/demo/wind/2016112000.png
deleted file mode 100644
index a58efecc..00000000
Binary files a/demo/wind/2016112000.png and /dev/null differ
diff --git a/demo/wind/2016112006.json b/demo/wind/2016112006.json
deleted file mode 100644
index 47ab5b34..00000000
--- a/demo/wind/2016112006.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "source": "http://nomads.ncep.noaa.gov",
- "date": "2016-11-20T600:00Z",
- "width": 360,
- "height": 180,
- "uMin": -19.38,
- "uMax": 25.57,
- "vMin": -21.19,
- "vMax": 22.77
-}
diff --git a/demo/wind/2016112006.png b/demo/wind/2016112006.png
deleted file mode 100644
index 57874cbe..00000000
Binary files a/demo/wind/2016112006.png and /dev/null differ
diff --git a/demo/wind/2016112012.json b/demo/wind/2016112012.json
deleted file mode 100644
index 2a6d7d85..00000000
--- a/demo/wind/2016112012.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "source": "http://nomads.ncep.noaa.gov",
- "date": "2016-11-20T1200:00Z",
- "width": 360,
- "height": 180,
- "uMin": -18.22,
- "uMax": 23.94,
- "vMin": -20.24,
- "vMax": 21
-}
diff --git a/demo/wind/2016112012.png b/demo/wind/2016112012.png
deleted file mode 100644
index 57bef6f4..00000000
Binary files a/demo/wind/2016112012.png and /dev/null differ
diff --git a/demo/wind/2016112018.json b/demo/wind/2016112018.json
deleted file mode 100644
index ca619327..00000000
--- a/demo/wind/2016112018.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "source": "http://nomads.ncep.noaa.gov",
- "date": "2016-11-20T1800:00Z",
- "width": 360,
- "height": 180,
- "uMin": -20.26,
- "uMax": 23.24,
- "vMin": -20.41,
- "vMax": 19.66
-}
diff --git a/demo/wind/2016112018.png b/demo/wind/2016112018.png
deleted file mode 100644
index 4ca23c46..00000000
Binary files a/demo/wind/2016112018.png and /dev/null differ
diff --git a/demo/wind/2016112100.json b/demo/wind/2016112100.json
deleted file mode 100644
index ae9a7ff0..00000000
--- a/demo/wind/2016112100.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "source": "http://nomads.ncep.noaa.gov",
- "date": "2016-11-21T00:00Z",
- "width": 360,
- "height": 180,
- "uMin": -19.16,
- "uMax": 26.04,
- "vMin": -22.08,
- "vMax": 19.17
-}
diff --git a/demo/wind/2016112100.png b/demo/wind/2016112100.png
deleted file mode 100644
index 9bc5ffbf..00000000
Binary files a/demo/wind/2016112100.png and /dev/null differ
diff --git a/demo/wind/2016112106.json b/demo/wind/2016112106.json
deleted file mode 100644
index 0dc5a681..00000000
--- a/demo/wind/2016112106.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "source": "http://nomads.ncep.noaa.gov",
- "date": "2016-11-21T600:00Z",
- "width": 360,
- "height": 180,
- "uMin": -19.73,
- "uMax": 24.57,
- "vMin": -21.79,
- "vMax": 19.6
-}
diff --git a/demo/wind/2016112106.png b/demo/wind/2016112106.png
deleted file mode 100644
index 3baf8670..00000000
Binary files a/demo/wind/2016112106.png and /dev/null differ
diff --git a/demo/wind/2016112112.json b/demo/wind/2016112112.json
deleted file mode 100644
index 24c30713..00000000
--- a/demo/wind/2016112112.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "source": "http://nomads.ncep.noaa.gov",
- "date": "2016-11-21T1200:00Z",
- "width": 360,
- "height": 180,
- "uMin": -21.69,
- "uMax": 25.09,
- "vMin": -20.24,
- "vMax": 19.17
-}
diff --git a/demo/wind/2016112112.png b/demo/wind/2016112112.png
deleted file mode 100644
index 44546b17..00000000
Binary files a/demo/wind/2016112112.png and /dev/null differ
diff --git a/demo/wind/2016112118.json b/demo/wind/2016112118.json
deleted file mode 100644
index cb0df4bc..00000000
--- a/demo/wind/2016112118.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "source": "http://nomads.ncep.noaa.gov",
- "date": "2016-11-21T1800:00Z",
- "width": 360,
- "height": 180,
- "uMin": -24.02,
- "uMax": 26.31,
- "vMin": -20.91,
- "vMax": 21.22
-}
diff --git a/demo/wind/2016112118.png b/demo/wind/2016112118.png
deleted file mode 100644
index 1b056497..00000000
Binary files a/demo/wind/2016112118.png and /dev/null differ
diff --git a/demo/wind/2016112200.json b/demo/wind/2016112200.json
deleted file mode 100644
index 07e25432..00000000
--- a/demo/wind/2016112200.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "source": "http://nomads.ncep.noaa.gov",
- "date": "2016-11-22T00:00Z",
- "width": 360,
- "height": 180,
- "uMin": -21.38,
- "uMax": 24.52,
- "vMin": -21.05,
- "vMax": 19.43
-}
diff --git a/demo/wind/2016112200.png b/demo/wind/2016112200.png
deleted file mode 100644
index 14992737..00000000
Binary files a/demo/wind/2016112200.png and /dev/null differ
diff --git a/demo/wind/2021062700.json b/demo/wind/2021062700.json
new file mode 100644
index 00000000..6f714f65
--- /dev/null
+++ b/demo/wind/2021062700.json
@@ -0,0 +1,10 @@
+{
+ "source": "http://nomads.ncep.noaa.gov",
+ "date": "2021-06-27T00:00Z",
+ "width": 360,
+ "height": 180,
+ "uMin": -49.9619,
+ "uMax": 101.538,
+ "vMin": -75.6065,
+ "vMax": 65.2935
+}
diff --git a/demo/wind/2021062700.png b/demo/wind/2021062700.png
new file mode 100644
index 00000000..b303d922
Binary files /dev/null and b/demo/wind/2021062700.png differ
diff --git a/demo/wind/2021062800.json b/demo/wind/2021062800.json
new file mode 100644
index 00000000..cfc438c6
--- /dev/null
+++ b/demo/wind/2021062800.json
@@ -0,0 +1,10 @@
+{
+ "source": "http://nomads.ncep.noaa.gov",
+ "date": "2021-06-28T00:00Z",
+ "width": 360,
+ "height": 180,
+ "uMin": -51.4175,
+ "uMax": 87.2825,
+ "vMin": -63.9471,
+ "vMax": 70.3529
+}
diff --git a/demo/wind/2021062800.png b/demo/wind/2021062800.png
new file mode 100644
index 00000000..5f7b6055
Binary files /dev/null and b/demo/wind/2021062800.png differ
diff --git a/demo/wind/2021062900.json b/demo/wind/2021062900.json
new file mode 100644
index 00000000..f3bc5c07
--- /dev/null
+++ b/demo/wind/2021062900.json
@@ -0,0 +1,10 @@
+{
+ "source": "http://nomads.ncep.noaa.gov",
+ "date": "2021-06-29T00:00Z",
+ "width": 360,
+ "height": 180,
+ "uMin": -59.0631,
+ "uMax": 94.7369,
+ "vMin": -66.5897,
+ "vMax": 70.7103
+}
diff --git a/demo/wind/2021062900.png b/demo/wind/2021062900.png
new file mode 100644
index 00000000..74ba0147
Binary files /dev/null and b/demo/wind/2021062900.png differ
diff --git a/demo/wind/2021063000.json b/demo/wind/2021063000.json
new file mode 100644
index 00000000..54f5cb28
--- /dev/null
+++ b/demo/wind/2021063000.json
@@ -0,0 +1,10 @@
+{
+ "source": "http://nomads.ncep.noaa.gov",
+ "date": "2021-06-30T00:00Z",
+ "width": 360,
+ "height": 180,
+ "uMin": -59.8576,
+ "uMax": 98.1424,
+ "vMin": -68.6488,
+ "vMax": 76.2512
+}
diff --git a/demo/wind/2021063000.png b/demo/wind/2021063000.png
new file mode 100644
index 00000000..76758b5d
Binary files /dev/null and b/demo/wind/2021063000.png differ
diff --git a/demo/wind/2021070100.json b/demo/wind/2021070100.json
new file mode 100644
index 00000000..2fd6b141
--- /dev/null
+++ b/demo/wind/2021070100.json
@@ -0,0 +1,10 @@
+{
+ "source": "http://nomads.ncep.noaa.gov",
+ "date": "2021-07-01T00:00Z",
+ "width": 360,
+ "height": 180,
+ "uMin": -56.0845,
+ "uMax": 96.3155,
+ "vMin": -69.8492,
+ "vMax": 68.2508
+}
diff --git a/demo/wind/2021070100.png b/demo/wind/2021070100.png
new file mode 100644
index 00000000..037a250d
Binary files /dev/null and b/demo/wind/2021070100.png differ