On Fri, 6 Oct 2006, luciana mara freitas diniz wrote:
> Hi!
> I need a help...
> How to generate an archive ".nc" from an archive ascii?
>
> The ascii file is prc30.grd (it contains 62483 rows)
>
> -4400 8300 293 0 0 0 0 0 0 0 0 0 0 0 0
> -4350 8300 293 0 0 0 0 0 0 0 0 0 0 0 0
> -4300 8300 167 0 0 0 0 0 0 0 0 0 0 0 0
> -3950 8300 350 0 0 0 0 0 0 0 0 0 0 0 0
> -3900 8300 467 0 0 0 0 0 0 0 0 0 0 0 0
> -3850 8300 627 0 0 0 0 0 0 0 0 0 0 0 0
> -3800 8300 553 0 0 0 0 0 0 0 0 0 0 0 0
> ...
> ...
> -6950 -5550 350 71 66 75 70 69 57 55 62 57 50 57 61
> -6900 -5550 417 65 60 66 61 61 50 49 56 50 44 53 57
> -6850 -5550 257 61 57 61 58 57 47 46 53 47 40 49 54
> -6800 -5550 110 58 55 58 55 54 45 45 50 45 38 47 52
> -6750 -5550 87 56 53 58 53 52 43 43 47 43 37 45 50
> -6700 -5550 57 55 52 58 51 50 42 42 45 42 36 44 49
> -6750 -5600 123 62 59 64 59 57 48 48 53 49 41 50 55
>
> And their file read.txt is:
> -----------------------------------------------------------------------------------------------------------------
> prc30.grd (f6.2,f5.2,f4.0,12f4.0) : lon, lat, elev, monthly mean
> precipitation
>
> The file contain the same 62483 pixels in the same order (from NW in spirals
> around the globe to SE), with 30' latitude and longitude resolution. The
> coordinates are in degree-decimals and indicate the SW corner of each pixel.
> Topography is from ETOPO5 and indicates modal elevation.
>
> -----------------------------------------------------------------------------------------------------------------
>
> I wait a reply anxiously?
> Thanks a lot!
>
> Luciana F. Diniz
>
____________________________________________________________________
Hello,
I don't understand the details of the grid but the following is
a template.
Please see: http://www.ncl.ucar.edu/Applications/o-netcdf.shtml
http://www.ncl.ucar.edu/Applications/ascii_multicol.shtml
good luck
nRow = 62483
nCol = 15
data = asciiread ("prc30.grd", (/nRow,nCol/), "float") ; or integer
lon = data(:,0) ; ??? lon=data(:,0)*0.01
lat = data(:,1)
elv = data(:,2)
prc = data(:,3:)
; variable attributes
lon_at_long_name = "longitude"
lon_at_units = "????"
lat_at_long_name = "latitude"
lat_at_units = "????"
elv_at_long_name = "elevation"
elv_at_units = "????"
elv_at_source = "ETOPO5"
prc_at_long_name = "precipitation"
prc_at_unit = "????"
prc_at_source = "????"
dout = "./" ; output directory
pName = "PRC30.GRD.nc"
fName = dout + pName
system("'rm' -f "+fName) ; remove any pre-existing file
fnc = addfile (fName, "c")
fAtt = True ; create file attributes
fAtt_at_title = " ..."
fAtt_at_source = " ..."
fAtt_at_conventions = "None"
fAtt_at_creation_date = "systemfunc("date")
fileattdef( fout, fAtt ) ; copy file attributes to netCDF
fnc->lat = lat
fnc->lon = lon
fnc->elv = elv
fnc->prc = prc
copy
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Oct 06 2006 - 08:33:40 MDT
This archive was generated by hypermail 2.2.0 : Fri Oct 06 2006 - 09:01:27 MDT