Smithsonian
  Astrophysical
    Observatory
SDSS @ CFA SAO Telescope Data Center

Sloan Digital Sky Survey at CFA
Data Release 6

Contents:

Introduction
  Photometric Data
  Spectral Data
  Spectral Line Data
  Tools & Examples getobjid - get thumbnail or finder image
   getspecid - get spectra from local archive
   footserver - Check if coordinate in SDSS footprint
   sdssquery - query Sloan SkyServer from CFA

Last update: 2008-04-15 by Bill Wyatt


INTRODUCTION    Back to top

A selection of the SDSS Data Release 6 (DR6) databases and associated files has been transferred to CFA. Each of these has been condensed by choosing a (we hope!) useful subset of the columns, and converted to Starbase tables, which are rows of tab-separated columns of ASCII characters.

The majority of the "best" photometric database (not including the image thumbnails) and all of the spectral databases (as reduced at Princeton by David Spergel et al.) have been so condensed. The files locally are stored in the directory:

/data/astrocat/SDSS-dr6
Much, much more information than could be provided here is available at the SDSS main web site http://www.sdss.org.

To ensure you get the latest version of the Starbase programs and the tools described below, please set your PATH variable to include the following two directories at its beginning:

   /data/oiropt/starbase
   /data/oiropt/bin


PHOTOMETRIC DATA    Back to top

The PhotoPrim.db starbase file is a subset of the SDSS PhotoPrimary view of the entire photometry database. It has been sequentially indexed (i.e. physically sorted) by declination, (the dec column), into 1/10 degree bins and right ascension-sorted (ra column) within each declination bin.

There are 218,098,488 rows in the database, out of over 354,000,000 in the full PhotObjAll set. Using the search program from the Starbase package (see http://www.cfa.harvard.edu/~john/starbase/starbase.html) makes obtaining region-delimited objects quick even for this size database of about 196 GB.

The selected columns are:

objIDfieldIDspecObjID   
skyVersionrerunrun camcolfield
objflagsflags2 typestatus
radecprobPSF   
ugr iz
Err_uErr_gErr_r Err_iErr_z
type_utype_gtype_r type_itype_z
flags_uflags_gflags_r flags_iflags_z
flags2_u flags2_g flags2_r flags2_i flags2_z
psfMag_u psfMag_g psfMag_r psfMag_i psfMag_z
psfMagErr_u psfMagErr_g psfMagErr_r psfMagErr_i psfMagErr_z
psfMag_u_gpsfMag_g_rpsfMag_r_ipsfMag_i_z 
fiberMag_ufiberMags_g fiberMag_rfiberMag_ifiberMag_z
fiberMagErr_ufiberMagErr_gfiberMagErr_r fiberMagErr_ifiberMagErr_z
fiberMag_u_gfiberMag_g_rfiberMag_r_ifiberMag_i_z 
petroMag_upetroMag_gpetroMag_rpetroMag_ipetroMag_z
petroMagErr_upetroMagErr_gpetroMagErr_r petroMagErr_ipetroMagErr_z
petroMag_u_gpetroMag_g_rpetroMag_r_ipetroMag_i_z 
extinction_u extinction_g extinction_r extinction_i extinction_z
sky_usky_gsky_r sky_isky_z
skyErr_u skyErr_g skyErr_r skyErr_i skyErr_z
isoA_uisoA_gisoA_r isoA_iisoA_z
isoAErr_uisoAErr_gisoAErr_r isoAErr_iisoAErr_z
isoB_uisoB_gisoB_r isoB_iisoB_z
isoBErr_uisoBErr_gisoBErr_r isoBErr_iisoBErr_z
isoPhi_u isoPhi_g isoPhi_r isoPhi_i isoPhi_z
isoPhiErr_uisoPhiErr_gisoPhiErr_r isoPhiErr_iisoPhiErr_z

To see this for yourself, use the Starbase progran headline and execute:

  headline </data/astrocat/SDSS-dr6/PhotoPrim.db

Full documentation on these columns is available at: http://cas.sdss.org/dr6/en/help/browser/browser.asp?n=PhotoPrimary&t=U

Note that the  u, g, r, i, z  magnitudes are the modelMag magnitudes from the SDSS view, and to get the dereddened magnitude, you need to subtract the corresponding extinction_ value. The petroMag_x magnitudes are recommended for use with galaxies and the psfMag_x magnitudes are recommended for stars.

Also, note that the colors, e.g. petroMag_u_g, are not in the original table view from Sloan, but were computed including the extinction corrections, when extracting the values to put in this database, e.g.:

  petroMag_u_g = (petroMag_u - extinction_u) - (petroMag_g - extinction_g)

These columns have been indexed for use by search, where all but the ra & dec are secondary indices:

ra dec type specObjID objID
petroMag_upetroMag_gpetroMag_rpetroMag_ipetroMag_z
petroMag_u_gpetroMag_g_rpetroMag_r_ipetroMag_i_z
psfMag_upsfMag_gpsfMag_rpsfMag_ipsfMag_z
psfMag_u_gpsfMag_g_rpsfMag_r_ipsfMag_i_z

The primary index being on RA and Dec means the database file itself is sorted by RA and Dec. In this case the sorting is optimized into into bins of 0.1 degrees in Dec and by RA within each Dec bin, so that nearby objects are likely to be in the same disk block or at least nearby. Each secondary index consists of a sorted file of pointers to the indexed column. The search program uses these indices, if available, for fast access. See also the section below Searching the database.

Validating objects in the database

Objects must be validated before you can be sure what you're getting.

For example, if the type field is 3, the object is (supposed to be) a galaxy, type == 6   is a star and type == 8   is a sky exposure. The full type table, reproduced from the SDSS web site:

ClassNameCode
Unknown UNK 0
Cosmic Ray CR 1
Defect DEFECT 2
Galaxy GALAXY 3
Ghost GHOST 4
Known object KNOWNOBJ 5
Star STAR 6
Star trail TRAIL 7
Sky SKY 8
Also, each object has associated flag bits from the reduction stage to allow selection or rejection on various citeria. These are 64-bit quantities in the original SDSS database. Since Starbase is an awk front end, it cannot handle these as numbers, so I have split them into two 32-bit fields, calling the lower-order one flags and the high order one flags2. Then, one or more bits can be tested using the bit-field testing functions, and(), or(), not(), and xor().

For example, the 0x4 bit signifies an object too close to the edge of the frame, the 0x40000 bit means the object has one or more saturated pixels, while the 0x400000 bit means the sky level was bad. To test and reject objects with any of these conditions, the following pipeline fragment can be used:

  [...input... ] | row 'and(flags, 0x440004) == 0' | [...output...]
Since the 'stationary' bit is 0x1000000000, it is in the upper 32 bits, so the bit-field and test would be
and(flags2,0x10) == 0x10
and has to be tested separately from the bits in flags.

The full set of 64 flag bits is documented at the cas.sdss.org site.

Searching the database

The search and row commands from the Starbase package can be used to search for rows with specific objects or values. The URL for the full Starbase documentation is:
http://www.cfa.harvard.edu/~john/starbase/starbase.html
Briefly, search uses index files, if available, to quickly seek to matching rows in the database, while row is a front-end for the awk variant mawk, for statements where the column names substitute for $1, $2, etc., so the user does not have to know the column order of the database.

To find all the objects with photometry near one or more coordinates, a small Starbase tab-separated table containing the RA and Dec is used containing the center(s) of the space to be searched. The example below is for one coordinate, but more are possible (the SDSS coordinates are all in degrees).

There are multiple ways to create a Starbase table. Two examples:

echo "190. 50." | fldtotable ra dec >/tmp/table

printf "ra\tdec\n-\t-\n190.\t50.\n" >/tmp/table

Both of these result in a table that looks like:
  ra      dec
  --      ---
  190.    50.
where the whitespace between the columns is a single tab character. Then, using this table /tmp/table, the command to search around the coordinate with a radius of 0.05 degrees is:
  search PhotoPrim.db -S2ddd ra dec 0.05 </tmp/table
Note that unless you are in the /data/astrocat/SDSS-dr6 subdirectory, you need to give the full path to PhotoPrim.db ; I am typing only the file name for clarity in this document.

A simple table cam be made on the fly, piping it directly into search:

  printf "ra\tdec\n-\t-\n190.\t50.\n" | search PhotoPrim.db -S2ddd ra dec 0.05  
This returns a short table with 165 rows in just a fraction of a second. Searching linearly through the 196 GB would take approximately 8 hours, depending on the speed of your network link and machine.

To find all the objects with observed spectra near one or more coordinates, the output of a search such as the above is checked for rows where the column specObjID is non-zero. It happens that the 165 returned objects from the above search contains just a single object with a corresponding spectrum. It can be isolated using row on the above output:

  printf "ra\tdec\n-\t-\n190.\t50.\n"    |
  search PhotoPrim.db -S2ddd ra dec 0.05 |
  row 'specObjID != 0'                   |
  project specObjID                       
[N.B.: the above is a single command broken across lines for readability]
Here, the project program outputs only the columns given as its arguments, in this case giving
  specObjID
  -
  359951516078964736  

Using this result for a query of the SpecPhoto.db database, the command:

  row <SpecPhoto.db 'specObjID == "359951516078964736"' |
  justify DR class subclass ra%.4f dec%.4f z z_err zwarning
Note that the awk statement inside the row command is using a string comparison, not a numeric one. The specObjID and objID columns are 64-bit numbers which are too big for starbase's underlying implementation of awk.

The command returns (where justify projects and formats a subset of the columns to display):

  DR   class   subclass     ra        dec      z         z_err     zwarning
  ---  ------  -----------  --------  -------  --------  --------  --------
  DR3  GALAXY  STARFORMING  189.9365  50.0143  0.083877  0.000009         0
Note that the two databases may have slightly different values of RA and Dec for the object. In the above case, for example, the positions differ radially by 0.076 arc-seconds.

To print the RA and Dec in the conventional sexagismal format instead of degrees, use the Starbase compute command as a filter to convert the RA to hours (i.e., divide by 15), then use the "@" format specifier with justify on the ra and dec columns (and see the column name change at the end):

  row <SpecPhoto.db 'specObjID == "359951516078964736"' |
  compute 'ra /= 15.'                                     |
  justify DR progName class subclass ra%.1@ dec%@ z%.4f z_err%.4f zwarning=zwarn
and the output is:
  DR   class   subclass     ra          dec       z      z_err  zwarn
  ---  ------  -----------  ----------  --------  -----  -----  -----
  DR3  GALAXY  STARFORMING  12:39:44.6  50:00:51  0.084  0.000      0

Getting Images of PhotoPrim Objects

getobjid is a tool to query the SDSS SkyServer for a JPEG image of the area around an object or coordinate, putting the image into a directory designated by the user.

for example, the command

   getobjid -d $HOME -h 200 -w 400 -e GL -q 'GA(15,18)'
            -b 1. -f sdss.jpg -v -o 587731511532060708 
(line broken into two or clarity) delivers this image whose objid = 587731511532060708, where there is a label, a grid marking the center, and triangles marking galaxies with magnitudes between 15 and 18 in any of its bands.

For those interested in the details, see the documentation on the getobjid tool, below, and the full set of options is documented at the SDSS help page: http://cas.sdss.org/dr6/en/tools/chart/chart.asp


Spectral Data     Back to top

In the datbase directory /data/astrocat/SDSS-dr6 are the SpecObjAll.db and SpecPhoto.db tables. These databases are a subset of the SpecObjAll view of the SDSS spectral database. The SpecObjAll.db table contains all the rows (but not all the columns) of the SpecObjAll view, while SpecPhoto.db rows are from the SpecPhoto view, where the rows are SciencePrimary, i.e. it eliminates rows that are flagged as poor quality or are duplicates from earlier data releases or do not have specPrimary == 1. The two databases have been indexed in RA and Dec for quicker searching for spectra near a particular coordinate.

The spectral reductions are from the Princeton/Sloan database, who redid the Sloan reductions. The Princeton info page is:

http://spectro.princeton.edu
There are 734,864 rows in the SpecPhoto.db table and 1,059,840 in the full set in SpecObjAll.db. These numbers from the Princeton data set are slightly different from those given by the Sloan server. The CFA database files are 279 MB and 395 MB, respectively.

The subset of columns is the same in both databases:

specObjIDobjIDDR progName
radecprimTarget secTargetspecPrimary  
platemjdfiberID plqualplsn2
classsubclassobjType waveMinwaveMaxwcoverage
zz_errzwarning RChi2RChi2Diff
vdispvdisp_errvdispChi2 vdispZvdispZ_err
firstRAfirstDecfirstWarning firstFIntfirstFPeakfirstRMS
firstMajfirstMinfirstFPA firstSkyRMSfirstMatchDistfirstNmatch
tmassRatmassDecfirstErrMaj tmassErrMintmassErrAng
tmassJtmassJIvartmassH tmassHIvartmassKtmassKIvar
tmassPhQualtmassRdFlgtmassBlflg tmassCcFlgtmassGalContam
tmassMpflgtmassJdatetmassDupSrc tmassMatchDisttmassNmatch
usnoRAusnoDecusnoRmag usnoBmagusnoMatchDistunnoNmatch

The DR column gives which data release this row is from, i.e., one of: DR0, DR1, DR2, DR3, DR4, DR5  or  DR6  (where I have renamed EDR to DR0).

Full information on the meaning of these columns is found at:

http://spectro.princeton.edu/#dm_spplate
See also their information on known problems. More information is also available from the SDSS web site:
http://cas.sdss.org/dr6/en/help/browser/browser.asp?n=SpecObj&t=U

Searching the databases

The row and search commands from the Starbase package can be used to search for rows with specific objects or values. The URL for the full Starbase documentation is:
http://www.cfa.harvard.edu/~john/starbase/starbase.html
Briefly, row is a front-end for awk statements where the column names substitute for $1, $2, etc., so the user does not have to know the column order of the database. The command to pull all primary observations from the SpecObjAll.db table is:
  row 'specPrimary == 1 && primTarget != 0 && secTarget == 0' <SpecObjAll.db
Note that this does not eliminate the duplications among the data releases, so it is still somewhat larger than the SpecPhoto.db dataset.

To find all the objects with spectra near one or more coordinates, a small Starbase tab-separated table containing the RA and Dec is used containing the center(s) of the space to be searched. [see the discussion above] The example below is for one coordinate, but more are possible (the SDSS coordinates are all in degrees):


  printf "ra\tdec\n-\t-\n190.\t50.\n"     |          [this makes the table]
  search SpecObjAll.db -S2ddd ra dec 0.05 |          [this performs the search]
  justify ra%4f dec%4f class subclass z z_err objID  [project & format output]

It happens that the search returns a single object, a starforming galaxy at Z = 0.08. The output from above is:
  ra        dec      class   subclass     z      z_err  objID             
  --------  -------  ------  -----------  -----  -----  ------------------
  189.9365  50.0143  GALAXY  STARFORMING  0.084  0.000  587735430151929950
And, since the objID is non-zero, that means it is in the photometric database PhotoPrim.db also. To access that data row, you could row the entire database, testing for the correct objID, but that would take hours. So, use search again, and scan the much smaller output of the search:
  printf "ra\tdec\n-\t-\n190.\t50.\n"     |  [this makes the table]
  search PhotoPrim.db -S2ddd ra dec 0.05  |  [this performs the search]
  row 'objID == "587735430151929950"'     |  [select the object]
  justify ra%.4f dec%.4f r Err_r%.3f i Err_i%.3f isoA_r isoB_r isoPhi_r
returns:
  ra        dec      r       Err_r  i       Err_i  isoA_r  isoB_r  isoPhi_r
  --------  -------  ------  -----  ------  -----  ------  ------  --------
  189.9365  50.0143  17.272  0.007  16.996  0.008  21.982  17.175    170.37
The search returns 165 rows in less than a second, so the row command has a far smaller table to check.

Actually, since the objID column is a secondary index, the PhotoPrim database should be directly searched:

  search PhotoPrim.db -V objID 587735430151929950 | 
  justify ra%.4f dec%.4f r Err_r%.3f i Err_i%.3f isoA_r isoB_r isoPhi_r
and the output is the same as before.

Joins between the spectral and photometric databases

The search program takes an input table, using one of its columns as values to search. The output rows can be joined with the input rows using the -j option to search.

For example, if the search in the SpecPhoto database is:

  printf "233.45. 54.75." | fldtotable ra dec | 
  search SpecPhoto.db -S2ddd ra dec 0.075     | 
  justify specObjID objID ra%.4f dec%.4f class z z_err  
then the output is:
  specObjID          objID             ra       dec     class  z      z_err
  ------------------ ----------------- -------- ------- ------ ------ --------
  173055145871933440 588007004725117130 233.4319 54.7478 GALAXY 0.1179 0.000042
  173613531751514112 588007004725117173 233.5103 54.7107 GALAXY 0.1531 0.000035
  173613531772485632 588007004725117186 233.5444 54.7246 GALAXY 0.1173 0.000028
This can be combined into a search on these objects in the PhotoPrim.db database, yielding columns from both. If a column name is duplicated between the two databases (other than the join field), the input database columns have "_1" appended to them and the searched database columns have "_2" appended. In the example below, "z" in SpecPhoto is the redshift, but "z" in PhotoPrim is a Z-filter magnitude. Other columns such as ra and dec also conflict.

This pipeline of commands:

  printf "233.45. 54.75." | fldtotable ra dec | 
  search SpecPhoto.db -S2ddd ra dec 0.075     | 
  search -j PhotoPrim.db objID                |
  compute 'ra_2 /= 15.                        |
  justify ra_2=ra%.1@ dec_2=dec%.0@ class petroMag_r petroMag_i \
           petroMag_r_i z_1=z%.3f zwarning=zw 
generates:
  ra          dec       class  petroMag_r petroMag_i petroMag_r_i  z     zw
  ----------  --------  ------ ---------- ---------- ------------  ----- --
  15:33:43.6  54:44:52  GALAXY     17.455     16.944     0.499152  0.118  0
  15:34:02.3  54:42:38  GALAXY     17.294     16.852     0.430647  0.153  0
  15:34:10.6  54:43:28  GALAXY     17.565     17.17      0.38362   0.117  0
Note that the "z" from the input SpecPhoto.db table had been renamed to "z_1" because of the join conflict with "z" from PhotoPrim.db. The justify restored its original name and ignored the "z" magnitude from the PhotoPrim.db table, which became "z_2".

Obtaining the spectra

The spectra are stored in the /data/astrocat archive as multspec FITS files, one for each plate. The easiest way to extract one or more of them is to use getspecid.

The getspecid program uses specObjID values from one of three sources: on the command line, input on standard input as a Starbase table, or input as a simple list on standard input.

For example, the search of SpecPhoto.db above yields three objects:

  specObjID         
  ------------------
  173055145871933440
  173613531751514112
  173613531772485632
These can be extracted by piping this table into getspecid:
  printf "233.45. 54.75." | fldtotable ra dec | 
  search SpecPhoto.db -S2ddd ra dec 0.075     | 
  getspecid -v
which prints:
  Extract fiber   1 to ./spPlate-0614-53437-001.fits
  Extract fiber 353 to ./spPlate-0616-52374-353.fits
  Extract fiber 358 to ./spPlate-0616-52374-358.fits
while writing the files to the current directory. Without the "-v" option, it would silently write out the files. The FITS header is updated with the correct fiber RA and Dec, the source file name as "SPECFILE", the specObjID as "SPEC_ID" and the fiber ID as "FIBERID".

Sometimes it may be useful simply to extract the path to the file and fiber:

  printf "233.45. 54.75." | fldtotable ra dec | 
  search SpecPhoto.db -S2ddd ra dec 0.075     | 
  getspecid -n
which prints:
  /data/astrocat/SDSS-dr6/Spectro/spectro_DR6/0614/spPlate-0614-53437.fits     1
  /data/astrocat/SDSS-dr6/Spectro/spectro_DR2/0616/spPlate-0616-52374.fits   353
  /data/astrocat/SDSS-dr6/Spectro/spectro_DR2/0616/spPlate-0616-52374.fits   358
The following gives the details of the spectra storage hierachy. For those who want more details on the program, see the discussion and examples below.

To create the full path to one of the FITS files, use the DR, plate, mjd, and fiberID values. Using, for example,  DR=="DR1", plate=="0649", mjd=="52201" and fiberid=="320", generates the full path which is

/data/astrocat/SDSS-dr6/Spectro/spectro_DR1/0649/spPlate-0649-52201.fits
To actually get the spectrum for fiberID = 320 into its own file, one possibility is to use the imcopy command in IRAF, e.g. to get the 320th spectrum from one of these FITS files (see below for HDU explanation):
cl> imcopy file.fits[0][*,320] mydir/my.fits
(where "file.fits" represents the actiual filename), or, using the funimage command from the FUNTOOLS package from a shell (single quotes prevent the shell from interpreting any characters as wildcards):
funimage file.fits'[0,*:*,320:320]' mydir/my.fits
The Princeton web site also has instructions on using IDL and SuperMONGO.
[ As of this writing, the SM links are broken due to a disk crash. Should be fixed ... soon? - WFW ]

In the Spectro subdirectory there is platelist.db, which lists all the plates from which release and MJD.

Each plate FITS file has 7 extensions, as documented at the Princeton web page.

   HDU #0 = Flux in units of 10^(-17) erg/s/cm^2/Ang [FLOAT]
   HDU #1 = Inverse variance (1/sigma^2) for the above [FLOAT]
   HDU #2 = AND mask [32-bit INT]
   HDU #3 = OR mask [32-fit INT]
   HDU #4 = Wavelength dispersion in pixels [FLOAT]
   HDU #5 = Plug-map structure from plPlugMapM file [BINARY FITS TABLE]
   HDU #6 = Average sky flux in units of 10^(-17) erg/s/cm^2/Ang [FLOAT]
Note that the spectra are in log-wavelength. To compute the wavelengths of each bin use the header values CRVAL1 and CD1_1. Below is an IDL code snippet contributed by Jenny Greene:
   pix1=sxpar(header, 'CRVAL1', OOPS)
   disp=sxpar(header, 'CD1_1', OOPS)
   l=fltarr(n_elements(respec))
   for k=0,n_elements(respec)-1 do begin
     l[k]=disp*k+pix1
   endfor
   l=10^l

Spectral Line Data     Back to top

The SpecLine.db starbase database is created from the Princeton group's spectral line reductions of the SDSS spectral database.

The Princeton info page is:

http://spectro.princeton.edu
The database table has 15,304,737 rows, or 21 different line observations for 728,797 spectra. The file size is 1.8 GB.

The columns are:

specObjIDobjID
plateIDmjdfiberID
linewave
zz_err
sigmasigerr
areaarea_err
eqweqw_err
contcont_err
pixdofchi2

The entry in the line column is a short identifier for the 21 lines below:

linename 
LyA Ly alpha 
Ha H alpha 
Hb H beta 
Hg H gamma 
Hd H delta 
C3a C III] 1908 <--(sic) typo?
C4 C IV 1549 
He2 He II 1640 
Mg2 Mg II 2799 
N5 N V 1240 
N2a [N II] 6548 
N2b [N II] 6583 
O1a [O I] 6300 
O1b [O I] 6363 
O2a [O II] 3725 
O2b [O II] 3727 
O3a [O III] 4363 
O3b [O III] 4959 
O3c [O III] 5007 
S2a [S II] 6716 
S2b [S II] 6730 

