subroutine rbfavg (bavg) c c----------------------------------------------------------------------- c c rbfavg computes the average of the rotated b-field components for c an 8-second maf1 record c c method: the b-field components for each second (1-8) of a maf1 c record are rotated and a running sum is kept for each c component which is averaged after all 8 seconds have been c summed. c c restrictions: maf1 record must be in common block "maf1" set up c as follows - c integer*2 idata c common /maf1/idata(2812) c c arguments: c bavg(1-3) (real,output) - averaged rotated b-field components c c----------------------------------------------------------------------- c real b(3), brot(3), bavg(3) integer*2 idat(2812) common /maf1/idat c c----------------------------------------------------------------------- c zero out b-field average components c----------------------------------------------------------------------- c do i = 1, 3 bavg(i) = 0. end do c c----------------------------------------------------------------------- c get b-field scale factor from maf1 record c----------------------------------------------------------------------- c bscale = idat(25) c c----------------------------------------------------------------------- c set k to b-field start location minus 1 c----------------------------------------------------------------------- c k = 100 c c----------------------------------------------------------------------- c j is second counter c----------------------------------------------------------------------- c do j = 1, 8 c c----------------------------------------------------------------------- c i is component counter (1=x,2=y,3=z) c b array is set equal to b-field components c----------------------------------------------------------------------- c do i = 1, 3 k = k + 1 b(i) = bscale * idat(k) end do c c----------------------------------------------------------------------- c get spin angle at each second [spang = ram * spinrate * (j-1)] c----------------------------------------------------------------------- c spang = 0.1 * idat(23) + 0.01 * idat(20) * (j-1) if (spang .lt. -180.0) spang = spang + 360.0 if (spang .gt. 180.0) spang = spang - 360.0 c c----------------------------------------------------------------------- c rotate to fixed frame c----------------------------------------------------------------------- c call axisrt (b, -spang, brot) c c----------------------------------------------------------------------- c sum rotated b-field components c----------------------------------------------------------------------- c do i = 1, 3 bavg(i) = bavg(i) + brot(i) end do end do c c----------------------------------------------------------------------- c end of second counter loop c c compute average of rotated b-field components c----------------------------------------------------------------------- c do i = 1, 3 bavg(i) = bavg(i) / 8. end do c c----------------------------------------------------------------------- c----------------------------------------------------------------------- c return end