SDSS Bright Stars Selection

Objective

 * Select bright and saturated stars within the Stripe82 region

Steps

 * 1) Select all the frames in Stripe82

SQL Tricks
""
 * Find information of Field and Run: (such as PSFwidth and Stripe number)

""
 * Group and Order by type

""
 * Using photometric flags (e.g, Saturated)

""
 * Select random sample (Using HTM index as random number generator)

Basics
The following Views can be used to select bright stars and saturated stars:
 * 1) Star
 * 2) * The objects classified as stars from PhotoPrimary
 * 3) ** The Star view essentially contains the photometric parameters (no redshifts or spectroscopic parameters) for all primary point-like objects, including quasars.
 * 4) PhotoObj or PhotoObjAll
 * 5) * All primary and secondary objects in the PhotoObjAll table, which contains all the attributes of each photometric (image) object.
 * 6) thingIndex
 * 7) * Full list of all 'things': unique objects in the SDSS imaging
 * 8) ** Each row in this table corresponds to a single 'thing' observed by the SDSS imaging survey. By joining with the 'detectionIndex' table one can retrieve all of the observations of a particular thing. NOTE: The RA and Dec in this table refer to the DR8 coordinates, which have errors in the region north of 41 deg in Dec, since those were used for the resolving of the survey. These errors should have a very small effect on the decision about which objects are matched to each other.

Useful Photometric Functions

 * fCalibStatus: Returns the CalibStatus flag value corresponding to a name
 * fCoordsFromEq: Returns table of stripe, lambda, eta, mu, nu derived from ra,dec
 * fDistanceArcMinEq or fDistanceEq: returns distance (arc minutes) between two points (ra1,dec1) and (ra2,dec2)

Useful Information from Photometric Catalogs:

 * Index: objid, run, rerun, camcol, field, obj, mjd
 * Position: ra, dec, raErr, decErr, b, l
 * mode: 1: primary, 2: secondary, 3: other
 * Useful function: fPhotoMode, fPhotoModeN
 * type: Type classification of the object
 * Including UNKNOWN=0; COSMIC_RAY=1; DEFECT=2; GALAXY=3; GHOST=4; KNOWNOBJ=5; STAR=6; SKY=8
 * Useful functions: fPhotoType, fPhotoTypeN
 * clean: Clean photometry flag (1=clean, 0=unclean).
 * probPSF, probPSF_u,g,r,i,z: Probability that the object is a star.
 * insideMask: Flag to indicate whether object is inside a mask and why
 * Including INMASK_NOT_IN_MASK; INMASK_BLEEDING; INMASK_BRIGHT_STAR; INMASK_TRAIL; INMASK_HOLE; INMASK_POOR_SEEING; INMASK_BAD_SEEING
 * Useful function: fInsideMask, fInsideMaskN
 * flags, flags_u,g,r,i,z: Photo Object Attribute Flags
 * Pay Attention to the Following ones: BRIGHT, EDGE, BLENDED, CHILD, NODEBLEND, NOPETRO, DEBLEND_TOO_MANY_PEAKS, COSMIC_RAY, SATURATED, SUBTRACTED, TOO_LARGE, SATUR_CENTER, INTERP_CENTER, PSF_FLUX_INTERP
 * Useful functions: fPhotoFlags, fPhotoFlagsN
 * rowc, colc, rowcErr, colcErr, rowc_u,g,r,i,z, colc_u,g,r,i,z
 * psfMag_u,g,r,i,z; psfMagErr_u,g,r,i,z, in mag
 * psfFlux_u,g,r,i,z in nanomaggies; and psfFluxIvar_u,g,r,i,z in nanomaggies^{-2}
 * aperFlux7_u,g,r,i,z; aperFlux7Ivar_u,g,r,i,z: Aperture flux and Inverse variance of aperture flux within 7.3 arcsec
 * extinction_u,g,r,i,z: Extinction in each band
 * psffwhm_u,g,r,i,z: FWHM in each band
 * airmass_u,g,r,i,z: Airmass at time of observation in each band
 * fieldID: Link to the field this object is in
 * thingID, nObserve, nDetect, nEdge
 * score: Quality of field (0-1)
 * calibStatus_u,g,r,i,z: Calibration status
 * Including: PHOTOMETRIC, UNPHOT_OVERLAP, UNPHOT_EXTRAP_CLEAR, UNPHOT_EXTRAP_CLOUDY, UNPHOT_DISJOINT, INCREMENT_CALIB
 * Useful functions: fCalibStatus, fCalibStatusN
 * nMgyPerCount_u,g,r,i,z: in nMgy/count
 * TAI_u,g,r,i,z: time of observation (TAI) in each filter