If a line is missing or not measured, the z, etc. is 0 and the z_err, etc. is -1.

The specObjID and objID values are unique across all the SDSS databases, so these can be used to locate rows in the PhotoPrim.db and SpecPhoto.db tables as well.

To get the location of the actual spectrum corresponding to a row in the database, I've set up directories of the plates containing the multispec files. The plateID, mjd and fiberID values provide a path to the spectrum.

For example, if the plateID is "649", mjd is "52201" and fiberID = "320", the file is

/data/astrocat/SDSS-dr6/Spectro/spectro_DR1/0649/spPlate-0649-52201.fits
and spectrum 320 of that file is the target. See getspecid for a method of extracting the spectrum to your own directory.


Tools and Examples    Back to Top   getobjid   getspecid   footserver   sdssquery

GETOBJID  -  get postage-stamp image of object

The getobjid program, located in /data/oiropt/bin, expects a starbase table as its standard input and decodes either the ra, dec columns or the objID or specObjID column to determine the area of sky to be returned. In the latter two cases, the CFA PhotoPrim.db database is queried to return the coordinates. Command-line options are avaliable to determine the overlays supplied on the image. Full documentation is at http://cas.sdss.org/dr6/en/tools/chart/chart.asp

  Usage: getobjid [options] [objID_1 objID_2 ...] < table.db

     If non-option args are present, they are taken as values for
     images (i.e. RA, Dec pairs OR objIDs OR specObjIDs) to be
     downloaded. The -l, -t flags are then ignored.

        -c       - input is ra, dec coordinates, degrees (default)
        -o       - input is objID
        -s       - input is specObjID

        -h 400   - image height
        -w 400   - image width
        -b 0.396127   - image scale
        -e GL    - image opt
        -q <str> - image query (Ex: "GR(15,20)")

        -t <dbfile>   - Take values from starbase file (STDIN is default)
        -l <file>     - Take values as simple list from file ("-" == STDIN)
        -d .          - Output directory
        -f <name>     - Output file name instead of default.
        -a /data/astrocat/SDSS-dr6      - Path to SDSS data
        -v            - verbose output

   Output: file(s) in directory "dirpath", with filename(s)
           of form: SDSSJHHMMSS.ss[pm]DDMMSS.s.jpg

Examples:

The command:
   getobjid -h 200 -w 400 -f sdss.jpg -o 587731511532060708 
SDSS sample image

generated the above image, while the command:

   getobjid -q 'GA(15,18)' -h 200 -w 400 -e GL -b 1. -f sdss.jpg -vo 587731511532060708 
SDSS sample image with options

generated the second image of the same coordinate, but where the GA(15,18) draws triangles around galaxies with any magnitude between 15 and 18, GL puts the grid and label on the image, and -b 1. enlarges the image scale (i.e. zooms out) from its default.


GETSPECID  -  get spectra from archive          Back to top

The getspecid program, located in /data/oiropt/bin, expects a starbase table as its standard input and decodes the specObjID column to determine the plate number, date (as MJD) and fiber ID. If the specObjID is zero for a given row, that row is ignored. Getspecid then locates the appropriate multi-spectrum FITS file in the Spectro directory hierarchy and writes that fiber's spectrum to a FITS file in the user's area. There are a number of options that may alter this default behavior, including using the command line arguments instead of standard input.
  Usage: getspecid [options] [specID_1 specID_2 ...]

     If non-option args are present, they are taken as specObjIDs
     to be decoded. The -t, -l, -c, and -a flags are then ignored.

  Options:
        -t      - Take specObjID's from STDIN as starbase table (default)
        -l      - Take specObjID's as simple list from STDIN, one per line
        -d .    - set output directory path
        -f <id> - use fiberID=<id>
        -m <mj> - use mjd=<mj>
        -n      - Print source file path+name, fiberid only
        -s      - Print source file name, fiberid only
        -p <pl> - use plate=<pl>
        -c specObjID    - Column name to use from starbase table
        -o <name>       - Output file name instead of default.
        -a /data/astrocat/SDSS-dr6/Spectro      - Path to SDSS data
        -v      - verbose output
        -x      - Print this message and exit.

   Output is file in directory "dirpath", which is "." by default.
   File name is of form: spPlate-<plate>-<mjd>-<fiberID>.fits

Example:

To gather candidate Hypervelocity Stars for his project, Warren Brown (see Brown et al.) searched the SDSS catalog for late B-type objects. An approximate replication of the search would be the following script ( see explanatory notes):

#! /data/oiropt/bin/ksh
echo 18.25 |
fldtotable psfMag_g |
search  /data/astrocat/SDSS-dr6/PhotoPrim.db -C1 psfMag_g 1.25 |
row 'type == 6 &&
     and(flags2, 0x03000810U) == 0x10U && and(flags,0x80441044U) == 0' |
row 'psfMag_g_r > -0.38 && psfMag_g_r < -0.28'    | 
row ' (2.67 * psfMag_g_r) + 1.30 < psfMag_u_g && 
      psfMag_u_g < (2.67 * psfMag_g_r) + 2.0'     |
row ' -0.5 < psfMag_r_i && psfMag_r_i < 0.0   &&
      17.0 < psfMag_g   && psfMag_g < 19.5'       |
column -a l b                                     |
compute '[ l, b ] = eqgal(ra/15.,dec); if(b > 180.) b = (b % 180)-180' |
row 'abs(b) > -l/5. + 50 || abs(b) < l/5. - 50.' 
Note that the multiple row statements are really for clarity and could be combined into a single command. Running this script (call it hvsearch) as:
hvsearch >hvstars.db
generates hvstars.db with 563 rows. That table can be piped straight into getspecid to pull out all the objects with observed spectra:
getspecid -v <hvstars.db
 Extract fiber 304 to ./spPlate-0339-51692-304.fits
 Extract fiber 261 to ./spPlate-0332-52367-261.fits
 Extract fiber 175 to ./spPlate-0372-52173-175.fits
   ...
 Extract fiber 373 to ./spPlate-0543-52017-373.fits
 Extract fiber 358 to ./spPlate-0439-51877-358.fits
 Extract fiber 533 to ./spPlate-0497-51989-533.fits
