Is there a way to do this without for loops?

From: Louis Wicker (Louis.Wicker AT noaa.gov)
Date: Thu Oct 20 2005 - 21:45:09 MDT


All:

I am looking for some hints on how to solve the following problem
without using 2 for loops in NCL.

The problem is I am trying to interpolate 3D gridded data fld to a
radar conical surface. I simply want the xy grid to remain the same,
but
to interpolate to that 2D plane given by some elevation angle and
distance from the radar.

So I have a scalar 3D field like reflectivity

dbz(z,y,x)

which has xg, yg, and zg grid dimensions (each are 1D).

and I have a 2D field of heights created from knowing where each xy
grid pt is and computing the distance from the radar so that

zhgt(y,x) = distance_from_radar * tan(elevation_angle).

So at each x,y point, I need to search for the correct height point
near zhgt(y,x) and then do a simple linear interpolation.

The dumb way would be (forgive the bad syntax)

for j = 0,ny-1
  for i = 0,nx-1

    k = (search for vertical grid pt right below zhgt(j,i))

    uzinterp = coeff * dbz(k,j,i) + (1-coefff)*dbz(k+1,j,i)

end for
end for

But I will bet for a 200x200 (or larger grid) this will be slow!

I am pretty sure that I can easily create a 2D array of the vertical
index "k"

k_2d = ind(zg .le. zhgt) ????

but how can I select the 2D set of points in the dbz(z,y,x) that are
given by k_2d? is there some fancy notation, or do I have to convert
the
dbz array to 1D, select the points out in some rather nasty fashion,
and then convert back to 2D?

Any help would be appreciated, as I am trying to get a nice figure
done for the meso/radar conference next week..

Cheers!

Lou Wicker

_______________________________________________
ncl-talk mailing list
ncl-talk@ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk



This archive was generated by hypermail 2b29 : Wed Oct 26 2005 - 18:25:11 MDT