Variable Background



<



SCRIPT SIMULATING VARIABLE BACKGROUND


; Crude simulation of changing bkgd

gg1 = {gaussian_source_str}

  gg1.amplitude = 1.0
  gg1.xysigma = [1., 1.]
  gg1.xypos = [-15.,10.]
  gg1.tilt_angle_deg = 0.

model = gg1
obj_im = hsi_image() 
px=2
obj_im->set,pixel_size=px
obj_im->set,det_index=[0,0,1,1,1,1,1,0,0]
; obj_im->set,time_range=[0,4]       
obj_im->set,sim_time_range=[0,4]     
obj_im->set,xyoffset=[600,200]
obj_im->set,sim_xyoffset=[600,200]
xyoffset=obj_im->get(/xyoffset)
print,'xyoffset=',xyoffset

 im = obj_im -> getdata(sim_model=model,sim_photons=6000,$
 sim_energy_band=[6,100],energy_band=[6,100],$
 /force) 

cbe=obj_im->getdata(class_name='hsi_calib_eventlist')

print,'Back Projecting original
obj_im-> plotman

wv=where(ptr_valid(cbe),nv)
print,'valid pointers:',wv
j1=min(wv)

!p.multi=[0,1,nv]
!x.style=1 & !P.CHARSIZE=2

tj=['1)','2)','3)','4)','5)','6)','7)','8)','9)']
ti="ORIGINAL COUNT PROFILE FOR POINT SOURCE (DET="
WINDOW,1
for j=0,nv-1 do plot,(*cbe(j+j1,0)).count,psym=10,$
TIT=TI+TJ[j+j1],xtIT='TIME BIN',YTIT='COUNTS/S'

; Need to use a different kind of map that requires only cbe:
 
im_=hsi_phasor_sum(cbe,[2,3,4,6],64,px,/verb)

; Add random bkgd to the count profiles. Total(bkgd)=total(count)

FOR k=0,nv-1 do begin
 j=wv[k]
  nbin=float(n_elements((*cbe(j,0)).count))
  bkgd=lonarr(nbin)
  countj=(*cbe(j,0)).count
  f=1+findgen(nbin)*max(countj)/nbin                    ; max(bkgd)=max(countj)
  for np=0,nbin-1 do bkgd(np)=randomn(seed,1,poisson=f[np]) 
  count=countj+long(bkgd)
 (*cbe(j,0)).count=count
ENDFOR

tj=['1)','2)','3)','4)','5)','6)','7)','8)','9)']
ti="COUNT PROFILE FOR POINT SOURCE WITH BKGD (DET="
WINDOW,2
for j=0,nv-1 do plot,(*cbe(j+j1,0)).count,psym=10,$
  TIT=TI+TJ[j+j1],xtIT='TIME BIN',YTIT='COUNTS/S'

;This just replots the old object: obj_im-> plotman
; need a bproj routine that uses only the cbe (phasor_sum or vis_nproj)
print,'RUNNING HSI_PHASOR_SUM...'

 vproj=hsi_phasor_sum(cbe,[2,3,4,5,6],64,px,/verb)

!p.multi=0
window,3,xsize=512,ysize=512
!x.style=1 & !y.style=1
x=600.+findgen(64)*2-64.
y=200+findgen(64)*2-64
xt='HELIOCENTRIC X COORDINATE (ARCSEC)'
Yt='HELIOCENTRIC Y COORDINATE (ARCSEC)'
ti='SIMULATED BACK-PROJECTION WITH RAMPED BACKGROUND'
lev=min(vproj)+findgen(16)*(max(vproj)-min(vproj))/15.
!p.charsize=1

PX = !X.WINDOW * !D.X_VSIZE
PY = !Y.WINDOW * !D.Y_VSIZE
;Desired size of image in pixels.
SX = PX[1] - PX[0] + 1
SY = PY[1] - PY[0] + 1
;Display the image with its lower-left corner at ;the origin of the plot window and with its size ;scaled to fit the plot window.
TVSCL, CONGRID(vproj, SX, SY), PX[0], PY[0]
!p.charsize=1
CONTOUR, vproj, X, Y, LEV=lev,TIT=ti,XTIT =xt,ytit=yt,/NOERASE


contour,vproj,x,y

PX = !X.WINDOW * !D.X_VSIZE
PY = !Y.WINDOW * !D.Y_VSIZE
;Desired size of image in pixels.
SX = PX[1] - PX[0] + 1
SY = PY[1] - PY[0] + 1
;Display the image with its lower-left corner at ;the origin of the plot window and with its size ;scaled to fit the plot window.
TVSCL, CONGRID(vproj, SX, SY), PX[0], PY[0]
!p.charsize=1
CONTOUR, vproj, X, Y, LEV=lev,TIT=ti,XTIT =xt,ytit=yt,/NOERASE

window,4,xsize=512,ysize=512
lev=min(im_)+findgen(16)*(max(im_)-min(im_))/15.
!p.charsize=1
contour,im_,x,y
PX = !X.WINDOW * !D.X_VSIZE
PY = !Y.WINDOW * !D.Y_VSIZE
;Desired size of image in pixels.
SX = PX[1] - PX[0] + 1
SY = PY[1] - PY[0] + 1
;Display the image with its lower-left corner at ;the origin of the plot window and with its size ;scaled to fit the plot window.
TVSCL, CONGRID(im_, SX, SY), PX[0], PY[0]
ti='SIMULATED BACK-PROJECTION WITH ORIGINAL COUNTS'
CONTOUR, im_, X, Y, LEV=lev,TIT=ti,XTIT =xt,ytit=yt,/NOERASE

end

Ed Schmahl
Last modified: Mon Feb 26 16:58:58 EST 2001