SEGUE Getting Started

Getting Started:
Accessing the SEGUE spectra and associated imaging

Here are some walk-through examples of how to access the SEGUE spectra and associated imaging for your research.

Example 1: Stellar Parameters of Globular Cluster stars

Example 2: List of SEGUE Plates

Example 3: High Confidence Low metal stars

Example 4: Photometry connected to plate centers SDSS and SEGUE

Example 5: Matching to Target photometry


Example 1: Stellar Parameters of Globular Cluster stars

This example demonstrates how to check the parameters of some SEGUE spectra of 'known objects' against values found in the literature. We will check the Radial Velocities, Metalicities [Fe/H], and stellar surface gravities of some stars in the Hercules Globular Cluster (M 13 = NGC6205) with their cataloged values in the W. Harris catalog:
	To select star around M13 we need to know the position of
	M13 on the sky, which is (alpha,delta) = (16 41 41.5 , +36 27 37)
	or (l,b) = (59.01,40.91).  
	We convert the H:M:S, D:M:S notation for (alpha,delta) (J2000)
	to decimal degrees for the database:
	(alpha,delta) = (16:41:41.5 , +36:27:37) = (250.42292,36.46028)

	Let's use the stellar parameters table in the DR6 database to
	select stars with spectra near (within 1 degree, globular
	clusters have diameter generally much smaller than 1 degree) of this 
	position on the sky.

	We recommend the CASJOBS interface for SQL database searches 
        of the SDSS/SEGUE data.All who are interested may sign up for 
        a free account under CASJOBs. CASJOBS has the all the advantages 
        of the regular skyserver SQL ASTRO along with a 'batch processing' 
        system for submitting long (up to 8 hours, with up to 500MB worth of 
        output) and complex queries to the database server for later retrieval 
	and cross-reference (through the MyDB system of user databases
	with intermediate results).  The output of CASJOBS queries may
	be downloaded to your home machine in CSV (comma-separated-value)
	ASCII text file format for uploading to EXCEL or further manipulation
	and plotting by the software package of your choice.

	The CASJOBS interface has on its 'Query' page a 'Context' menu,
	which indicates the database you will be searching in.
	You should use the 'DR6' context. This, by default, searches
	the 'BESTDR6' database which contains the SDSS imaging tables
	and the SDSS and SEGUE spectroscopic catalog tables.
	There is additionally a database called 'SEGUEDR6' which contains
	imaging catalogs for areas of the SEGUE Footprint not in the 
        regular SDSS survey Footprint.

	If you wish to determine whether or not a specific coordinate
	is in either the SDSSDR6 or SEGUEDR6 footprint,
	you may feed a list of (RA,DEC) coordinates into the respective 
        SDSS FOOT or Supplemental (includes SEGUE, M31 and Per-Pic) 
        FOOT servers.

The names of the key tables you will be interested in searching for SEGUE catalog information are:
	Context  tablename (case insensitive) what
	-----------------------------
	DR6	sppParams   Radial Velocities, 
			    de-reddened PSF magnitudes and colors, 
			    '[Fe/H]' metalicity estimates,
			    log g surface gravity indictors (used to
					tell a Red Giant from a Red Dwarf)
			    effective temperature (correlated with color)
			    proper motion information on star,
			    stellar classification information

	DR6     Star	    Full photometric information for all point
			    sources in the SDSS footprint.
			    Includes ugriz PSF magnitudes,
			    reddening information,  (colors may be calculated)
			    RA,DEC position information


	DR6    SegueDR6..star	Full photometric information for
			 	all point sources in the SEGUE footprint.
				
   SEGUEDR6    Star		Another way to access the seguedr6..star
				table. 

	DR6	SpecObjAll	Spectroscopic information for objects in
				SDSS+SEGUE.  Note that the subset table
				'SpecObj' doesn't contain SEGUE spectra,
				only 'main survey' SDSS spectra (mostly
				galaxies).  

	DR6    PlateX		Metadata information about plates (which
				contain 640 spectra each) in the  SDSS+SEGUE
				surveys.  The information here (specificially 
				the 'programname' field) can be used to 
				distinguish SDSS (galaxy+qso+star) plates 
				from SEGUE (all star) plates.

	DR6    PhotoObj        Full photometric object information for 
			       all primary (i.e. non-duplicate) sources 
				(including extended objects such as galaxies), 
				in the DR6 SDSS footprint, a superset of
				'star'.

	DR6    PhotoObjAll     Full photometric information for all sources
				(including duplicates) in the DR6 footprint.
				A superset of 'photoobj'.

	
