#fig = plt.figure()
#ax = fig.add_subplot(111)
#ax.plot(jd, xpos,'k.')
#ax.plot(jd, ypos,'k.',color='red')
#plt.show()

Corotcurve = 2*pi*amps*widths**2
#need to convert to Jy: curve*wvlrange*aveE/(1Hz*intTime*Area)

fwhm = 2*np.sqrt(2*np.log(2))*widths#pixels
#fwhm = 0.5*fwhm #arcsec
#fwhm = widths
corotWidths = fwhm

CorotmeanXpos = utils.mean_filterNaN(xpos,size=7)
CorotmeanYpos = utils.mean_filterNaN(ypos,size=7)
#jd = jd[curve<=500]
#curve = curve[curve<=500]
#jd = jd[curve>=100]
#curve = curve[curve>=100]


####LOAD COMPANION LIGHT CURVE######
param = readDict()
param.read_from_file('corot18Compparams.dict')

FileName = param['npzLoadFitFile']
FramesPerFile = param['FramesPerFile']
print FramesPerFile
TotalNumFiles = param['TotalNumFiles']
ax = fig.add_subplot(211)
ax2 = fig.add_subplot(212)
curve = amps*widths**2
#curve /= np.median(curve)
#amps /= np.median(amps)
x = np.arange(0,360*30,30)
#xpos/=np.median(xpos)
#ypos/=np.median(ypos)

fwhm = 2*np.sqrt(2*np.log(2))*widths#pixels
fwhm = 0.5*fwhm #arcsec
fwhm = widths
#medFwhm = utils.median_filterNaN(fwhm,size=5)
#meanFwhm = utils.mean_filterNaN(fwhm,size=5)

meanXpos = utils.mean_filterNaN(xpos,size=7)
meanYpos = utils.mean_filterNaN(ypos,size=7)

curve/=np.median(curve)
fwhm/=np.median(fwhm)
ax.plot(x,curve,'k')
ax.plot(x,fwhm,'m')
#ax.plot(x,medFwhm,'k')
#ax.plot(x,meanFwhm,'b')
#plt.plot(x,amps)
ax2.plot(x,xpos)
ax2.plot(x,ypos)
ax2.plot(x,meanXpos)
ax2.plot(x,meanYpos)
plt.show()
#np.savez('fix.npz',widths=medFwhm,x=meanXpos,y=meanYpos)