Skip to content

Instantly share code, notes, and snippets.

@Miladiouss
Last active June 15, 2019 00:22
Show Gist options
  • Save Miladiouss/d34180ba82a1013af3b7ead846ef967a to your computer and use it in GitHub Desktop.
Save Miladiouss/d34180ba82a1013af3b7ead846ef967a to your computer and use it in GitHub Desktop.
An HSC-PDR2 SQL query to extract RA, Dec, tract, patch of clean galaxies with a magnitude cut.
-- An HSC-PDR2 SQL query to extract RA, Dec, tract, patch of clean galaxies with a magnitude cut.
-- Useful Links:
-- /https://hsc-release.mtk.nao.ac.jp/hscMap-pdr2/app/#/?_=%7B%22view%22%3A%7B%22a%22%3A5.770914805732617,%22d%22%3A-0.019535944017082533,%22fovy%22%3A0.0002503311005562077,%22roll%22%3A0%7D,%22sspParams%22%3A%7B%22type%22%3A%22SDSS_TRUE_COLOR%22,%22filter%22%3A%5B%22HSC-I%22,%22HSC-R%22,%22HSC-G%22%5D,%22simpleRgb%22%3A%7B%22beta%22%3A22026.465794806718,%22a%22%3A1,%22bias%22%3A0.05,%22b0%22%3A0%7D,%22sdssTrueColor%22%3A%7B%22beta%22%3A26003.369421497522,%22a%22%3A1,%22bias%22%3A0.14439999999999995,%22b0%22%3A0%7D%7D%7D
-- https://hsc-release.mtk.nao.ac.jp/schema/#pdr2.pdr2_wide.forced
SELECT
object_id
, tract
, patch
, forced.ra
, forced.dec
-- , i_kronflux_mag
-- , r_kronflux_mag
-- , g_kronflux_mag
-- , i_kronflux_magsigma
-- , r_kronflux_magsigma
-- , g_kronflux_magsigma
-- , i_kronflux_radius
-- , r_kronflux_radius
-- , g_kronflux_radius
-- , sqrt((24 - g_kronflux_mag)^2 + (24 - r_kronflux_mag)^2 + (24 - i_kronflux_mag)^2) / (g_kronflux_radius^2 + r_kronflux_radius^2 + i_kronflux_radius^2)^.3
FROM
pdr2_wide.forced
JOIN
pdr2_wide.forced2 USING (object_id)
WHERE
--- Coordinate bound
-- Typical:
-- boxSearch(coord, 32.9-.07, 32.9+.07, -4.4-.07, -4.4+.07)
-- Edge:
boxSearch(forced.coord, 330.6-.06, 330.6+.06, -1.15-.06, -1.15+.06)
-- DEEP2-3:
-- boxSearch(forced.coord, 352.188-.06, 352.188+.06, -0.698-.06, -0.698+.06)
--- Magnitude bound
AND (
g_kronflux_mag BETWEEN 15 AND 24.8
and r_kronflux_mag BETWEEN 15 AND 23.5
and i_kronflux_mag BETWEEN 15 AND 23.5
)
--- No inacurate mags (medium priority)
AND g_kronflux_magsigma < 0.135
AND r_kronflux_magsigma < 0.135
AND i_kronflux_magsigma < 0.135
--- No sources near bright objects (high priority)
AND forced.g_pixelflags_bright_objectcenter = false
AND forced.r_pixelflags_bright_objectcenter = false
AND forced.i_pixelflags_bright_objectcenter = false
--- No saturated pixels (low priority)
AND g_pixelflags_saturated = false
AND r_pixelflags_saturated = false
AND i_pixelflags_saturated = false
--- No general failure (low priority)
AND forced.g_pixelflags = false
AND forced.r_pixelflags = false
AND forced.i_pixelflags = false
--- No saturation (low priority)
AND forced.g_pixelflags_saturatedcenter = false
AND forced.r_pixelflags_saturatedcenter = false
AND forced.i_pixelflags_saturatedcenter = false
--- No bad mags (low priority)
AND g_kronflux_flag = false
AND r_kronflux_flag = false
AND i_kronflux_flag = false
--- OTHER
AND g_kronflux_radius < 2.5
AND g_extendedness_value = 1
AND forced.isprimary = true
AND detect_ispatchinner = true
--- Off
-- AND forced.g_localbackground_flag = false
-- AND forced.r_localbackground_flag = false
-- AND forced.i_localbackground_flag = false
-- AND g_pixelflags_saturated = false
-- AND r_pixelflags_saturated = false
-- AND i_pixelflags_saturated = false
-- AND g_pixelflags_cr = false
-- AND r_pixelflags_cr = false
-- AND i_pixelflags_cr = false
-- AND g_pixelflags_edge = false
-- AND r_pixelflags_edge = false
-- AND i_pixelflags_edge = false
-- AND g = false
-- AND r = false
-- AND i = false
-- AND g = false
-- AND r = false
-- AND i = false
-- LIMIT 500
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment