pro puffy_events_samp_histogram_jpg_too

;Pretty much copied directly from Ernie's makehistogram_crosstalk.pro

readcol,'C:\H2RG_15_EVENTS\stats.txt',background,amplitude,x_pix,y_pix,sigma,file_name,format='f,f,i,i,f,a'
psfile='c:\H2RG_15_EVENTS\Events_in_H2RG-015_amplitude.ps'

white=255
black=0
fg=0

_min=0
_max=2.5
_nbins=50
_binsize=(_max-_min)/(_nbins-1)

theHist=histogram(sigma,nbins=_nbins,max=_max,min=_min,locations=theVals)

    !x.minor = 3
    !y.minor = 3

    set_plot, 'ps'
         !p.font=-1
         device, filename= psfile
         fsub = psfile           ;filename to be written at bottom of plot

         ;set line and text characteristics for publication quality
         !P.CHARSIZE=1.2
         !P.CHARTHICK=4.
         !X.THICK=8.
         !Y.THICK=8.
         !P.THICK=8.
         !P.MULTI=0
         !P.TICKLEN=0.03
         symsize=1.5
         filenamecharsize=1.1

    erase
    plot,theVals,theHist,psym=10,title="Gaussian Fit for large Events",xtitle="Sigma (Pixels)",charsize=1.10*!P.CHARSIZE,ytitle='Number of Events', $
         color=black,background=white,position=[0.15,0.15,0.8,0.9],ystyle=1,$
         xrange=[0, _max],xstyle=1

   ; xyouts,'hello','Total Exposure time',color=0,$
         ; align=1.0,charsize=!P.CHARSIZE/1.25
    device, /close

    set_plot, 'z'
         device, set_resolution=[8000,6000]
         device, set_font='Courier'
         ;fsub = jpgfile          ;filename to be written at bottom of plot

         ; set line and text characteristics for publication quality
         !P.CHARSIZE=10
         !P.CHARTHICK=15.
         !X.THICK=20.
         !Y.THICK=20.
         !P.THICK=20.
         symsize=10.
         filenamecharsize=8.


           erase
         plot,theVals,theHist,psym=10,title="Gaussian Fit for large Events",xtitle="Sigma (Pixels)",charsize=1.10*!P.CHARSIZE,ytitle='Number of Events', $
         color=black,background=white,position=[0.15,0.15,0.8,0.9],ystyle=1,$
         xrange=[0, _max],xstyle=1

        jpgimg = tvrd()
         write_jpeg, 'C:\H2RG_15_EVENTS\samp_histogram.jpg', congrid(jpgimg, 1600, 1200, /interp, /center), quality=100


      device,/close

end