爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 3752|回复: 5

[作图] 时间剖面图出错,看不懂

[复制链接]

新浪微博达人勋

发表于 2018-4-9 10:01:51 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
我想画个剖面图,出错,以前也画过好像没有问题。不过这次的是时间剖面图。有高手帮忙看看怎么回事吗?脚本如下:
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"

begin
  lat1=30
  lon1=90
  lat2=35
  lon2=100
  lat3=40
  lon3=120
  lat4=50
  lon4=135
  for_shixiao_1=24
  for_shixiao_2=36
  for_shixiao_3=60
  for_shixiao_4=120


  levels_choosed=7
  points=4
  day="2016120700"
  pltType="png"
  year=str_get_cols(day,0,3)
  month=str_get_cols(day,4,5)
  days=str_get_cols(day,6,7)
  hours=str_get_cols(day,8,9)
  diri="/fs01/home/climate/INTERP/data/global_atmo/ToGRIB025/"
  pltDir=diri+day+"/"
  strT=new(points,string)

  U_points_isbls=new((/points,26/),float)
  V_points_isbls=new((/points,26/),float)
  RH_points_isbls=new((/points,26/),float)
  TIME=new(points,"integer")
  U_points_isbls_7lels=new((/points,7/),float)
  V_points_isbls_7lels=new((/points,7/),float)
  RH_points_isbls_7lels=new((/points,7/),float)

  UV=new((/points,7/),float)
  do ss=1,points
  if(ss.eq.1)then
  for_shixiao=for_shixiao_1
  lat_o=lat1
  lon_o=lon1
  TIME((ss-1):(ss-1))=for_shixiao_1
  end if
  if(ss.eq.2)then
  for_shixiao=for_shixiao_2
  lat_o=lat2
  lon_o=lon2
  TIME((ss-1):(ss-1))=for_shixiao_2
  end if
  if(ss.eq.3)then
  for_shixiao=for_shixiao_3
  lat_o=lat3
  lon_o=lon3
  TIME((ss-1):(ss-1))=for_shixiao_3
  end if
  if(ss.eq.4)then
  for_shixiao=for_shixiao_4
  lat_o=lat4
  lon_o=lon4
  TIME((ss-1):(ss-1))=for_shixiao_4
  end if

  do n=0,points-1,1      
      strT(n)=str_concat(tostring(TIME(n)))
  end do
  print(strT)

   if(for_shixiao.lt.10)then
     shixiao_biaoshi2="00"+tostring(for_shixiao)
   end if
   if(for_shixiao.lt.100 .and. for_shixiao.gt.10)then
     shixiao_biaoshi2="0"+tostring(for_shixiao)
   end if
   if(for_shixiao.gt.100)then
     shixiao_biaoshi2=tostring(for_shixiao)
   end if
   fils_u = systemfunc ("ls "+diri+day+"/HTUUG*"+shixiao_biaoshi2+".grb") ;
   fils_v = systemfunc ("ls "+diri+day+"/HTVVG*"+shixiao_biaoshi2+".grb")
   fils_rh = systemfunc ("ls "+diri+day+"/HTRHG*"+shixiao_biaoshi2+".grb")


   currentFile_u=addfile(fils_u,"r")
   currentFile_v=addfile(fils_v,"r")
   currentFile_rh=addfile(fils_rh,"r")
   lv_ISBL0=currentFile_u->lv_ISBL0
   U_GRD_3_ISBL=short2flt(currentFile_u->U_GRD_3_ISBL)
   V_GRD_3_ISBL=short2flt(currentFile_v->V_GRD_3_ISBL)
   RH_GRD_3_ISBL=short2flt(currentFile_rh->R_H_3_ISBL)
   lat=currentFile_u->lat_3
   lon=currentFile_u->lon_3
   U_points_isbl=ndtooned(U_GRD_3_ISBL({lv_ISBL0|:},{lat_3|lat_o:lat_o},{lon_3|lon_o:lon_o}))
   V_points_isbl=ndtooned(V_GRD_3_ISBL({lv_ISBL0|:},{lat_3|lat_o:lat_o},{lon_3|lon_o:lon_o}))
   RH_points_isbl=ndtooned(RH_GRD_3_ISBL({lv_ISBL0|:},{lat_3|lat_o:lat_o},{lon_3|lon_o:lon_o}))

   dim_u=dimsizes(U_points_isbl)
   U_points_isbls((ss-1):(ss-1),:)=onedtond(U_points_isbl,(/1,dim_u/))
   V_points_isbls((ss-1):(ss-1),:)=onedtond(V_points_isbl,(/1,dim_u/))
   RH_points_isbls((ss-1):(ss-1),:)=onedtond(RH_points_isbl,(/1,dim_u/))
  end do
        TIME@units="hours since "+year+"-"+month+"-"+days+" "+hours+":00:00"
  date_fore=ut_calendar(TIME,-3)
  U_points_isbls!0="time"
  U_points_isbls!1="level"
  U_points_isbls&time=date_fore
  U_points_isbls&level=lv_ISBL0
  copy_VarCoords(U_points_isbls,V_points_isbls)
  copy_VarCoords(U_points_isbls,RH_points_isbls)
  U_points_isbls_7lels(:,0:0)=U_points_isbls({time|:},{level|1000:1000})
  U_points_isbls_7lels(:,1:1)=U_points_isbls({time|:},{level|925:925})
  U_points_isbls_7lels(:,2:2)=U_points_isbls({time|:},{level|850:850})
  U_points_isbls_7lels(:,3:3)=U_points_isbls({time|:},{level|700:700})
  U_points_isbls_7lels(:,4:4)=U_points_isbls({time|:},{level|500:500})
  U_points_isbls_7lels(:,5:5)=U_points_isbls({time|:},{level|300:300})
  U_points_isbls_7lels(:,6:6)=U_points_isbls({time|:},{level|100:100})

  V_points_isbls_7lels(:,0:0)=V_points_isbls({time|:},{level|1000:1000})
  V_points_isbls_7lels(:,1:1)=V_points_isbls({time|:},{level|925:925})
  V_points_isbls_7lels(:,2:2)=V_points_isbls({time|:},{level|850:850})
  V_points_isbls_7lels(:,3:3)=V_points_isbls({time|:},{level|700:700})
  V_points_isbls_7lels(:,4:4)=V_points_isbls({time|:},{level|500:500})
  V_points_isbls_7lels(:,5:5)=V_points_isbls({time|:},{level|300:300})
  V_points_isbls_7lels(:,6:6)=V_points_isbls({time|:},{level|100:100})

  RH_points_isbls_7lels(:,0:0)=RH_points_isbls({time|:},{level|1000:1000})
  RH_points_isbls_7lels(:,1:1)=RH_points_isbls({time|:},{level|925:925})
  RH_points_isbls_7lels(:,2:2)=RH_points_isbls({time|:},{level|850:850})
  RH_points_isbls_7lels(:,3:3)=RH_points_isbls({time|:},{level|700:700})
  RH_points_isbls_7lels(:,4:4)=RH_points_isbls({time|:},{level|500:500})
  RH_points_isbls_7lels(:,5:5)=RH_points_isbls({time|:},{level|300:300})
  RH_points_isbls_7lels(:,6:6)=RH_points_isbls({time|:},{level|100:100})

  lv_ISBL0_7lels=new(levels_choosed,"integer")
  lv_ISBL0_7lels=(/1000,925,850,700,500,300,100/)
  ;fu shuxing     
  TIME@units="hours since "+year+"-"+month+"-"+days+" "+hours+":00:00"
  date_fore=ut_calendar(TIME,-3)
  UV=sqrt(U_points_isbls_7lels*U_points_isbls_7lels+V_points_isbls_7lels*V_points_isbls_7lels)
  U_points_isbls_7lels=U_points_isbls_7lels*2.5
  V_points_isbls_7lels=V_points_isbls_7lels*2.5
  U_points_isbls_7lels!0="time"
  U_points_isbls_7lels!1="level"
  U_points_isbls_7lels&time=date_fore
  U_points_isbls_7lels&level=lv_ISBL0_7lels
  copy_VarCoords(U_points_isbls_7lels,V_points_isbls_7lels)
  copy_VarCoords(U_points_isbls_7lels,RH_points_isbls_7lels)



      pltName="wind_hr_line_501-rh"
      pltPath=pltDir+pltName
      wks  = gsn_open_wks(pltType,pltPath)
            gsn_define_colormap(wks,"GMT_drywet");
            ;gsn_reverse_colormap(wks)
       ymin=100;
       ymax=1000;
       yy = ispan(0,6,1)*1.
  z0=(/1000,800,600,400,225,175,100/)
   do gg = 0,points-1   
     z    = lv_ISBL0_7lels;lv_ISBL0
     u = ndtooned(U_points_isbls_7lels(gg:gg,:))
     v = ndtooned(V_points_isbls_7lels(gg:gg,:))
     uv=ndtooned(UV(gg:gg,:))

        res = True
        res@gsnDraw = False
        res@gsnFrame = False
        res@vpWidthF = 0.7
        res@vpHeightF = 0.5
        res@vpXF = 0.15
        res@vpYF = 0.9
        res@trYMinF = ymin
        res@trYMaxF = ymax        
                           res@tmYLMode    ="Explicit"
                           res@tmYLValues  = (/1000,800,600,400,250,175,100/)
        res@tmYLLabels = (/"100","300","500","700","850","925","1000"/)
                     res@tmXBMode = "Explicit"
        res@tmXBValues = (/0.5,1.5,2.5,3.5/)
        res@tmXBLabels = strT
        res@tmYMajorGrid                = True    ; Turn on grid lines
                                res@tmYMajorGridLineDashPattern = 2       ; Dashed lines
                          res@tmYMajorGridThicknessF      = 1.0     ;
                          res@tmXMajorGrid                = True    ; Turn on grid lines
                                res@tmXMajorGridLineDashPattern = 2       ; Dashed lines
                          res@tmXMajorGridThicknessF      = 1.0     ;
        res@tiYAxisString = "Pressure (hPa)"
        ;res@tiXAxisString = "time"
        res@tiMainString = "Wind Profile"
        res@tmXBMajorLengthF=-0.01
        xc = (/0,4,4,0,0/)
        yc = (/ymin,ymin,ymax,ymax,ymin/)
        if (gg.eq.0) then     
        plot = gsn_csm_xy(wks,xc,yc,res)  
        end if                     ; draw blank xy plot by outlining min/max of X/Y axes
        contours = ispan(5,65,5)*1.                               ; set contours used to define barb color
        colors = (/20,30,40,45,50,55,60,65,70,75,80,85,90,95/)    ; set colors



     wmsetp ("wdf", 1)                 ; meteorological dir
     wmsetp("wbs",0.035)
     wmsetp ("blw",3.0)    ; increase line thickness of wind barbs
     do hh = 0,dimsizes(z)-1
      wmsetp("col", GetFillColorIndex(contours,colors,uv(dimsizes(z)-1-hh)))   
      wmbarb(wks, gg*1.+0.5, z0(hh),u(dimsizes(z)-1-hh), v(dimsizes(z)-1-hh))
     end do     
     delete([/z,u,v/])
    end do
                                
      vcres=True
      ;vcres@gsnDraw              =False
      ;vcres@gsnFrame             =False
      vcres@cnFillOn             = True         ; turn on color fill
      vcres@cnFillPalette        = "BlWhRe"
      vcres@cnLinesOn            = False        ; True is default
      vcres@cnLineLabelsOn       = False        ; True is default
      ;vcres@cnLineLabelPlacementMode="Constant"
      ;vcres@cnLineDashSegLenF=0.065
      ;vcres@cnLineLabelInterval=1
      ;vcres@cnLevelSelectionMode="ExplicitLevels"
      ;vcres@cnLevels=(/0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0/)
      ;vcres@cnFillColors=(/10,14,18,23,27,29,33,37,39,43/)
      vcres@cnLevelSpacingF = 0.1


      rrh_plot=RH_points_isbls_7lels(level|:,time|:)
      plot2=gsn_csm_pres_hgt(wks,rrh_plot,vcres)
      ;overlay(plot,plot2)
                        draw(plot2)  
      frame(wks)

end




出错信息是:
warning:IrTransInitialize: trXCoordPoints contains invalid coordinate array: defaulting trXAxisType to LinearAxis
warning:_NhlCreateSplineCoordApprox: Attempt to create spline approximation for X axis failed: consider adjusting trXTensionF value
warning:_NhlCreateSplineCoordApprox: Attempt to create spline approximation for X axis failed: consider adjusting trXTensionF value
warning:_NhlCreateSplineCoordApprox: Attempt to create spline approximation for X axis failed: consider adjusting trXTensionF value
fatal:IrTransInitialize: spline coordinate approximation not possible:
fatal:Unable to initialize layer-Can't Create
fatal:ContourPlotInitialize: Error creating transformation object
fatal:ContourPlotInitialize: error setting up transformation
fatal:Unable to initialize layer-Can't Create
fatal:PID #-4 can't be found in NhlSetValues
fatal:NhlGetValues:PID #-4 is invalid
fatal:["Execute.c":8640]:Execute: Error occurred at or near line 2222 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl

fatal:["Execute.c":8640]:Execute: Error occurred at or near line 9571 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl

fatal:["Execute.c":8640]:Execute: Error occurred at or near line 13393 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl

fatal:["Execute.c":8640]:Execute: Error occurred at or near line 13532 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl

fatal:["Execute.c":8640]:Execute: Error occurred at or near line 13813 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl

fatal:["Execute.c":8638]:Execute: Error occurred at or near line 172

由于我在找错误,所以提示的line172行显示的就是  plot2=gsn_csm_pres_hgt(wks,rrh_plot,vcres)这里头。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2018-4-9 10:03:37 | 显示全部楼层
前面画风剖面的部分是没有错的。我想把湿度的画出来,看能不能叠加上去,结果直接画湿度都有问题了。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2018-4-10 11:03:35 | 显示全部楼层
版主帮我删了吧,已经解决了。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2020-11-25 15:12:38 | 显示全部楼层
dengxiaohua_121 发表于 2018-4-10 11:03
版主帮我删了吧,已经解决了。

我也出现了同样的错误,请问楼主是怎么解决的呢?
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2020-11-25 15:14:42 | 显示全部楼层
flowers940815 发表于 2020-11-25 15:12
我也出现了同样的错误,请问楼主是怎么解决的呢?

warning:IrTransInitialize: trXCoordPoints contains invalid coordinate array: defaulting trXAxisType to LinearAxis    请问,这是是什么原因造成的呢?
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2021-6-18 09:16:29 | 显示全部楼层
flowers940815 发表于 2020-11-25 15:14
warning:IrTransInitialize: trXCoordPoints contains invalid coordinate array: defaulting trXAxisTyp ...