Let's return to the example of searching for SEGUE information about stars in the globular cluster M13.
	We'll select all stars within about 1 degree
	of the known center of the cluster at (ra,dec) [J2000] = 
		(250.42292, 36.46028).

	The RA coordinate has a cos(DEC) 'shrinkage' in it,
	so to get stars in a box 1 degree on a side, we wish
	to search +/- 0.5/cos(DEC) degrees away in RA, but
	the standard +/- 0.5 degrees away in DEC:

Thus cut and paste this query to the DR6 context of Casjobs 'query' window:

	select count(*) from sppParams where
	ra between 250.42292-cos(36.46*3.14159/180) 
		and 250.42292+cos(36.46*3.14159/180) 
	and dec between 36.46 -0.5 and 36.46 + 0.5

and hit the 'Quick' button. In a few seconds it should return a number like '1044', the number of stars which meet these conditions. You may return all the known information, including the 12 measures of [Fe/H] and the 9 measures of log g for these stars with a query like:
	select * from sppParams where
        ra between 250.42292-cos(36.46*3.14159/180) 
                and 250.42292+cos(36.46*3.14159/180) 
        and dec between 36.46 -0.5 and 36.46 + 0.5

However, that table is a bit hard to parse. Instead, let's select specific columns we wish to return from the complete list of all columns in the sppParams table.

We'll also restrict to objects which have 'good quality' measurements of [Fe/H] (we pick the 'refined' measure of [Fe/H] named: 'fehr'), by requiring that the error (fehrerr) on the measure is greater than 0 but less than 0.7 dex. We'll also restrict to objects with errors (rvaerr) on their radial velocity (rva) of 20 km/s or less:

	select plate,mjd,fiberid,brun,brerun,bcamcol,bfield,bobj,
	       rva,rvaerr,fehr,fehrerr,fehrn,logga,loggaerr,loggan,
	       fehspectype,sptypea,hammersptype,flag,g0,umg0,gmr0,
	       ra,dec,l,b,chiHK,chiGband,chiMg,teffa,teffaerr from sppParams
	    where
		 ra between 250.42292-cos(36.46*3.14159/180)
                and 250.42292+cos(36.46*3.14159/180)
	        and dec between 36.46 -0.5 and 36.46 + 0.5
		and fehrerr between 0.01 and 0.7 
		and rvaerr between 0.01 and 20

Instead of entering this as a 'Quick' query, hit the 'Submit' button instead. Though the query only takes a few seconds to run, this will save the output of your query as a named table in your 'MyDB', for instance MyTable_21 (your exact table name will vary depending on your query history, and it may be manually named to whatever you like).

After the query runs (hit 'History' repeatedly to check if it succeeded, you may also choose receive an email when the query is done), go to 'MyDB' and find your 'MyTable_21'. It should have about 699 rows and take up 472 Kbytes of space in your MyDB area.

Click on the table and select 'Download', then click on 'Go' to reformat your table as a 'CSV' file. Then go to 'Output' and click repeatedly until the reformatted table is available for 'Download'. Click 'Download' to put the table on your local box. Now you may use a variety of tools (Excel spreadsheet, AWK, TCL) to manipulate and plot your data.

The columns of your output file (based on what you 'select'ed above) are:

	 0 plate
	 1 mjd
	 2 fiberid
	 3 brun
	 4 brerun
	 5 bcamcol
	 6 bfield
	 7 bobj
         8 rva
	 9 rvaerr
	 10 fehr
	 11 fehrerr
	 12 fehrn
	 13 logga
	 14 loggaerr
	 15 loggan
         16 fehspectype
	 17 sptypea
	 18 hammersptype
	 19 flag 
	 20 g0
	 21 umg0
	 22 gmr0
         23 ra
	 24 dec
	 25 l
	 26 b
	 27 chiHK
	 28 chiGband
	 29 chiMg 
	 30 teffa
	 31 teffaerr

Here are some plots you should be able to easily reproduce:

	1. Plot of gmr0 on the X-axis (limits -1 to 2.0) vs. g0 on
		the Y-axis (limits 21 to 12).
	   This is a classical Color Magnitude Diagram

		You will notice that the 'top' of this diagram is not
		populated, i.e. the Red Giant Branch. Photometry of 
		these stars saturated the regular SDSS 2.5m imaging camera
		(stars brighter than about with g=14 do this).

		We have obtained limited amounts of spectra of such stars,
		however their magnitudes are not cataloged in all cases
		(see example #XXX, below).


	2.  Plot a histogram of rva, the radial velocity, with limits
		from about -500 to 500 km/s.  
		The catalog heliocentric RV of M13 is
			-245.6 km/s, does your plot look like this.


	Based on the above plot number of of RVs, let's subselect only stars 
	near the RV peak of the cluster, say with RV between -300 and -200 km/s.  
	Then histogram the Metalicities (histogram fehr from -4 to 0) of these:

	3. Do you get something like this?

	Let's look at the surface gravity now.  Subselect those stars with RV between
	-300 and -200 that have small errors on the surface gravity, i.e. 
	loggerr between 0 and 0.5.  Then make a faux Hertzsprung-Russell diagram
	for the cluster by plotting Teff (teffa) on the x axis from 10000 to 3000 (K) and
	log g (Luminosity indicator) on the y axis from 6 to 0.

	4. This color vs. surface gravity plot for a cluster is one 
	step closer to a 'physical' Hertzsprung-Russell diagram (usually plotted as 
	Teff vs. Luminosity) as opposed 
	to an observed parameter (color vs. magnitude) diagram.

	We see from this plot that some red giant branch stars have appeared. These had
	non-SEGUE photometry and so their g, g-r values were 0 in the inital selection.
	We may be able to find some indication of their magnitudes by looking at other
	magnitude indicators available.

	There are also a few BHB stars apparent at the hot (high Teff) left edge of the
	diagram. Let's examine the individual spectra for these stars:

In particular, let's look at examples of a K-giant, and an F turnoff star.

To find them, even though we don't know the g-r, g for the brighter objects, let's select on Teff, log g.

K-giant:

	select teffa between 5000 and 5200, log g between 1.8 and 2,
	RV between -300 and -200, [Fe/H] between -1.8 and -1.3,
	extract the plate,mjd,fiberid triplet.

	There are two objects selected:
	plate/mjd/fiberid = 2174/53521/167
	and
	plate/mjd/fiberid = 2255/53565/518

	Browse these spectra by going to the link for the SEGUE DR6 plate list 
	and (scrolling down to the globular cluster section of plates near 
	the bottom) click on the link for plate 2174, (mjd = 53521) then in 
	the menu on the left, click on the link for fiberid = 167.  Nice spectrum!

	Note the weak Mg triplet at 5100-5200A, indicating a low surface gravity
	of a giant star.

	Also note that the photometry for this star is a 'place-holder' (it's 
	bogus). The photo catalogs info for this object, with run =0 indicates a 
	manually selected target not deblended or saturated in this crowded field 
	by the photo software.  Other information on this well-known object 
	(an M13 giant branch star) may be found in the literature by using the 
	RA,DEC information presented.

	Also examine the bright red giant on plate 2255, fiberid= 518.
	The spectrum of this object is clearly a red giant, with very 
	weak Mg 5100-5200, however,the astrometry on this object is 
	special, it is a 'shifted' plate, used to obtain spectra of 
	very bright stars. Thus, don't trust the RA,DEC for this star, 
	for reference in the literature until we post an updated version 
	(plate 2255 is the only one with this issue in DR6 SEGUE).

F-turnoff:


	select gmr0 between 0.2 and 0.3, log g between 1.8 and 2,
	RV between -300 and -200, [Fe/H] between -1.8 and -1.3,
	extract the plate,mjd,fiberid triplet. There are about 18,
	so sort by mag, take the brightest,
	which is:

	2185/53532/500 = plate/mjd/fiberid.
	Examine plate 2185, fiberid = 500. 
	It's a blue thing, with narrow balmer lines, pretty typical (early?) F star.

	If you'd like to grab more than just the picture of a spectrum, 
	but are interested in examining the spectrum in more detail,
	you can fetch this object from the DR6 DAS, with a 'wget' style 
	command like so:

	wget http://das.sdss.org/dr6/data/spectro/1d_25/2185/1d/spSpec-53532-2185-500.fit

	(you may grab it in your browser and download it, an rsync 
	interface is available for bulk downloads).

	Note that the plate number is padded with leading 0's to 
	four places and the fiberid to three places, thus 371/52078/1 
	would be: 

	wget http://das.sdss.org/dr6/data/spectro/1d_25/0371/1d/spSpec-52078-0371-001.fit


	Any available individual spectrum may be so obtained.


	This FITS file may be read into IRAF or any other imaging processing program.
	The data model for the contents of the spSpec files is given here.

	If you wish to retrieve all spectra for a given plate in one big FITS file,
	they are available from the DAS as spPlate* files.

	For plate 2185, this wget will retrieve the (typically 60MB) file:

	wget http://das.sdss.org/dr6/data/spectro/2d_25/2185/spPlate-2185-53532.fits

	The data model for spPlate files, in order that you may examine them
	with IRAF or another processing package is here.

	Any other plate may be retrieved the same way.

Example 2: List of SEGUE Plates

A query to list all SEGUE plates with their (RA,DEC) centers in the CAS database:

	select plate,mjd,ra,dec,programname from plateX where programname like 'segue%'

	

Example 3: High Confidence Low metal stars

A query to select objects with very high quality spectra that have very low estimated metalicity ([Fe/H] less than one-thousandth of solar).

We use the chiHK, chiMg, chiGband indicators and require that they give values between 0 and 2; also that the fehr indicator has an error of no more than 0.5 and that the number of different reliably [Fe/H] estimation methods (fehrn) is greater than 3 and that the S/N ratio of the object is greater than 20.

	select plate,mjd,fiberid,flag,ra,dec,g0,umg0,gmr0,rmi0,imz0,
		fehr,fehrerr,fehrn,rva,rvaerr,chihk,chigband,chimg,sna from
	   sppParams where 
		fehr between -9 and -3 and 
		chihk between 0.01 and 2 and 
		chimg between 0.01 and 2 and 
		chigband between 0.01 and 2 and 
		sna > 20 and fehrn > 3 and fehrerr between 0.01 and 0.5
	
Four stars are returned in DR6, all with [Fe/H] ~ -3:
		plate/mjd/fiberid RA  (J2000)   DEC
		--------------------------------------------
		2401/53768/322 138.3556061	31.0887051
		1711/53535/285 219.1344604	9.3087473
		1049/52751/126 226.1047211	46.3891373	
		2327/53710/166 9.0451527	7.1922379
	

Only the first and last are SEGUE targeted stars, the other two are main Survey targets (for which the sppParams table is also available).

To browse these stars, use the skyserver interface, or download the spSpec file and examine the spectra with IRAF.

i.e. for the second spectrum
	wget http://das.sdss.org/dr6/data/spectro/1d_25/1711/1d/spSpec-53535-1711-285.fit

A skyserver link to these objects looks like the following:
http://cas.sdss.org/astro/en/tools/explore/obj.asp?ra=219.1344&dec=9.308

Click on all spectra and the spectrum id for a picture of the spectrum. This uses the RA DEC to look up the objects in the skyserver; you may also lookup by plate/mjd/fiberid.


Example 4: Photometry connected to plate centers SDSS and SEGUE

It is often desirable to select stars from an area of sky where not every star has a spectrum. The ugriz photometry alone for a deep sample of stars is often enough to do significant Galactic Structure science. In addition, it is often desirable to determine the 'selection function' of a set of spectra determined with some possibly not well known target selection algorithm. For this reason one often wishes to select imaging from an area of sky where one has spectra, including objects for which no spectra exist in the same part of sky.

All of the spectra reside in the CAS specobjall database, including both SDSS main survey footprint spectra and SEGUE spectra (along with assorted other spectra).

Due to the difficulty in processing and interpreting highly reddened low-latitude, crowded stellar field imaging with the standard SDSS photo pipeline (which was designed for galaxy photometry in uncrowded fields), the SEGUE imaging for DR6 has been segregated into its own database context, called 'SEGUEDR6'. The imaging tables in SEGUEDR6 (namely 'star', 'photoObjall' and 'photoObj') are the same as in the regular DR6 context (also called the BESTDR6 database), however the area of sky covered differs.

In order to match a SEGUE spectrum with its full photometric information (i.e. fields beyond that in the sppParams table, which is often but not always enough), one must check both the SEGUEDR6 imaging database and the SDSS DR6 imaging database in order to be certain that one can find the matching imaging.

The 'star' tables in SEGUEDR6 and DR6 are disjoint, that is, they contain no objects in common. The 'photoobjall' tables in SEGUEDR6 and DR6 are not quite disjoint, there is some overlap between the two imaging surveys. Objects in the SEGUEDR6 database which overlapped a 'primary' imaging scan in the main DR6 database were marked 'secondary' to allow avoiding duplicate objects when a union of the two databases was searched.

In addition, because of the way the 'targetid' is recorded without first field information two additional queries are required to match possible first field (of a given imaging segment) information to a given spectrum.

Thus, to match a SEGUE spectrum from the specobjall table with its corresponding photometric information, one should take a union of the following four queries:


        select top 10 s.plate,s.mjd,s.fiberid,sp.psfmag_g from specobjall s,
        seguedr6.photoobjall sp where dbo.frun(targetid) in
        (select run from seguedr6.segment where camcol = 1) and
        s.targetid+ 576460752303423488    = sp.objid

        select top 10 s.plate,s.mjd,s.fiberid,sp.psfmag_g from specobjall s,
        photoobjall sp where dbo.frun(targetid) in
        (select run from segment where camcol = 1) and
        s.targetid+ 576460752303423488    = sp.objid

        select top 10 s.plate,s.mjd,s.fiberid,sp.psfmag_g from specobjall s,
	seguedr6.photoobjall sp where dbo.frun(targetid) in
	(select run from seguedr6.segment where camcol = 1) and
	s.targetid+ 576460752303423488+268435456    = sp.objid

	select top 10 s.plate,s.mjd,s.fiberid,sp.psfmag_g from specobjall s,
	photoobjall sp where dbo.frun(targetid) in
	(select run from segment where camcol = 1) and
	s.targetid+ 576460752303423488+268435456    = sp.objid

To query for imaging information around a given (ra,dec), one may determine whether or not that coordinate is in the SDSS (main) DR6 database or in the SEGUE database, or query both and take the union.

	For instance, the plate 1880 has imaging data from stripe 1220,
	stripe 1220 is an exclusively SEGUE stripe, and thus its corresponding
	imaging data will be in the SEGUEDR6..star database rather than
	the DR6..star database.

	Stripe 9-44, 76,82 and 86 are Main survey SDSS Footprint stripes.
	Imaging associated with these spectra is in the main DR6..star
	database.

	Stripes 72,79, and stripe greater than 1000 are SEGUE stripes.
	Imaging for these spectra is in the SEGUEDR6..star database.

	To find objects in the plate 1880 field, centered at
	(RA,DEC) = (358.26,36.40) 
	one may perform one query as follows to select
	all stellar photometry:

	Query A: (done on the DR6 context):

	select run,rerun,camcol,field,obj,ra,dec,
		psfmag_u,psfmag_g,psfmag_r,psfmag_i,psfmag_z,extinction_u,
		extinction_g,extinction_r,extinction_i,extinction_z
           from star 
	    where ra between 358.26-1.5/cos(36.4*3.14159/180) and 358.26+1.5/cos(36.4*3.14159/180) 
		and dec between 36.40 -1.5 and 36.4 + 1.5
		and psfmag_g < 22
		

	Returns 0 objects


	Query B: (done in the SEGUEDR6 context, or with the SEGUEDR6.. prefix)

	select run,rerun,camcol,field,obj,ra,dec,
		psfmag_u,psfmag_g,psfmag_r,psfmag_i,psfmag_z,extinction_u,
		extinction_g,extinction_r,extinction_i,extinction_z
           from SEGUEDR6..star 
	    where ra between 358.26-1.5/cos(36.4*3.14159/180) and 358.26+1.5/cos(36.4*3.14159/180) 
		and dec between 36.40 -1.5 and 36.4 + 1.5
		and psfmag_g < 22
		
	You should submit this 2nd job to the SEGUEDR6 context. If
	you submit this job to the DR6 context, it will return
	0 objects unless you replace 'from star' with 'from SEGUEDR6..star'.
	This query returns a large number (54,750) objects, and you should
	'Submit' it rather than running it as a 'Quick' query.

	Once you download the output you may further subselect to
	only get objects within 1.49 degrees of (ra,dec) = (358.26,36.4)
	and you may with to add in cuts on color or magnitude,
	for instance, throw out objects fainter than 20.5, which
	is the faint limit of the spectrscopic sample.
	
	Then, if you are, for instance, examining spectroscopic completeness
	of the F subdwarf sample, you may further select objects with
	(g-r)_0 between 0.1 and 0.4 and compare the density of photometric
	objects as a function of magnitude with the spectroscopic sample
	of F stars on plates 1880 and 1881.

	In this fashion, one may obtain photometric information for	
	all SEGUE plates.  And dervive empirical selection functions
	based on the photometry with the same color cuts as the spectroscopy.

Example 5: Matching to Target photometry

This is best done in a two step process, where one first 'uploads' a set of id,ra,dec triplets for objects in question into a MyDb, say mytable_14 in this example.

Then one connects to the TARGETDR6 context and matches the target photometry information to each id,ra,dec in the list, using a position match.

SELECT myid, ra,dec, dbo.fGetNearestObjIdEqtype(ra,dec,1.2,6) as objId into #x
FROM mydb.mytable_14  

select n.myid,n.ra as inra,n.dec as indec,s.objid,s.run,s.rerun,s.camcol,s.field
,s.obj,s.ra,s.dec,s.psfmag_u,s.psfmag_g,s.psfmag_r,s.psfmag_i,s.psfmag_z ,s.type
from star s,
#x as N where s.objid = n.objid