C+ C NAME: C set_cr_backgnd C PURPOSE: C To provide the bland background removed during the cosmic ray recognition routine. C CATEGORY: C Data processing C CALLING SEQUENCE: C call set_cr_backgnd(mode,ic,ifm,id,jd,avg) C INPUTS: C mode integer 1 - "Engineering" frame records, no onboard binning C 2 - "Hi-res" frame records, binned 2 x 2 pixels C 4 - "Normal Data" frame records, binned 4 x 4 pixels C ic integer Camera 0,1,2, or 3 C ifm integer frame mask mode - 0 mask not imposed, 1 frame mask imposed C id integer data frame max x-value (along rows) C jd integer data frame max y-value (down columns) C OUTPUTS: C avg(id,jd) real Expected bland background for this frame C CALLS: C PROCEDURE: C Presently reads the TMO average data file for zenith viewing (camera ic=0) or zeroes (ic>0) C Note iframemask not used here. This may change. C yoffset is the number of rows skipped by EGSE before beginning the 256-row readout rectangle C MODIFICATION HISTORY: C Jan, 2003 A. Buffington (UCSD) C- subroutine set_cr_backgnd(mode,ic,ifm,id,jd,avg) integer*4 mode,ic,ifm,id,jd,i,j real*4 avg(id,jd),avgmap(1242,599),avgcnt(id,jd),yoffset(5) character*7 head(5) data yoffset /0.,65.,59.,62.,55./ c if(mode.ne.1.or.mode.ne.2.or.mode.ne.4)then print *,'Bad camera mode = ',mode,', no cosmic-ray background loaded' return endif if(ic.eq.0)then open(10,file="avg.grd") read(10,1)head read(10,2)avgmap 1 format(a7) 2 format(20f8.2) else do j=1,599 do i=1,1242 avgmap(i,j)=0. enddo enddo endif c c Drop this down where it goes into RAL format c do j=1,jd do i=1,id avg(i,j)=0. avgcnt(i,j)=0. enddo enddo if(mode.eq.1)then do j=1,599 do i=1,1242 iarg=i+22 jarg=j+1 avg(iarg,jarg)=avgmap(i,j) enddo enddo print *,'Cosmic-ray average background map loaded for mode = ',mode endif if(mode.eq.2)then do j=1,599 do i=1,1242 iarg=11+(i+1)/2 jarg=1+j/2 avg(iarg,jarg)=avg(iarg,jarg)+avgmap(i,j) avgcnt(iarg,jarg)=avgcnt(iarg,jarg)+1. enddo enddo do j=1,jd do i=1,id if(avgcnt(i,j).gt.1.)avg(i,j)=avg(i,j)/avgcnt(i,j) enddo enddo print *,'Cosmic-ray average background map loaded for mode = ',mode endif if(mode.eq.4)then do j=1,599 do i=1,1242 iarg=5+(i+1)/4 jarg=1+j/4 avg(iarg,jarg)=avg(iarg,jarg)+avgmap(i,j) avgcnt(iarg,jarg)=avgcnt(iarg,jarg)+1. enddo enddo do j=1,jd do i=1,id if(avgcnt(i,j).gt.1.)avg(i,j)=avg(i,j)/avgcnt(i,j) enddo enddo print *,'Cosmic-ray average background map loaded for mode = ',mode endif return end