Useful Information from Field catalog

 * Index: fieldID, run, rerun, camcol, field
 * Number of Objects: nTotal, nObjects, nChild, nGalaxy, nStars
 * Number of Bright Objects: nBrightObj_u,g,r,i,z
 * quality: Quality of the field
 * Including BAD, ACCEPTABLE, GOOD, MISSING, HOLE
 * Useful function: fFieldQuality, fFieldQualityN
 * Astrometry terms: a,b,c,d,e,f in _u,g,r,i,z
 * Center of the field: ra, dec
 * Min and Max Ra/Dec: raMin, raMax, decMin, decMax
 * Pixel scalte: pixScale in arcsec/pix
 * Saturation level: saturationLevel_u,g,r,i,z in counts
 * Effective area of PSF: nEffPsf_u,g,r,i,z in pix
 * Sky Estimate from Postage Stamp Pipeline: skyPsp_u,g,r,i,z in nmgy/arcsec^2
 * Frames sky value: skyFrames_u,g,r,i,z in nmgy/arcsec^2
 * Sigma of pixel values: sigPix_u,g,r,i,z in nmgy/arcsec^2
 * Fractional Sigma of Sky Value Distribution: skySig_u,g,r,i,z in mag
 * $$Noise_{Sky}=skySig\times sky\times ln(10)/2.5$$
 * Error in PSP estimate of sky: skyErr_u,g,r,i,z, in nmgy/arcsec^2
 * Rate of change in sky value along columns: skySlope_u,g,r,i,z, in nmgy/arcsec^2/field
 * Number of bins in PSF profile (in fieldProfile table): nProf_u,g,r,i,z
 * Number of stars used in PSF measurement: psfNStar_u,g,r,i,z
 * Photometric uncertainty due to imperfect PSF model: psfApCorrectionErr_u,g,r,i,z, in mag
 * Inner gaussian sigma for composite fit: psfSigma1_u,g,r,i,z
 * Outer gaussian sigma for composite fit: psfSigma2_u,g,r,i,z
 * Ratio of inner to outer components at origin: psfB_u,g,r,i,z
 * Value of power law at origin in composite fit: psfP0_u,g,r,i,z
 * Slope of power law in composite fit: psfBeta_u,g,r,i,z
 * Width of power law in composite fit: psfSigmaP_u,g,r,i,z
 * Effective PSF width from 2-Gaussian fit: psfWidth_u,g,r,i,z, in arcsec
 * Sigma of inner gaussian in 2-Gaussian fit: psf2GSigma1_u,g,r,i,z, in arcsec
 * Sigma of outer gaussian in 2-Gaussian fit: psf2GSigma2_u,g,r,i,z, in arcsec
 * Ratio of inner to outer components at origin: osf2GB_u,g,r,i,z
 * Gain averaged over amplifiers: gain_u,g,r,i,z
 * Dark variance: darkVariance_u,g,r,i,z
 * Quality of field: score, from 0 to 1
 * nanomaggies per count due to instrument: aterm_u,g,r,i,z, in nmgy/count
 * atmospheric k-term at reference time in calibration: kterm_u,g,r,i,z
 * Calibration status bitmask: calibStatus_u,g,r,i,z
 * Image status bitmask: imageStatus_u,g,r,i,z
 * nanomaggies per count: nMgyPerCount_u,g,r,i,z, in nmgy/count
 * Start and End of Field in Stripe coords, muStart, muEnd, nuStart, nuEnd, in arcsec

Useful Information in FieldProfile

 * Filter: band, u,g,r,i,z=0,1,2,3,4
 * Bin Number: bin, from 0 to 14
 * Mean pixel flux in annulus: profMean, in nmgy/arcsec^2
 * Median profile: profMed, in nmgy/arcsec^2
 * Sigma of profile: profSig, in nmgy/arcsec^2
 * Links to the field object: fieldID
 * For the profile radii, see the ProfileDefs table.
 * bin, cell, sinc, see definition Here
 * rInner, rOuter, in arcsec
 * aAnn, aDisk, in arcsec^2

Useful Information in the Neighbors catalog

 * objid, NeighborObjID
 * Distance between center and neighbor: distance, in arcmins
 * type, neighborType
 * mode, neighborMode

Useful Information in RUN Catalog

 * Index: run, rerun, mjd, datestring, stripe, strip
 * node, incl

Useful Information in Frame catalog

 * Index: fieldID, run, rerun, camcol, field, stripe, strip
 * Astrometry: a, b, c, d, e, f, node, incl
 * Region: raMin, raMax, decMin, decMax
 * Center: mu, nu, ra, dec, cx, cy, cz, htmid
 * JPEG Image: img
 * To use it, see fGetUrlFrameImg
 * dbo.fGetUrlFrameImg( @frameId, @zoom )