for a total of 39 spectra, of which only 2 do not appear to be late B-type stars.

A test run of this script took about 3 hours 52 minutes on the tdc computer, of which all but 7 minutes was the initial search with the condition   17.0 < psfMag_g > 19.5, which passed 6.8 million rows on to the pipeline of row statements.

Some notes on the hvsearch script:
 
  1. The search command is passed a trivial key table with psfMag_f = 18.25, and told (via "C1 1.25") to do a one-dimensional search  ±1.25, in other words   17.0 < psfMag_g < 19.5.

  2. Bit fields being tested; note that the trailing "U" forces interpretation as an unsigned integer:
      flags2 & 0x03000810U == 0x10U  (i.e. stationary only)
        0x02000000U MAYBE_EGHOST
        0x01000000U MAYBE_CR
        0x00000800U SATUR_CENTER
        0x00000010U STATIONARY
    
      flags & 0x80441044U == 0
        0x80000000U MOVED
        0x00400000U BADSKY
        0x00040000U SATURATED
        0x00001000U COSMIC_RAY
        0x00000040U NODEBLEND
        0x00000004U EDGE
    
  3. The compute command calls the eqgal subroutine to convert equatorial to galactic coordinates, with the input ra in hours and dec in degrees, then makes the b value   -180 ≤ b < +180 instead of the normal range of  0 ≤ b < 360.

