C+ C NAME: C pedestalr C PURPOSE: C To determine the pedestal - this pedestal is removed from each data frame C Note this pedestal, to be distinguished from "dark current" is determined C from "empty pixels", not "covered pixels". C CATEGORY: C SMEI Data processing C CALLING SEQUENCE: C call pedestalr(mode,ic,ifm,id,jd,iframemask,frame,ped) 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 iframemask(id,jd) integer data mask - 0 data are invalid 1 data are valid C frame(id,jd) real data frame that needs to have its pedestal removed C OUTPUTS: C frame(id,jd) real data frame that now has its pedestal removed C ped real Pedestal value removed from the data frame C CALLS: C PROCEDURE: C Uses empty (not covered) pixels to determine the electronic pedestal C The first row is skipped for RAL (600 rows) data C Note each row here skips the empty 4 unbinned pixels just before 1st covered ones C MODIFICATION HISTORY: C Dec, 2002 B. Jackson (UCSD), Jan, 2003 A. Buffington (UCSD) C Feb, 2003 A. Smith (UCSD) C- c Here we have introduced the convention [i,j]= along [rows,columns], to render c compatible with the convention in C. Let i always here be the "inner loop". c subroutine pedestalr(mode,ic,ifm,id,jd,iframemask,frame,ped) real*4 frame(id,jd),ped,pedcnt integer*4 i,j,id,jd integer iframemask(jd,id) pedcnt = 0.0 ped=0.0 if(mode.eq.1.and.ic.eq.0) then C C Remove the known pedestal from the data frame in Engineering mode for Camera 0 (RAL data format) C Here id = 600 and jd = 1280 C c do j=3,600 !These limits are those used by Aaron Smith c do i=1272,1280 !These limits are those used by Aaron Smith do j=2,600 !Full frame, typical A.B. use do i=1270,1273 !These limits are compatible with those below ped = ped + frame(i,j) pedcnt = pedcnt + 1.0 end do c do i=5,13 !These limits are those used by Aaron Smith do i=6,13 !These limits are compatible with those below ped = ped + frame(i,j) pedcnt = pedcnt + 1.0 end do end do end if C if(mode.eq.2.and.ic.eq.0) then C C Remove the known pedestal from the 2 by 2 pixel binning mode, Camera 0 C c (This depends upon how the camera 0 data get binned...) end if C if(mode.eq.4.and.ic.eq.0) then C C Remove the known pedestal from the 4 by 4 pixel binning mode, Camera 0 C c (This depends upon how the camera 0 data get binned...) end if C if(mode.eq.1.and.ic.ge.1) then C C Remove the known pedestal from the data frame in Engineering mode for Flight Cameras (GSE format) C C Here id = 1272 and jd = 256; this rectangle is shifted relative to Camera 0 (RAL format) C by +1 pixel in i, and in j by +61, +55, and +57 rows respectively for Cameras 1, 2, and 3 C do j=1,256 do i=1269,1272 ped = ped + frame(i,j) pedcnt = pedcnt + 1.0 end do do i=5,12 ped = ped + frame(i,j) pedcnt = pedcnt + 1.0 end do end do end if C if(mode.eq.2.and.ic.ge.1) then C C Remove the known pedestal from the 2 by 2 pixel binning mode for Flight Cameras C Here id = 636 and jd = 128 C******** This quick version, iframemask disabled C do j=1,128 do i=635,636 if(j.ne.128)then !Funny business sometimes happens end of last line ped = ped + frame(i,j) pedcnt = pedcnt + 1.0 endif end do do i=7,8 ped = ped + frame(i,j) pedcnt = pedcnt + 1.0 end do end do end if C if(mode.eq.4.and.ic.ge.1) then C C Remove the known pedestal from the 4 by 4 pixel binning mode for Flight Cameras (presumed format) C Here id = 318 and jd = 64 C do j=1,64 do i=318,318 ped = ped + frame(i,j) pedcnt = pedcnt + 1.0 end do do i=2,3 ped = ped + frame(i,j) pedcnt = pedcnt + 1.0 end do end do end if if(pedcnt.eq.0)then print *,"No pedestal: mode, ic = ",mode,ic return endif ped=ped/pedcnt if(ifm.eq.0)then do j=1,jd do i=1,id if(frame(i,j).gt.0.)frame(i,j) = frame(i,j) - ped end do end do else do j=1,jd do i=1,id if(iframemask(i,j).ne.0.and.frame(i,j).gt.0.)frame(i,j) = frame(i,j) - ped end do end do endif return end