In [1]:
from astroquery.irsa import Irsa
import astropy.units as u
import numpy as np


WARNING: ConfigurationDefaultMissingWarning: Requested default configuration file /Applications/Ureka/variants/common/lib/python2.7/site-packages/astroquery/astroquery.cfg is not a file. Cannot install default profile. If you are importing from source, this is expected. [astroquery]
/Applications/Ureka/variants/common/lib/python2.7/site-packages/astroquery/__init__.py:132: UserWarning: You are using an 'old' version of astropy prior to the change that made all units singular.  astropy is being monkeypatched such that degrees and degree are both allow and hours and hour are both allowed.  This is NOT normal astropy behavior.
  warn("You are using an 'old' version of astropy prior to the change "

In [38]:
Irsa.ROW_LIMIT = 100000 # value of new row limit here.
# Irsa.query_region(catalog='wise_allsky_4band_p3as_psd',spatial='All-Sky')

table1 = Irsa.query_region("01h41m58.23s -46d33m57.4s", catalog='wise_allwise_p3as_psd', spatial='Box', width=1 * u.degree)
#add 1 degree = 4 min
table2 = Irsa.query_region("01h45m58.23s -46d33m57.4s", catalog='wise_allwise_p3as_psd', spatial='Box', width=1 * u.degree)
#subtract 1 degree = 4 min
table3 = Irsa.query_region("01h37m58.23s -46d33m57.4s", catalog='wise_allwise_p3as_psd', spatial='Box', width=1 * u.degree)

print len(table1),len(table2),len(table3)


16248 15709 17022

In [69]:
from astropy.table import vstack
table = vstack([table1,table2,table3])
len(table)


Out[69]:
48979

In [54]:
flags = []
for l1 in 'AB':
    for l2 in 'AB':
        for l3 in 'ABC':
            for l4 in 'ABC':
                flags.append(l1+l2+l3+l4)

In [70]:
from astropy.io import ascii
ascii.write(table, output='/Users/kelle/Desktop/wise.csv', delimiter=',')

In [3]:
from astropy.io import ascii
table = ascii.read('/Users/kelle/Desktop/wise.csv')

In [4]:
ph_qual = np.zeros(len(table)).astype(bool)
for flags in [l1+l2+l3+l4 for l1 in 'AB' for l2 in 'AB' for l3 in 'ABC' for l4 in 'ABC']: # same as cell above
    ph_qual |= table["ph_qual"] == flags
print(sum(ph_qual))


873

In [5]:
good_data_index, = np.where( (table["cc_flags"]=='0000') & (table["ext_flg"]==0) & ph_qual) 
len(good_data_index)


Out[5]:
785

In [6]:
good_data = table[good_data_index]

In [36]:
good_data.show_in_browser()


Out[36]:
<open file '<fdopen>', mode 'w+b' at 0x102ed6810>

Exercise 0


In [7]:
import matplotlib.pyplot as plt
import matplotlib
%pylab inline


Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].
For more information, type 'help(pylab)'.

In [23]:
w1 = good_data['w1mpro'].astype(float)
w2 = good_data['w2mpro'].astype(float)
w3 = good_data['w3mpro'].astype(float)
w4 = good_data['w4mpro'].astype(float)

In [24]:
plt.hist(w1)
plt.figure()
plt.hist(w2)
plt.figure()
plt.hist(w3)
plt.figure()
plt.hist(w4)


Out[24]:
(array([   2.,    0.,    0.,    0.,    7.,   16.,   29.,   72.,  273.,  386.]),
 array([ 4.355,  4.852,  5.349,  5.846,  6.343,  6.84 ,  7.337,  7.834,
        8.331,  8.828,  9.325]),
 <a list of 10 Patch objects>)

In [ ]:


In [28]:
color1=w1-w2
plt.hist(color1)


Out[28]:
(array([  22.,   72.,  227.,  216.,   98.,   64.,   48.,   17.,   10.,   11.]),
 array([-0.333 , -0.0959,  0.1412,  0.3783,  0.6154,  0.8525,  1.0896,
        1.3267,  1.5638,  1.8009,  2.038 ]),
 <a list of 10 Patch objects>)

In [30]:
mean_color1 = np.mean(color1)
var_color1 = np.var(color1)

In [34]:
from scipy.stats import norm

In [31]:
def gaussian (x,mean,var):
    return 1/np.sqrt(2*np.pi*var)*np.exp(-0.5*(x-mean)**2/var)

In [35]:
n,bins,bluh = plt.hist(color1,normed=True)
plt.plot(bins,gaussian(bins,mean_color1,var_color1))
plt.plot(bins,norm.pdf(bins,mean_color1,np.sqrt(var_color1)))


Out[35]:
[<matplotlib.lines.Line2D at 0x108973bd0>]

In [37]:
color2=w1-w3
mean_color2 = np.mean(color2)
var_color2 = np.var(color2)
n,bins,bluh = plt.hist(color2,normed=True)
plt.plot(bins,norm.pdf(bins,mean_color2,np.sqrt(var_color2)))


Out[37]:
[<matplotlib.lines.Line2D at 0x108acb050>]

In [38]:
color3=w1-w4
mean_color3 = np.mean(color3)
var_color3 = np.var(color3)
n,bins,bluh = plt.hist(color3,normed=True)
plt.plot(bins,norm.pdf(bins,mean_color3,np.sqrt(var_color3)))


Out[38]:
[<matplotlib.lines.Line2D at 0x108b10e50>]

In [ ]: