C+ C NAME: C A_mod_mainf C PURPOSE: C This is the main Fortran program to index TMO/SMEI data using utilizing C Spatial Index functions from the c++ file A_mod_L12_all.cpp C CATEGORY: C SMEI data analysis C CALLING SEQUENCE: C INPUTS: C Various parameters are presently specified by data statements at the top C This program presently combines data from a single SMEI camera C OUTPUTS: C A data file listing pedestal and dark current values versus frame number C A grid file containing the resulting sky map C CALLS: C set_flatfields !sets the appropriate flatfields for the selected camera C read_frame !reads a frame of data C pedestalr !removes pedestal from empty pixels C darkr !removes dark current from covered pixels C cosmicra !cosmic ray removal C lsff !large scale flatfield C ssff !small scale flatfield C rotate8 !euler angle rotation C indexframe !frame indexing routine C SEE ALSO: C INCLUDE: C COMMON BLOCKS: C PROCEDURE: C This program uses the hierarchical triangle coordinate system from Johns Hopkins, C as a base upon which the photometric measurements from a single SMEI camera are C combined and then averaged to produce a surface-brightness sky map. The "level" C parameter governs the granularityof the triangular coordinate frame. The C coordinates of the four corners of a pixel (or bin) are transformed down into C this frame, and the photometric surface brightness as measured by that pixel is C added to all triangles whose centers lie within the rectangle. C This surface brightness is corrected by 1/cosine of the pixel's angle to the camera C axis, and by r/r0 the pixel's1 fractional distance to the FOV's rotational center C When the data sequence is finished, all triangle response sums are C averaged and the resulting sky map binned into an output surface brightness map. C MODIFICATION HISTORY: C 2002,2003 Aaron Smith (UCSD/CASS) C 2002->Original version C 2003->removed most C++ functions and re-wrote in fortran as subroutines C Feb -> WORK IN PROGRESS C DEC-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C Defined LEVEL and KMAX as parameters. KMAX is determined from LEVEL. C KMAX is then used to dimension arrays node, nodeid and hits C JAN-2003, Andrew Buffington (UCSD/CASS) C Integrated standard pedestal and dark current routines, FORTRAN C Rendered names compliant with those of B.V. Jackson C Incorporated 1/cosine surface-brightness correction for aperture perspective (currently in C++ routine) C Incorporated large and small scale flatfield corrections C Incorporated FORTRAN read subroutine C- PROGRAM A_mod_mainf implicit none ! Dimensions for node, nodeid, hits above must be at least 2*(4**(level+1)) ! For LEVEL = 12, KMAX = 134217728 ! For LEVEL = 8, KMAX = 524288 integer*2 TOP_LEVEL parameter ( TOP_LEVEL = 12 ) integer*8 TOP_KMAX parameter ( TOP_KMAX = 2*(4**(TOP_LEVEL+1)) ) real*4 node ( TOP_KMAX ) !/TOP_KMAX*0.0/ integer*8 nodeid( TOP_KMAX ) !/TOP_KMAX*0 / integer*2 hits ( TOP_KMAX ) !/TOP_KMAX*0 / integer*2 level /TOP_LEVEL/ integer*8 kmax /TOP_KMAX/ real*4 frame (636,128) real*4 framessff (636,128) real*4 framelsff (636,128) real*4 framelsffu (636,128) real*4 ped /0./ real*4 dark /0./ real*4 avg (636,128) /0./ real*4 hroom /49400./ !'headroom'=new onboard value of 65k ADUs real*4 adu2e real*8 affine(6) /6*0.0D0/ ! Affine parameters zero for now real*8 cra real*8 cdec real*8 alfa real*8 beta real*8 gamma real*8 euler(3) real*8 camlat real*8 degperminute real*8 ra0 real*8 arg real*8 arg1 real*8 dusk integer*4 mode /2/ !onboard binning mode integer*4 ic /2/ !Camera # integer*4 ifm /0/ !ROI mask (0=no,1=yes) integer*4 id /636/ !1280 for TMO integer*4 jd /128/ !600 for TMO integer*4 icrcnt /0/ integer*4 neighbors /0/ integer*4 iframe integer*4 iframemask (636,128) /81408*1/ integer*4 ihit(636,128) integer*4 ihist(250) integer*4 ifmin /193/ integer*4 ifmax /469/ integer*4 i integer*4 j integer*4 night /40/ integer*4 image(1200,1200) /1440000*0/ integer*4 polarimage(1600,1600) /2560000*0/ integer*4 dummypolar(1600,1600) /2560000*0/ integer*8 k character infile*17 !not compatable with TMO data character outfile*10, outfile2*16 c c AARON'S DECLARATIONS c integer*4 iairplane, airplane, idarkcr, ii, jj, dumcnt4 real*8 rq, dr, thetax, thetaxsq, thetay, cx, cy, cz, crsq real*8 rccd, x0, y0, r0, tempx real*8 response, arg, arg1, phi, rlat real*8 x(4), y(4), ra(4), dec(4) real*8 f0, f, xf, yf, zf, rfsq, rf, raf, decf data ihist /250*0/ data ihit /81408*0/ x0=630.6D0 y0=1291.38D0 r0=1194.5D0 print*, 'Fortran IN ...' print*, 'Level: ', level, ' (array size: ', kmax,')' adu2e=4.5*65536./hroom c call set_flatfields(ic,framessff,framelsff,framelsffu) !note dimensions should be checked before ff is done... call set_cr_backgnd(mode,ic,ifm,id,jd,avg) c if(night.eq.40)ifmin = 13 !remove 10 minute early start for night 40 c if(night.eq.30)ifmin = 322 !sky reversed c if(night.eq.30)ifmax = 580 !sky reversed c ra0 = 279.425D0 c adjustments relative to Andy's ra0 for selected stars...night 42 start 19:40 c ra0 = ra0 - 0.985626D0 !by-the-clock converts from night 42 to night 41, start 19:40 c ra0 = ra0 - 0.985626D0 - 2.5079D0 !by-the-clock converts from night 41 to night 40, start 19:30 c note that gap interval setting was 56 ms larger on night 40: see degperminute adjustments below c if(night.eq.41) ra0 = 279.425D0 + 0.005D0 !Andy's value with small ad hoc adjustment c if(night.eq.42) ra0 = 279.425D0 + 0.97D0 !Aaron's value with ad hoc adjustment (of -0.015626) c if(night.eq.40) ra0 = 279.425D0 - 0.985626D0 - 2.5079D0 - 0.007D0 !Andy's 41 value, with by-the-clock & adhoc adjustment degperminute = 0.2506845D0 camlat = 34.9471D0 !!TMO Lattitude if(night.eq.42) degperminute=degperminute*1.0001D0 !Ad hoc adjustment if(night.eq.41) degperminute=degperminute*1.00044444D0 !Uses observed end time if(night.eq.40) degperminute=degperminute*1.001389D0 !56-millisecond adjustment (+ observed end time) if(night.eq.40) camlat = camlat -0.61D0 !Southward looking ad hoc adjustment... alfa = -0.5D0 beta = camlat-90.D0 do k=1,kmax node(k)=0.0 nodeid(k)=0 hits(k)=0 enddo write (outfile,'(I2.2,A2,I2.2,A4)') night,'_L',level,'.dat' open (11,file = outfile, form = 'formatted') ifmin = 193 ifmax = 469 do iframe=ifmin,ifmax c do k=27,29 c iframe = 180 + k*10 !for 0