C C C ROUTINE: AMP_HIST C C VERSION: V01 C C VECTOR: OFF C C PURPOSE: To measure populations of amplitude in user_supplied C bins. Also returns counts of samples above and below C the defined histogram. C This routine will not count zero samples in the front C or back-end mute zones, but it will count zeros elsewhere. C C CALLED BY: XPAMPSCN C C USAGE: CALL AMP_HIST (ADATA,N,ABIN,ZBIN,NBIN,POP8) c C Where: C C (I) ADATA Trace of N samples. C (I) N Number of samples in ADATA. C (I) ABIN Lowest bin threshold C (I) ZBIN Highest bin threshold C (I) NBIN Number of bins to create in range ABIN to ZBIN C (O) POP8 REAL*8 array of dimension (0:NBIN+1) returned C with sample population in each bin (1 thru N), C plus: C POP8(0) = no. values below lower limit C POP.(N+1) = no. values beyond higher limit C The calling program clears POP8 at the start C of the job (or whenever it wants to start C collecting data for a new histogram). C This array needs to be REAL*8 as neither C INTEGER*4 or REAL*4 would provide enough C dynamic range for a big 3D dataset. C C----------------------------------------------------------------------- C C UPDATE HISTORY C C V01 - JUN 2001 - SHM C Initial release on UNIX. C C$$$$------------------------------------------------------------------- C SUBROUTINE AMP_HIST (ADATA,N,ABIN,ZBIN,NBIN,POP8) IMPLICIT NONE C C Arguments C REAL ADATA(*) INTEGER N REAL ABIN, ZBIN ! lower and upper bin limits INTEGER NBIN ! no bins DOUBLE PRECISION POP8(0:N+1) ! output population array C C Local REAL DELTA REAL AA INTEGER I, IBIN INTEGER MUTE_F, MUTE_B C DELTA=(ZBIN-ABIN)/REAL(NBIN) cc PRINT *,'Bin Thresholds:' cc PRINT *,((ABIN+I*DELTA), I=0,NBIN) C In order to make as sensible an analysis as possible, we C first scan the trace for front-end and back-end mute, so we C do not include a lot of man-made zeros in our estimate. C If trace is dead, FBMUTES returns MUTE_F=N. C CALL FBMUTES(ADATA,N,MUTE_F,MUTE_B) IF(MUTE_F.LT.N) THEN C C Add one so that lowest bin no is 1. C As our bin indexing starts from 0, C we use POP8(0) to record samples that are lower than ABIN C and POP8(N+1) to record samples that are greater than ZBIN. C DO I=MUTE_F+1, N-MUTE_B AA=(ADATA(I) - ABIN)/DELTA IBIN=INT(AA) + 1 IF(ADATA(I).LT.ABIN) THEN IBIN=0 ELSEIF (ADATA(I).GT.ZBIN) THEN IBIN=NBIN+1 ENDIF POP8(IBIN)=POP8(IBIN)+1.0D0 ccc PRINT *,I,ADATA(I),aa,IBIN,POP8(IBIN) ENDDO ENDIF RETURN END