Chris Beaumont's IDL Library

Download source code

single page | use frames     summary     class     fields     routine details     file attributes



image processing, catalog processing

densitymap, x, y, num, map, errmap, head [, crval=crval] [, naxis=naxis] [, cdelt=cdelt] [, galactic=galactic] [, cartesian=cartesian] [, verbose=verbose] [, robust=robust] [, debug=debug] [, out=out]

This procedure creates a smoothed map of the suface density of objects on the sky or in a plane.

The method is taken from section 3.5 of Gutermuth et al 2005ApJ...632..397G. For each pixel, the procedure finds the distance r to the (num)'th closest object. The surface density of that pixel is num / (pi r^2).


x in required

Vector of x-coordinate positions for a group of objects, in degrees

y in required

Corresponding y-coordinate positions for these objects, in degrees.

num in required

The number of objects to use when smoothing. See PROCEDURE section for details.

map in required

A named variable to hold the density map

errmap in required

A named variable to hold the error map. This is just map / sqrt(num - 1)

head in required

A named variable to hold the fits header describing the map


crval in optional

The output map center. The default is the middle of the input data. A two element array.

naxis in optional

The output map size, in pixels. The default is the smallest necessary to overlap all input data, given the values for cdelt and crval. A scalar or two element array.

cdelt in optional

The pixel size of the smoothed map, in degrees / pixel. Either a scalar or two element array. The default pixel size is roughly 1/2 the mean input point spacings.

galactic in optional

If set, then the input is assumed to be in galactic coordinates.

cartesian in optional

By default, the procedure assumes that the input coordinates are on the sky. Set the CARTESIAN keyword to treat the coordinates as on a flat plane.

verbose in optional

If set, this procedure will print information as it works. Set to a value 1-4 to control the amount of output produced.

robust in optional

If set, the distances between objects will be computed using rigorous spherical trigonometry. This will be MUCH slower, as this appoach is not vectorized well. The default behavior is to treat the coordinates as cartesian, which is adequate for small fields.

debug in optional

Keyword which runs both robust and non-robust methods, and reports for how many pixels the non-robust method gets the wrong result.

out in optional

A name used when writing out files. The map and error map will be written to the file out_map.fits and out_err.fits


x = randomn(seed, 500) y = randomn(seed, 500) num = 10 DENSITYMAP, x, y, num, map, errmap, head, /verbose, /cartesian tvscl, congrid(map, 500, 500)

Author information


Written by: Chris Beaumont, December 2008 May 11 2009: Added CARTESIAN keyword. cnb. June 15 2009: Updated things so that VERBIAGE handles text output. cnb. June 15 2009: Fixed some bugs related to the CARTESIAN keyword. cnb. June 15 2009: Enhancements to cdelt. Added crval and naxis keywords. cnb. Oct 8 2009: Fixed a bug which led to integer overflow when manipulating naxis1, naxis2 keywords. cnb

File attributes

Modifcation date: Fri Apr 6 11:30:05 2012
Lines: 239