Re: readAsciiTable and automatic array dimension reduction

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue, 23 Jun 2009 21:54:50 -0600

Hi Bruce,

I'm afraid this is simply the way readAsciiTable was implemented.
It wants to return an array of "nrows x ncols", and doesn't do
anything special if ncols=1.

This is the kind of thing that we can't change to behave differently,
because we might break some old code that is expecting that
second dimension to be there no matter what.

You can modify readAsciiTable yourself and change the behavior.
I think you would just need to change the "nrow,ncol" in both
"asciiread" calls to simply "nrow".

The code is in $NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl

However, if you are indeed calling this function with:

data = readAsciiTable(filename,1,"float",0)

then this is the same as:

data = asciiread(filename,-1,"float")

except that "data" will be 1D.


On Tue, 23 Jun 2009 14:30:45 -0400
  "Lunde, Bruce N CIV NAVOCEANO, NP1" <> wrote:
> Hello,
> A minor observation:
> When using readAsciiTable(filename,1,"float",0)
> to read one column of data, it returns an array
> with dimensions numpt x 1.
> I was assuming that it would return an array of
> dimension numpt , based on NCL's automatic array
> dimension reduction feature.
> If you do
> data = readAsciiTable(filename,1,"float",0)
> and then
> newdata = data(:,0)
> the dimension of "newdata" is a 1D array of
> length numpt.
> I'm not sure what should be the preferred
> behaviour of readAsciiTable ?
> Thanks, Bruce

ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
Received on Tue Jun 23 2009 - 21:54:50 MDT

This archive was generated by hypermail 2.2.0 : Thu Jun 25 2009 - 06:30:15 MDT