C+ C NAME: C plane C PURPOSE: C Removes tilt and offset from a 3 x 3 array of values C CATEGORY: C Data processing: called by subroutine "cosmicra.f" C CALLING SEQUENCE: C call plane(z,z0) C INPUTS: C z(3,3) real a 3x3 square array of values C OUTPUTS: C z(3,3) real the above array with LSQ fit removed C z0 real the average value removed from all 9 C CALLS: C PROCEDURE: C Finds a least-squares planar fit through the 8 outside z values, C then reduces all 9 z's to values relative to the plane C MODIFICATION HISTORY: C Jan, 2003 A. Buffington (UCSD) C- subroutine plane(z,z0,a,b) c c This subroutine solves for a least-squares planar fit through the 8 z-values c surrounding [2,2], then reduces all 9 z's relative to the plane, c and returns with the reduced values. c real*4 z(3,3),sumz,sumx,sumy,a,b,z0 integer*4 i,j c sumz=z(1,2)+z(3,2) sumx=0. sumy=0. do i=1,3 sumz=sumz+z(i,1)+z(i,3) sumx=sumx+z(1,i)-z(3,i) sumy=sumy+z(i,1)-z(i,3) enddo a=sumx/6. b=sumy/6. z0=sumz/8. do i=1,3 do j=1,3 z(i,j)=z(i,j)-z0+a*float(i-2)+b*float(j-2) enddo enddo return end