爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
123
返回列表 发新帖
楼主: 1649518749

[作图] ncl画整层水汽通量求助

[复制链接]

新浪微博达人勋

发表于 2018-7-31 11:53:24 | 显示全部楼层
最后出来的图不知道是不是这样的?
1.png
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2018-12-7 11:48:31 | 显示全部楼层
请问楼主mm1 = sqrt(data11^2+data12^2)这个是计算什么的
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2018-12-7 13:16:02 | 显示全部楼层
18021719881 发表于 2018-12-7 11:48
请问楼主mm1 = sqrt(data11^2+data12^2)这个是计算什么的

水汽通量(单层水汽通量单位g∙cm^(-1) hPa^(-1)  s^(-1),整层水汽通量积分单位:g∙cm^(-1) s^(-1)),那会刚接触ncl,脚本写的不简洁。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2018-12-10 15:48:46 | 显示全部楼层
1649518749 发表于 2018-12-7 13:16
水汽通量(单层水汽通量单位g∙cm^(-1) hPa^(-1)  s^(-1),整层水汽通量积分单位:g∙cm^(-1)  ...

谢谢,我用的比湿算的q单位是g/kg u v 单位是m/s 海平面气是milibalr 算出来整层单位就是这样,画水汽通量的时候直接画vint_qu 和vint_qv两个量,就能画出箭头,mm1=sqrt(data11^2+data12^2,这个应该是画等值线t填色的吧,等同于箭头长度所代表的大小
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2019-2-7 19:47:57 | 显示全部楼层
楼主能否分享一下修改后的完整版本,供我们这样的小白学习一下啊
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2020-5-10 11:23:22 | 显示全部楼层
码一下我改的楼主的脚本,0:7层不是我们需要的1000:300,要单独从里面挑出来。
; http://bbs.06climate.com/forum.php?mod=viewthread&tid=28890
; http://bbs.06climate.com/forum.php?mod=viewthread&tid=35437
; 资料是FNl的grib2,调了一晚上都没成功,跪求大神帮忙,红色是报错
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
begin
;************************************************
; open file and read in variable
;***********************************************
;levels 1000 925 850 700 600 500 400 300  
; 层数    0   1   2   3   4   5   6   7      
;***********************************************
     nlat  = 181
     nlon  = 360
     nyear = 1   
     nlev  = 8     
      
grb_file = addfile("/home/sma/data/work/ping/fnl_20190620_00_00.grib2","r")
  q        = grb_file->SPFH_P0_2L108_GLL0(::-1,:)
  u        = grb_file->UGRD_P0_L100_GLL0(:,::-1,:)
  v        = grb_file->VGRD_P0_L100_GLL0(:,::-1,:)
slp       = grb_file->PRES_P0_L1_GLL0(::-1,:)
;printVarSummary(q)

  u8       = u({30000},:,:)
  u7       = u({40000},:,:)
  u6       = u({50000},:,:)
  u5       = u({60000},:,:)
  u4       = u({70000},:,:)
  u3       = u({85000},:,:)
  u2       = u({92500},:,:)
  u1       = u({100000},:,:)
  uu       = new((/nlev,nlat,nlon/),float)
  uu       = (/u1,u2,u3,u4,u5,u6,u7,u8/)

  v8       = v({30000},:,:)
  v7       = v({40000},:,:)
  v6       = v({50000},:,:)
  v5       = v({60000},:,:)
  v4       = v({70000},:,:)
  v3       = v({85000},:,:)
  v2       = v({92500},:,:)
  v1       = v({100000},:,:)
  vv       = new((/nlev,nlat,nlon/),float)
  vv       = (/v1,v2,v3,v4,v5,v6,v7,v8/)

    lev  =  (/1000,925,850,700,600,500,400,300/)
    lat  =  fspan(90,-90,181)
    lon  =  fspan(0,360,360)
        lon!0             = "lon"
        lon@units         = "degrees_east"
        lat!0             = "lat"
        lat@units         = "degrees_north"
        lev!0             = "lev"
        lev@units         = "hPa"
        
        uu!0         = "lev"
        uu!1         = "lat"
        uu!2         = "lon"
        uu&lon       = lon
        uu&lat       = lat
        uu&lev       = lev

        vv!0         = "lev"
        vv!1         = "lat"
        vv!2         = "lon"
        vv&lon       = lon
        vv&lat       = lat
        vv&lev       = lev
  ;printVarSummary(uu)       ;(uu(:,{38:43},{92:100}))  

    qu1 = new((/nlev,nlat,nlon/),float)
    qv1 = new((/nlev,nlat,nlon/),float)

     do iz=0,7
        qu1(iz,:,:) = uu(iz,:,:)*q(:,:)
        qv1(iz,:,:) = vv(iz,:,:)*q(:,:)
     end do

    copy_VarMeta(uu, qu1)
    copy_VarMeta(vv, qv1)

        qu1!0         = "lev"
        qu1!1         = "lat"
        qu1!2         = "lon"
        qu1&lon       = lon
        qu1&lat       = lat
        qu1&lev       = lev

        qv1!0         = "lev"
        qv1!1         = "lat"
        qv1!2         = "lon"
        qv1&lon       = lon
        qv1&lat       = lat
        qv1&lev       = lev

    ; print(qu1(:,{38:43},{92:100}))
    ; print(qv1(:,{38:43},{92:100}))
    ; exit
  
        ;qu1  = latFlip
        ;asciiwrite("qu1.txt",qu1(0:7,{38:43},{92:100}))  
        ;print(qu1(0:7,{38:43},{92:100}))
        ;exit
;**************************************************************************************
        qu11 = qu1(lat|:, lon|:, lev|:)
        delete(qu1)
        qv11 = qv1(lat|:, lon|:, lev|:)
        delete(qv1)
         p       = (/ 1000.,925.,850.,700.,600.,500.,400.,300. /)
         linlog = 2
         pbot   = 1000.                                             
         ptop   = 300.
                                                            
                                                                    ; 1为线性积分  2为对数积分
        data11 = (vibeta(p,qu11,linlog,slp,1000,300))/9.8           ; 返回的数值是2维的(lat,lon)
        data12 = (vibeta(p,qv11,linlog,slp,1000,300))/9.8

        qu  = new((/nlat,nlon/),float)
        qv  = new((/nlat,nlon/),float)
        mm  = new((/nlat,nlon/),float)
        mm1 = sqrt(data11^2+data12^2)
                     
        mm = mm1
        qu = data11
        qv = data12

        ; copy_VarMeta(q, mm)
        ; copy_VarMeta(uu(0,:,:), qu)
        ; copy_VarMeta(vv(0,:,:), qv)  
        mm!0 = "lat"
        mm!1 = "lon"
        mm&lat = lat
        mm&lon = lon
        lon!0 = "lon"
        lon@units = "degrees_east"
        lat!0 = "lat"
        lat@units = "degrees_north"        
        qu!0 = "lat"
        qu!1 = "lon"
        qu&lat = lat
        qu&lon = lon
        lon!0 = "lon"
        lon@units = "degrees_east"
        lat!0 = "lat"
        lat@units = "degrees_north"
        qv!0 = "lat"
        qv!1 = "lon"
        qv&lat = lat
        qv&lon = lon
        lon!0 = "lon"
        lon@units = "degrees_east"
        lat!0 = "lat"
        lat@untis = "degrees_north"  

     ; printVarSummary(qu)
     ; printVarSummary(qv)
     ; printVarSummary(mm)

     print(qu({38:43},{92}))
     print(qv({38},{92:100}))
     print(qu({38:43},{100}))
     print(qv({43},{92:100}))
  ; exit

wks =  gsn_open_wks("pdf","vapour_flux")
        gsn_define_colormap(wks,"BlAqGrYeOrReVi200")

;***************************************************************************        
        vcres                                         = True                    ; plot mods desired
        vcres@gsnAddCyclic                            = False
        vcres@gsnDraw                                 = False                   ; don't draw yet
        vcres@gsnFrame                                = False                   ; don't advance frame yet
     
        vcres@vcMinFracLengthF            = 0.33        ;设置了矢量对于参考矢量的长度的最小数量级(default=0)0.33  
        vcres@vcRefAnnoOrthogonalPosF     = -1.0
        vcres@vcRefAnnoArrowLineColor     = "black"
        vcres@vcRefMagnitudeF             = 20          ;20     风速矢量长度参考
        vcres@vcRefLengthF                = 0.045           ;0.045  0.02

        vcres@vcGlyphStyle                = "CurlyVector" ; turn on curly vectors

        vcres@vcLineArrowThicknessF       = 1.5
        ;vcres@vcRefAnnoOn                 = True
        vcres@vcRefAnnoArrowUseVecColor   = False           ; don't use vec color for ref
        vcres@vcLineArrowColor            = "black"           ; change vector color  
        vcres@vcVectorDrawOrder           = "PostDraw"
        vcres@vcRefAnnoString1          = "20"
        vcres@vcRefAnnoSide             = "Top"
        vcres@vcRefAnnoString2On        = False
        vcres@vcRefAnnoPerimOn          = False
        vcres@vcRefAnnoOrthogonalPosF   = -0.105
        vcres@vcRefAnnoParallelPosF     = 0.999

        vector = gsn_csm_vector(wks,qu,qv,vcres)  ; create plot
;***************************************************************************        
;
;***************************************************************************        
        res                                         = True                    ; plot mods desired
        res@gsnMaximize                             = False
        res@gsnAddCyclic                            = False
        res@gsnDraw                                 = False                   ; don't draw yet
        res@gsnFrame                                = False                   ; don't advance frame yet
        
        res@mpDataSetName              = "Earth..4"   ; This new database contains                                   
        res@mpDataBaseVersion          = "MediumRes"  ; Medium resolution database
        res@mpAreaMaskingOn            = True
        res@mpMaskAreaSpecifiers       = (/"China"/)
        res@mpOutlineSpecifiers        = (/"China","China:Provinces"/)
        res@mpLandFillColor            = "white"   
        res@mpOceanFillColor           = "white"
        res@mpFillBoundarySets         = "NoBoundaries"
        res@mpOutlineBoundarySets      = "NoBoundaries"
        res@mpNationalLineColor        = "black"
        res@mpProvincialLineColor      = "black"
        res@mpGeophysicalLineColor     = "black"
        res@mpGeophysicalLineThicknessF =  2.
        res@mpNationalLineThicknessF    =  2.
        res@mpOutlineOn                 = True         ; Turn on map outlines
        res@mpLimitMode                 = "LatLon"
        res@mpMinLonF                   =  75    ;92   
        res@mpMaxLonF                   =  135   ;100      
        res@mpMinLatF                   =  25    ;38
        res@mpMaxLatF                   =  50    ;43
        res@mpShapeMode                 = "FreeAspect"
        res@vpHeightF                   =  0.55   
        res@vpWidthF                    =  0.8
        res@pmTickMarkDisplayMode       = "Always"

        res@cnFillOn                                = True                    ; turn on color
        res@gsnSpreadColors                         = True                    ; use full colormap
        res@gsnSpreadColorStart                     = 0
        res@gsnSpreadColorEnd                       = 199
        res@cnLinesOn                               = False                   ; turn off contour lines
        res@cnLineLabelsOn                          = False                   ; tuen off line labels
        res@cnInfoLabelOn                           = False


        res@cnLevelSelectionMode           = "ExplicitLevels"
        ;res@cnLevels                       = (/20,24,28,32,36,40,44/)                 ;(/14,18,22,26,30,34,38,42,46,50,52/)

        res@gsnLeftString                                 =""
        res@gsnRightString                                =""
        res@tiMainString                                  =""

        res@lbLabelBarOn                                  = True
        res@lbLabelOffsetF                                = 0.06
        res@pmLabelBarWidthF                              = 0.1
        res@lbOrientation                                 = "Vertical"         ; vertical label bars
        res@lbAutoManage                                  = True
        res@lbLabelFontHeightF                            = 0.009              ; make labels smaller


        mm = smth9(mm,0.5,0.25,False)
        ;print(mm(128:133,92:100))
        ;mm = mm*100
        ;print(mm(128:133,92:100))
        contour = gsn_csm_contour_map(wks,mm,res)
        overlay(contour,vector)


        x=(/92,100,100,92,92/)
        y=(/43,43,38,38,43/)
        lnres   =    True
        lnres@gsLineColor="red"
        lnres@gsLineThicknessF= 4
        lnres@gsLineDashPattern= 0
        dum=gsn_add_polyline(wks,contour,x,y,lnres)

        draw(contour)        
        frame(wks)
end
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

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