# Random Points (PDR3)

We draw random points with a density of 100 points per arcmin2 for each patch and each filter. These random points can be used for several purposes;  (1) a random sample for clustering analysis, (2) to identify problematic areas, (3) to compute the survey area and the fraction of masked areas, etc.  Available information carried by the random points, per filter and per patch, is:

• whether a point is in a non-overlapping region of a patch/tract (patch_inner and tract_inner)
• pixel flags such as pixelflags_interpolatedcenter
• number of visits contributed to the point (inputcount_value)
• local PSF size: recorded as the second moment of the PSF model (see FAQ: how to measure the size of an object, to convert into FWHM)
• sky_mean: mean of sky value in 2″ diameter apertures for the sky objects (merge.footprint.sky == True objects, see FAQ). Constant within patch.
• sky_std: standard deviation of sky value in 2″ diameter apertures for the sky objects (merge.footprint.sky == True objects). Constant within patch. To compute the limiting magnitude at 5 sigma, do: lim_mag = -2.5 log10(5*sky_std) + 27.0
• adjust_density parameter: a random number between 0 and 1 to adjust the sky density. A cut like adjust_density < 0.5 will decrease the sky density by a factor of two
• pix_variance : pixel variance at random point position (note that the variance given for the object is the sum of the pixel variance over the source footprint).

## Examples

### Query the database

-- This is a simple sql query to get all columns from the random database in one single patch -- Use tractSearch(object_id, tract) function or skymap_id (= tract * 10000 + patch_x * 100 + patch_y) -- For the randoms, the "NOT i_pixelflags_edge" is mandatory -- near the border of the survey. SELECT * FROM pdr3_wide.random AS ran WHERE tractsearch(object_id, 8523) AND patch_s = '3,5' -- AND skymap_id = 85230305 AND i_pixelflags_bright_objectcenter is not True AND i_pixelflags_edge is not True LIMIT 10;

### Compute the survey area

The random point density is 100 per arcmin2. Thus the area in deg2 is simply the number of random points given a selection:
SELECT COUNT(*) / 100.0 / 3600.0 FROM pdr3_dud.random WHERE i_inputcount_value > 10 AND isprimary = True;

### Adjust the random local density

The "adjust_density" is a random number in the interval [0:1]. For example, to divide the random point density by a factor of two (to get 50 /arcmin2), set: