C+ C NAME: C read_framecrx_mode(infile,mode,ic,id,jd,frame) C PURPOSE: C To read a frame of SMEI data and convert the unsigned short integers to floating C CATEGORY: C SMEI Data processing C CALLING SEQUENCE: C call read_frame(infile,mode,ic,id,jd,frame) C INPUTS: C infile character Input file name (currently 18 characters) C*** This will have to change... 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,3 or 4 C id integer data frame max x-value (along rows) C jd integer data frame max y-value (down columns) C OUTPUTS: C frame(id,jd) real data frame C CALLS: C none C PROCEDURE: C Wind off header, read in one data frame, convert to short unsigned integer, float to real C Note: ***This procedure probably needs significant alteration for the SMEI data C coming to us on the weekly CD's.*** C In particular, the FITS header probably contains desirable information which will C want to be passed out through this subroutine's argument list. Also, the unsigned C short integer format of our *.nic files is probably not Hanscom's convention. C yoffset is the number of rows skipped by EGSE before starting its 256-row readout rectangle C MODIFICATION HISTORY: C Jan, 2003 A. Buffington (UCSD/CASS) C Feb, 2003 A. Smith (UCSD/CASS) C- subroutine read_framecrx_mode(infile,mode,ic,id,jd,frame,q,meascnt) implicit none integer*1 trail1(75),trail2(275),trail3(21),trail4(69) real*8 q(4) integer*2 head(3),k integer*4 i,j,ic,id,jd,mode,itemp,ipedcnt,idarkcnt,inegmeas,meascnt,ineigh,icrcnt,icrneig real*4 ped, dark, frame(id,jd) real*4 tempframe(id,jd), maxr character infile*47 c real*8 x0(5), y0(5),x00(5), y00(5), yref(5), r0, dr, rccd c real*4 yoffset(5), xoffset(5) c integer*8 count CCC numbers from Andy's memo c data yoffset /0.,65.,59.,61.,55./ c data xoffset /0.,1.,1.,1.,1./ c data x00 /630.D0,634.D0,628.7D0,637.7D0,633.D0/ c data y00 /1291.38D0,1306.1D0,1297.1D0,1304.9D0,1294.3D0/ c if(ic.eq.2) r0=1188.5 c x0(ic+1)=x00(ic+1)-xoffset(ic+1) c y0(ic+1)=y00(ic+1)-yoffset(ic+1) c count=0 c c read data file -- 1 frame c if(mode.eq.1)then open(10,file=infile,form='binary',readonly) read(10)head,((frame(i,j),i=1,id),j=1,jd),trail1,q,trail2,ped,dark,dark,trail3,ipedcnt,idarkcnt,inegmeas,meascnt, & ineigh,icrcnt,icrneig,trail4 close(10) elseif(mode.eq.2.or.mode.eq.4)then open(10,file=infile,form='binary',readonly) read(10)head,((tempframe(i,j),i=1,id),j=1,jd),trail1,q,trail2,ped,dark,dark,trail3,ipedcnt,idarkcnt,inegmeas,meascnt, & ineigh,icrcnt,icrneig !,trail4 close(10) c meascnt=0 else print *,' Bummer!!, bad mode = ',mode return endif c print*, head c print*, q c print*, ped, dark, ipedcnt c print*, idarkcnt,inegmeas,meascnt c print*, ineigh,icrcnt,icrneig c c convert from short unsigned integer to real*4 ... see note below c maxr=0 do j=1,jd do i=1,id c if(maxr.lt.tempframe(i,j)) maxr=tempframe(i,j) c itemp=int4(tempframe(i,j)) c if(itemp.lt.0)itemp=itemp+65536 c frame(i,j)=float(itemp) frame(i,j)=tempframe(i,j) !is real*4 already c rccd = dsqrt( (i-x0(ic+1))*(i-x0(ic+1)) + (j-y0(ic+1))*(j-y0(ic+1)) ) c dr = rccd - r0 c !!this dr test is for cameras 2 and 3 c if( (ic.eq.2.and.dr.lt.32.4D0.and.dr.gt.-27.D0).or.(ic.eq.3.and.dr.lt.30.D0.and.dr.gt.-26.D0) )then c if( (dabs( (i-x0(ic+1))/(j-y0(ic+1)) ) ).lt.0.57735D0 )then !!less than tan 30 c if(frame(i,j).lt.1..or.frame(i,j).ge.65535.) count=count+1 c endif c endif c c Now fix covered pixels c if(mode.eq.1.and.(i.eq.21.or.i.eq.1264))frame(i,j)=0.0 if(mode.eq.2.and.(i.eq.11.or.i.eq.632))frame(i,j)=2.*frame(i,j) c if(mode.eq.4.and.(i.eq.6.or.i.eq.316))frame(i,j)=1.333*frame(i,j) !already done enddo enddo C print*, 'Count: ',count c print*, 'Max: ',maxr return end