爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 4897|回复: 5

[作图] NCL有一个小问题不知道怎么回事

[复制链接]
发表于 2016-9-11 19:59:35 | 显示全部楼层 |阅读模式

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

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

x
我刚学NCL,然后看到个例2 有一句 asciiwrite(ascii_file,temp(7:3:2,0:4))  为什么是temp(7:3:2,0:4)呢,按照数组下标的规则不是应该为temp(7:3:-2,0:4)吗
密码修改失败请联系微信:mofangbao
发表于 2016-9-12 09:46:56 | 显示全部楼层
可能是个例写错了
密码修改失败请联系微信:mofangbao
发表于 2016-9-12 16:09:55 | 显示全部楼层
能把例子贴全么,或者给个链接
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2016-9-12 19:47:33 | 显示全部楼层
xuebiz 发表于 2016-9-12 16:09
能把例子贴全么,或者给个链接

http://www.ncl.ucar.edu/Document/Manuals/Getting_Started/Examples/gsun02n.shtml
94行~
密码修改失败请联系微信:mofangbao
发表于 2016-9-13 08:38:56 | 显示全部楼层
我没用过ascii文件的功能,所以具体不是很清楚。但是这些例子都有详细注解,而且运行过没有报错。
等候ascii达人解释下~~
-------------------------------------------------------------------------------------------------------------------------------------
这个网页下面有注释,可以仔细看下。部分原文如下:
Lines 92-94:

  ascii_file = "data.asc"
  system("/bin/rm -f " + ascii_file)
  asciiwrite(ascii_file,temp(7:3:2,0:4))


Write a subset of the temperature data to an ASCII file using asciiwrite. The first argument of asciiwrite is the file name to which the data will be written, and the second argument is the data to write. The syntax "7:3:2" selects indices 7 to 3 with a stride of 2, so only indices "7", "5", and "3" are selected for the first dimension (in that order).

The system call takes a string as an argument and executes a UNIX system command from NCL. In this case, it is being used to remove the file before writing to it. The "+" symbol, in addition to being used as an arithmetic operator, is also used in NCL to concatenate strings.

For more information on asciiwrite, system, and other NCL functions and procedures, see the list of built-in NCL functions and procedures.
----------------------------------------------------------------
这个例子我运行了下,没有错误。运行结果如下:
#ncl gsun02n.ncl

Copyright (C) 1995-2014 - All Rights Reserved
University Corporation for Atmospheric Research
NCAR Command Language Version 6.2.0
The use of this software is governed by a License Agreement.
See http://www.ncl.ucar.edu/ for more details.


Variable: temp (subsection)
Type: float
Total Size: 48 bytes
            12 values
Number of Dimensions: 2
Dimensions and sizes:   [lat | 4] x [lon | 3]
Coordinates:
            lat: [22.5..26.25]
            lon: [-122.5..-117.5]
Number Of Attributes: 6
  _FillValue :  -9999
  valid_range : (  0, 400 )
  units :       (C)
  long_name :   temperature
  frtime :      0
  level :       1000
(0,0)   -30.31982
(0,1)   -30.31982
(0,2)   -30.31982
(1,0)   -31.31982
(1,1)   -31.81982
(1,2)   -31.81982
(2,0)   -31.31982
(2,1)   -31.81982
(2,2)   -31.81982
(3,0)   -28.31982
(3,1)   -28.81982
(3,2)   -28.81982
(0)     lat
(0)     lon
(0)     temperature
(0)     (C)


Variable: lat (coordinate)
Type: float
Total Size: 132 bytes
            33 values
Number of Dimensions: 1
Dimensions and sizes:   [lat | 33]
Coordinates:
Number Of Attributes: 2
  long_name :   latitude
  units :       degrees_north
(0)     20
(1)     21.25
(2)     22.5
(3)     23.75
(4)     25
(5)     26.25
(6)     27.5
(7)     28.75
(8)     30
(9)     31.25
(10)    32.5
(11)    33.75
(12)    35
(13)    36.25
(14)    37.5
(15)    38.75
(16)    40
(17)    41.25
(18)    42.5
(19)    43.75
(20)    45
(21)    46.25
(22)    47.5
(23)    48.75
(24)    50
(25)    51.25
(26)    52.5
(27)    53.75
(28)    55
(29)    56.25
(30)    57.5
(31)    58.75
(32)    60


Variable: lon (coordinate)
Type: float
Total Size: 144 bytes
            36 values
Number of Dimensions: 1
Dimensions and sizes:   [lon | 36]
Coordinates:
Number Of Attributes: 2
  long_name :   longitude
  units :       degrees_east
(0)     -140
(1)     -137.5
(2)     -135
(3)     -132.5
(4)     -130
(5)     -127.5
(6)     -125
(7)     -122.5
(8)     -120
(9)     -117.5
(10)    -115
(11)    -112.5
(12)    -110
(13)    -107.5
(14)    -105
(15)    -102.5
(16)    -100
(17)    -97.5
(18)    -95
(19)    -92.5
(20)    -90
(21)    -87.5
(22)    -85
(23)    -82.5
(24)    -80
(25)    -77.5
(26)    -75
(27)    -72.5
(28)    -70
(29)    -67.5
(30)    -65
(31)    -62.5
(32)    -60
(33)    -57.5
(34)    -55
(35)    -52.5
密码修改失败请联系微信:mofangbao
发表于 2016-9-13 08:43:34 | 显示全部楼层
本帖最后由 xuebiz 于 2016-9-13 08:50 编辑

The syntax "7:3:2" selects indices 7 to 3 with a stride of 2, so only indices "7", "5", and "3" are selected for the first dimension (in that order).

我理解的是,7到3,幅度2,系统会根据给出的数值自动加2或者减2

------------------------------------------------------------------------------------------------------
我把例子中的2,改成-2,运行也不报错,运行结果跟之前一样一样的。。。
SO,2,-2 都可以的吧
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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