Re: Convert ascii to a netCDF

From: Ian Harris <i.harris_at_nyahnyahspammersnyahnyah>
Date: Sun, 22 Oct 2006 22:58:09 +0100

On 20 Oct 2006, at 23:47, Dennis Shea wrote:

> Hello,
>
> The following is not enough information.
> Where is a format description of the file?

Dennis, this is a climatology file for the CRU_TS_2.10 precip dataset.

> Where did you get the file?
> Did they make available a C or fortran code
> that reads the ascii.

We do, here:

http://www.cru.uea.ac.uk/~timm/grid/software.html

(this is clearly linked on the site)

The software is not written by, or maintained by, CRU.

I'm currently working on CRU_TS_3.0, which will be available in NetCDF
format. No firm date yet though.

Harry

> What does
> Grid-ref= 1, 148
> refer to? Are 1, 148 subscripts for the (720,360) grid?
> If subscripts, I assume they are fortran type indexing.
>
> Just taking a look at the info below,
> I took a guess at how you could make a netCDF file.
> Obviously, it has not been tested.
>
> Good luck
>
>
>
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Hi!
> How can I convert an archive ascii to netCDF.
>
> clim.6190.lan.pre
> -----------------------------------------------------------------------
> -----
> ---------------------------------
> Tyndall Centre grim file created on 12.01.2004 at 11:44 by Dr. Tim
> Mitchell
> .pre = precipitation (mm)
> 0.5deg lan clim:1961-90 MarkNew
> [Long=-180.00, 180.00] [Lati= -90.00, 90.00] [Grid X,Y= 720, 360]
> [Boxes= 67420] [Years=1975-1975] [Multi= 0.1000] [Missing=-999]
> Grid-ref= 1, 148
> 3020 2820 3040 2880 1740 1360 980 990 1410 1770 2580 2630
> ... (12 values with number "1")
> Grid-ref= 2, 313
> 450 270 260 200 190 260 430 510 460 390 510 390
> ...(12 values with number "2")
> ...
> Grid-ref= 720, 323
> 170 80 80 90 110 170 300 340 260 180 210 90
> -----------------------------------------------------------------------
> -----
> -----------------------
>
> I have doubts if has "teams" variavel and if it is used as attribute of
> "precipitacao" like lat and lon.
> I wait the reply!
> Thanks!
>
> Luciana F.
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> begin
> ntim = 12
> nlat = 360
> mlon = 720
> lat = latGlobeFo (nlat, "lat", "latitude", "degrees_north")
> lon = lonGlobeFo (mlon, "lon", "longitude", "degrees_east")
> lon = (/ lon -180 /)
> lon&lon = lon
>
> prc = new ( (/ntim,nlat,mlon/), "float", -999.)
> prc_at_long_name = "precipitation"
> prc_at_units = "mm"
> prc!0 = "time"
> prc!1 = "lat"
> prc!2 = "lon"
> prc&lat = lat
> prc&lon = lon
>
> x = asciiread("clim.6190.lan.pre", -1, "float")
> ;print(x)
> nx = dimsizes(x)
>
> year = floattoint( x(14) )
> time = year*100 + ispan(1,12,1)
> time!0 = "time"
> time_at_long_name = "time"
> time_at_units = "yyyymm"
> prc&time = time
>
> ngrup = 14 ; 14 = two subscripts + 12 values
> nStrt = 18
> nLast = nStrt+ngrup-1
> npts = (nLast-nStrt+1)/ngrup
> print(npts)
>
> do n=0,npts
> jlat = floattoint( x(nStrt ) ) - 1
> ilon = floattoint( x(nStrt+1) ) - 1
> prc(:,jlat,ilon) = (/ x(nStrt+2:nStrt:14) /)
> nStrt = nStrt + ngrup
> nLast = nLast + ngrup
> end do
>
> printVarSummary( prc )
> printMinMax( prc, True )
>
> fnc = "prc."+year+".nc"
> system("'rm' -f "+fnc) ; remove any pre-existing file
> ncdf= addfile( fnc ,"c") ; open output netCDF file
>
> ; make time and UNLIMITED dimension
> filedimdef(ncdf,"time",-1,True)
> ncdf->PRC = prc
>
> end
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
Ian "Harry" Harris
Climatic Research Unit
School of Environmental Sceinces
University of East Anglia
Norwich, UK NR4 7TJ

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sun Oct 22 2006 - 15:58:09 MDT

This archive was generated by hypermail 2.2.0 : Mon Oct 23 2006 - 08:51:16 MDT