官网的解释及改错举例:
_NhlCreateSplineCoordApprox: Attempt to create spline approximation for X axis failed: consider adjusting trXTensionF value

Cause: If you are plotting regional data over a map via one of the gsn_csm_xxxx_map routines, then the error might be caused by the code trying to add a longitude cyclic point. Try setting res@gsnAddCyclic = False.

If you are not plotting regional data over a map, this message can come from trying to plot data that has highly irregularly-spaced X and/or Y axis coordinate values.

Sample code that causes the error: The script below shows the problem and also the fix, which is to subscript the data over a region that is not so irregularly-spaced.

;
; Generate some dummy data with dummy 1D lat/lon coordinate arrays,
; with highly irregular spacing for the latitudes.
;
  lat       = (/-88,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10,88/)
  lon       = ispan(-179,179,60)
  nlat      = dimsizes(lat)
  nlon      = dimsizes(lon)
  lat@units = "degrees_north"
  lon@units = "degrees_east"
  x         = generate_2d_array(10, 10, -19.69, 15.82, 0, (/nlat,nlon/))
  x!0       = "lat"
  x!1       = "lon"
  x&lat     = lat
  x&lon     = lon

  wks = gsn_open_wks("x11","spline_error")

  res              = True
  res@cnFillOn     = True
  res@tiMainString = "Contours are in wrong latitude location"  

  plot = gsn_csm_contour_map(wks,x,res)              ; Warning from "_NhlCreateSplineCoordApprox"

  res@tiMainString = "Contours are in correct latitude location"   

  plot = gsn_csm_contour_map(wks,x({-10:10},:),res)  ; Using {-10:10} subscripting for the
                                                                               ; latitudes removes the warning.



X/Y坐标轴数值“突变”就会出现这种错误,不过似乎对结果影响不大,当然前提是你得能够出图......
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表