In [2]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%config InlineBackend.figure_format = 'retina'  # linux only
%matplotlib inline
In [16]:
w = .02
d = .7
t = w/d*180/np.pi
In [17]:
t
Out[17]:
1.6370222718023522
In [2]:
from IPython.display import Image
Image('20191023_155351a.jpg')
Out[2]:

Didn't get a photo of the calculation in degrees. Answer (number of square degrees in the whole sky) is $$\frac{(360)^2}{\pi}$$

Note added after class

I discovered there's another API that allows us to do everything within Python:

In [1]:
import requests
from io import StringIO
import pandas as pd

q = '''SELECT TOP 10
   p.objid,p.ra,p.dec,p.u,p.g,p.r,p.i,p.z,
   s.specobjid, s.class, s.z as redshift
FROM PhotoObj AS p
   JOIN SpecObj AS s ON s.bestobjid = p.objid
WHERE 
   p.ra between 210 and 211.41 and
   p.dec between 10 and 11.39
'''
url = 'http://skyserver.sdss.org/dr14/SkyServerWS/SearchTools/SqlSearch?cmd={}&format=csv'.format(q.replace(' ','%20'))
r = requests.get(url)
if r.status_code==200:
    csv = StringIO(r.text)
    df = pd.read_csv(csv,skiprows=1)
    display(df.head())
else:
    print('Unsuccessful :-(')
objid ra dec u g r i z specobjid class redshift
0 1237662198275964990 210.062512 10.675982 24.63469 21.61024 20.16959 19.42505 21.37176 6136282960704282624 GALAXY 0.231328
1 1237662198275965094 210.040437 10.701546 20.77148 19.86950 19.82795 19.80578 19.45640 6130528116861280256 QSO 2.429156
2 1237662198275965097 210.032363 10.600976 18.83063 17.93813 17.42541 17.03312 16.88778 1917482646758254592 GALAXY 0.083846
3 1237662198275965121 210.056922 10.536011 19.45395 19.28237 19.02846 19.00387 18.74313 1917489518705928192 QSO 0.964885
4 1237662198275965156 210.135966 10.630947 19.02458 17.95087 17.55897 17.31828 17.05492 1917482097002440704 GALAXY 0.039221
In [21]:
df = pd.read_csv('Skyserver_SQL10_23_2019_3_39_44_PM.csv', skiprows=1)
len(df)
df.head()
Out[21]:
objid ra dec u g r i z run rerun camcol field specobjid class redshift plate mjd fiberid
0 1237661949191651545 210.236163 10.775909 22.08275 21.45550 20.57958 19.69971 19.21028 3836 301 2 406 6136274164611260416 GALAXY 0.772345 5450 55986 435
1 1237661949191586869 210.021155 10.808928 24.04676 22.70465 21.22926 19.91845 19.69853 3836 301 2 405 6130526467593838592 GALAXY 0.630324 5445 55987 5
2 1237661949191587017 210.112843 10.796653 22.82343 23.66406 21.07325 19.84088 19.18587 3836 301 2 405 6130527017349652480 GALAXY 0.739999 5445 55987 7
3 1237661949191587034 210.116243 10.727700 23.46184 22.19988 20.42217 19.38699 18.97184 3836 301 2 405 6130525917838024704 GALAXY 0.624173 5445 55987 3
4 1237661949191651520 210.196356 10.853605 19.25913 17.86728 17.18836 16.84309 16.64900 3836 301 2 406 1917482371880347648 GALAXY 0.102109 1703 53799 272
In [22]:
df['class'].value_counts()
Out[22]:
GALAXY    456
QSO        71
STAR       61
Name: class, dtype: int64
In [24]:
plt.subplot(111,aspect=1/np.cos(10*np.pi/180))
plt.scatter( df['ra'], df['dec'] );