NCL常用统计学函数怎么用

发布时间:2022-01-07 09:17:50 作者:iii
来源:亿速云 阅读:1487

这篇文章主要介绍“NCL常用统计学函数怎么用”,在日常操作中,相信很多人在NCL常用统计学函数怎么用问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”NCL常用统计学函数怎么用”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

NCL作为一门气象专业语言,自带了很多气象届常用的算法和命令, 比如计算相关系数、均方根误差等统计量,相关系数显著性检验,EOF,以及各种插值。这里将一些常用函数做了归纳:

1、相关系数
NCL中计算相关系数的函数有好几个,常用的为escorc系列和regCoef系列。

escorc(x,y)是计算两个数组最右侧一列的相关系数。如果想指定计算的列数,比如想计算x(lat,lon)和y(lat,lon,year)在lat这一列上的相关系数,就要用到escorc_n: escorc_n(x,y,0)。

相关系数的检验方法包括t检验、f检验和显著性检验,分别为ttest,ftest,rtest。

regCoef系列的命令比escorc强大很多,因为它除了返回相关系数rc,还捎带手把两个序列的标准差(rc@rstd)和t检验结果(rc@tval)都给算了。

2、均方根误差
函数名为dim_rmsd。它是计算两个变量在所有其他维度上最右侧维度的均方根误差。而对于想要计算指定维度的情况,则要用dim_rmsd_n。

3、EOF分解
计算EOF分解的函数为eofunc开头的系列函数,一般用eofunc_Wrap计算空间模态,用eofunc_ts_Wrap计算时间系数。

以下为针对变量x计算EOF分解并绘图的NCL子程序:

undef("draw_eof_plot")procedure draw_eof_plot(dir_plot,file_plot,type_plot,x,year,neof)begin;--EOF analysisoptEof = Trueeof    = eofunc_Wrap( x, neof, optEof)eof_ts = eofunc_ts_Wrap( x, eof, False)lat = x&latlon = x&lon;--Begin plotting section.wks  = gsn_open_wks(type_plot,dir_plot+file_plot)      ; Opens a ps file gsn_define_colormap(wks,"rainbow")   plot = new(neof,graphic)   res              = True                       ; plot mods desired;************************************************; original data;************************************************   res@gsnDraw                    = False        ; don't draw yet   res@gsnFrame                   = False        ; don't advance frame yet   res@gsnAddCyclic             = False;--map plot resources  res@mpFillOn                   = False        ; no grey continents  res@mpCenterLonF      = 180.  res@mpDataBaseVersion     = "MediumRes"    ; or "Ncarg4_1"  res@mpDataSetName="Earth..4"  res@mpOutlineSpecifiers=(/"China:states","Taiwan"/)  res@mpOutlineBoundarySets = "AllBoundaries"  res@mpMinLatF  = min(lat)            ; range to zoom in on  res@mpMaxLatF  = max(lat)  res@mpMinLonF  = min(lon)  res@mpMaxLonF  = max(lon)
;--contour resources  res@cnFillOn             = True              ; turn on contour fill  res@cnLineLabelsOn       = False              ; turn off contour  res@cnLinesOn            = False        ; add countor or not,True is default  res@gsnLeftString = " "  res@gsnRightString = " "
;--tickmark resources  res@tmXTOn            = False  res@tmYROn            = False  res@tmYLLabelFontHeightF =0.02  res@tmXBLabelFontHeightF =0.018  res@tmXTOn            = False  res@tmYROn            = False
;--labelbar resources  res@lbLabelBarOn         = False  res@lbLabelFontHeightF   = 0.02  res@lbOrientation       = "Vertical"          ; vertical label bar
 symMinMaxPlt(eof, 16, False, res); contributed.ncl; panel plot only resources  resP                     = True         ; modify the panel plot  resP@gsnMaximize         = True         ; large format  resP@gsnPanelLabelBar    = True         ; add common colorbar  resP@txString  = "EOF"do n=0,neof-1        res@gsnLeftString  = " EOF "+(n+1)        res@gsnRightString = sprintf("%5.1f", eof@pcvar(n)) +"%"        plot(n) = gsn_csm_contour_map(wks,eof(n,:,:),res)end do   gsn_panel(wks,plot,(/neof/1,2/),resP)     ; draw all 'neof' as one plot;*******************************************; time series (principal component) plot;*******************************************  eof_ts@long_name = "Amplitude"  rts           = True  rts@gsnDraw   = False       ; don't draw yet  rts@gsnFrame  = False       ; don't advance frame yet
; decide exactly where on the page to draw it.  rts@vpHeightF = 0.40        ; Changes the aspect ratio  rts@vpWidthF  = 0.85  rts@vpXF      = 0.10        ; change start locations  rts@vpYF      = 0.75        ; the plot  rts@gsnYRefLine           = 0.              ; reference line  rts@gsnAboveYRefLineColor = "red"           ; above ref line fill red  rts@gsnBelowYRefLineColor = "blue"          ; below ref line fill blue; panel plot only resources  rtsP                     = True             ; modify the panel plot  rtsP@gsnMaximize         = True             ; large format  rtsP@txString  = "EOF"  do n=0,neof-1        rts@gsnLeftString  = " EOF "+(n+1)        rts@gsnRightString = sprintf("%5.1f", eof@pcvar(n)) +"%"        plot(n) = gsn_csm_xy (wks,year,eof_ts(n,:),rts)  end do  gsn_panel(wks,plot,(/neof/1,2/),rtsP)        ; draw all 'neof' as one plotend

到此,关于“NCL常用统计学函数怎么用”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!

推荐阅读:
  1. dojo常用函数
  2. 统计学bootstrap能够解决什么问题

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

ncl

上一篇:Win8客户预览版任务栏图标变化过程是怎样的

下一篇:SCCM管理中的包和应用程序如何分析

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》