From 7c5f8ebe492d807fc5a1b2b5c64e15bb815e1183 Mon Sep 17 00:00:00 2001 From: shizukanaqun <40553750+shizukanaqun@users.noreply.github.com> Date: Tue, 5 Jul 2022 09:16:57 +0800 Subject: [PATCH 1/6] Update download.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改数据下载URL --- data/download.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 From 6d8d94ef05e4aa4c109f69fa4ec9f202ea3af7d3 Mon Sep 17 00:00:00 2001 From: shizukanaqun <40553750+shizukanaqun@users.noreply.github.com> Date: Tue, 5 Jul 2022 09:18:26 +0800 Subject: [PATCH 2/6] Update prepare.js --- data/prepare.js | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) 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) { From 9f61e52e2631d44703c53df012ead5cbf01ca028 Mon Sep 17 00:00:00 2001 From: shizukanaqun <40553750+shizukanaqun@users.noreply.github.com> Date: Tue, 5 Jul 2022 09:19:47 +0800 Subject: [PATCH 3/6] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index a0971ee3..73a1f356 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +修改了data文件夹内shell脚本及处理数据用的prepare.js文件,使脚本可正常运行 + + + ## WebGL Wind — [Demo](https://mapbox.github.io/webgl-wind/demo/) A WebGL-powered visualization of wind power. From 90b64907496ed3ed79ac161dcb3f3f05223eb298 Mon Sep 17 00:00:00 2001 From: shizukanaqun <40553750+shizukanaqun@users.noreply.github.com> Date: Tue, 5 Jul 2022 09:22:08 +0800 Subject: [PATCH 4/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 73a1f356..a3b596c1 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,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. From 9517a2c7ef78922d9ac46517a9b253bb3ff101a0 Mon Sep 17 00:00:00 2001 From: shizukanaqun <40553750+shizukanaqun@users.noreply.github.com> Date: Tue, 5 Jul 2022 09:22:31 +0800 Subject: [PATCH 5/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a3b596c1..cc18b819 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,6 @@ npm start ### Downloading weather data -1. Install [ecCodes](https://confluence.ecmwf.int//display/ECC/ecCodes+Home) (e.g. `brew install eccodes`)(如果是ubuntu可以运行命令:apt install libeccodes-tools). +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. From 45414bdc0943c492f901e98338a30e1bc8c9f7fd Mon Sep 17 00:00:00 2001 From: shizukanaqun <40553750+shizukanaqun@users.noreply.github.com> Date: Tue, 5 Jul 2022 09:27:49 +0800 Subject: [PATCH 6/6] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index cc18b819..11ee0f2f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ + + +## 更新 修改了data文件夹内shell脚本及处理数据用的prepare.js文件,使脚本可正常运行