Re: ascii read proble

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Thu, 20 Jul 2006 11:53:03 -0600 (MDT)

>I am trying to read three dimension (72x46x48) asc data from asc file.
>but got error like:
>
>fatal:Number of dimensions on right hand side do not match number of
>dimension in left hand side,
>but print out vary info is correct:
>Variable: data
>Type: float
>Total Size: 635904 bytes
> 158976 values
>Number of Dimensions: 3
>Dimensions and sizes: [72] x [46] x [48]
>Coordinates:
>Number Of Attributes: 1
> _FillValue : -999
>
>Following is part of code I used. Any help and suggestions are very
>appreciated!
>
>
>spe_nbr = 48
>lat_nbr = 46
>lon_nbr = 72
>data=new((/lon_nbr,lat_nbr,spe_nbr/),float)
>printVarSummary(data)
>data = asciiread("./annl_avg_emi95.dat", -1 ,"float")
>_______________________________________________

As noted in the documentation:

Description
[snip]
If -1 is given for the dimensions parameter, all values
in the file will be read into a one dimensional variable.
The dimension size of this variable will be equal to the
number of elements in the file.
[snip]

So the returned variable from asciiread was 1D and
you were putting into a variable [data] with a
different shape [3D].

You do *not* have to predeclare "data".
asciiread can shape the data

data = asciiread("./annl_avg_emi95.dat" \
                  , (/lon_nbr,lat_nbr,spe_nbr/),"float")
printMinMax(data, True)

I speculate that the dimension order should be:

data = asciiread("./annl_avg_emi95.dat" \
                  , (/spe_nbr,lat_nbr,lon_nbr/),"float")

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Jul 20 2006 - 11:53:03 MDT

This archive was generated by hypermail 2.2.0 : Thu Jul 20 2006 - 14:36:52 MDT