%matplotlib inline
import numpy as np
import scipy.signal, scipy.stats
import matplotlib.pyplot as plt
import mpld3
import dateutil
from numpy.polynomial.chebyshev import chebfit
from astropy.io import fits
mpld3.enable_notebook()
def getdata(filename,filterwidth=49):
m = fits.open(filename)[0].data
t=np.median(m,axis=1)
dt=t-scipy.signal.medfilt(t,filterwidth)
ct,clo,chi=scipy.stats.sigmaclip(dt)
print(filename,len(m),m.mean(),m.std(),np.median(m))
print(ct.std(),ct.mean(),len(ct),clo,chi)
k=np.where((clo<dt)&(dt<chi))[0]
mt = np.array([dateutil.parser.parse(line[-28:-5]) for line in open(filename.replace('.fits','.filenames'))])
assert len(mt) == len(m), (len(mt),len(m))
return mt[k],m[k,:]
def normalizepixelwrt1chip(m,chip,xpos):
scalefactor=np.median(m[:,chip*2144:(chip+1)*2144])
# print('scalefactor:',scalefactor)
return m[:,chip*2144+xpos]/scalefactor
def markvstevents(figs):
import datetime
for datum,comment in [
(datetime.date(2012,12,5), 'System throughput increased by 5% due to washing of M1.'),
(datetime.date(2013,3,24), 'Temporary change in sky flat morphologies due to technical tests with improved baffling.'),
(datetime.date(2014,1,8), 'Change of flat field morphology due to installation of improved baffling on the VST.'),
(datetime.date(2014,4,6), 'The installation of the baffle is completed.'),
(datetime.date(2014,8,16), 'VST is back to normal service.'),
(datetime.date(2015,4,30), 'A set of baffle with a complete redesign of the inner ribs to reduce oblique reflections have been installed.'),
]:
for fig in figs:
if hasattr(fig,'get_ylim'):
fig.plot([datum,datum],fig.get_ylim())
else:
fig.plot([datum,datum],fig.gca().get_ylim())
print(datum,comment)
tg,g = getdata('dome-g-y2800-73-80.fits')
ti,i = getdata('dome-i-y2800-73-80.fits')
tu,u = getdata('dome-u-y2800-73-80.fits')
tugri,ugri = getdata('dome-ugri-y2800-73-80.fits')
tHa,Ha = getdata('dome-Halpha-y2800-73-80.fits')
f, (ax1, ax2, ax3, ax4, ax5) = plt.subplots(5, sharex=True, sharey=False, figsize=(12,10))
chip, xpos = 2, 500
ax1.plot(tg,g[:,chip*2144+xpos],'.g')
ax2.plot(ti,i[:,chip*2144+xpos],'.r')
ax3.plot(tu,u[:,chip*2144+xpos],'.b')
ax4.plot(tugri,ugri[:,chip*2144+xpos],'.c')
ax5.plot(tHa,Ha[:,chip*2144+xpos],'.m')
chip, xpos = 2, 2144-500
ax1.plot(tg,g[:,chip*2144+xpos],'.g')
ax2.plot(ti,i[:,chip*2144+xpos],'.r')
ax3.plot(tu,u[:,chip*2144+xpos],'.b')
ax4.plot(tugri,ugri[:,chip*2144+xpos],'.c')
ax5.plot(tHa,Ha[:,chip*2144+xpos],'.m')
markvstevents([ax1,ax2,ax3,ax4,ax5])
plt.figure(figsize=(12,4))
plt.ylim(0.8,1.2)
plt.rc('lines',markersize=3)
chip, xpos = 2, 500
plt.plot(tg,normalizepixelwrt1chip(g,chip,xpos),'.g')
plt.plot(ti,normalizepixelwrt1chip(i,chip,xpos),'.r')
plt.plot(tu,normalizepixelwrt1chip(u,chip,xpos),'.b')
plt.plot(tugri,normalizepixelwrt1chip(ugri,chip,xpos),'.c')
plt.plot(tHa,normalizepixelwrt1chip(Ha,chip,xpos),'.m')
markvstevents([plt])
plt.figure(figsize=(12,4))
plt.ylim(0.8,1.2)
plt.rc('lines',markersize=3)
chip, xpos = 2, 2144-500
plt.plot(tg,normalizepixelwrt1chip(g,chip,xpos),'.g')
plt.plot(ti,normalizepixelwrt1chip(i,chip,xpos),'.r')
plt.plot(tu,normalizepixelwrt1chip(u,chip,xpos),'.b')
plt.plot(tugri,normalizepixelwrt1chip(ugri,chip,xpos),'.c')
plt.plot(tHa,normalizepixelwrt1chip(Ha,chip,xpos),'.m')
markvstevents([plt])
f, (ax1, ax2, ax3, ax4, ax5) = plt.subplots(5, sharex=True, sharey=False, figsize=(12,8))
chip, xlo, xhi = 2, 400, 2144-400
ax1.plot(tg,g[:,chip*2144+xlo]-g[:,chip*2144+xhi],'.g')
ax2.plot(ti,i[:,chip*2144+xlo]-i[:,chip*2144+xhi],'.r')
ax3.plot(tu,u[:,chip*2144+xlo]-u[:,chip*2144+xhi],'.b')
ax4.plot(tugri,ugri[:,chip*2144+xlo]-ugri[:,chip*2144+xhi],'.c')
ax5.plot(tHa,Ha[:,chip*2144+xlo]-Ha[:,chip*2144+xhi],'.m')
markvstevents([ax1,ax2,ax3,ax4,ax5])
f, (ax1, ax2, ax3, ax4, ax5) = plt.subplots(5, sharex=True, sharey=False, figsize=(12,8))
chip, xlo, xhi = 5, 500, 2144-500
ax1.plot(tg,g[:,chip*2144+xlo]/g[:,chip*2144+xhi],'.g')
ax2.plot(ti,i[:,chip*2144+xlo]/i[:,chip*2144+xhi],'.r')
ax3.plot(tu,u[:,chip*2144+xlo]/u[:,chip*2144+xhi],'.b')
ax4.plot(tugri,ugri[:,chip*2144+xlo]/ugri[:,chip*2144+xhi],'.c')
ax5.plot(tHa,Ha[:,chip*2144+xlo]/Ha[:,chip*2144+xhi],'.m')
markvstevents([ax1,ax2,ax3,ax4,ax5])
#for fig in [ax1,ax2,ax3,ax4,ax5]: fig.set_ylim(0.95,1.05)
chip, xlo, xhi = 2, 500, 2144-500
plt.plot(tg,g[:,chip*2144+xlo]-g[:,chip*2144+xhi],'.g')
#ax2.plot(ti,i[:,chip*2144+xlo]-i[:,chip*2144+xhi],'.r')
#ax3.plot(tu,u[:,chip*2144+xlo]-u[:,chip*2144+xhi],'.b')
#ax4.plot(tugri,ugri[:,chip*2144+xlo]-ugri[:,chip*2144+xhi],'.c')
#ax5.plot(tHa,Ha[:,chip*2144+xlo]-Ha[:,chip*2144+xhi],'.m')
#for fig in [ax1,ax2,ax3,ax4,ax5]: markvstevents(fig)