import sys,os,getopt,re,string
import numdisplay
import pyfits
import scipy
from pyraf import iraf
from numpy import *
from pylab import *
from Return_Refpix import *
from ReturnCentroid import *
from ReturnRadialProfiles import *
from ReturnRadialAvg import *
from ReadCol import *
from Return_Persistence_Quantities import *
from Persistence_Get_Dark_Times import *
import numdisplay
import matplotlib.pylab as mplot
import TableIO
import MySQLdb
from Linefit_func import *
from strip_scf import *
import glob
from PathFromFileName import *
from ReadCol import *
import optimize
from HxRG_Class import *
from Rebin import *
import histOutline
import time
import pdb

##MAKE THE PLOT 
Fig=mplot.figure(0) 
mplot.clf() 
 
#Axis 1 
Ax1=Fig.add_axes([0.100,0.100,0.65,0.290])
mplot.plot(CGain*MedADU_NRP_1[0:-1], DeltasCumMed_NRP_1/(DeltasCumMed_NRP_1[0]), 'r', \
           label=r'\textbf{No Reference Pixels Applied}')
 
mplot.figtext(0.78, 0.35, r'V$_{SUB}$ = ' + "%.2f" % HxRG1.VSUB)
mplot.figtext(0.78, 0.32, r'D$_{SUB}$ = ' + "%.2f" % HxRG1.DSUB)
mplot.figtext(0.78, 0.29, r'V$_{RESET}$ = ' + "%.2f" % HxRG1.VRESET)
mplot.figtext(0.78, 0.26, r'V$_{BIASGATE}$ = ' + "%.2f" % HxRG1.VBIASGAT)
mplot.figtext(0.78, 0.23, r'V$_{BIASPWR}$ = ' + "%.2f" % HxRG1.VBIASPWR)
mplot.figtext(0.78, 0.20, r'V$_{DDA}$ = ' + "%.2f" % HxRG1.VDDA)
mplot.figtext(0.78, 0.17, r'V$_{DD}$ = ' + "%.2f" % HxRG1.VDDD)
mplot.figtext(0.78, 0.14, r'V$_{CELLDRAIN}$ = ' + "%.2f" % HxRG1.CELLDRAI)
mplot.figtext(0.78, 0.11, r'V$_{DRAIN}$ = ' + "%.2f" % HxRG1.DRAIN)
mplot.xlabel(r'\textbf{Mean Signal ($e^{-}$ in well)}')
 
 
#Axis 2 
Ax2=Fig.add_axes([0.100,0.390,0.65,0.290])
mplot.plot(CGain*MedADU_NRP_2[0:-1], DeltasCumMed_NRP_2/(DeltasCumMed_NRP_2[0]), 'r', \
           label=r'\textbf{No Reference Pixels Applied}')
mplot.figtext(0.78, 0.65, r'V$_{SUB}$ = ' + "%.2f" % HxRG2.VSUB)
mplot.figtext(0.78, 0.62, r'D$_{SUB}$ = ' + "%.2f" % HxRG2.DSUB)
mplot.figtext(0.78, 0.59, r'V$_{RESET}$ = ' + "%.2f" % HxRG2.VRESET)
mplot.figtext(0.78, 0.56, r'V$_{BIASGATE}$ = ' + "%.2f" % HxRG2.VBIASGAT)
mplot.figtext(0.78, 0.53, r'V$_{BIASPWR}$ = ' + "%.2f" % HxRG2.VBIASPWR)
mplot.figtext(0.78, 0.50, r'V$_{DDA}$ = ' + "%.2f" % HxRG2.VDDA)
mplot.figtext(0.78, 0.47, r'V$_{DD}$ = ' + "%.2f" % HxRG2.VDDD)
mplot.figtext(0.78, 0.44, r'V$_{CELLDRAIN}$ = ' + "%.2f" % HxRG2.CELLDRAI)
mplot.figtext(0.78, 0.41, r'V$_{DRAIN}$ = ' + "%.2f" % HxRG2.DRAIN)
xt2 = Ax2.get_xticklabels()  
for i in xt2: 
  i.set_visible(False) 
draw() 
 
#Axis 3 
Ax3=Fig.add_axes([0.100,0.680,0.65,0.290])
mplot.plot(CGain*MedADU_NRP_2[0:-1], DeltasCumMed_NRP/(DeltasCumMed_NRP_2[0]), 'r', \
           label=r'\textbf{No Reference Pixels Applied}') 
mplot.figtext(0.78, 0.65, r'V$_{SUB}$ = ' + "%.2f" % HxRG3.VSUB)
mplot.figtext(0.78, 0.62, r'D$_{SUB}$ = ' + "%.2f" % HxRG3.DSUB)
mplot.figtext(0.78, 0.59, r'V$_{RESET}$ = ' + "%.2f" % HxRG3.VRESET)
mplot.figtext(0.78, 0.56, r'V$_{BIASGATE}$ = ' + "%.2f" % HxRG3.VBIASGAT)
mplot.figtext(0.78, 0.53, r'V$_{BIASPWR}$ = ' + "%.2f" % HxRG3.VBIASPWR)
mplot.figtext(0.78, 0.50, r'V$_{DDA}$ = ' + "%.2f" % HxRG3.VDDA)
mplot.figtext(0.78, 0.47, r'V$_{DD}$ = ' + "%.2f" % HxRG3.VDDD)
mplot.figtext(0.78, 0.44, r'V$_{CELLDRAIN}$ = ' + "%.2f" % HxRG3.CELLDRAI)
mplot.figtext(0.78, 0.41, r'V$_{DRAIN}$ = ' + "%.2f" % HxRG3.DRAIN)
xt3 = Ax3.get_xticklabels()
for i in xt3: 
  i.set_visible(False) 
draw()

