[ncl-talk] Write table problem

snow snowflake_822 at yahoo.com
Thu Jun 16 19:17:52 MDT 2016


Dear Wei,
Thank you for your reply. My problem is that I want to write a table with one column and four rows. your suggested script writes the table with four columns and one row. The typical scripts should be written in this way:
write_table("list.txt", "a", alist, "%5.5f")
but it dose not work!




 

    On Thursday, June 16, 2016 10:33 PM, Wei Huang <whuang at univ-wea.com> wrote:
 

 #yiv6024404186 #yiv6024404186 -- _filtered #yiv6024404186 {font-family:SimSun;panose-1:2 1 6 0 3 1 1 1 1 1;} _filtered #yiv6024404186 {panose-1:2 4 5 3 5 4 6 3 2 4;} _filtered #yiv6024404186 {font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;} _filtered #yiv6024404186 {font-family:Tahoma;panose-1:2 11 6 4 3 5 4 4 2 4;} _filtered #yiv6024404186 {panose-1:3 1 1 1 1 1 1 1 1 1;} _filtered #yiv6024404186 {panose-1:2 1 6 0 3 1 1 1 1 1;}#yiv6024404186 #yiv6024404186 p.yiv6024404186MsoNormal, #yiv6024404186 li.yiv6024404186MsoNormal, #yiv6024404186 div.yiv6024404186MsoNormal {margin:0in;margin-bottom:.0001pt;font-size:12.0pt;}#yiv6024404186 a:link, #yiv6024404186 span.yiv6024404186MsoHyperlink {color:blue;text-decoration:underline;}#yiv6024404186 a:visited, #yiv6024404186 span.yiv6024404186MsoHyperlinkFollowed {color:purple;text-decoration:underline;}#yiv6024404186 span.yiv6024404186EmailStyle17 {color:#1F497D;}#yiv6024404186 .yiv6024404186MsoChpDefault {font-size:10.0pt;} _filtered #yiv6024404186 {margin:1.0in 1.0in 1.0in 1.0in;}#yiv6024404186 div.yiv6024404186WordSection1 {}#yiv6024404186 Snow,    Please check the docs at:https://www.ncl.ucar.edu/Document/Functions/Built-in/write_table.shtml    You need to change line:    write_table("list.txt", "a", alist, "%5.5f")    To    write_table("list.txt", "a", alist, "%10.5f%10.5f%10.5f%10.5f")    You may add a separator, such as “,” as:    write_table("list.txt", "a", alist, "%10.5f,%10.5f,%10.5f,%10.5f")    Try this script:         R5=(/189,193,191,192,192,193,192,188,198,196,192,187,197,194,190,187,197,196,195,195,196/)      R6=(/285,286,287,288,289,290,291,292,293,294,295,296,296,297,298,299,298,299,300,301,302/)      R7=(/180,174,172,181,179,173,184,175,185,174,184,173,183,193,182,191,179,189,178,188,176/)      R8=(/264,266,267,267,268,269,270,270,271,271,272,273,273,273,274,273,275,274,276,275,277/)         ca=tofloat(R5)      cb=tofloat(R6)      cc=tofloat(R7)      cd=tofloat(R8)        alist=[/ca,cb,cc,cd/] write_table("list.txt", "w", alist, "%10.5f,%10.5f,%10.5f,%10.5f")       Regards,       Wei Huang    From: ncl-talk-bounces at ucar.edu [mailto:ncl-talk-bounces at ucar.edu]On Behalf Of snow
Sent: Wednesday, June 15, 2016 8:05 PM
To: Ncl Talk
Subject: [ncl-talk] Write table problem       To whom it may concern,    My below ncl code has aproblem in writting the table with 4 data in one column. It only writes the first data and doesnt continue to write the other data.    does anyone know how to fix this problem?    I appreciate your time and consideration.     Best regards,    Snow Sho       this is the code: 
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
begin
;----------------------------------------------------------------------
; WRF data translate NetCDF file to  ascii file  
;----------------------------------------------------------------------        infile=("wrfout_d03_2007-07-24_00_00_00")
    fn=dimsizes(infile)     fin=addfile(infile,"r")
    R=fin->RAINNC(0,:,:)      a=(/189,193,191,192,192,193,192,188,198,196,192,187,197,194,190,187,197,196,195,195,196/)
     b=(/285,286,287,288,289,290,291,292,293,294,295,296,296,297,298,299,298,299,300,301,302/)      c=(/180,174,172,181,179,173,184,175,185,174,184,173,183,193,182,191,179,189,178,188,176/)
     d=(/264,266,267,267,268,269,270,270,271,271,272,273,273,273,274,273,275,274,276,275,277/)
     e=(/202,205,206,206,198,197,206,205,204,202,200,200,200,200,210,209,205,202,212,208,204,203/)
     f=(/270,271,272,273,274,276,277,278,279,280,281,282,283,284,284,284,285,286,287,288,289,290/)
     g=(/208,208,209,210,211,210,207,205,215,212,213,215,216,207,209,210,211,214,215,209,211,215,214/)
     h=(/263,264,265,266,267,267,268,269,269,270,271,273,274,276,277,278,279,279,280,282,283,284,287/)         R1=new((/21/),"float")        
        R2=new((/21/),"float")
        R3=new((/22/),"float")
        R4=new((/23/),"float")            do k=0,20
        R1(k)=R(a(k),b(k))
        end do
     ;  print(R1)
        do k=0,20
        R2(k)=R(c(k),d(k))
        end do
        do k=0,21
        R3(k)=R(e(k),f(k))
        end do
        do k=0,22
        R4(k)=R(g(k),h(k))
        end do         R5=avg(R1(:))
        R6=avg(R2(:))
        R7=avg(R3(:))
        R8=avg(R4(:))            ca=new((/1/),"float")
        ca=(/R5/)
        cb=new((/1/),"float")
        cb=(/R6/)
        cc=new((/1/),"float")
        cc=(/R7/)
        cd=new((/1/),"float")
        cd=(/R8/)    ;   alist=[/R5,R6,R7,R8/]
   alist=[/ca,cb,cc,cd/]
  write_table("list.txt", "a", alist, "%5.5f")   end 


  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160617/b1d1bd8d/attachment.html 


More information about the ncl-talk mailing list