気象庁再解析データ JRA-25&JCDAS 取得スクリプト
http://ds.data.jma.go.jp/gmd/jra/download/tool.html*1 にサンプルがあるのだけど、自分的に使いにくかったので改造したもの。えらい人から見ればびっくりするほど素朴なスクリプトですみません (苦笑)。anl_p, anl_chipsi, fcst_phy2m の 3 種の 6 時間ごとデータをとってくるものです。適当に改造して役立ててもらえれば幸いです:
2010 年 3 月 15 日: 2 月 29 日のデータがとれないバグがありました。訂正します。(訂正前のものもあわせて掲げておきます。) うるう年判定の周りが冗長になっている理由は、ここ に。
(訂正後)
#!/bin/sh ###################################################################### # initialization ###################################################################### set -eu : ${user:=jra0????}# <= ユーザ ID を書く。 : ${pass:=????????}# <= パスワードを書く。 : ${option:="-N -r -np -nH --level=0"} : ${URL:=http://ds.data.jma.go.jp/gmd/jra/download/data/GribFinal} : ${prefix:=anl_p} : ${prefix1:=anl_chipsi} : ${prefix2:=fcst_phy2m} : ${suffix:=gr} : ${start:=19840228}# <= 取得するデータの初日 : ${end:=19840302}# <= 取得するデータの終日 : ${hour:=00} : ${sleep:=5} : ${WGET:=/usr/local/bin/wget} ###################################################################### # get JRA-25 data ###################################################################### year=`echo ${start} | cut -c 1-4` month=`echo ${start} | cut -c 5-6` date=`echo ${start} | cut -c 7-8` while [ ${year}${month}${date} -le ${end} ] do ${WGET} ${option} ${user:+--http-user=${user}} ${pass:+--http-passwd=${pass}} ${URL}/${prefix}/${year}${month}/${prefix}.${year}${month}${date}${hour} sleep ${sleep} ${WGET} ${option} ${user:+--http-user=${user}} ${pass:+--http-passwd=${pass}} ${URL}/${prefix1}/${year}${month}/${prefix1}.${year}${month}${date}${hour} sleep ${sleep} ${WGET} ${option} ${user:+--http-user=${user}} ${pass:+--http-passwd=${pass}} ${URL}/${prefix2}/${year}${month}/${prefix2}.${year}${month}${date}${hour} sleep ${sleep} case ${hour} in 00 ) hour=06;; 06 ) hour=12;; 12 ) hour=18;; 18 ) hour=00 date=`expr ${date} + 1` dten=10 monthd=31 case ${month} in 04) monthd=30;; 06) monthd=30;; 09) monthd=30;; 11) monthd=30;; esac # echo ${year}${month}${date} if [ ${month} -eq 02 ] then intqyear=`expr $year / 4` # echo $intqyear intqyear=`expr $intqyear \* 4` # echo $intqyear xyear=$((year - intqyear)) # echo ${year}${month}${date} # echo $xyear if [ ${xyear} -eq 0 ] then monthd=29 else monthd=28 fi echo $monthd fi if [ ${date} -lt $dten ]; then date=0${date} elif [ ${date} -gt ${monthd} ]; then month=`expr ${month} + 1` if [ ${month} -lt 10 ]; then month=0${month} elif [ ${month} -gt 12 ]; then year=`expr ${year} + 1` if [ ${year} -lt 1000 ]; then year=0${year} if [ ${year} -lt 100 ]; then year=0${year} if [ ${year} -lt 10 ]; then year=0${year} fi fi fi month=01 fi date=01 fi esac done exit 0
(訂正前)
#!/bin/sh ###################################################################### # initialization ###################################################################### set -eu : ${user:=jra0????}# <= ユーザ ID を書く。 : ${pass:=????????}# <= パスワードを書く。 : ${option:="-N -r -np -nH --level=0"} : ${URL:=http://ds.data.jma.go.jp/gmd/jra/download/data/GribFinal} : ${prefix:=anl_p} : ${prefix1:=anl_chipsi} : ${prefix2:=fcst_phy2m} : ${suffix:=gr} : ${start:=19790305}# <= 取得するデータの初日 : ${end:=20091231}# <= 取得するデータの終日 #: ${end:=19790304} : ${hour:=00} : ${sleep:=5} : ${WGET:=/usr/local/bin/wget} ###################################################################### # get JRA-25 data ###################################################################### year=`echo ${start} | cut -c 1-4` month=`echo ${start} | cut -c 5-6` date=`echo ${start} | cut -c 7-8` while [ ${year}${month}${date} -le ${end} ] do ${WGET} ${option} ${user:+--http-user=${user}} ${pass:+--http-passwd=${pass}} ${URL}/${prefix}/${year}${month}/${prefix}.${year}${month}${date}${hour} sleep ${sleep} ${WGET} ${option} ${user:+--http-user=${user}} ${pass:+--http-passwd=${pass}} ${URL}/${prefix1}/${year}${month}/${prefix1}.${year}${month}${date}${hour} sleep ${sleep} ${WGET} ${option} ${user:+--http-user=${user}} ${pass:+--http-passwd=${pass}} ${URL}/${prefix2}/${year}${month}/${prefix2}.${year}${month}${date}${hour} sleep ${sleep} # ↑ たとえば、fcst_phy2m がいらなければ、この直上の ${WGET} から sleep までの行をコメントアウトする case ${hour} in 00 ) hour=06;; 06 ) hour=12;; 12 ) hour=18;; 18 ) hour=00 date=`expr ${date} + 1` dten=10 monthd=31 case ${month} in 04) monthd=30;; 06) monthd=30;; 09) monthd=30;; 11) monthd=30;; esac if [ ${month} -eq 02 ] then ryear=${year}%4 if [ ${ryear} -eq 0 ] then monthd=29 else monthd=28 fi fi if [ ${date} -lt $dten ]; then date=0${date} elif [ ${date} -gt ${monthd} ]; then month=`expr ${month} + 1` if [ ${month} -lt 10 ]; then month=0${month} elif [ ${month} -gt 12 ]; then year=`expr ${year} + 1` if [ ${year} -lt 1000 ]; then year=0${year} if [ ${year} -lt 100 ]; then year=0${year} if [ ${year} -lt 10 ]; then year=0${year} fi fi fi month=01 fi date=01 fi esac done exit 0
*1:このサイトは再解析データのユーザ登録をしないとみられません