[Thread Prev][Thread Next][Index]

Re: Using @Ave function for irr. data files

Hi Steve,
	This sounds like an issue that came up before.  For evenly
spaced data @ave is just like a simple average - add the values and
divide by the number of points.  But for unevenly spaced points, what
one wants is the weighted average, the weighting being the length of
axis to which each value applies.  In the absence of other information
ferret assigns the boundaries/edges of the boxes to the midpoints
between the data locations.  If one wants the simple average in the
case of unevenly spaced data the ratio v[l=@sum]/v[l=@ngd] will
supply it.
Heres a demo
	let v=tsequence({1,4,6,5}) ! evenly spaced
	list v[l=@ave]             ! gives 4.000 as expected
! now locate those same values on an uneven time axis
	let tax=tsequence({2,5,8,10})
	def axis/t/from_data/name=taxis tax
	def grid/t=taxis grd
	let vt=v[g=grd,gt=@asn]
	list vt[l=@ave]            ! gives 3.810 as expected since
	show grid/t grd            ! shows the box widths are
                                   ! 3,3,2.5,2 respectively.
	list vt[l=@sum]/vt[l=@ngd] ! still gives 4.000


|__Room 2070 Bldg#3 NOAA/PMEL__|

[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement