wiki:db/queries/030
Last modified 6 years ago Last modified on 01/31/2013 11:24:22 PM

The BRG sample. Create a volume-limited sample of luminous red galaxies with ? < z < ?

In practice, this query will be a full table scan of the Object table:

SELECT objectId, ra_SG, decl_SG
FROM   Object
WHERE  extendedness > 0.8 -- is a galaxy
  AND  (                  -- (r-i)-(g-r)/4-0.18 between -0.2 and 0.2
         fluxToAbMag(rFlux_SG)-fluxToAbMag(iFlux_SG) - 
         (fluxToAbMag(gFlux_SG)-fluxToAbMag(rFlux_SG))/4 - 0.18
        ) BETWEEN -0.2 AND 0.2
  AND  (                 -- (r-i)-(g-r)/4-0.18>0.45-4*(g-r)
          (
            (fluxToAbMag(rFlux_SG)-fluxToAbMag(iFlux_SG)) - 
            (fluxToAbMag(gFlux_SG)-fluxToAbMag(rFlux_SG))/4 - 0.18 
          ) > (0.45 - 4*(fluxToAbMag(gFlux_SG)-fluxToAbMag(rFlux_SG))) 
       )
  AND flags ...
}

This query originally came from SDSS (S-10). See: http://tdserver1.fnal.gov/project/sdss/dp-review-700/dp-review-docs/requirements/requirements.html :

Bright Red Galaxies (BRGs): The BRG sample attempts to create a volume-limited sample of luminous red galaxies with 0.2 < z < 0.45.

if {AR_DFLAG_BINNED1 || AR_DFLAG_BINNED2 || AR_DFLAG_BINNED4} {
   if {! ( AR_DFLAG_BLENDED AND !( AR_DFLAG_NODEBLEND || AR_DFLAG_CHILD)} {
      if {!AR_DFLAG_EDGE & !AR_DFLAG_SATUR} {
         if { galaxy} { ;# not star, asteroid, or bright
           if { primary_object} {
              if {! (petroMag<2> < 15.5 AND petror50<2> < 2) } {
                if {petroMag<r> > 0 AND Mag_model<g> > 0 AND
                    Mag_model<r> > 0 AND Mag_model<i> > 0 } {
                    petSB = deRed_r + 2.5*log10(2*3.1415*petror50<r>^2)
                    deRed_g = petroMag<g> - extinction<g>
                    deRed_r = petroMag<r> - extinction<r>
                    deRed_i = petroMag<i> - extinction<i>
                    deRed_gr = deRed_g - deRed_r
                    deRed_ri = deRed_r - deRed_i
                    cperp = deRed_ri - deRed_gr/4.0 - 0.18
                    cpar = 0.7*deRed_gr + 1.2*(deRed_ri -0.18)
                    if {(deRed_r < 19.2 AND deRed_r < 13.1 + cpar/0.3 AND
                         abs(cperp) < 0.2 AND petSB < 24.2 ) ||
                         (deRed_r < 19.5 AND cperp > 0.45 - deRed_gr/0.25 AND
                          deRed_gr > 1.35 + deRed_ri*0.25 AND petSB < 23.3) {
                         accept ;# whew!!!
                     }
                  }
               }
            }
          }
       }
    }
 }
SET @binned =   dbo.fPhotoFlags('BINNED1') +
dbo.fPhotoFlags('BINNED2') +
                dbo.fPhotoFlags('BINNED4') 
SET @deblendedChild =   dbo.fPhotoFlags('BLENDED')   +
                        dbo.fPhotoFlags('NODEBLEND') +
                        dbo.fPhotoFlags('CHILD')
SET @blended = dbo.fPhotoFlags('BLENDED')
DECLARE @edgedSaturated BIGINT
SET @edgedSaturated =   dbo.fPhotoFlags('EDGE') +
                        dbo.fPhotoFlags('SATURATED')
SELECT  run,
        camCol,
        rerun,
        field,
        objID,
        ra,
        dec
FROM    Galaxy
WHERE  (flags & @binned)> 0  
   AND (flags & @deblendedChild) !=  @blended
   AND (flags & @edgedSaturated)  = 0  
   AND petroMag_i > 17.5
   AND (petroMag_r > 15.5 OR petroR50_r > 2)
   AND (petroMag_r > 0 AND g>0 AND r>0 AND i>0)
   AND (petroR50_r > 0 ) -- petroR50 value is valid, need to avoid log(0)
   AND ((    (petroMag_r-extinction_r) < 19.2
         AND (petroMag_r - extinction_r < (13.1 + (7/3)*( g - r) + 4 *( r  - i) - 4 * 0.18 ))          
         AND (((r-i) - (g-r)/4 - 0.18) <  0.2) 
         AND (((r-i) - (g-r)/4 - 0.18) > -0.2) 
         AND           -- petSB - deRed_r + 2.5 log10(2Pi*petroR50^2)
             ((petroMag_r - extinction_r + 2.5 * LOG( 2 * 3.1415 * petroR50_r * petroR50_r )) < 24.2)
             OR
             (    (petroMag_r - extinction_r < 19.5) 
              AND (( (r-i) - (g-r)/4 - 0.18 ) > (0.45 - 4*( g-r)) )  -- 0.45 - deRed_gr/0.25       
              AND ((g-r) > (1.35 + 0.25 *(r-i)))
              AND  -- petSB - deRed_r + 2.5 log10(2Pi*petroR50^2)
                  ((petroMag_r - extinction_r  +  2.5 * LOG(2 * 3.1415 * petroR50_r * petroR50_r)) < 23.3) 
             )
       ))