diff --git a/README.md b/README.md
index a0971ee3..11ee0f2f 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,10 @@
+
+
+## 更新
+修改了data文件夹内shell脚本及处理数据用的prepare.js文件,使脚本可正常运行
+
+
+
## WebGL Wind — [Demo](https://mapbox.github.io/webgl-wind/demo/)
A WebGL-powered visualization of wind power.
@@ -25,6 +32,6 @@ npm start
### Downloading weather data
-1. Install [ecCodes](https://confluence.ecmwf.int//display/ECC/ecCodes+Home) (e.g. `brew install eccodes`).
+1. Install [ecCodes](https://confluence.ecmwf.int//display/ECC/ecCodes+Home) (e.g. `brew install eccodes`)(如果是ubuntu可以运行命令:`apt install libeccodes-tools`).
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.
diff --git a/data/download.sh b/data/download.sh
index 6feae97d..4601b93f 100755
--- a/data/download.sh
+++ b/data/download.sh
@@ -1,11 +1,12 @@
#!/bin/bash
-GFS_DATE="20161120"
+GFS_DATE="20220615"
GFS_TIME="00"; # 00, 06, 12, 18
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}"
+#更改了数据下载URL
+GFS_URL="https://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}%2F${GFS_TIME}%2Fatmos"
curl "${GFS_URL}&var_UGRD=on" -o utmp.grib
curl "${GFS_URL}&var_VGRD=on" -o vtmp.grib
@@ -18,6 +19,6 @@ printf "{\"u\":`grib_dump -j utmp.grib`,\"v\":`grib_dump -j vtmp.grib`}" > tmp.j
rm utmp.grib vtmp.grib
DIR=`dirname $0`
-node ${DIR}/prepare.js ${1}/${GFS_DATE}${GFS_TIME}
+node ${DIR}/prepare.js ${DIR}/${GFS_DATE}${GFS_TIME}
rm tmp.json
diff --git a/data/prepare.js b/data/prepare.js
index 94cbd732..3bb63078 100644
--- a/data/prepare.js
+++ b/data/prepare.js
@@ -6,8 +6,20 @@ const name = process.argv[2];
const u = data.u;
const v = data.v;
-const width = u.Ni;
-const height = u.Nj - 1;
+const udataDate=u.messages[0].find((temp)=>{return temp.key=='dataDate'}).value;
+const udataTime=u.messages[0].find((temp)=>{return temp.key=='dataTime'}).value;
+
+const uminimum=u.messages[0].find((temp)=>{return temp.key=='minimum'}).value;
+const umaximum=u.messages[0].find((temp)=>{return temp.key=='maximum'}).value;
+
+const vminimum=v.messages[0].find((temp)=>{return temp.key=='minimum'}).value;
+const vmaximum=v.messages[0].find((temp)=>{return temp.key=='maximum'}).value;
+
+const uvalues=u.messages[0].find((temp)=>{return temp.key=='values'}).value;
+const vvalues=v.messages[0].find((temp)=>{return temp.key=='values'}).value;
+
+const width = u.messages[0].find((temp)=>{return temp.key=='Ni'}).value;
+const height = u.messages[0].find((temp)=>{return temp.key=='Nj'}).value-1;
const png = new PNG({
colorType: 2,
@@ -20,8 +32,8 @@ for (let y = 0; y < height; y++) {
for (let x = 0; x < width; x++) {
const i = (y * width + x) * 4;
const k = y * width + (x + width / 2) % width;
- png.data[i + 0] = Math.floor(255 * (u.values[k] - u.minimum) / (u.maximum - u.minimum));
- png.data[i + 1] = Math.floor(255 * (v.values[k] - v.minimum) / (v.maximum - v.minimum));
+ png.data[i + 0] = Math.floor(255 * (uvalues[k] - uminimum) / (umaximum - uminimum));
+ png.data[i + 1] = Math.floor(255 * (vvalues[k] - vminimum) / (vmaximum - vminimum));
png.data[i + 2] = 0;
png.data[i + 3] = 255;
}
@@ -31,13 +43,13 @@ png.pack().pipe(fs.createWriteStream(name + '.png'));
fs.writeFileSync(name + '.json', JSON.stringify({
source: 'http://nomads.ncep.noaa.gov',
- date: formatDate(u.dataDate + '', u.dataTime),
+ date: formatDate(udataDate + '', udataTime),
width: width,
height: height,
- uMin: u.minimum,
- uMax: u.maximum,
- vMin: v.minimum,
- vMax: v.maximum
+ uMin: uminimum,
+ uMax: umaximum,
+ vMin: vminimum,
+ vMax: vmaximum
}, null, 2) + '\n');
function formatDate(date, time) {