C+ C NAME: C orbit_binner C PURPOSE: C This program will take composite images of orbits and re-bin them C CATEGORY: C SMEI data analysis C OUTPUTS: C A grid file that represents the re-binned orbits C PROCEDURE: C Read in the orbits to be used, re-bin them C MODIFICATION HISTORY: C July 2003, Aaron Smith (UCSD/CASS) C- PROGRAM orbit_binner implicit none integer*4 i, j, k, s, hour, date, numorbstart,numorbend, ic, mode, testi, testj integer*4 eqorbit(1200,1200),auroraswitch integer*4 plorbit(1600,1600) real*4 eqorbitbin(600,600) integer*4 eqorbitbincnt(600,600) real*4 plorbitbin(400,400) integer*4 plorbitbincnt(400,400) character eqinfile*27, plinfile*25,aureqinfile*34, aurplinfile*32 character dum, eqoutfile*31, ploutfile*29,aureqoutfile*38, aurploutfile*36 ic=2 mode=4 numorbstart = 1 numorbend = 18 auroraswitch = 1 do k=numorbstart,numorbend if(k.eq.1) then date=0529 hour=03 elseif(k.eq.2) then date=0529 hour=04 elseif(k.eq.3) then date=0529 hour=06 elseif(k.eq.4) then date=0529 hour=08 elseif(k.eq.5) then date=0529 hour=09 elseif(k.eq.6) then date=0529 hour=11 elseif(k.eq.7) then date=0529 hour=13 elseif(k.eq.8) then date=0529 hour=14 elseif(k.eq.9) then date=0529 hour=16 elseif(k.eq.10) then date=0529 hour=18 elseif(k.eq.11) then date=0529 hour=20 elseif(k.eq.12) then date=0529 hour=21 elseif(k.eq.13) then date=0529 hour=23 elseif(k.eq.14) then date=0530 hour=01 elseif(k.eq.15) then date=0530 hour=02 elseif(k.eq.16) then date=0530 hour=04 elseif(k.eq.17) then date=0530 hour=06 elseif(k.eq.18) then date=0530 hour=07 endif do s=1,5 print*, ' Beginning Orbit Binning Process for Orbit, Map ',k,', ',s if(auroraswitch.eq.0)then if(s.eq.1)then write (eqinfile,'(A7,I4.4,A1,I2.2,A13)') 'Orbits/',date,'_',hour,'_EqPlot_1.grd' write (eqoutfile,'(A7,I4.4,A1,I2.2,A17)') 'Orbits/',date,'_',hour,'_EqPlot_1_bin.grd' elseif(s.eq.2)then write (eqinfile,'(A7,I4.4,A1,I2.2,A13)') 'Orbits/',date,'_',hour,'_EqPlot_2.grd' write (eqoutfile,'(A7,I4.4,A1,I2.2,A17)') 'Orbits/',date,'_',hour,'_EqPlot_2_bin.grd' elseif(s.eq.3)then write (eqinfile,'(A7,I4.4,A1,I2.2,A13)') 'Orbits/',date,'_',hour,'_EqPlot_3.grd' write (eqoutfile,'(A7,I4.4,A1,I2.2,A17)') 'Orbits/',date,'_',hour,'_EqPlot_3_bin.grd' elseif(s.eq.4)then write (plinfile,'(A7,I4.4,A1,I2.2,A11)') 'Orbits/',date,'_',hour,'_spolar.grd' write (ploutfile,'(A7,I4.4,A1,I2.2,A15)') 'Orbits/',date,'_',hour,'_spolar_bin.grd' else write (plinfile,'(A7,I4.4,A1,I2.2,A11)') 'Orbits/',date,'_',hour,'_npolar.grd' write (ploutfile,'(A7,I4.4,A1,I2.2,A15)') 'Orbits/',date,'_',hour,'_npolar_bin.grd' endif else if(s.eq.1)then write (aureqinfile,'(A14,I4.4,A1,I2.2,A13)') 'Orbits/Aurora/',date,'_',hour,'_EqPlot_1.grd' write (aureqoutfile,'(A14,I4.4,A1,I2.2,A17)') 'Orbits/Aurora/',date,'_',hour,'_EqPlot_1_bin.grd' elseif(s.eq.2)then write (aureqinfile,'(A14,I4.4,A1,I2.2,A13)') 'Orbits/Aurora/',date,'_',hour,'_EqPlot_2.grd' write (aureqoutfile,'(A14,I4.4,A1,I2.2,A17)') 'Orbits/Aurora/',date,'_',hour,'_EqPlot_2_bin.grd' elseif(s.eq.3)then write (aureqinfile,'(A14,I4.4,A1,I2.2,A13)') 'Orbits/Aurora/',date,'_',hour,'_EqPlot_3.grd' write (aureqoutfile,'(A14,I4.4,A1,I2.2,A17)') 'Orbits/Aurora/',date,'_',hour,'_EqPlot_3_bin.grd' elseif(s.eq.4)then write (aurplinfile,'(A14,I4.4,A1,I2.2,A11)') 'Orbits/Aurora/',date,'_',hour,'_spolar.grd' write (aurploutfile,'(A14,I4.4,A1,I2.2,A15)') 'Orbits/Aurora/',date,'_',hour,'_spolar_bin.grd' else write (aurplinfile,'(A14,I4.4,A1,I2.2,A11)') 'Orbits/Aurora/',date,'_',hour,'_npolar.grd' write (aurploutfile,'(A14,I4.4,A1,I2.2,A15)') 'Orbits/Aurora/',date,'_',hour,'_npolar_bin.grd' endif endif if(s.lt.4)then !!do eq plots do i=1,600 do j=1,600 eqorbitbin(i,j)=0. eqorbitbincnt(i,j)=0 enddo enddo !! read in headers and orbit image arrays if(auroraswitch.eq.0)then open(12,file=eqinfile,form='formatted',readonly) else open(12,file=aureqinfile,form='formatted',readonly) endif read(12,120)dum read(12,120)dum read(12,120)dum read(12,120)dum read(12,120)dum 120 format(a20) read(12,12)((eqorbit(i,j),i=1,1200),j=1,1200) 12 format(20i6) close(12) !! re-bin orbit do testi=2,1200,2 do testj=2,1200,2 do i=testi-1,testi do j=testj-1,testj if(eqorbit(i,j).gt.0) then eqorbitbin(testi/2,testj/2)=eqorbitbin(testi/2,testj/2)+float(eqorbit(i,j)) eqorbitbincnt(testi/2,testj/2)=eqorbitbincnt(testi/2,testj/2)+1 endif enddo enddo enddo enddo do i=1,600 do j=1,600 if(eqorbitbin(i,j).ne.0) eqorbitbin(i,j)=eqorbitbin(i,j)/float(eqorbitbincnt(i,j)) enddo enddo else !!do polar plots do i=1,400 do j=1,400 plorbitbin(i,j)=0. plorbitbincnt(i,j)=0 enddo enddo !! read in headers and orbit image arrays if(auroraswitch.eq.0)then open(17,file=plinfile,form='formatted',readonly) else open(17,file=aurplinfile,form='formatted',readonly) endif read(17,122)dum read(17,122)dum read(17,122)dum read(17,122)dum read(17,122)dum 122 format(a20) read(17,17)((plorbit(i,j),i=1,1600),j=1,1600) 17 format(20i6) close(17) !! re-bin orbit do testi=4,1600,4 do testj=4,1600,4 do i=testi-3,testi do j=testj-3,testj if(plorbit(i,j).gt.0) then plorbitbin(testi/4,testj/4)=plorbitbin(testi/4,testj/4)+plorbit(i,j) plorbitbincnt(testi/4,testj/4)=plorbitbincnt(testi/4,testj/4)+1 endif enddo enddo enddo enddo do i=1,400 do j=1,400 if(plorbitbin(i,j).ne.0) plorbitbin(i,j)=plorbitbin(i,j)/float(plorbitbincnt(i,j)) enddo enddo endif if(s.lt.4)then !!Write image(orbit re-binned) to file if(auroraswitch.eq.0)then open (14,file = eqoutfile, form = 'formatted') else open (14,file = aureqoutfile, form = 'formatted') endif if(s.eq.1)then write(14,14) 14 format('DSAA'/'600 600'/'0 120'/'-60 60'/'0 1400') elseif(s.eq.2)then write(14,15) 15 format('DSAA'/'600 600'/'120 240'/'-60 60'/'0 1400') else write(14,16) 16 format('DSAA'/'600 600'/'240 360'/'-60 60'/'0 1400') endif do j=1,600 write(14,'(20f9.1)')(eqorbitbin(i,j),i=1,600) enddo close(14) else !!Write image(orbit re-binning) to file if(auroraswitch.eq.0)then open (19,file = ploutfile, form = 'formatted') else open (19,file = aurploutfile, form = 'formatted') endif write(19,19) 19 format('DSAA'/'400 400'/'-40 40'/'-40 40'/'0 1400') do j=1,400 write(19,'(20f9.1)')(plorbitbin(i,j),i=1,400) enddo close(19) endif enddo !!end s loop to include all 5 maps of the sky enddo !!end k loop to include many orbits print*, 'Fortran out!!!' end