IPHAS Sample SQL Queries
This page provides examples of queries against the IPHAS catalogue using AstroGrid. You can type (or copy'n'paste) the query in the Query Builder window as shown in the image below.
Example queries
Search for objects around a position
This is the most basic query returning all objects in a specific box:
SELECT * FROM PhotoObjBest as P WHERE P.ra > 15.4 AND P.ra < 15.6 AND P.dec > 59.0 AND P.dec < 60.1
Cone search
Return coordinates and magnitudes of objects in a cone defined by its center at RA=300.0 and Dec=30.0 and radius r=10 arcmin. In this case instead of coding the whole trigonometry in the query we use the auxiliary table tGetNearbyObj which returns the object IDs which satisfy a cone search specified by the center coordinates (ra, dec) and radius (r) in minutes of arc:
SELECT P.ra, P.dec, P.coremag_r, P.coremag_i, P.coremag_ha, P.coremagerr_r, P.coremagerr_i, P.coremagerr_ha FROM PhotoObjBest as P, tGetNearbyObj as G WHERE G.ra=300.0 AND G.dec=30.0 AND G.r=10.0 AND P.objID = G.objID
Object classification and additional constraints
As previous example but only return objects classified as point-like in r and observed in conditions of seeing better than 1.5 arcsec as measured in the r band.
In this query we are asking for information about the quality of observations and this is stored in the ChipsAll table. We need therefore to join the results with this table in order to select only observation with good seeing conditions.
SELECT P.ra, P.dec, P.coremag_r, P.coremag_i, P.coremag_ha, P.coremagerr_r, P.coremagerr_i, P.coremagerr_ha FROM PhotoObjBest as P, tGetNearbyObj as G, ChipsAll as CR WHERE G.ra=300.0 AND G.dec=30.0 AND G.r=10.0 AND CR.seeing<1.5 AND (P.class_r=-1 OR P.class_r=-2) AND P.objID = G.objID AND P.chipsall_r=CR.chipID
Adding additional constraints on e.g. object colours, magnitude limits, observation dates are trivially implemented in the same way, e.g.:
SELECT P.ra, P.dec, P.coremag_r, P.coremag_i, P.coremag_ha, P.coremagerr_r, P.coremagerr_i, P.coremagerr_ha FROM PhotoObjBest as P, tGetNearbyObj as G, ChipsAll as CR WHERE G.ra=300.0 AND G.dec=30.0 AND G.r=10.0 AND P.coremag_r-P.coremag_ha>0.8 AND P.coremag_r-P.coremag_i>1.5 AND P.coremagerr_r<0.02
Objects by field
Select all objects observed in a particular field in the off position.
The following example returns all objects detected in a particular observation from the (not cleaned) PhotoObj catalogue.
SELECT * FROM PhotoObj as P FieldsAll as F WHERE F.fieldID = P.field_id AND F.fieldno=7012 AND F.onoff=0
Attachments
- IphasQ.png (119.3 kB) - added by gg 6 months ago.
- voexp-iphas-cone.png (136.9 kB) - added by gg 6 months ago.

