      SUBROUTINE demean_noise(A,ns,N)
C
c	demean uses the pre-signal noise estimate
c	(from pt 1 to point ns) to determine the 
c	the mean value and removes the mean from
c     the entire time series.
c
c     based on routine demean
C                                                    
      INTEGER*4 N,I,ns
      DIMENSION A(*)
c
      XM=0.
      DO 1 I=1,ns
 1      XM=XM+A(I)
      XM=XM/ns
c
      DO 2 I=1,N
 2      A(I)=A(I)-XM
      RETURN
      END
