爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 5932|回复: 4

[经验总结] 【求助】【已解决】各位达人,NCL语言自己能实现批处理制图么?

[复制链接]

新浪微博达人勋

发表于 2016-5-31 10:22:03 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 xuebiz 于 2016-6-7 16:40 编辑

各位达人,NCL语言自己能实现批处理制图么?

比如一个nc文件,里面有N个时间点M个高度,能不能一个NCL脚本实现画N*M个单点单高度的图,实现循环、条件什么的。
我看NCL官网介绍主要集中在数据的读写、处理、可视化上。



密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-5-31 10:38:58 | 显示全部楼层
肯定可以啊,do end do, if end if,随便用啊
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-5-31 12:01:16 | 显示全部楼层
pigzero527 发表于 2016-5-31 10:38
肯定可以啊,do end do, if end if,随便用啊

谢谢,找到一段do的例子
http://www.ncl.ucar.edu/Applications/Scripts/narr_5.ncl
-----------------------------------------------------------------------------------------
    do nv=0,nvar-1
       x        := sfile->$varName(nv)$
       x_regrid := ESMF_regrid_with_weights(x, wgtFilePath, False)
       printVarSummary(x_regrid)

       res@gsnMajorLonSpacing = 10
       res@tiMainString = "Pressure x Longitude at "+latXsec+"N"
       plot  = gsn_csm_pres_hgt(wks,x_regrid(:,{latXsec},{latLonStrt:latLonLast}),res) ; (b)
       delete(res@gsnMajorLonSpacing)

       res@gsnMajorLatSpacing = 10
       res@tiMainString = "Pressure x Latitude at "+lonXsec+"E"
       plot  = gsn_csm_pres_hgt(wks,x_regrid(:,{lonLatStrt:lonLatLast},{lonXsec}),res)                       ; (c)
       delete(res@gsnMajorLatSpacing)
      
       res@tmXBMode   = "Explicit"
       res@tmXBValues = XBValues
       res@tmXBLabels = XBLabels
       res@tiMainString = "Pressure x User_Specified_Locations"
       xsecUser = linint2_points_Wrap(x_regrid&lon ,x_regrid&lat,x_regrid, False \           
                                     ,lonXsecUser, latXsecUser, 2)
       printVarSummary(xsecUser)
       plot = gsn_csm_pres_hgt(wks,xsecUser,res)                                      ; (d)
       delete( [/ res@tmXBMode, res@tmXBValues, res@tmXBLabels /] )
    end do
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-5-31 14:56:22 | 显示全部楼层
有点儿清醒了,哈哈
官方教程language_man
--------------------------------
Section 2.6 Statements
Statements  are  the  fundamental  element  of  NCL.  Everything  NCL  does  happens  only
after  a  statement  is  entered.  Statements are  case  sensitive  and are  not  restricted  to
being a single line of source, and statements can be nested within statements. There are
17  different  kinds  of  statements:  assignment,  procedure  call,  function  definition,
procedure  definition,  block,  do,  if-then,  if-then-else,  break,  continue,  setvalues,
getvalues, return, record, new, stop, and quit.
Section 2.7 Loops
NCL provides two kinds of do loops: a while loop that repeats until its
scalar_logical_expression evaluates to False, and a traditional do loop that loops from a
start value through an end value incrementing or decrementing a loop variable either by
one or by a specified stride.
do n=start,end,optional_stride
[statement(s)]
end do    ; space is required
do while (scalar_logical_expression)
[statement(s)]
end do
With each kind of loop, the keywords break and continue can be used.
break:  jump to first statement after end do
continue:  proceed directly to the next iteration
Use of loops should be minimized in any interpreted language. Often, loops can be
replaced by array syntax or a built-in function. If multiple do loops are required and
execution speed is a concern, linking codes written in Fortran or C may be the best
approach. (Section 7.)
Section 2.8 Blocks and if statements
Blocks  provide  a  way  to  group  a  list  of  statements. Since  blocks  are  statements,  the
statements  within the begin and end do  not  get  executed  until  the end statement  is
parsed and the source is determined to be free of syntax errors. The use of begin and
end is optional for the main or driver script.
begin  ; optional but recommended
[statement(s)]
end  ; required if begin present
There  are  two  kinds  of if  statements:  the if-then  statement  and  the if-then-else
statement. These function like if statements in other popular programming languages.
if (scalar_logical_expression) then
[statement(s)]
end if
if (scalar_logical_expression) then
[statement(s)]
else
[statement(s)]
end if
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-5-31 15:30:36 | 显示全部楼层
do
end do

测试画一个文件中2个变量循环批量出图,很好用

next,测试批量文件出图,理论上没问题,祝自己好运。
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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