[Thread Prev][Thread Next][Index]

Re: [ferret_users] Plotting ascii data and/or converting ascii to netcdf



It looks like your delta-x and delta-y in the definitions of the axes are off. You're saying that the grid intervals are 1 degree in each direction, but the axis endpoints (and the first 10 rows pasted in the message) don't look like that should be the case.

If that's the problem, then you are reading only a subset of the data file.

Try SHO GRID salgrid. Does it have the right number of values to encompass your data?

Is the underlying grid regular? You have defined a regular grid. (In which case you would not need to read the lats and lons at all).

If the grid is regular, then just use the correct definition for your axes. If it is not, then read the coordinates in the first step, define the axes from it using DEFINE AXIS/FROM_DATA and use those to define your grid. Then read the file again using the newly-defined grid, but this time you only need to read the u and v values.

Anotehr option would be to plot the triplets directly (see "3-axis SHADE" in the documentation). But that will be an interpolation (which is what Matlab is probably doing). I would say you are better off using the exact coordinates as above, unless the data points are truly irregularly spaced.

Billy

On Sep 14, 2011, at 3:42 PM, david hitzl wrote:

Hello,

I am trying to use ferret to plot an ascii data file. My data file is comprised of four columns which include latitude, longitude, and u and v components respectively. The first ten rows (out of a total of 56745) looks like this (I have attached the full file "filename.txt" above):

   15.66400      -166.1470      -7.553388      -1.256299
   15.66800      -166.0910      -7.556085      -1.258102
   15.67200      -166.0360      -7.558600      -1.260010
   15.67500      -165.9800      -7.560195      -1.262088
   15.67900      -165.9250      -7.560886      -1.265384
   15.68200      -165.8690      -7.560416      -1.268836
   15.68600      -165.8140      -7.559073      -1.272530
   15.69000      -165.7580      -7.556891      -1.277025
   15.69300      -165.7030      -7.554591      -1.281174
   15.69700      -165.6470      -7.553061      -1.285058

Here is the script I have been using to read it into ferret and plot:

cancel mode logo
set view full
DEFINE AXIS/X=166.946W:149.529W:1/UNIT=degrees salx
DEFINE AXIS/Y=15.664N:26.456N:1/UNIT=degrees saly
DEFINE GRID/X=salx/Y=saly salgrid
FILE/GRID=salgrid/VAR="y,x,u,v"/COL=4 filename.txt
let wind1 = u^2
let wind2 = v^2
let wind3 = (wind1+wind2)^0.5
let wind_speed=wind3*1.94
fill/LEV=(1.8,21,.5)/AXES=1,1,1,1/nolab/NOKEY/PALETTE=rainbow wind_speed
vector/over u,v
 DEFINE AXIS/Z=1:11680:1 vec_len
    DEFINE GRID/Z=vec_len vec_grid
    FILE/VAR=lon,lat/G=vec_grid hawaii.dat
    PLOT/VS/LINE/OVER/COLOR=BLACK/NOLABEL 360+lon,lat
GO ccbar  0.93,0.96 0.22,0.8, 3,21,.5, v,rainbow

I have attached the image the script produces above (islands_wind.gif). This image is incorrect. With matlab, using the TriScatteredInterp function, I was able to produce a correct image of the data (islands_wind_correct.jpg) but unfortunately it is important that I get this done in ferret. Any suggestions would be greatly appreciated.

thanks
David


<filename.txt><islands_wind.gif><islands_wind_correct.jpg>



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

Privacy Policy | Disclaimer | Accessibility Statement