# Re: [ferret_users] Gridding Scattered Data:scat2grid functions

Hi Steve,
Regarding the last argument to the scat2gridgauss functions, we've changed the requirements of that argument, first requiring it as a necessary argument, and then after consulting further with the author of the underlying code, we made it unused. If you're using a version of Ferret prior to v5.81 you should set the last two arguments equal to each other, and for v5.81 and after you can set the last argument to anything.

This sounds like a problem, however, that might be better solved as an external function, using the code that you've written to put the data into bins and then average it. Either do this as a Ferret external function or run your Fortran code separately. This is going to be slow, going through that much data and deciding which grid cell each point is in. I don't think you need to go through the data multiple times though; you might organize it as follows:

Input variables for scattered points lon(npts), lat(npts), var(npts)

Define the output grid; here its 0.1 degrees, with variable SUM and COUNT which are initialized to 0.
If the data is in the range, say, 300 to 360 LON and 22 to 65 LAT, then your Fortran grid could be

SUM(3000:3600, 220:650)
COUNT(3000:3600, 220:650)

loop through scattered points n = 1:npts
iloc = INT(lon(n)*10 )
jloc = INT(lat(n)*10 )
SUM(iloc,jloc) = SUM(iloc,jloc) + var(n)
COUNT(iloc,jloc) = COUNT(iloc,jloc) + 1.
end loop

and then take the average SUM/COUNT for each i,j .

This puts the value at (302.14, 29.87) would go in the bin (3021,298). You'll need to be careful about how the INT works and whether you want the lon,lat values rounded off or truncated, but this is the idea.

Ansley

guimond@coaps.fsu.edu wrote:

Hello,
I have a large set of scattered satellite data that I want to put onto a regular lat-lon grid. My data looks like this:

dbz i=1:105000
lat i=1:105000
lon i=1:105000

I defined two axes of my destination grid like so:

def axis/x=122:134:0.10/units=deg glon
def axis/y=27:33:0.10/units=deg glat

and tried using the scat2gridgauss_xy function call like this:

let a = scat2gridgauss_xy(lon,lat,dbz,x[gx=glon],y[gy=glat],0.5,0.5,2.,2)

However, the graph that results does not look right. Does anyone know what I am doing wrong here? I made a fortran routine to smooth my satellite data to a 0.10deg grid and this looks right, but takes very long to cycle through the file so many times. Is there another FERRET routine that does the sort of thing I am looking for? I really just want to average all satellite points that fall within a 0.10x0.10 deg box to get a regular grid, but @AVE needs lat/lon grid on source data. One further note, the last argument to scat2gridgauss_** says it can be zero since it is not used. However, I get an error when I don't put something greater than zero.

Thanks for your help,

Steve

=======================================================
Stephen R. Guimond
Center for Ocean-Atmospheric Prediction Studies (COAPS)
Tallahassee, FL 32304
=======================================================

----------------------------------------------------------------

• References: