;ExaminePersistenceBoundaryLaserDiodeAtTeledyne
;
;PURPOSE:
;  To find out what the very sharp persistence boundary in the 
;  persistence is caused by
;
pro ExaminePersistenceBoundaryLaserDiodeAtTeledyne

;fits_read_datacube, '/nfs/slac/g/ki/ki04/lances/H2RG-001/ASIC/08Dec15/TestDiode/TurnOnDiodeWhileCoolingAt135K_H2RG_SIPIN_10_Reads_Dec15_2008_11_14_40.fits', ImBP, HBP

fits_read_datacube, '/nfs/slac/g/ki/ki04/lances/H2RG-001/ASIC/08Dec15/TestDiode/TurnOnDiodeWhileCoolingAt135K_H2RG_SIPIN_10_Reads_Dec15_2008_11_15_27.fits', ImBP, HBP

fits_read_datacube, '/nfs/slac/g/ki/ki04/lances/H2RG-001/ASIC/08Dec15/TestDiode/TurnOnDiodeWhileCoolingAt135K_H2RG_SIPIN_10_Reads_Dec15_2008_11_16_22.fits', ImAP, HAP

fits_read_datacube, '/nfs/slac/g/ki/ki04/lances/H2RG-001/ASIC/08Dec15/TestDiode/TurnOnDiodeWhileCoolingAt135K_H2RG_SIPIN_10_Reads_Dec15_2008_11_17_36.fits', ImAP2, HAP2

fits_read_datacube, '/nfs/slac/g/ki/ki04/lances/H2RG-001/ASIC/08Dec15/TestDiode/TurnOnDiodeWhileCoolingAt135K_H2RG_SIPIN_10_Reads_Dec15_2008_11_18_17.fits', ImAP3, HAP3

;Center of Persistence
XCen    = 1024
YCen    = 1034
BoxSize = 620
XStart  = XCen-BoxSize/2
XStop   = XCen+BoxSize/2
YStart  = YCen-BoxSize/2
YStop   = YCen+BoxSize/2

PImLMF  = ImAP(XStart:XStop, YStart:YStop, 9)-$
     long(ImAP(XStart:XStop, YStart:YStop, 0))
PImLMF2 = ImAP2(XStart:XStop, YStart:YStop, 9)-$
     long(ImAP2(XStart:XStop, YStart:YStop, 0))
PImLMF3 = ImAP3(XStart:XStop, YStart:YStop, 9)-$
     long(ImAP3(XStart:XStop, YStart:YStop, 0))

tv, congrid(bytscl(PImLMF, min=-100, max=3000), 512,512)

RadNeg = where(PImLMF lt -60)

;PImLMF(RadNeg) = 10000
tv, congrid(bytscl(PImLMF, min=-100, max=3000), 512,512)

LastImBP = ImBP(XStart:XStop, YStart:YStop, 4)
LastImAP = ImAP(XStart:XStop, YStart:YStop, 9)

plot, LastImBP(RadNeg), yrange=[40000,66000]
Col=540
window, xsize=512, ysize=768
erase
!p.multi=[2,1,2]
plot, LastImBP(Col,*)
oplot, LastImAP(Col,*)
plot, PImLMF(Col,*);, xrange=[000,100]
oplot,PImLMF2(Col,*)
oplot,PImLMF3(Col,*)
stop
end

