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

From: Saji Njarackalazhikam Hameed <saji_at_nyahnyahspammersnyahnyah>
Date: Thu, 18 May 2006 10:45:26 -1000

Lin,

I wonder if your precip data covers both land and ocean (likely it does
not : was there enough oceanic observations of rainfall before the
satellite era to create a monthly precip product over the ocean?).

I have used a gridded precipitation data before. That data was only for
land regions. Thus the grid was regular but not a complete global grid.
(this makes sense because you don't want to fill an ascii file with
undefined values)

This may be true for your case too. However you assume that the data
coverage is global - please check that. If it is not global, you
need a different strategy to read the data to the PRCP array.

Also I believe the original data is in integer format (You are using
"float" to describe the data). Regarding no of rows, a simple "wc File"
or "wc -l File" should give the number of rows.

Saji
...

* LEO_ARIES <Leo_Aries_at_tom.com> [2006-05-19 01:51:55 +0800]:

> Hi$B!$(BThank 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

> ??$B7o?M!'(B Yi Wang
> ??$BAw(B?$BK[^0(B? 2006-05-19 00:24:29
> $BZ_at_7o?M!'(B LEO_ARIES
> $B>6Aw!'(B
> $B<g(B??$B!'(B 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$B!$(Bbut fail to finish running$B!K(B
> ?
> ?
> 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

> ??$B7o?M!'(B Dennis Shea
> ??$BAw(B?$BK[^0(B? 2006-05-17?03:59:11
> $BZ_at_7o?M!'(B Leo_Aries_at_tom.com
> $B>6Aw!'(B
> $B<g(B??$B!'(B 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

-- 
Saji N. Hameed,
Assistant Researcher,			Tel:808 9569534
International Pacific Research Center,	email:saji_at_hawaii.edu
2525 Correa Rd, Honolulu, HI 96822	http://iprc.soest.hawaii.edu/~saji
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu May 18 2006 - 14:45:26 MDT

This archive was generated by hypermail 2.2.0 : Thu May 18 2006 - 15:56:17 MDT