[Thread Prev][Thread Next][Index]

Re: Spatial 2points averaging



On Mon, 5 Jul 2004, Enrique Sanchez wrote:
> I have a field in a XY plane, of let's say 80x72 points. But I want to
> average it to a 40x36 domain, just averaging every 2 points in both
> dimensions. How can I do this?

Hi Enrique,
	Try defining a new grid of points centered in the 2x2 blocks of
the original grid.  Then regrid the old data to the new grid. Here is an
example for an original 8x6 region that we want to reduce to 4x3.
Good luck,
Mick
!-----------------------------------------------------------------
def axis/x=1:8:1 xax ; def axis/y=1:6:1 yax
def grid/x=xax/y=yax grd   ! the original grid ...
let v=int(10*randu(x[g=grd]+y[g=grd]))
list v
             VARIABLE : INT(10*RANDU(X[G=GRD]+Y[G=GRD]))
             SUBSET   : 8 by 6 points (X-Y)
             1      2      3      4      5      6      7      8
             1      2      3      4      5      6      7      8
 1   / 1:  9.000  5.000  0.000  1.000  7.000  1.000  8.000  4.000
 2   / 2:  4.000  8.000  3.000  9.000  9.000  5.000  7.000  9.000
 3   / 3:  4.000  0.000  0.000  6.000  7.000  7.000  8.000  1.000
 4   / 4:  1.000  3.000  8.000  4.000  1.000  2.000  7.000  1.000
 5   / 5:  5.000  6.000  1.000  7.000  5.000  8.000  9.000  3.000
 6   / 6:  6.000  3.000  5.000  0.000  8.000  5.000  1.000  7.000

def axis/x=1.5:7.5:2 xax2 ; def axis/y=1.5:5.5:2 yax2
def grid/x=xax2/y=yax2 grd2 ! the new grid, centered in each 2x2 group
let v2=v[g=grd2]            ! regrid data to the new grid
list v2
             VARIABLE : V[G=GRD2]
             SUBSET   : 4 by 3 points (X-Y)
             1.5    3.5    5.5    7.5
             1      2      3      4
 1.5 / 1:  6.500  3.250  5.500  7.000
 3.5 / 2:  2.000  4.500  4.250  4.250
 5.5 / 3:  5.000  3.250  6.500  5.000

! it seems to work ...
! (9+5+4+8)/4=6.5 ; (0+1+3+9)/4=3.25 ; (7+1+9+5)/4=5.5 ; (8+4+7+9)/4=7
! (4+0+1+3)/4=2.0 ; ...              ; ...             ; (8+1+7+1)/4=4.25
! (5+6+6+3)/4=5.0 ; ...              ; ...             ; (9+3+1+7)/4=5



[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement