Home > hfrc > matlab > utility > density.m

# density

## PURPOSE DENSITY - Calculates the spatial density of grid points around a

## SYNOPSIS function dens = density( tg, gd, r, xy, type )

## DESCRIPTION ``` DENSITY - Calculates the spatial density of grid points around a
certain set of points for each timestep.

Usage: dens = density( totalGrid, gooddata, radius, coord_pts )

totalGrid is a 2-column set of coordinate points where data is located.

gooddata is a matrix where each row corresponds to a grid point (point
in totalGrid) and each column is a timestep.  Grid points and time steps for
which data is present should be represented by a 1, bad data by a zero.
If gooddata=[] (i.e. is empty), then a one column matrix of ones with the
same number of elements as grid points in totalGrid will be used.

radius is a distance in Km around each grid point to look for other data
points.  It can be a scalar, in which case a single distance is used, or
it can be a vector with as many elements as points in coord_pts.

coord_pts is a two column matrix of the coordinates of the points at which
the density is to be determined.  It should be in the same units as
totalGrid (i.e. either Km or lon,lat).  If this argument is absent, then
totalGrid is used.

type is a string indicating the units of totalGrid and coord_pts.  It
can be either 'lon,lat' or 'km' (must be exact). Defaults to 'lon,lat'.

NOTE that this function requires the lonlat2km function from Mike Cook's
HFradarmap toolbox if lon,lat coordinates are used.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\$Id: density.m,v 1.2 2006-08-01 18:16:09 dmk Exp \$

Copyright (C) 2006 David M. Kaplan
Licence: GPL

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%```

## CROSS-REFERENCE INFORMATION This function calls:
• end END - basic end method for HFRC objects.
• isempty
• length LENGTH - returns number of times in HFRC object.
• lonlat2km LONLAT2KM - Converts dimensions of totalGrid to kms from lon,lat
• mean MEAN - mean of a field in an HFRC object
• size SIZE - returns [ (num times), (num gridpts) ].
This function is called by:

Generated on Mon 18-Dec-2006 07:26:46 by m2html © 2003