FOOTSERVER  -  Check if coordinate in SDSS footprint           Back to top

The footserver program, located in /data/oiropt/bin, is a shell script that formats an input set of one or more coordinates, then sends a query to the Sloan SkyServer that returns an indication if each coordinate is covered by the DR6 survey. This is a command-line interface to the Sloan GUI found at http://das.sdss.org/DR6-cgi-bin/FOOT.

Usage

    footserver [options] [ra1 dec1  ra2 dec2 ...]
      -f  - input file of coords, one ra,dec per line ('-' for stdin)
      -d        - force decimal output
      -s        - force sexagismal output
      -v        - verbose: see wget output (for debugging)
      -h        - print this usage message and quit
The input can be on the command line or the standard input or from a file, using the -f filename option. The coordinates must be either comma-separated or whitespace separated. The coordinates can be in sexagismal format (RA hours, Dec degrees) or both in floating point degrees. If any one of the input coordinates is in sexagismal format, the output will be entirely so unless the -d option is supplied. The option -s forces the output to be degrees regardless of the input format.

Example 1:

Pairs of coordinates can be input on the command line:
   footserver 12:04:22 10:12:33 16:38:12.2 -1:20:00
outputs
    ra              dec             run     rerun   camcol  field
    -----------     ----------      ----    -----   ------  -----
    12:04:22.08     10:12:33.0      3525       40        4    174
    16:38:12.12     -1:20:00.0         0        0        0      0
