请选择 进入手机版 | 继续访问电脑版
爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 4545|回复: 2

修改NCL模板中的例子,出错,请高手指点!

[复制链接]

新浪微博达人勋

发表于 2019-3-14 23:10:01 | 显示全部楼层 |阅读模式

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

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

x
想把一个nc格式数据转存到txt文本文件中,修改ncl网站write_asc_4.ncl,出错提醒:fatal:process_list: can only handle list less than 128 elements.
查不出原因。贴出来,请高手指点。
;----------------------------------------------------------------------
; write_asc_4.ncl
;
; Concepts illustrated:
;   - Generating dummy data
;   - Writing a formatted 3D array of data to an ASCII file using write_table
;   - Appending data to an existing ASCII file
;   - Formatting integers using "sprinti"
;----------------------------------------------------------------------
begin
;---Generate a dummy 3D array
  in = addfile("/home/xyr/ncl_data/LTNG_2011.nc","r")
  nx   = 37    ; # of blocks
  ny   = 118    ; # of rows
  nt   = 135     ; # of columns
  data = in->LNT
; Use this to create "nice" numbers for debug purposes. This makes it easier to
; see how the data file is being written.
;
;  data = reshape(conform_dims((/200,ny*nt/),ispan(1,ny*nt,1),1),(/nx,ny,nt/)) + \
;         conform_dims((/nx,ny,nt/),ispan(1,nx,1),0)/1000.

;---Remove file just in case
  filename = "file4.txt"
  system("rm -f " + filename)

;---Write a header to the file
;  header = "This ASCII file contains " + nx + " blocks of " + ny + " x " + nt + " arrays"
; write_table(filename, "w", [/header/], "%s")    ; Use "w" to create file

;---Create row format string. It will have "%7.3f" repeated nt times
;  fmt_str = "%s " + str_concat(conform_dims(nt,"%8.3f",-1))
  fmt_str = "%s" + str_concat(conform_dims(nt,"%8.3f",-1))

;
; Loop through each column of each block and write the
; column of data to a List object.  We can then use
; write_table to append a whole block of formatted data
; to an ASCII file.
;
  row_labels = sprinti("%3i",ispan(1,ny,1))

  dtmp = True   ; Variable to hold temporary attributes
  do i=0,nx-1

;---Write out the block number
    slist = [/"Block " + (i+1) + " of " + nx/]
    write_table(filename, "a", slist, "%s")   ; Use "a" to append to existing file

;---Create a new List object for this block of data
    dlist = NewList("lifo")

;---Loop in reverse order so items are written in correct order
    do j=nt-1,0,1
      ListPush(dlist,(/data(i,:,j)/))
    end do  

;---Push array of row headers onto list object
    str = unique_string("test")
    dtmp@$str$ = row_labels
    ListPush(dlist,dtmp@$str$)

;---Append this List of data to file.
    write_table(filename, "a", dlist, fmt_str)
  end do  
end

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

新浪微博达人勋

发表于 2019-3-15 08:53:32 | 显示全部楼层
can only handle list less than 128 elements.    楼主你的column是135,超了
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2019-3-15 17:48:36 | 显示全部楼层
我修改试试,谢谢!
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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