# Random Points

The random points are drawn with a density of 100 points per sq. arcmin, for each patch and each filter that have been processed by the pipeline. We draw the points and probe the mask information at each random position using a python module running within the HSC pipeline environment. The source code can be accessed on gitHub here: https://github.com/jcoupon/maskUtils.

The 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:

• patch and tract number
• patch and tract geometry (non-overlapping regions: patch_inner and tract_inner)
• pixel mask bits such as flags_pixel_interpolated_any
• local PSF size: recorded as the second moment matrix (see FAQ: how to measure the size of an object, to convert into FWHM)
• sky_mean: mean of sky value in 2″ diameter apertures (merge.footprint.sky == True objects). Constant within patch.
• sky_std: standard deviation of sky value in 2″ diameter apertures (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
• number of visits contributed to coadds (countinputs)
• 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).
• Milky Way extinction value (Schlegel map).

## Known issues

• centroid_sdss_flags and flags_badcentroid flags must be ignored because they are meaningless for randoms. If set to False, 85% of randoms are lost.
• The bright-star masks are too large for a few very bright stars and include about 10% of bright galaxies.  See also the Known Problems page.
• Some functions of the object database are not available in the randoms database.

## Examples

### Query the database

-- This is a simple sql query to get all columns from the random database -- in one single patch SELECT * FROM pdr1_wide.random AS ran WHERE tract=8523 AND patch_s='3,5' AND iflags_pixel_bright_object_center is not True AND iflags_pixel_edge is not True

### Do a joint object/random query

-- The object version. SELECT object_id, ra, dec, imag_kron, imag_kron_err FROM pdr1_wide.forced WHERE boxSearch(coord, 34.0, 36.0, -5.0, -4.5) AND NOT iflags_pixel_bright_object_center AND NOT iflags_pixel_edge AND icountinputs > 4 -- The random version. -- Note that the boxSearch function is not available in -- the random database. -- For the randoms, the "NOT iflags_pixel_edge" is mandatory -- near the border of the survey. SELECT object_id, ra, dec FROM pdr1_wide.random WHERE ra BETWEEN 34.0 AND 36.0 AND dec BETWEEN -5.0 AND -4.5 AND NOT iflags_pixel_bright_object_center AND NOT iflags_pixel_edge AND icountinputs > 4

### Add a cut on PSF size

Note that in the random database, the moments are in pixel, whereas in the object data, it's in arcsec (hence the 0.17 factor for the random). The factor 2sqrt(2) is to convert from sigma to FWHM, assuming the PSF is gaussian
random: shape_detradius(array[ishape_sdss_psf_11, ishape_sdss_psf_22, ishape_sdss_psf_12])*2.0*sqrt(2.0)*0.17 < 1.0 object: shape_detradius(array[ishape_sdss_psf_11, ishape_sdss_psf_22, ishape_sdss_psf_12])*2.0*sqrt(2.0) < 1.0

### 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 pdr1_udeep.random WHERE icountinputs > 10;

### 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: