you can access the sql query code, the data retrieved, the python codes used and the ipython notebooks mentioned here with on the github reposity here.
!ls
# the files in the github repository are
gal_coordinates_plot.py MyTable_rahul.poruri.csv quasar_coordinates.ipynb quasars_coordinates_galactic.png quasars_coordinates_ra,dec.png sdss_coverage.jpg sql_query
select
plateX.plate, plateX.mjd,
PhotoPrimary.ra, PhotoPrimary.dec, PhotoPrimary.l, PhotoPrimary.b, PhotoPrimary.ObjID,
specObj.fiberID, specObj.z into mydb.MyTable from PhotoPrimary, specObj, plateX
where
specObj.bestObjid = PhotoPrimary.ObjID
AND plateX.plateID = specObj.plateID
AND specObj.class = 'qso'
AND specObj.zWarning = 0
AND PhotoPrimary.modelMag_u < 22.3
AND PhotoPrimary.modelMag_g < 22.6
AND PhotoPrimary.modelMag_r < 22.7
AND PhotoPrimary.modelMag_i < 22.4
AND PhotoPrimary.modelMag_z < 20.5
you can submit the sql query here at the SDSS sql query page.
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
data = [line.split(',') for line in open('MyTable_rahul.poruri.csv')]
# a .csv file has values or columns seperated by commas
# the data format in the .csv file
print data[0]
print data[1]
['plate', 'mjd', 'ra', 'dec', 'l', 'b', 'ObjID', 'fiberID', 'z\n'] ['339', '51692', '196.240031499488', '-1.23006495320075', '310.018771055342', '61.4554170817091', '1237648702972100785', '413', '0.4322039\n']
#ra = np.zeros(len(data))
#dec = np.zeros(len(data))
ra, dec = [], []
for i in range(1,len(data)):
temp = float(data[i][2])
temp1 = float(data[i][3])
ra.append(temp)
dec.append(temp1)
#ra[i] = float(temp)
#dec[i] = float(temp1)
ra = np.asarray(ra)
dec = np.asarray(dec)
ra = (ra-180)*(np.pi/180)
dec = dec*(np.pi/180)
plt.subplot(111,projection='aitoff')
# aitoff, mollweide and hammer are 3 of the options
plt.grid(True)
plt.scatter(ra,dec,s=5)
plt.title('Quasars from the SDSS DR10')
plt.xlabel('ra')
plt.ylabel('dec')
<matplotlib.text.Text at 0xab6e0a4c>
for a brief theory on how the conversion between equatorial and galactic coordinates works, refer here
#ra = np.zeros(len(data))
#dec = np.zeros(len(data))
l, b = [], []
for i in range(1,len(data)):
temp = float(data[i][4])
temp1 = float(data[i][5])
l.append(temp)
b.append(temp1)
#ra[i] = float(temp)
#dec[i] = float(temp1)
b = np.asarray(b)
l = np.asarray(l)
l = (l-180)*(np.pi/180)
b = b*(np.pi/180)
plt.subplot(111,projection='aitoff')
plt.grid(True)
plt.scatter(l,b,s=5)
plt.title('Quasars from the SDSS DR10')
plt.xlabel('galactic longitude')
plt.ylabel('galactic latitude')
<matplotlib.text.Text at 0xab6808ec>
gnuplot> set term wxt
gnuplot> set datafile separator ','
gnuplot> plot 'MyTable_rahul.poruri.csv' u 3:4 or 5:6 for a simple pllot of (ra, dec) or (l, b).
we figure out how to do projections in gnuplot!