NCL學習筆記

4 篇文章 0 订阅

fo=addfile("test1.nc","c")

創建文件

Variable: fo

Type: file

filename:    test1

path: test1.nc

   file global attributes:

   dimensions:

   variables:

filedimdef(fo,(/"lon","lat"/),(/360,180/),(/False,False/))

定義維

Variable: fo

Type: file

filename:    test1

path: test1.nc

   file global attributes:

   dimensions:

      lon = 360

      lat = 180

   variables:

lat1=fspan(-90,90,181)

lat1@name="lat:-90to90"

filevardef(fo,"lat1",typeof(lat1),"lat")

創建變量

Variable: fo

Type: file

filename:    test1

path: test1.nc

   file global attributes:

   dimensions:

      lon = 360

      lat = 180

   variables:

      float lat1 ( lat )

filevarattdef(fo,"lat1",lat1)

賦屬性

Variable: fo

Type: file

filename:    test1

path: test1.nc

   file global attributes:

   dimensions:

      lon = 360

      lat = 180

   variables:

      float lat1 ( lat )

         name :            lat:-90to90

因為dimensions: lat = 180所以不能fo->lat1=(/lat1/)

lon=fspan(0,359,360)

lon@name="lon:0to360"

filevardef(fo,"lon",typeof(lon),"lon")

創建變量

Variable: fo

Type: file

filename:    test1

path: test1.nc

   file global attributes:

   dimensions:

      lon = 360

      lat = 180

      ncl2 = 181

   variables:

      float lat1 ( lat )

         name :            lat:-90to90

 

      float lat ( ncl2 )

 

      float lon ( lon )

filevarattdef(fo,"lon",lon)

賦屬性

Variable: fo

Type: file

filename:    test1

path: test1.nc

   file global attributes:

   dimensions:

      lon = 360

      lat = 180

      ncl2 = 181

   variables:

      float lat1 ( lat )

         name :            lat:-90to90

 

      float lat ( ncl2 )

 

      float lon ( lon )

         name :            lon:0to360

fo->lon=(/lon/)

賦值

Variable: fo

Type: file

filename:    test1

path: test1.nc

   file global attributes:

   dimensions:

      lon = 360

      lat = 180

      ncl2 = 181

   variables:

      float lat1 ( lat )

         name :            lat:-90to90

 

      float lat ( ncl2 )

 

      float lon ( lon )

         name :            lon:0to360

 

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"

;;--open file--;;
a=addfile("wrfout_d02_2015-10-21_06_00_00","r")

;;--output file--;;
wks=gsn_open_wks("pdf","test0405f")

;;--color map--;;
gsn_define_colormap(wks,"WhViBlGrYeOrReWh")

res = True
res@MainTitle                   = "REAL-TIME WRF"

pltres = True

;;--geo map--;;
mpres = True
mpres@mpGeophysicalLineColor      = "Black"
mpres@mpGridLineColor             = "Black"
mpres@mpLimbLineColor             = "Black"
mpres@mpNationalLineColor         = "Black"
mpres@mpPerimLineColor            = "Black"
mpres@mpUSStateLineColor          = "Black"
mpres@mpDataSetName="Earth..4"
mpres@mpOutlineSpecifiers=(/"China:states","Taiwan"/)

;;--time, because there are many time in the file--;;
times = wrf_user_getvar(a,"times",-1)  
ntimes = dimsizes(times)
it=1
print("Working on time: " + times(it) )

res@TimeLabel = times(it)

;;--get var: mdbz--;;
mdbz = wrf_user_getvar(a,(/"mdbz","1","1"/),it) 

opts = res                         
opts@cnFillOn = True
opts@cnLevelSelectionMode="ExplicitLevels"
opts@cnLevels=(/10,15,20,25,30,35,40,45,50,55,60,65,70/)
opts@cnFillColors=(/(/255,255,255/),(/1,160,246/),(/0,236,236/),(/0,216,0/),(/1,144,0/),(/255,255,0/),(/231,192,0/),(/255,144,0/),(/255,0,0/),(/214,0,0/),(/192,0,0/),(/255,0,240/),(/150,0,180/),(/173,144,240/)/) /255.0

;;--draw contour--;;
contour = wrf_contour(a,wks,mdbz,opts)

;;--show the plots--;;
plot = wrf_map_overlays(a,wks,(/contour/),pltres,mpres)

;;--some wonderful things--;;
;print(getfiledimsizes(a)+getvardims(a))
;print(getfilevarnames(a))

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值