Query language

Basic syntax

At this website it is possible to select galaxies in the RCSED catalog using simple boolean expressions query language which mimics syntax of WHERE clause in SQL language. The language consists of arbitrary number of expressions combined together using AND or OR clauses. Expression usually has the following structure (square brackets mean optional clauses):

parameter operator value [AND | OR [NOT] expression] [, …]

where parameter is the name of any galaxy property (i.e. column) present in the database or simple arithmetical operation between any number of properties (*, /, -, and + are supported). There is no unit specification so the actual query compares the data with user input value in the default database units. See the RCSED schema documentation for the list of available catalog columns.

Operator can be any comparison operator from SQL-like languages:

  • = tests equality
  • != tests non-equality
  • > greater than (does not work for string parameters)
  • < less than (does not work for string parameters)
  • >= greater or equal than (does not work for string parameters)
  • <= less or equal than (does not work for string parameters)

Value in expression can be any string in double or single quotes, integer or float number in decimal notation with the point as a decimal separator. Value must correspond to parameter datatype, i.e. one can't compare string and float number. Use keyword NOT before the expression to negate it.

Slightly different syntax for expression is employed for testing substring inclusion in parameters of a string type:
"substring" IN parameter_string
Another alternative tests for presence of desired substring(s) as a separate word(s) in parameter_string:
{"substring1" [, "substring2" [, ...]]} IN parameter_string
which is often equivalent of the query "substring1" IN parameter_string AND "substring2" IN parameter_string, though not exactly. Please also keep in mind that you have flexibility to change places of parameter and value in expressions and the overall language is case-insensitive.

Special functions

  • cone('object_name', 'search_radius')
  • Make cone search in the catalog with specified radius around object. object_name is a quoted string with an object name to be resolved through the CDS Simbad service and search_radius is a quoted string in a format of value with units, e.g. 1.0deg, 1arcmin, 15arcsec
  • cone('ra', 'dec', 'search_radius')
  • Cone search the catalog around known coordinates ra and dec with specified radius search_radius. ra and dec can be quoted colon-separated strings in sexagesimal notation, or unquoted float numbers. search_radius is same as in the cone search function above.
  • object_name
  • Unquoted object name without any other conditions is rewritten to cone('object_name', '1arcmin')

Query related tables

By default query language operates on main rcsed table and transparently uses its column names, whereas there is a lot of additional information in related tables such as rcsed_fibermags or rcsed_lines_gauss. To be able to query them and address their columns as well we implemented transparent join on objid column and namespaced additional tables columns as follows:

  • rcsed_fibermags (column name prefix: fibermags_)
  • galaxyzoo (column name prefix: galaxyzoo_)
  • rcsed_lines_gauss (column name prefix: gauss_)
  • rcsed_lines_nonpar (column name prefix: nonpar_)
  • rcsed_lines_nonpar_reg (column name prefix: nonpar_reg_)
So you one just needs to prepend table column name with corresponding table prefix, for example query

corrmag_g - corrmag_r > 0.75 AND galaxyzoo_spiral = 1

will return all galaxies with red g-r color, classified as spirals in Galaxy Zoo. For the full list of related table columns see the RCSED columns page.

Example queries

  • M60 – select galaxies in 1 arcmin vicinity of M60 center
  • 12:58:09.22 +28:42:30.9 or 12 58 09.22 28 42 30.9 or 194.5385 28.7086 – search 1 arcmin vicinity of sexagesimal or decimal coordinates
  • cone('NGC4889', '1deg') AND z < 0.032 AND corrmag_u < 18 – select galaxies from Coma cluster brighter than 18 mag in SDSS u band not further than 1 degree from its central galaxy NGC4889
  • objid IN {587722952230175138, 587722952230634398} – select specific galaxies by their object IDs (useful for larger subsets)

SQL access

If you feel constrained with this simple query language, try more powerful SQL-like queries in the Astronomical Data Query Language interface which serves as an open source SDSS CasJobs analog.