- 积分
- 269
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2017-11-17
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
使用ncl中svdcov会出现这个warning:Warning all X values in column are missing or are constant
而且还会出现经纬度未设置的问题
check_for_y_lat_coord: Warning: Data either does not contain
(0) a valid latitude coordinate array or doesn't contain one at all.
(0) A valid latitude coordinate array should have a 'units'
(0) attribute equal to one of the following values:
(0) 'degrees_north' 'degrees-north' 'degree_north' 'degrees north' 'degrees
_N' 'Degrees_north' 'degree_N' 'degreeN' 'degreesN' 'deg north'(0) check_for_lon_coord: Warning: Data either does not contain
(0) a valid longitude coordinate array or doesn't contain one at all.
(0) A valid longitude coordinate array should have a 'units'
(0) attribute equal to one of the following values:
(0) 'degrees_east' 'degrees-east' 'degree_east' 'degrees east' 'degrees_E'
'Degrees_east' 'degree_E' 'degreeE' 'degreesE' 'deg east'
想问一下大神们该如何解决?以下是我的程序
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/run_cor.ncl"
begin
latmin = 35
latmax = 55
lonmin = 45
lonmax = 90
yrS = 1905
yrE = 2015
season = "MAM"
year = ispan(yrS,yrE,1)
nyear = dimsizes(year)
;===================================================================
;Variables List:
; var1----------sst
; var2----------pre
;===================================================================
fsst = addfile("/home/yxli/data/hadisst/HadISST_sst.nc","r")
time_sst = fsst->time
yyyymm = cd_calendar(time_sst,-1)
t_index_start1 = ind(yyyymm.eq.190501)
t_index_end1 = ind(yyyymm.eq.201512)
sst = fsst->sst(t_index_start1:t_index_end1,:,:)
sst_s2m = month_to_season(sst,"MAM")
;sst_s2m@missing_value = 0
guess = 1
is_cyclic = True
nscan = 1500
eps = 1.e-2
relc = 0.6
opt = 0
poisson_grid_fill(sst_s2m,is_cyclic,guess,nscan,eps,relc,opt)
;sst_spring = dim_standardize_n(sst_s2m,0,0)
;copy_VarCoords(sst_s2m,sst_spring)
printVarSummary(sst)
delete(sst)
sst = dim_standardize_n(sst_s2m,0,0)
copy_VarCoords(sst_spring,sst)
fpre = addfile("/home/yxli/data/cru/cru_ts4.02.1901.2017.pre.dat.nc","r")
time_pre = fpre->time
pre = fpre->pre(48:1379,:,:)
pre_s2m = month_to_season(pre,"MAM")
printVarSummary(pre_s2m)
guess = 1
is_cyclic = True
nscan = 1500
eps = 1.e-2
relc = 0.6
opt = 0
poisson_grid_fill(pre_s2m,is_cyclic,guess,nscan,eps,relc,opt)
delete(pre)
pre = dim_standardize_n(pre_s2m,0,0)
copy_VarCoords(pre_s2m,pre)
printVarSummary(pre)
printVarSummary(sst)
nmca = 2
var1_region = sst(:,{latmin:latmax},{lonmin:lonmax})
;var1_region = sst(:,:,:)
var1_size = dimsizes(var1_region)
n_var1_size = var1_size(1)*var1_size(2)
homlft = new((/nmca,n_var1_size/),float)
hetlft = new((/nmca,n_var1_size/),float)
var1_ano_line = reshape(var1_region,(/var1_size(0),n_var1_size/))
var1_ano_line!0 = "time"
var1_ano_line!1 = "pts"
var2_region = pre(:,{latmin:latmax},{lonmin:lonmax})
;var2_region = pre(:,:,:)
var2_size = dimsizes(var2_region)
n_var2_size = var2_size(1)*var2_size(2)
homrgt = new((/nmca,n_var2_size/),float)
hetrgt = new((/nmca,n_var2_size/),float)
var2_ano_line = reshape(var2_region,(/var2_size(0),n_var2_size/))
var2_ano_line!0 = "time"
var2_ano_line!1 = "pts"
ntime = nyear
ncols = n_var1_size
ncolz = var2_size
nsvd = 2
x = svdcov(var1_ano_line(pts|:,time|:),var2_ano_line(pts|:,time|:),nsvd,homlft,hetlft,homrgt,hetrgt)
printVarSummary(x)
ak = onedtond(x@ak,(/nsvd,ntime/))
bk = onedtond(x@bk,(/nsvd,ntime/))
ak!0 = "sv"
ak!1 = "time"
bk!0 = "sv"
bk!1 = "time"
ccr = escorc(ak(0,:),bk(0,:))
printVarSummary(ccr)
printVarSummary(ak)
printVarSummary(bk)
ak_std = dim_standardize_Wrap(ak,1)
bk_std = dim_standardize_Wrap(bk,1)
printVarSummary(ak_std)
printVarSummary(bk_std)
data = new((/2,nyear/),float)
data(0,:) = ak_std(0,:)
data(1,:) = bk_std(0,:)
ccr_ak = escorc_n(ak(0,:),pre,0,0)*-1
copy_VarCoords(pre(0,:,:),ccr_ak)
printVarSummary(ccr_ak)
ccr_bk = escorc_n(bk(0,:),sst,0,0)*-1
copy_VarCoords(pre(0,:,:),ccr_bk)
printVarSummary(ccr_bk)
test_ak = rtest(ccr_ak,nyear,0)
copy_VarCoords(ccr_ak,test_ak)
test_bk = rtest(ccr_bk,nyear,0)
test_bk = where(ccr_bk.eq.ccr_bk@_FillValue,test_bk@_FillValue,test_bk)
copy_VarCoords(ccr_bk,test_bk)
test_bk_reverse = 1-test_bk
copy_VarCoords(ccr_bk,test_bk_reverse)
printVarSummary(test_ak)
printMinMax(test_ak,False)
printVarSummary(test_bk)
printMinMax(test_bk,False)
;=======================================================================
wks = gsn_open_wks("png","sst&pre")
plot = new(2,"graphic")
plot_prob = new(2,"graphic")
gsn_define_colormap(wks,"BlueWhiteOrangeRed")
res = True
res@gsnDraw = False
res@gsnFrame = False
res@gsnAddCyclic = False ;EOF data is not cyclic
res@cnFillOn = True ; turn on color fill
res@cnLinesOn = False
res@cnLineLabelsOn = False ;turn off cn line labels
res@cnInfoLabelOn = False ;turn off contour information label
res@mpFillOn = True ; turn off map fill
res@mpMinLatF = latmin
res@mpMaxLatF = latmax
res@mpMinLonF = lonmin
res@mpMaxLonF = lonmax
res@mpCenterLonF = (lonmin+lonmax)/2
res@mpGridAndLimbOn = True
res@mpGridLineThicknessF = 0.5
res@mpGridLineDashPattern = 2
res@mpGridSpacingF = 10.
res@mpFillOn = True
res@mpOutlineOn = True
res@mpOutlineBoundarySets = "National"
res@mpGeophysicalLineColor = "black"
res@mpGeophysicalLineThicknessF = 1.0
res@mpDataBaseVersion = "MediumRes"
;res@trGridType = "TriangularMesh"
res@lbLabelBarOn = False
; res@lbOrientation = "Vertical"
res@pmLabelBarHeightF = 0.08
res@pmLabelBarWidthF = 0.55
res@lbLabelFontHeightF = 0.018
res@pmLabelBarOrthogonalPosF = 0.14
res@tmXBLabelFontHeightF = 0.022 ;font height of tick labels
res@tmYLLabelFontHeightF = 0.022
res@tmXBTickSpacingF = 10. ;label spacing
res@tmYLTickSpacingF = 10. ;label spacing
res@gsnLeftStringFontHeightF = 0.022
res@gsnRightStringFontHeightF = 0.022
res@gsnLeftString = "(a)SST"
res@gsnRightString = season
res@cnLevelSelectionMode = "ManualLevels"
res@cnMinLevelValF = -1
res@cnMaxLevelValF = 1
res@cnLevelSpacingF = 0.1
plot(0) = gsn_csm_contour_map(wks,ccr_bk,res)
res@tmYLTickSpacingF = 10.
res@tmXBTickSpacingF = 10. ;label spacing
res@pmLabelBarOrthogonalPosF = 0.25
res@mpMinLatF = latmin
res@mpMaxLatF = latmax
res@mpMinLonF = lonmin
res@mpMaxLonF = lonmax
res@mpCenterLonF = (lonmin+lonmax)/2
res@gsnLeftString = "(b)PRE"
res@cnLevelSelectionMode = "ManualLevels"
res@cnMinLevelValF = -1
res@cnMaxLevelValF = 1
res@cnLevelSpacingF = 0.1
plot(1) = gsn_csm_contour_map(wks,ccr_ak,res) ; create a default plot
res2 = True
res2@gsnDraw = False
res2@gsnFrame = False
res2@gsnDraw = False
res2@gsnFrame = False ;don't advance frame
res2@gsnAddCyclic = False ;EOF data is not cyclic
res2@cnFillOn = True ; turn on color fill
res2@cnLinesOn = False
res2@cnLineLabelsOn = False ;turn off cn line labels
res2@cnInfoLabelOn = False ;turn off contour information label
res2@cnFillOn = True
res2@cnLinesOn = False
res2@cnLineLabelsOn = False
res2@cnInfoLabelOn = False
res2@lbLabelBarOn = False
res2@cnMonoFillPattern = False
res2@cnLevelSelectionMode = "ExplicitLevels"
res2@cnLevels = (/0.1/) ;; set to significance level
res2@cnFillPatterns = (/17,-1/)
res2@cnFillColors = (/1,0/)
res2@cnFillDotSizeF = 0.003
res2@gsnLeftString = ""
res2@gsnAddCyclic = True
plot_prob(0) = gsn_csm_contour(wks, test_bk, res2)
; res2@cnLevelSelectionMode = "ExplicitLevels"
; res2@cnLevels = (/0.05/) ;; set to significance level
; res2@cnFillPatterns = (/-1,17/)
; res2@cnFillColors = (/1,0/)
plot_prob(1) = gsn_csm_contour(wks, test_ak, res2)
do i = 0, 1
overlay(plot(i), plot_prob(i))
end do
;===============================================================================
resP = True
resP@gsnPanelLabelBar = True
; resP@lbOrientation = "Vertical"
resP@gsnPanelMainString = "MAM IO SST&PRE SVD"
gsn_panel(wks,plot,(/2,1/),resP) ; now draw as one plot
;==============================================================================
wks_ts = gsn_open_wks("png","pre&sst_shijian")
rts = True
rts@gsnDraw = False ; don't draw yet
rts@gsnFrame = False ; don't advance frame yet
rts@vpXF = 0.15
rts@vpWidthF = 0.8
rts@vpHeightF= 0.35
rts@tiYAxisString = "Standardized" ; y-axis label
; rts@tiYAxisString = " " ; y-axis label
rts@tmXBLabelFontHeightF = 0.02 ;font height of tick labels
rts@tmYLLabelFontHeightF = 0.02
rts@gsnLeftStringFontHeightF = 0.02
rts@gsnRightStringFontHeightF = 0.02
rts@gsnYRefLine = 0. ; reference line
rts@xyLineColors = (/"blue","red"/) ; colors chosen
rts@xyLineThicknesses = (/3.0,3.0/) ; line thicknesses
rts@xyDashPatterns = (/0.,0./) ; make all lines solid
rts@trXMinF = yrS ; leave a margin for legend
rts@trXMaxF = yrE
;rts@tmXBMode = "Manual" ; Define own tick mark labels.
rts@tmXBTickSpacingF = 5
rts@trYMinF = -3.0 ; min value on x-axis
rts@trYMaxF = 3.0 ; max value on x-axis
rts@gsnLeftString = "Time Series of SVD1 (R = "+sprintf("%5.2f",ccr)+")"
rts@gsnRightString = sprintf("%5.2f",x(0))+"%"
plot_ts = gsn_csm_xy(wks_ts,year,data*-1,rts)
;---------------------------Add plot legend-----------------------------------
res_lines = True ; polyline mods desired
res_lines@gsLineDashPattern = 0. ; solid line
res_lines@gsLineThicknessF = 3. ; line thicker
res_text = True ; text mods desired
res_text@txFontHeightF = 0.015 ; change text size
res_text@txJust = "CenterLeft" ; text justification
res_lines@gsLineColor = "blue"
yy = (/2.5,2.5/)
xx = (/2007,2010/)
text_pos = 2011
dum11 = gsn_add_polyline(wks_ts,plot_ts,xx,yy,res_lines) ; add polyline
dum12 = gsn_add_text(wks_ts,plot_ts,"SST",text_pos,yy(0),res_text); add text
res_lines@gsLineColor = "red"
yy = yy - 0.6
dum21 = gsn_add_polyline(wks_ts,plot_ts,xx,yy,res_lines) ; add polyline
dum22 = gsn_add_text(wks_ts,plot_ts,"PRE",text_pos,yy(0),res_text); add text
draw(plot_ts)
frame(wks)
frame(wks_ts)
end
|
|