Hi Vincent,
I'll work on getting examples showing the use of SAMPLEXY_CURV into the
documentation!
I see two things you need to change:
1) The order of arguments for SAMPLEXY_CURV has the data field first:
SAMPLEXY_CURV(seaice, lon,
lat, myxpts, myypts)
You can simplify things more as follows; no need to
write the data out to intermediate files
use bt_200009_f13_v02_n.nc
use lon.nc
use lat.nc
let seaice_curv = seaice[d=1]
let lon_curv = lon[d=2]
let lat_curv = lat[d=3]
! Look at the data on its curvilinear grid
shade seaice_curv, lon_curv, lat_curv
2) When you define the points for sampling,
they must have the same units as the coordinate variables and lie
inside the range of the coordinates. Looking at the map drawn by the
last command above, the longitudes are degrees EAST. So, when you
define the sampling points,
let np1 = 141
let np2 = 109
DEFINE
AXIS/X=-120:0/NPOINTS=`np1`/UNITS="degrees_east" xnew
DEFINE
AXIS/Y=65:90/NPOINTS=`np2`/UNITS="degrees_north" ynew
You might also want to redefine the
missing-value flag for seaice, so that the data is flagged as missing
over land. After opening the file,
set var/bad=1200 seaice[d=1]
Then the rest of what you've done is fine.
You can put the sampled data back onto the new lat-lon grid with RESHAPE
! Define the points at which
to sample
let np1 = 141
let np2 = 109
DEFINE
AXIS/X=-120:0/NPOINTS=`np1`/UNITS="degrees west" xnew
DEFINE
AXIS/Y=65:90/NPOINTS=`np2`/UNITS="degrees north" ynew
let lonrct= x[gx=xnew] + 0*y[gy=ynew]
let latrct= 0*x[gx=xnew] + y[gy=ynew]
let myxpts=xsequence(lonrct)
let myypts=xsequence(latrct)
! show the locations on the original map
plot/vs/over/symbol=dot myxpts,myypts
let seaice2 = samplexy_curv(seaice_curv,
lon_curv, lat_curv, myxpts,myypts)
! look at the result, using the same color
levels
set win/new
let/title="sampled with samplexy_curv" seaice_samplexy =
reshape(seaice2, lonrct)
shade/lev seaice_samplexy
save/clobber/file=seaice_sample.nc seaice_samplexy
VINCENT_LEFOUEST@xxxxxxxxxx wrote:
Hi Ansley,
The sea ice data are projected on a polar stereo grid so I guess I
should use samplexy_curv. I attached the sea ice data, lon and lat
files. What I wish is subsampling my sea ice data on a narrower
subregion delimited by lon/lat I define. I wrote the couple of lines
below but it does not work:
use bt_200009_f13_v02_n
use lon
use lat
list/CLOBBER/order=yz/NOHEAD/format=(4(1x,E12.5))/file=temporaire.ascii
lon[d=2],lat[d=3],seaice[d=1]
cancel data/all
DEFINE AXIS/X=1:100000:1 xlist
DEFINE GRID/X=xlist listgrid
SET DATA/EZ/grid=listgrid/VARIABLES="lon,lat,seaice" temporaire.ascii
let np1 = 141
let np2 = 109
DEFINE AXIS/X=0:120/NPOINTS=`np1`/UNITS="degrees west" xnew
DEFINE AXIS/Y=65:90/NPOINTS=`np2`/UNITS="degrees north" ynew
let lonrct= x[gx=xnew] + 0*y[gy=ynew]
let latrct= 0*x[gx=xnew] + y[gy=ynew]
let myxpts=xsequence(lonrct)
let myypts=xsequence(latrct)
let seaice2 = SAMPLEXY_CURV(lon, lat, seaice, myxpts, myypts)
shade seaice2
Thanks Ansley for any advice,
Cheers, Vincent
-----Original Message-----
From: Ansley Manke [mailto:Ansley.B.Manke@xxxxxxxx]
Sent: Thu 20/11/2008 21:37
To: LEFOUEST VINCENT
Cc: oar.pmel.ferret_users@xxxxxxxx
Subject: Re: [ferret_users] Subsampling
Hi Vincent,
There are several sampling functions in Ferret, one of which will help
you. Take a look at SAMPLEXY and SAMPLEXY_CURV. Or say
yes? show function samplexy*
to see them all. Which one you need depends on what the grid of the data
is like.
If you need a hand figuring out how to use one of these, then please
write back - Is the 2D field on a rectilinear grid? Or do the
longitudes and latitudes represent a curvilinear grid? If you open the
datasets, what does the output of SHOW DATA look like?
Ansley
VINCENT_LEFOUEST@xxxxxxxxxx wrote:
>
> Dear users,
>
> I got 3 files, one with a 2D field, an other with the respective
> longitudes and the last one with the respective latitudes. I would
> like to subsample my 2D field on a smaller geographical region.
What
> would be the best approach to use?
>
> Thanks for any tip,
>
> Cheers, Vincent
>
|