and the zeroes in the run, etc. fields denote that the object is not in the Sloan coverage.

Example 2:

A sample file, query, contains the following:
    138.719 +29.3497
    138.888 +29.4622
    138.901 +29.3232
Running the command:
    footserver -d -f query
gernerates the output:
    ra              dec             run     rerun   camcol  field
    ----------      --------        ----    -----   ------  -----
    138.719000      29.34970        4518       40        6     81
    138.719000      29.34970        3900       41        2    114
    138.888000      29.46220        3900       41        2    115
    138.901000      29.32320        4518       40        6     82
    138.901000      29.32320        3900       41        2    115
Without the -d option, the output would be:
    ra              dec             run     rerun   camcol  field
    ----------      ----------      ----    -----   ------  -----
    9:14:52.55      29:20:58.9      4518       40        6     81
    9:14:52.55      29:20:58.9      3900       41        2    114
    9:15:33.12      29:27:43.9      3900       41        2    115
    9:15:36.25      29:19:23.5      4518       40        6     82
    9:15:36.25      29:19:23.5      3900       41        2    115

Example 3:

The footserver program can take input as part of a pipe:
    ok> echo 18:03:10 -10:55:00 | ~/progs/Sloan/footserver -d -f -
    
    ra              dec             run     rerun   camcol  field
    ----------      ---------       ---     -----   ------  -----
    270.791667      -10.91667         0         0        0      0

SDSSQUERY  -  make direct Sloan SQL query           Back to top

The sdssquery program, located in /data/oiropt/bin, is a small shell script wrapper around a Sloan-provided Python script to send an SQL query to the SDSS SkyServer via the Web, returning the output on STDOUT as a Starbase table.

The Skyserver has row and time limits on this kind of Web query. Currently a query taking longer than 10 minutes will be aborted, as will one returning more than 100,000 rows. Also, no more than 60 queries per minute are permitted from any one computer.

Example 1:

The command (split across lines for clarity - the command is a single line):

    sdssquery '
       select ra, dec, type, psfMag_r, psfMag_i
       from PhotoPrimary 
       where type = 6 and  
          objID between 587727177912614921 and 587727177912614940
    ' | 
    justify
which produces:
    ra              dec             type    psfMag_r        psfMag_i 
    -------------   ------------    ----    ---------       ---------
    4.10721167E-3   -11.20992605       6    16.671963       16.471029
    6.99093652E-3   -11.09600821       6    10.826494       14.766943
    0.01242457      -11.09817569       6    23.750692       22.300419
Note that when the SQL query has shell wildcard characters, it will have to be quoted or the characters individually escaped.

Example 2:

The below example demonstrates passing the SQL query in a text file, as well as a sample use of database functions.

If the file 'query' has the following contents:

  select ra, dec, type, petroMag_r, petroMag_i
  from PhotoPrimary 
    where type = dbo.fPhotoType("GALAXY") and  
      objID between 587727177912614921 and 587727177912614940
then the command:
   sdssquery query | justify
will print:
    ra              dec             type    petroMag_r      petroMag_i
    --------------- ------------    ----    ----------      ----------
      2.19374561E-3 -11.21108779       3     21.808626       21.082067
    359.99718839    -11.09709042       3     19.723789       19.228863
      2.48314006E-4 -11.10074393       3     21.412432       20.003176
      0.01382232    -11.09129188       3     28.062342       19.627892
    359.99900278    -11.09956301       3     24.264151       20.487772
      7.35112938E-3 -11.10532238       3     21.843147       21.612478
      0.01313465    -11.09560537       3     21.185026       21.257969
      4.74492335E-3 -11.10250524       3     22.213799       21.227732
      5.17074845E-3 -11.10311999       3     23.016922       20.577419
    359.9997454     -11.09724859       3     21.910898       20.741583
      0.01066068    -11.10371495       3     23.119787       20.838671
      0.01215572    -11.10134416       3     21.81654        20.78879 
      0.01505928    -11.09949988       3     24.35099        23.41531 
      4.43446229E-4 -11.09211681       3     27.203613       20.465734
      3.96360601E-3 -11.08906882       3     25.067053       24.315235
Note that only the first query in a file is processed.

Example 3:

Type   sdssquery -h    and see more options:
    >> sqlcl << command line query tool by Tamas Budavari 
    -
    Usage: sqlcl [options] sqlfile(s)
    
    Options:
            -s url     : URL with the ASP interface (default: pha)
            -f fmt     : set output format (html    xml     csv - default: csv)
            -q query   : specify query on the command line
            -l         : skip first line of output with column names
            -v         : verbose mode dumps settings in header
            -h         : show this message
Note that sdssquery assumes the -q option if the argument on the command line is not a file.

Back to top