#PlotPersistenceAtTwoTemps.py
#
#PURPOSE:
#  To show that the halo is almost nonexistent at 100 K, but has 
#  a very large width at 170 K.
#
execfile('/afs/slac/u/ki/lances/python/python_HxRG/HxRG_Setup.py')
from HxRG_Class import *
from pylab import *
from matplotlib.finance import quotes_historical_yahoo
from matplotlib.dates import YearLocator, MonthLocator, DateFormatter
import datetime

#Set Up for plotting
PlotFile='/afs/slac/u/ki/lances/python/ThesisPlotSettings.py'
if os.path.exists(PlotFile) : execfile(PlotFile)
PlotDir ='/nfs/slac/g/ki/ki04/lances/LSST/KPNO/Latex/Thesis/NegPersistence/Figures/'
#PLOT SETUP
mplot.figure(0)
mplot.clf()

#FILE AT 100 K
FitsFileName100K = '/nfs/slac/g/ki/ki04/lances/H2RG-001/ASIC/08Dec15/TestDiode/TurnOnDiodeWhileCoolingAt135K_H2RG_SIPIN_10_Reads_Dec15_2008_11_16_22.fits'
HxRG_100K = HxRG_C(FitsFileName=FitsFileName100K)
HxRG_100K.Get_Raw_Header(FitsFileName100K)
Im_100K = pyfits.getdata(FitsFileName100K)
Im_100K = Im_100K.astype(float32) 
Row100K = 1200
Col100K = 1080
LMF     = Im_100K[9,:,:]-(Im_100K[0,:,:])
mplot.plot(LMF[Row100K-100:Row100K+500, Col100K], label=r'\textbf{100 K}')

FitsFileName156K = '/nfs/slac/g/ki/ki04/lances/H2RG-001/ASIC/08Dec15/TestDiode/H2RG_SIPIN_10_Reads_Dec15_2008_10_46_29.fits'
HxRG_156K = HxRG_C(FitsFileName=FitsFileName156K)
HxRG_156K.Get_Raw_Header(FitsFileName156K)
Im_156K = pyfits.getdata(FitsFileName156K) 
Im_156K = Im_156K.astype(float32) 
Row156K = 1200
Col156K = 1080
LMF     = Im_156K[9,:,:]-(Im_156K[0,:,:])
#mplot.plot(LMF[Row156K-100:Row156K+500, Col156K])

FitsFileName174K = '/nfs/slac/g/ki/ki04/lances/H2RG-001/ASIC/08Dec15/TestDiode/H2RG_SIPIN_10_Reads_Dec15_2008_10_44_25.fits'
HxRG_174K = HxRG_C(FitsFileName=FitsFileName174K)
HxRG_174K.Get_Raw_Header(FitsFileName174K)
Im_174K = pyfits.getdata(FitsFileName174K)
Im_174K = Im_174K.astype(float32)
Row174K = 1200
Col174K = 1080
LMF     = Im_174K[9,:,:]-(Im_174K[0,:,:])
mplot.plot(LMF[Row174K-100:Row174K+500, Col174K], label=r'\textbf{175 K}')

FitsFileName186K = '/nfs/slac/g/ki/ki04/lances/H2RG-001/ASIC/08Dec15/TestDiode/H2RG_SIPIN_10_Reads_Dec15_2008_10_41_44.fits'
HxRG_186K = HxRG_C(FitsFileName=FitsFileName186K)
HxRG_186K.Get_Raw_Header(FitsFileName186K)
Im_186K = pyfits.getdata(FitsFileName186K) 
Im_186K = Im_186K.astype(float32) 
Row186K = 1200
Col186K = 1080
LMF     = Im_186K[9,:,:]-(Im_186K[0,:,:])
#mplot.plot(LMF[Row186K-200:Row186K+400, Col186K])
mplot.ylabel(r'\textbf{ADU (Bias Subtracted)}')
mplot.xlabel(r'\textbf{Row Number (Starting from 1200)}')
mplot.legend()
mplot.savefig(PlotDir+'RowPlotOf_LED_H2RG_001_Persistence_At_100K_and_170K.png')
mplot.savefig(PlotDir+'RowPlotOf_LED_H2RG_001_Persistence_At_100K_and_170K.eps')
