[Thread Prev][Thread Next][Index]

Re: [ferret_users] order=Y-X for ASCII file?



Hi Ryo,
/ORDER=  is supported only for reading netCDF files.  It uses NetCDF library calls to read in the data in a reversed or reordered order.

You could define the axes in the direction they appear in the file, that is, pretend that x is y and y is x.  Read the data. Write it to netCDF, then open THAT with /ORDER=

Now there's another issue.  DEFINE AXIS is always LO:HI:DELTA.  If LO is larger than HI, Ferret will switch things around:

yes? define axis/x=0:-90000:100/units=kilometers xax
yes? show axis xax
 name       axis              # pts   start                end
 XAX       X (KILOMETERS)     901 r   -90000               0
   Axis span (to cell edges) = 90100

yes? list/i=1:5 x[gx=xax]
             VARIABLE : X
                        axis XAX
             SUBSET   : 5 points (X (KILOMETERS))
 -90000   / 1: -90000.
 -89900   / 2: -89900.
 -89800   / 3: -89800.
 -89700   / 4: -89700.
 -89600   / 5: -89600.
That's not what you intended, is it. You want i=1 to be x=0, and i=2 refers to x=-100 and so forth  We do not have coordinate axes with decreasing coordinate values in Ferret. The ORDER=-X  or -Y is intended to handle Longitude and Latitude data only, data stored as south-to-north rather than north-to-south and so forth. When using /ORDER, the DATA will be flipped  or reversed (using netCDF library calls), but not the coordinate axes.

So, I think what I'd do is define a grid with the right number of points, but in the direction they appear in the file:
define axis/y=0:90000:100/units=kilometers ax1
define axis/x=-6000:-2000:10/units=kilometers ax2
define grid/x=ax2/y=ax1 mygrid
file/var="xpnt,ypnt,h"/grid=mygrid/skip=1 diffsol.dat
save/clobber/file=diffsol.nc xpnt,ypnt,h

cancel data/all
use/order=yx diffsol.nc

shade h
To handle the reversing of the x axis, once you've got the data into Ferret, you could use the XREVERSE function,
use/order=yx diffsol.nc
let hreverse = xreverse(h)
The output of the xreverse function is on an abstract x axis.  Now, on this axis, i=1 corresponds to your original data x=0, and i=2 corresponds to -100km, etc.   We've reversed the data, but I don't think there's a good way to do anything about the coordinates.  You could remove the automatic axis tic labels, and just put your own labels on the plot axis using the LABEL command.

Definitely check what I've done here by making plots and listing out parts of the data and coordinates. I'm just typing commands here, so there may be mistakes!

Anyone have more ideas on this?  Handling ascii data is pretty much always a customized solution because the data is organized in whatever non-standard way the file was created.

Ansley


On 8/15/2013 1:26 PM, Ryo Furue wrote:
Ferret users,

I have a strange ASCII data file representing a two-dimensional (x-y)
field, in which the Y axis varies fastest and the X axis is inverted:

  i = 1,       2,       3, . . .
  x = 0, -100 km, -200 km, . . .

that is, the datapoints are stored in the file from east to west.
So, I thought "ORDER=Y-X" is the answer, but it leads to

   **ERROR: command syntax: order=Y-X

See the attached script.  Is this not supported?

I'll next look at SAMPLEI .

Regards,
Ryo
----
define axis/x=0:-90000:100/units=kilometers xax
define axis/y=-6000:-2000:10/units=kilometers yax
define grid/x=xax/y=yax mygrid
file/var="xpnt,ypnt,h"/grid=mygrid/order=Y-X/skip=1 diffsol.dat


[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement