NCL的樣本1:常見符號的用法

來源:互聯網
上載者:User

NCL的樣本1這個例子中示範了三個符號的使用:

。設定(維數)座標名稱

@設定資源屬性

&:設定(維數)座標值

在字串引用中,還會遇到美元$符號:

dimnames = (/"frtime","lat","lon"/)attnames = (/"_FillValue", "long_name"/)att0 = temperature@$attnames(0)$     ; access to attribute; Example of referencing a coordinate variable ; without knowing the dimension nameif(iscoord(dimnames(0)) coord0 = temperature&$temperature!0$end if
下面的指令碼會輸出以下圖形:


; =================================================;; LearnNCL1.ncl; =================================================;load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"; =================================================;begin;建立一個 3X4 的數組t,3行2列. 下面的\表示換行t=(/\(/1.,2.,3.,4./),\(/5.,6.,7.,8./),\(/9.,10.,11.,12./)\/);列印資訊print(t);設定維數座標名稱使用 ! 符號t!0="lon"t!1="lat";列印資訊print(t!0)print(t!1);設定維數座標值使用 & 符號t&lon=(/-180,0,180/)t&lat=(/-90,-45,45,90/);列印資訊print(t&lon)print(t&lat);設定屬性使用 @ 符號t@long_name="temperature"t@units="K";列印維數座標值print(t@long_name)print(t@units)  xwks   = gsn_open_wks( "x11","ncltest") ; Open an X11 workstation.;------------------------------------------------------------------  resources                 = True      ; set some resources.  resources@cnFillOn          = True    ; Turn on contour line fill.    resources@tiMainString    = t@long_name  resources@tiXAxisString    = t!0  resources@tiYAxisString    = t!1  resources@sfXArray         = t&lon   ;用這個做橫座標刻度值  resources@sfYArray         = t&lat   ;用這個做縱座標刻度值    contourmap = gsn_contour_map(xwks,t(lat|:,lon|:),resources);------------------------------------------------------------------  delete(resources)  resources                 = True      ; set some resources.  resources@cnFillOn          = True    ; Turn on contour line fill.    resources@tiMainString    = t@long_name  resources@tiXAxisString    = t!0  resources@tiYAxisString    = t!1  resources@sfXArray         = t&lon   ;用這個做橫座標刻度值  resources@sfYArray         = t&lat   ;用這個做縱座標刻度值  contour = gsn_contour(xwks,t(lat|:,lon|:),resources) ;------------------------------------------------------------------end

列印輸出的資訊如下:

 Copyright (C) 1995-2013 - All Rights Reserved University Corporation for Atmospheric Research NCAR Command Language Version 6.1.2 The use of this software is governed by a License Agreement. See http://www.ncl.ucar.edu/ for more details.Variable: tType: floatTotal Size: 48 bytes            12 valuesNumber of Dimensions: 2Dimensions and sizes:[3] x [4]Coordinates: (0,0) 1(0,1) 2(0,2) 3(0,3) 4(1,0) 5(1,1) 6(1,2) 7(1,3) 8(2,0) 9(2,1)10(2,2)11(2,3)12(0)lon(0)latVariable: lon (coordinate)Type: integerTotal Size: 12 bytes            3 valuesNumber of Dimensions: 1Dimensions and sizes:[lon | 3]Coordinates: (0)-180(1)0(2)180Variable: lat (coordinate)Type: integerTotal Size: 16 bytes            4 valuesNumber of Dimensions: 1Dimensions and sizes:[lat | 4]Coordinates: (0)-90(1)-45(2)45(3)90(0)temperature(0)K


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.