Re: question about reading ascii : declaring a format?

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Wed Nov 30 2011 - 12:27:22 MST

Hi Erik,
In short no. Give it a shot. When it comes to reading ascii files I
usually go through a trial and error approach.. You will likely need to
tell asciiread you're reading in type double (and not float), and you'll
of course have to modify your nlat/nlon/ntime values. But really, to me
it's just trial and error.. Adam

On 11/30/2011 12:16 PM, Erik N wrote:
> Dear NCL, I have read the example pages, but I don't see an example of
> how a user tells ncl to read (not write) formatted data (i.e.
> 10f8.2...).
>
> Am I missing something? Is this even a necessary step does the NCL
> software figure it out?
>
> Below is an example snip of code I've used to successfully read .txt
> file with NCL and I already know that the data is in 10f.82 format. Do
> I need to declare this format before reading the data?
> -Erik
>
>
> ; **************************
> 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"
> ; **************************
> ; USER CHANGES BEGIN
> ; **************************
> ; RM3 Model
> dirI = "./" ; Input directry
> filI = "uv7_4x_ek_sep2-14-2006" ; Input file
> nrow = numAsciiRow("vort.b2")
> ncol = numAsciiCol("vort.b2")
> print("rows: "+nrow )
> print("columns: "+ncol )
> dirO = dirI
> filO = "test_rm3_dvdx"
> ntime = 56 ; 13 days, 4x daily BUT FOR 2 VARIABLES !!! (so
> 56 x 2 = 112)
> nlat = 111 ; latitude gridpoints
> nlon = 141 ; longitude gridpoints
> ; **************************
> ; END USER CHANGES
> ; **************************
> begin
>
> data = asciiread(filI, (/ntime,nlat,nlon/), "float") ; read the whole file
> printVarSummary(data)
> .
> .
> .
> <snip>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
______________________________________________________________
Adam Phillips                                asphilli@ucar.edu
NCAR/Climate and Global Dynamics Division       (303) 497-1726
P.O. Box 3000				
Boulder, CO 80307-3000    http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Nov 30 12:27:30 2011

This archive was generated by hypermail 2.1.8 : Wed Nov 30 2011 - 19:52:47 MST