In [4]:
import pyfits
import pandas
import statsmodels
import mdp
import numpy as np
# pylab's already imported...
import agpy # need PCA tools
import aplpy
cubes.py requires pywcs for some subimage_integ,aper_wordl2pix,getspec, and coords_in_image

In [5]:
matplotlib.rcParams['figure.figsize'] = (12,7)
matplotlib.rcParams['savefig.dpi'] = 120
In [6]:
D = pyfits.getdata('/Users/adam/work/fastphot/TEST.fits')
RF = pyfits.getdata('/Users/adam/work/fastphot/Robberto_Found.fits')
In [7]:
D = D.astype('float')
DF = pandas.DataFrame(D)
cov = DF.cov()
In [8]:
imshow(cov)
Out[8]:
<matplotlib.image.AxesImage at 0x106285ad0>
In [9]:
imshow(DF)
Out[9]:
<matplotlib.image.AxesImage at 0x1062c0bd0>
In [10]:
# above shows that the first couple observations were wrong - maybe focusing?  Maybe off-source?  Probably off source, and just by chance overlapped enough to get included
D = D[:,30:] # exclude first 30 stars
# first observing block - correlations are more clear here...
firstchunk = D[18:516,:] # first dim is time
In [11]:
# filter out sections with too few data points
OKfirst = np.isnan(firstchunk).sum(axis=0) < 20
firstchunk_filtered = firstchunk[:,OKfirst]
FCF = pandas.DataFrame(firstchunk_filtered)
FCFcov = FCF.cov()
# filter the RA/Dec data (etc) als0
RFfirst = RF[30:][OKfirst]
In [12]:
imshow(log10(FCFcov))
Out[12]:
<matplotlib.image.AxesImage at 0x1085f8050>
In [13]:
# PCA subtraction - remove 0'th component
efuncarr,covmat,evals,evects = agpy.PCA_tools.efuncs(np.nan_to_num(firstchunk_filtered),return_others=True)
efuncarr_blanked = efuncarr.copy()
efuncarr_blanked[:,0] = 0
firstchunk_subd = np.inner(efuncarr_blanked,evects)
In [14]:
figure(); imshow(log10(firstchunk_subd.real))
# there is a clear difference between first 300ish and the rest!
figure(); imshow(evects.real);
figure(); semilogy(evals.real)
Out[14]:
[<matplotlib.lines.Line2D at 0x10ce1df50>]