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))