Link Search Menu Expand Document

地面觀測數據之自動下載

Table of contents

背景

  • 全球地面觀測數據(ds461.0)是MM5/WRF進行四階同化需要的數據,資料格式是little_r格式,可以被obsgridWRFDA等程式接受。
  • 同樣的,NCEP並無提供指定範圍自動下載的工具,只能下載全球範圍所有觀測值。幸好檔案是ASCII格式,可以達到很高的壓縮率。

批次執行與自動執行

詳見樓上

程式差異說明

因程式與ff.py很相像,此處介紹其差異之處

  • 結果檔案儲存位置
kuang@114-32-164-198 ~/python_eg/NCEP_fetch
$ diff ff.py ss.py
53c53
< path='/Users/WRF4.1/NCEP/FNL/'
---
> path='/Users/WRF4.1/NCEP/SRF_ds461.0/'
  • 檔名中的日期出現在不同位置(範例)
    • FNL: fnl_20211124_18_00.grib2
    • SRF: SURFACE_OBS:2021111818
    • UPA: OBS:2021111818
55c55,57
< blk=os.popen('ls '+path+yrold+'|tail -n1').read().strip('\n').split('_')
---
> print yrold
> blk=os.popen('ls '+path+yrold+'|tail -n1').read().strip('\n').split('_')[-1].split(':')
> print blk
  • 地面數據有可能被壓縮(gzip),取用檔名時要多加此一選項。(如沒有gz則不會有任何改變)
57c59
<   begd=int(blk[1])
---
>   begd=int(int(blk[1].replace('.gz',''))/100)
  • 數據更新較慢,比實際日期晚8天
64c66
< edate = tdate+datetime.timedelta(days=-2)
---
> edate = tdate+datetime.timedelta(days=-8)
  • url字串的內容也有所差異
76,82c78,79
< mos=[ymd[4:6] for ymd in ymds]
< head=['grib2/'+yr+'/'+yr+'.' for yr in yrs]
< med='/fnl_'
< udl='_'
< tail='_00.grib2'
< listoffiles=[head[i]+mos[i]+med+ymds[i]+udl+str(h)+tail for i in xrange(len(ymds)) for h in ['00','06','12','18']]
< #sys.exit('OK')
---
> head=['little_r/'+yr+'/SURFACE_OBS:' for yr in yrs]
> listoffiles=[head[i]+ymds[i]+str(h)  for i in xrange(len(ymds)) for h in ['00','06','12','18']]
  • macOS能夠處理冒號,不需更換。
86c83
<     ofile=file[idx+1:].replace(':','_')
---
>     ofile=file[idx+1:]#.replace(':','_')
88c85
<     ofile=file.replace(':','_')
---
>     ofile=file#.replace(':','_')
  • 地面數據有可能被壓縮(gzip),測試邏輯要多加此一選項。
91c88
<   if os.path.isfile(path1+ofile):continue
---
>   if os.path.isfile(path1+ofile) or os.path.isfile(path1+ofile+'.gz') :continue
  • NCEP 資料庫編碼,地面數據是ds351.0
96c93
<     infile=opener.open("http://rda.ucar.edu/data/ds083.2/"+file)
---
>     infile=opener.open("http://rda.ucar.edu/data/ds461.0/"+file)

完整程式碼