Re: Re: [ncl-talk] How to read a 3-d ascii grid data file ?

From: LEO_ARIES <Leo_Aries_at_nyahnyahspammersnyahnyah>
Date: Fri, 19 May 2006 01:51:55 +0800

Hi,Thank you for the advice. I also suggest it is associated the ascii written format .
And here below is one piece of my fortran program:

integer :: X(216,12),im,iy,il,ic,ilat,ilon,nrec
real :: PRCP(36,72,12,106)
real :: lat(36,72),lon(36,72)
...........
open(2,file='Grid_PRCP_1900-2005_Ascii.dat')
do iy=1,106
   do ilat=1,36;do ilon=1,72
   write(2,201)(1899+iy)*100+1,87.5-(ilat-1)*5.0,-177.5+(ilon-1)*5,(PRCP(ilat,ilon,im,iy),im=1,12)
   enddo;enddo
enddo
close(2)
201 format(i6,1x,f7.2,1x,f8.2,12f10.2) ! I change the format of "yyyymm" back to integer type now
 ................

And here below is my ncl code:

>filName = "Grid_PRCP_1900-2005_Ascii.dat"
print(filName) ; ncl can give a output
>nRow = numAsciiRow (filName)
print("nRow",+nRow) ; here ncl can't give a output. So I prefer it to be a problem of my ascii data format.
>nCol = 15

But I can't find error in my f90 code above.

Thanks


Lin



LEO_ARIES
2006-05-19



发件人: Yi Wang
发送时间: 2006-05-19 00:24:29
收件人: LEO_ARIES
抄送:
主题: Re: [ncl-talk] How to read a 3-d ascii grid data file ?

Hi:


?? ?I can see a few issues associated with your NCL code:


1) Please try to print anything before "data = asciiread" and after "data = asciiread". If the thing (e.g. "Test Before" and "Test After") can not show up after "data = asciiread". I guess that your ascii data file might have something wrong.


2) What is the format to write the ascii data? Do you have any description at beginning or end?


3) I cannot see any reason to write yyyymm into float. Asciiread can handle it even if it is integer.


3) Also, you can try with asciiread = (file,-1,"float"), which will read in your data in order of its appearance. Then, you just reorder it in your NCl script.


Yi


On May 18, 2006, at 11:07 AM, LEO_ARIES wrote:


Thanks for the? reply. I have set my data as the format below:
?
190001.0?? 87.50? -157.50?? -327.68?? -327.68?? -327.68?? -327.68?? -327.68?? -327.68?? -327.68?
190001.0?? 87.50? -152.50?? -327.68?? -327.68?? -327.68?? -327.68?? -327.68?? -327.68?? -327.68
........
the 1st column is yyyymm (float) and 2nd/3rd is lat/lon, the other right 12 colums is the?value of?Jan to Dec.
?
I use the code below to read it,But still can't get the right result.
(NCL use more than 95% of my xeon cpu,but fail to finish running)
?
?
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/shea_util.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
;*****************************************************
begin
filName = "Grid_PRCP_1900-2005_Ascii.dat"
nRow??? =? numAsciiRow (filName)
nCol??? =? 15
?
data??? = asciiread (filName, (/nRow,nCol/), "float")
printVarSummary(data)??????? ; It seem that ncl stop here because the printVarSummary(data)
???????????????????????????????????????? didn't give a output ?
?
yyyymm? = floattointeger(data(:,0)) ;? this convert float to integer
?
lats??? = data(0:2591,1)??????;?36*72=2592 grids?
lons??? = data(0:2591,2)
PRCP??? = data(:,3:)

PRCP!0??? =?'lat'???????????????
PRCP!1??? = 'lon'
PRCP!2????= 'time'
PRCP_at_lat?= lats
PRCP_at_lon?= lons
PRCP_at_time = ???????????????? ;I also want to know how to set time property of PRCP appropriately.
?
?
Thanks!
?
?
?
Lin
?



LEO_ARIES
2006-05-18



发件人: Dennis Shea
发送时间: 2006-05-17?03:59:11
收件人: Leo_Aries_at_tom.com
抄送:
主题: Re: [ncl-talk] How to read a 3-d ascii grid data file ?
?
>
>Thank ?you ?for ?your ?comment ?and ?help! ?I ?still ?have ?something ?need ?to ?know ?:
>
>
>[1] ? ?I ? ?would ? ?advise ? ?writing ? ?the ? ?ascii ? ?generated ? ?from ? ?fortran ? ?as:
>
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?yyyymm ? ? ? ?lat ? ?lon ? ? ? ?jan ? ? ? ?feb ? ?.... ? ?dec
> ? ? ? ? ? ? ?
> ? ? ? ? ? ? ?This ? ?would ? ?give ? ?you ? ?15 ? ?columns. ?
> ? ? ? ? ? ? ?
> ? ? ? ? ? ?the ?real ?format ?of ?yyyymm? ?
> ? ? ? ? ? ?Since ?all ?12 ?monthly ?value ?in ?a ?year ?are ?
> ? ? ? ? ? ?written ?in ?one ?line,how ?to ?set ?the ?value ?of ?yyyymm?
?
?
? ? ? ?load ?"$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
? ? ? ?
? ? ? ?filName ?= ?"..."
? ? ? ?nRow ? ? ? ?= ?numAsciiRow ?(filName)
? ? ? ?nCol ? ? ? ?= ?15
? ? ? ?
? ? ? ?data ? ? ? ?= ?asciiread ?(filName, ?(/nRow,nCol/), ?"float")
? ? ? ?
? ? ? ?yyyymm ? ?= ?floattointeger(data(:,0))
? ? ? ? ? ? ? ? ? ? ? ? ? ?^^^^^^^^^^^^^^^^^^^^^^^^ ? ? ?this ?convert ?float ?to ?integer
? ? ? ?lats ? ? ? ?= ?data(:,1)
? ? ? ?lons ? ? ? ?= ?data(:,2)
? ? ? ?prc ? ? ? ? ?= ?data(:,3:) ? ?
? ? ?
? ? ?
> ? ? ? ? ? ? ? ? ? ? ? ? ? ?
>[2] ? ?comment: ? ?commonly ? ?netCDF ? ?uses ? ?only ? ?one ? ?time ? ?dimension
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?eg: ? ? ? ? ? ?prc(lat,lon,time) ? ?or ? ?prc(time,lat,lon)
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?If ? ?time ? ?has ? ?units ? ?yyyymm ? ?you ? ?can ? ?readily
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?extract ? ?the ? ?yyyy ? ?and ? ?mm
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?yyyy ? ?= ? ?time/100
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?mm ? ? ? ?= ? ?time ? ?- ? ?yyyy*100 ? ? ? ? ? ?
> ? ? ? ? ? ? ?
>? ?I'm ?not ?sure ?about ?the ?exact ?format ?of ?
>yyyy ?and ?mm.For ?example ?,when ?refering ?to ?
>the ?Jan ?of ?1901 ?, ?yyyymm=190101?
?
yes
?
?
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk


Yi Wang PhD
Center for Climatic Research
University of Wisconsin-Madison
1225 West Dayton Street
Madison, WI 53706-1695
USA
Tel: (608) 263-0232
Fax: (608) 263-4190
wang29_at_wisc.edu
http://ccr.aos.wisc.edu/contacts/yiwang.html

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu May 18 2006 - 11:51:55 MDT

This archive was generated by hypermail 2.2.0 : Thu May 18 2006 - 15:57:32 MDT