[Thread Prev][Thread Next][Index]

Re: [ferret_users] plotting and interpolating data given on curvilinear grids

Hi Paula,

I gave it up to put the track data in daily files. I have a script ready that does this for me. It is based on curv_to_rect_map and works. However, I confine my data to a smaller region (south Atlantic). Otherwise it reveals as too slow. I moved to a fast machine that
serves as frontend of a supercomputer. Otherwise - as said - really slow.
I also had a short look into the code. Is far as I see the method does something like a nearest neighbour search for each grid point of the rectangular grid and searches over all grid points of the curvilinear grid. There are some pieces of code where I believe that the index order should be changed for speed up, but this is not in the central part of the code and should
not really matter.

Finally I was not convinced, that the interpolation was correct everywhere and did not find a way for a good and final check. So I gave up and wrote a little fortran code to read the swath data. The method used here is more basic - I do not interpolate but put the track data simply into boxes on a regular grid. However, the swath width of the ASCAT data is much smaller than that of QuikSCAT and the final product reveals a lot of jumps from overlapping tracks too distant in time. Playing around with the interpolation and averaging method does not really help. So a more sophisticated gridding method is definitely required.

Fortunately, such data are available now from IFREMER. Please have a look at


I think this is was you need!

Good luck,

PaulaOCN Nunes wrote:
Hi Martin;

I work with ASCAT files as well, and I use the command "scat2gridgauss_xy" to plot over all the passes in the end of a day. Not sure if I'm doing right, but comparing with the shading output it looks similar (also the "min" and "max" values), I attached an example of the shade picture for the "scat2gridgauss_xy" output ("shadeWIND_SPEEDscat2grid.gif") and for " shade WIND_SPEED, lon,lat" ("shadeWIND_SPEED.gif"). Your question about the shade command got me curious, and for sure, I tried to do the same and I still don't understand, if there isn't interpolation, why it plots in areas between the points of LON/LAT ("plotLONLAT.gif") . Sorry Ansley, would you explain better this "checkerboard" variable? I reproduced it but could not understand...besides, it uses the "shade" command as well (shade checkerboard, lon, lat), equal "shade WIND_SPEED, lon,lat". By the end, I had a problem when I tried to do the same as Martin, with the command "curv_to_rect_map", Ferret stops; don't show any error and remains in the in blank display. I first tried axis with 12.5 km ( ASCAT resolution) and after 1°, but ferrets locks anyway...does anyone have a clue way I'm not able to do it?

OBS: I use FERRET v6.401
         Linux(g77) 2.6.9-89.ELsmp - 12/09/09

Above these tests commands:

*set memo/size=1000
use ascat_20110316_011801_metopa_22850_eps_o_125_1019_ovw.l2.nc
shade WIND_SPEED,LON,LAT; go land_hires

plot/vs lon,lat ; go land_hires

define axis/x=1:267238:1 tripaxis
let tripaGRID=X[gx=tripaxis]

define axis/x=0:360:0.1126/UNIT=degrees xaxis
define axis/y=-90:90:0.1126/UNIT=degrees yaxis

let uASCAT=sin(WIND_DIR*(3.1416/180))*WIND_SPEED
let vASCAT=cos(WIND_DIR*(3.1416/180))*WIND_SPEED

let lon2=reshape(lon,tripaGRID)
let lat2=reshape(lat,tripaGRID)

let uASCATgrau=scat2gridgauss_xy(lon2,lat2,uASCAT,x[gx=xaxis],y[gy=yaxis],0.2252, 0.2252, 2, 0) let vASCATgrau=scat2gridgauss_xy(lon2,lat2,vASCAT,x[gx=xaxis],y[gy=yaxis],0.2252, 0.2252, 2, 0)
let mag=(uASCATgrau^2+vASCATgrau^2)^0.5

shade/level=(0,20,1) mag; go land_hires

plot/vs lon,lat
let checkerboard = 0*wind_speed+mod(i+j,2)
shade/pal=greyscale/lev=(0,2,1) checkerboard, lon, lat

let lonlatout=y[gy=yaxis]+x[gx=xaxis]
let lonin=lon;let latin=lat
let map=curv_to_rect_map(lonin,latin,lonlatout,1)
shade map

Paula Lamosa Nunes

Date: Fri, 18 Feb 2011 11:23:37 -0800
From: ansley.b.manke@xxxxxxxx
Subject: Re: [ferret_users] plotting and interpolating data given on curvilinear grids
To: martin.schmidt@xxxxxxxxxxxxxxxxx
CC: oar.pmel.ferret_users@xxxxxxxx

Hi Martin,
There is a newer interpolation method in the pipeline, but not yet available. The libcf library being developed by Unidata and a group of collaborators will give us faster tools for interpolating between grids. We are paying close attention to this development and will implement it in Ferret as soon as it's ready. When there's a beta version of the interpolation code, and other capabilities available, we will add it as an option for people to experiment with. Here's the link to the information about libcf:

With the existing tools in Ferret, if all your data has the same curvilienar grid and are interpolating to the same rectilinear grid, you can re-use the map function. This speeds up the entire process quite a lot, and it's the reason we have two functions; one to compute the map and the other to apply it.

The SHADE command only fills each grid box with the corresponding color. It's not doing any interpolation. The curvilinear version of the shade command can use curvlinear coordinate variables that define either the edges of the grid cells or their centers. Here it looks like the grid defines the centers - else their size would be one larger than the grid size of the data fields.

yes? use "ascat_20100111_005400_metopa_16755_eps_o_125_1018_ovw.l2.nc"
yes? sh dat
     currently SET data sets:
1> ./ascat_20100111_005400_metopa_16755_eps_o_125_1018_ovw.l2.nc (default) name title I J K L TIME time 1:82 1:3259 ... ... LAT latitude 1:82 1:3259 ... ... LON longitude 1:82 1:3259 ... ...
cross track wind vector cell nu 1:82 1:3259 ... ...
model wind speed at 10 m 1:82 1:3259 ... ...
model wind direction at 10 m 1:82 1:3259 ... ... ICE_PROB ice probability 1:82 1:3259 ... ... ICE_AGE ice age (a-parameter) 1:82 1:3259 ... ...
wind vector cell quality 1:82 1:3259 ... ...
wind speed at 10 m 1:82 1:3259 ... ... WIND_DIR wind direction at 10 m 1:82 1:3259 ... ...
backscatter distance 1:82 1:3259 ... ...

A nice way to visualize a grid is to define a "checkerboard" variable, which alternates 1 and zero over the grid, based on the variable we're looking at.

yes? let checkerboard = 0*wind_speed+mod(i+j,2)
yes? shade/hlim=50e:150e/vlim=-80:0/pal=greyscale/lev=(0,2,1) checkerboard, lon, lat

So I think what looks in your shade.gif image like data smeared across the middle of this swath is really just the way the shape of the cells changes. The question is why the regridded data has a gap in that area. There should be many points within the 1-degree radius that you've chosen, to use in the interpolation. I don't understand that, but will try to look into it.


On 2/18/2011 8:42 AM, Martin Schmidt wrote:

    Hi Ferreters,

    I am trying to use ASCAT data downloaded from


    The files are netcdf files in curvilinear form, lat, lon and data
    are defined on a common abstract (x,y) grid.
    It does not have a geophysical meaning.

    Ferret should be able to deal with such data. Indeed

    use ascat_20100111_005400_metopa_16755_eps_o_125_1018_ovw.l2.nc
    shade/d=1 WIND_SPEED, lon,lat; frame /file=shade.gif

    works and gives figure shade.gif.It does not look really bad.

    Now I want to put the data on a regular grid in geographic
    coordinates. The GFDL routine curv_to_rect_map
    should be fine.
    yes? define axis/x=0:360:1/modulo/units=degrees xax
    yes? def axis/y=-85:85:1/units=degrees yax
    yes? let lonlatout = y[gy=yax] + x[gx=xax]
    yes? let lonin = lon[d=1]
    yes? let latin = lat[d=1]
    yes? let map = curv_to_rect_map ( lonin,latin,lonlatout,1)
    yes? save/clobber/file=curv_map.nc  map
    (1 degree resolution)

    After some coffee:

    yes? cancel var/all
    yes? use curv_map.nc
    yes? let wo=curv_to_rect(wind_SPEED[d=1], map[d=2])
    yes? shade wo; frame /file=curv_to_rect.gif

    Both figures are in the attachment. The results have something to
    do with each other but they are also pretty different.

    So my question:
    I do not really believe in the figure shade.gif. The reason is,
    that I may plot (lon,lat) pairs into
    the figure (plot/vs/ov lon,lat. In shade.gif there remain broad
    bands of coloured areas, in curv_to_rect.gif most data are covered
    by the symbols.
    So I guess, that the shade command implies some inappropriate
    Does anyone have experience with plotting and processing such
    curviliear data?

    It is great to have the interpolation tool curv_to_rect. But is
    there a chance to optimize the code
    for a speed up of the curv_to_rect_map routine? I would like to
    process years of data on a finer grid and it is very slow with 1
    degree resolution.
    Unfortunately the weights are changing for every file.

    Is there another and faster way to do this with ferret?

    Martin Schmidt

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

Privacy Policy | Disclaimer | Accessibility Statement