View full text: TOAP: Third Octave Analysis Program, Version 6.0

Transcription

View full text: TOAP: Third Octave Analysis Program, Version 6.0
NRC Publications Archive
Archives des publications du CNRC
TOAP: Third Octave Analysis Program, version 6.0 : reference manual
Guan, W.; Hunaidi, O.
For the publisher’s version, please access the DOI link below./ Pour consulter la version de l’éditeur, utilisez le lien
DOI ci-dessous.
Publisher’s version / Version de l'éditeur:
http://doi.org/10.4224/20337910
Internal Report, Institute for Research in Construction, National Research Council
Canada, 1996-04-01
NRC Publications Record / Notice d'Archives des publications de CNRC:
http://nparc.cisti-icist.nrc-cnrc.gc.ca/eng/view/object/?id=acaed5c3-7b2a-4ff0-9a2b-492c96b99f57
http://nparc.cisti-icist.nrc-cnrc.gc.ca/fra/voir/objet/?id=acaed5c3-7b2a-4ff0-9a2b-492c96b99f57
Access and use of this website and the material on it are subject to the Terms and Conditions set forth at
http://nparc.cisti-icist.nrc-cnrc.gc.ca/eng/copyright
READ THESE TERMS AND CONDITIONS CAREFULLY BEFORE USING THIS WEBSITE.
L’accès à ce site Web et l’utilisation de son contenu sont assujettis aux conditions présentées dans le site
http://nparc.cisti-icist.nrc-cnrc.gc.ca/fra/droits
LISEZ CES CONDITIONS ATTENTIVEMENT AVANT D’UTILISER CE SITE WEB.
Questions? Contact the NRC Publications Archive team at
[email protected]. If you wish to email the authors directly, please see the
first page of the publication for their contact information.
Vous avez des questions? Nous pouvons vous aider. Pour communiquer directement avec un auteur, consultez la
première page de la revue dans laquelle son article a été publié afin de trouver ses coordonnées. Si vous n’arrivez
pas à les repérer, communiquez avec nous à [email protected].
Ser
1
1*1
National Research
Council Canada
Conseil national
de reckrcher Canada
no. 728
c. 2
I
IUC-CHC
l LLT
TOAP: Third Octave Analysis
Program, Version 6.0
Reference Manual
By W. Guan and M.O. Al-Hunaidi
CIsTI,ICIST
NRC,CNRC
I R C R e f Ser
R e c e i v e d o n : 04-17-97
I n t e r n a l report.
Internal Report No. 728
Date of Issue: April 1996
I t e r n a l report ( I n s t i t u t e f
3
ANALYSE
This is an internal report of the Institute for Research in Construction. Although not
intended for general distribution, it may be cited as a reference in other publications.
TOAP: THIRD OCTAVE ANAL,YSIS PROGRAM
VERSION 6.0
REFERENCE &iiL\TAL
by
W. Guan and M.O. Al-Hunaidi
Structures Laboratory
Institute for Research in Construction
National Research Council
April 1996
ABSTRACT
The program TOAP version 6.0 performs 113 octave band analysis and frequency weighting
of acceleration signals acquired with the GLOBAL LAB, Snap-Master, and MTAS data
acquisition systems. Acceleration signals stored in ASCII format (acquired with other
systems) can also be analyzed with TOM. Digital filtering is employed directly in the time
domain to decompose the signal into its 113 octave band frequency components, and to apply
frequency weightings which simulate the human response to whole-body vibration. T O M
allows multi-channel processing of vibration data with flexibility in various analysis
parameters. It is a convenient and inexpensive alternative to existing one or two channel
analysis hardware and human-vibration filter units, such as the B & K 2134 Sound Intensity
Analyzer and B & K 2522 Human-vibration Unit. It is also a useful supplement to the
GLOBAL LAB analysis software which does not include 113-octave processing.
TABLE OF COhTENTS
ABSTRACT
..
11
1
DIGITAL FILTERNG
1.1
Third Octave Filters
1.1.1 Filter Type
1.1.2 Filtering Parameters
1.1.3 Filtering Procedure
1.1.4 Effect of Sampling Frequency
1.2
Frequency-Weighting Fitter
1.2.1 Weighting filters
2
PREPROCESSING INFORMATION AXD ACCESSING OF DATA FILES
F i Needed for the Operation of TOAP
2.1
2.1.1 h4TAS Acquired Data
2.1.2 GLOBAL LAB Acqulred Data
2.1.3 Snap Master Acquired Data
2.1.4 ASCII Data Format
User Options and Checking Procedures
2.2
2.2.1 Job NameFilename
2.2.2 Setup Information
2.2.3 Channel Information
3
PROCESSING PROCEDURES
3.1
Processing Parameters
Processing Loop of Y3-Octave Analysis
3.2
Processing Loop of Frequency-Weighted Analysis
3.3
Processing Loop Exit Function
3.4
4
OUTPUT
20
5
HOW TO RUN TOAP
21
6
MAKEFILE AND COMPILING
22
ACKNOWLEDGMENTS
25
APPENDIX 1: VERIFICATION OF THE PROPER R3-CTIOhIiG OF TOAP
26
APPENDIX 2: DETAILED VERIFICATION OF TAIRD OCTAVE BAND FILTERS 50
APPENDIX 3: VERIFICATION OF FREQUENCY WEIGHTING FILTERS
104
APPENDIX 4: VERIFICATION OF ADDING STATISTICS AND SNAP-MASTER
108
DATA FOILMAT
APPENDIX 5: VERIFICATION OF ADDING ASCII D.ITA FOR&MT
E X P O N E h i L AVERAGING
118
APPENDIX 6: SHORT USER'S GUIDE TO TOAP
122
APPENDIX 7: SOURCE CODE OF M U O R SUBROLTINES
127
1
DIGITAL FILTERING
1.1
Third Octave Filters (by M. Hofmeister and hI.0. Al-Hunaidi)
1.1.1 Filter Type
In TOAP the filtering duties for third octave analysis are performed by tangent Butterworth
filters. The square of the absolute value of the transfer function of a tangent Butterworth
filter has the following form
/ H(f) /
= 1 I (1 + (tan x f f / r a m B n 2 M )
where f is the independent variable, frequency, B is the signal bandwidth, T is the sampling
interval, and M is the number of poles of the filter. The Butterworth family of filters is
among some of the simplest higher-order filters yet these filterscan be used in many different
situations. Another type of filter from this family is the sine Butterworth filter. The transfer
function expression for this filter is the same as that for the former except that the tangent
tenns are replaced by sine terms. The tangent filters have better definition at the bandedge
than their sine counterparts and therefore provide better performance in this respect. The
tangent filters, however, do contain zeroes which, in some applications, may act to increase
the calculation time associated with them.
All of the filters used in TOAP have been made 12-pole filters. This was done because it
was found to give the best conformance (see results in Appendix 2). The number of poles
can, however, be changed, if desired, by a minor modification to the source code of the
subroutine filter-info21(found in the larger subroutine processjl). Within the code for
this subroutine is a parameter statement which sets the variable numgoles to 12. To change
the number of poles would simply be to change this statement. In the sections to follow,
unless otherwise noted, any subroutine can be assumed to be found in the major subroutine
process_gl which itself is found in the mainline program toap.
1.1.2 Filtering Parameters
The frequency range over which the signal is to be filtered into 113-octaves is user given and
is asked for in the routine filter-infoxl. The range must fall within the limits of 2.5 and 250
Hz, inclusive. The user enters the upper and lower 1B-octaves of the range of interest and
these must span an integral number of octaves. In addition, the upper and lower limits must
be ANSI standard 113-octave centre frequencies which are listed in Table I . If any of the
above criteria are not met or if a poor entry such as the lower limit being higher than the
upper limit is given, the user is told so and given as many chances as required to make a
proper entry. Also needed as a filtering parameter, but not user given, is the sampling
frequency of the raw time signal. For MTAS data format the sampling frequency is read
from the .DOC file by the subroutine get-sjreq which itself is called by filter-info~l. For
GLOBAL LAB data format it is read from the header of the source file by the subroutine
rend-&#-header.
1.1.3 Filtering Procedure
The routine which generates the coefficients for the filters is found in the source code of the
subroutine lptb (an acronym for lowpass tangent Butterworth) which was taken straight out
of Applied Time Series Analysis Vol. 1 by Otnes and Enochson (1978). This subroutine is
manipulated by its mother routine digfilh and is used to generate the coefficients for both
low- and highpass fdters. These coefficients calculated by digfiltm are written to disk where
they are later read by tmrdoct. From here they are sent to the subroutines hipuss3 and
lopass3 (both found in th3rdoct) which are repeatedly used to filter the raw signal into its
113-octave bands. The exact process by which the filtering occurs in TOAP is presented
below and was designed to save both memory and processing time.
The frequency range of interest is user given and may include as many as seven octaves.
The filter coefficients for the highest octave only, are calculated and written to disk by
digfiltm to be used later by th3rdoct. These coefficients include those calculated for lowpass
filters having bandedge frequencies of the upper limits of the highest four in-octave bands.
In addition, the coefficients for highpass filters having bandedge frequencies of the lower
limits of the top three 113-octave bands are also calculated. From now on, the upper l i i t s of
the top four 113-octaves in the processing range will be referred to as points 0,2,4, and 6,
with point 0 being the highest frequency and point 6 being the lowest. As well, the lower
limits of the top three 113-octaves will be denoted points 1, -, and 5 with point 1 being the
highest frequency and point 5 being the lowest. Figwe 1 illustrates where these points occur
in the highest 113-octave bands of the processing range.
Table 1 ANSI S 1 . 1 1-1986 1/3-Octave Centre Frequencies
\\-ithin thirdoct, three arrays, signal,b4000,and b3I50 are used to manipulate the signal.
To begin with, the raw signal is lowpassed at point 0 and placed in the first half the array
signal. This is then lowpassed at point 6 and the resultant values are placed in the second
half of signal. Similarly, the raw data is lowpassed at point 4 and the filtered signal is placed
in the second half of b31.50. Finally, the raw data is lowpassed at point 2 and the result
placed in the second half of b4000. The values in the first half of signal are then highpassed
at point 1 and placed back in the first half of signal. The data in the second half of b4000 is
highpassed at point 3 and placed in the fust half of this array. Finally, the signal in the
second half of b3 150 is highpassed at point 5 and placed in the first half of that array. After
this process is complete, the first half of the array signal will contain the highest 113-octave
bandpassed data, the fust half of b4000 will have the second highest 113-octave bandpassed
data, and the first half of b3150 will have the third highest 113-octave bandpassed data. In
addition, the second half of the array signal will contain the data lowpassed at the upper limit
of the fourth highest 113-octave in the processing range.
Thus, the data has been filtered into the highest three 113-octave bands of the processing
range. To filter the lower 113-octave bands the routine th3rdoct does the following. Every
second point of the lowpassed data in the second half of the array signal is discarded which
effectively reduces the sampling frequency by half. By doing so, the filter coefficients used
for the highest octave can be used for the one just below it. Thus, the whole procedure
described above is repeated for this lower octave. This can also be repeated for however
many octaves have been specified. The fmal result is that the first halves of the arrays
signal, b4000, and b3 150 all contain bandpassed data of the three 113-octaves comprising the
top octave, the next quarters of these arrays contain the 113-octaves of the next highest
octave, and so on until all of the octaves have been covered.
This procedure saves space since only three arrays are needed; the dimensions of each equal
to twice the number of points to be processed. Time is also saved since the filter coefficients
need be calculated for only the top octave; all lower octaves use these same coefficients.
This is because with a halving of the sampling frequency the same coefficients apply an
octave 10x1-er.
1.1.4 Effect of Sampling Frequency
The response of the 113 octave band filters implemented in TOAP, like all other bandpass
filter, depends on the number of poles and the ratio between the sampling frequency of data
and the center frequency of the filter. The results of an investigation of the effect of these
two factors on the filter's response are given in Appendix 2.
From these results, it can be seen that for sampling frequencies between 500 to 4000 Hz, ths
113 octave band digital filters conform to specifications given in the standard IEC 225
mainly when the filters should conform to IEC 225.
I
I
I
1
4th dghest
3rd dghest
2nd hghest
highest i/3-octave
centre frequency
frequency
+
'
Figure 1. Illustration of the bandedge frequencies found in the top
four 1/3-octaves of the processing range.
Figure 1 Illustration of the Bandedge Frequencies Found in the Top
Four 113-Octaves of the Processing Range
1.2
Frequency-Weighting Fiter (by W. Gum)
1.2.1 Weighting filters
Frequency-weighting filters specified in both the British Standard BS 6841:1987 and the
International Standard IS0 8041:1990 for h u m body vibration are implemented in TOAP.
In both standards weighting filters are defined as analog filters in the form of a Laplace
transform. These filters are k h i t e impulse-response (IIR) filters, and the number of poles,
comer frequencies, and frequency responses are all clearly specified by definitions. A
weighting filter consists of two filters, a frequency band-limiting filter and a frequency
weighting filter. The transfer functions of filters. H(s),are given by the standards as follows:
Band-limiting (for both weighting B and weighting D)
~
~-
Frequency weighting: weighting B
s + 2nf,
2x~f,'
HP8 (s)=
S 2 +-22xf4s+4X2f42
Qz
Frequency weighting: weighting D
where f, (n = 1 to 6) designates cutoff or resonance frequency of filter, Q, (n = 1 to 4)
designates selectivity, and K is a constant gain. For a spenfic weighting type, coefficients fn,
Qn,and K are all constants. H(s) is the trausfer function of the filter, and s is the Laplace
operator.
I S 0 8041:1990
Band-limiting (for both W.Bx-y and R7.B.z)
Frequency weighting: W.B.x-y
1 + 0.08s
Hz.., ( s )=
1+0.125~+(0.08s)~
Frequency weighting: W.B.z
0.42 + 0.045s
Hz ( s )=
1+o.044s+(o.03s)2
wherefi and f, are the lower limiting frequency and upper limiting frequency, respectively. fi
- 100.1NI, fU = 100.lNu, where N[ and Nu are integer numbers. For whole body vibration, Nl
= 0 and Nu = 19. H(s) is the transfer function of the filter. and s is the Laplace operator.
These analog filters have to LX converted into digital fd:ers bsiore they can be simulated in
software. The frequency band-limiting filters shown in Equations ( 1 ) and (4) are both 4-pole
Butterworth bandpass fdters which can be understood as the combinations of 2-pole
The bilinear
Butterworth lowpass filters and 2-pole Bunerworth highpass filters.
transformation method with frequency prewrapping, which is the most frequently used method
for converting filters with flat gain in the passband, is used for converting these filters. The ztransform of a digital filter is obtained from the followins equation:
i=1
where f, is the cutoff frequency of the filter, and T is the sampling interval. The cutoff
frequency and the number of poles are kept the same as in analog filter so that the digital
band-limiting filters are also 4-pole W filters. ai and bi are constant coefficients, z is ztransform operator, and M and N are number of zeros and poles, respectively.
The frequency weighting filters shown in Equations (2), ( J ) , and ( 6 ) have 2 poles, and the one
in Equation ( 3 ) has 4 poles. Because of the complicated properties in their frequency
responses, these filters are converted into digital filters by the impulse invariant method. If
H(s) is expanded in terms of partial fractions, it can be w-rinenzs
then digital filters can be obtained as follows:
where H(z) is the digital filter transfer function in z-transform, Ki is constant, si is pole. T is
sampling interval, and M and N are number of zeros and poles, respectively. The results are
also IIR filters and have the same number of poles as in analog filters. Further details about
the implementation of these filters can be found in Al-Hunaidi and Gum ( 1996).
The frequency responses of the combinations of frequency weighting filters and band-limiting
filters specified by the IS0 and BS standards are shown in Figures 2 to 5.
As with 113 octave filters, the response function of digital frequency-weighting filter is
influenced by the sampling frequency. The effect of the sampling frequency is investigated
in Appendix 3. It was found that digital frequency-weishting filters implemented have
conformed to tolerances specified in the I S 0 and BS standards when the sampling frequency
is behx-een 300 and 1500 Hz. At higher frequencies these filters slightly exceed the specified
tolerances.
t""@
:
I
Sampling rate = 500 Hz
1
- I S 0 8041 (z-axis weighting) :
I
- - - Digital filter
-
-
I
0.1
1.o
10.0
100.0
Frequency (Hz)
Figure 2 Comparison of IS0 8041 Standard and Digital Filter in TOAP (z-axis weighting)
k""'
I
I
Sampling rate = 500 Hz
j
- IS0 8W1 (x,y-axes weighting) :
---
Digital fiiter
-
-
,
0.1
1.o
Frequency (Hz)
10.0
100.0
Figure 3 Comparison of IS0 8041 Standard and Digital Filter in TOAP (x,y-axis weighting)
8
I""'
- BS 6841 (Weighting \Nb )
- Sampling rate = 500 H Z
- - - Digital filter
-
I
I
I
0.1
1.o
10.0
100.0
Frequency (Hz)
Figure 4 Comparison of BS 6841 Standard and Digital Filter in T O M (Weighting W,)
10.0
k.
...I
I
- BS 6841 (Weighting Wd)
- - - Digital filter
:Sampling rate = 500 Hz
.-c
cl
-
I
1.0 :
Q
-3
5:
2
0.1
1
I
0.1
1.o
10.0
100.0
Frequency (Hz)
Figure 5 Comparison of BS 6841 Standard and Digital Filter in TOAP (Weighting W,)
2
PREPROCESSLNG INFORMATIOX AND ACCESSING O F DATA FILES
(by M. Hofmeister, M.O. Al-Hunaidi, W. Guan, and J. Marans)
2.1
Files Needed for the Operation of TOAP
2.1.1 MTAS Acquired Data
There are certain files required by TOAP if MTAS acquired data is to be processed. These
files are needed to give various pieces of information necessary for the processing of the job.
Included in these files are the <jobname>.HDR file, <jobname>.STi (i=setup characterr file,
Cjk=chmel
and the <jobname>.DOC file. In addition to these are the <jobname-.Djk
number) files which contain the data for each channel. These files must all be located in the
same directory which does not necessarily have to be the working directory from which
TOAP is being run. The reader is referred to the MTAS User's Guide Version 2 for the exact
contents of these files.
From now on whenever an extension is used to refer to a file it is assumed that the root
<jobname> precedes it. For example, the hypothetical file TEST.DOC would simply bs
referred to as the .DOC file.
2.1.2 GLOBAL LAB Acquired Data
There is only one file needed for the processing of GLOBAL LAB formatted data and rhar is
the data source file which is recorded directly from the AID board. The default extension for
these fies is .DAT and they usually take the form <filename roob.DAT. This file does not
have to be in the working directory for processing to take place. After this point, where job
name appears for the MTAS option, filename will appear for the GLOBAL LAB option.
Note for the versions after Nov. 12, 1993, including the current version, version 6.0. The
current version was tested for DT2821 board only. It is not clear yet whether this version
works with DT2801A board anymore after the modification on Nov. 12, 1993. To maks
sure that this version works correctly with the board that you are using, run a known ~ L
tone signal to see whether you can get the correct rms value, i.e., 0.707 of the peak value of
the known pure tone signal.
I
Note for the versions before Nov. 12, 1993, that is, for any versions older and including
version 4.0. It should be noted that, for version 2.0, the GLOBAL LAB interface of T 0 . e
was written to accommodate data acquired from the DT2801A board. Data acquired from
other boards, particularly those which record in offset binary unsigned words will be
processed incorrectly. For this reason, take note of the board used to acquire the data before
using the GLOBAL LAB option in TOAP.
2.1.3 Snap Master Acquired Data
TOAP will process plotter binary, and standard binary Snap Master files. SNAP MASTER
automatically assigns plotter binary files a .PLT extension. The file name extension assigned
to standard binary files by SNAP MASTER, however, is arbitrary. Hence, the user must
enter the entire file name when selecting standard binary file format. Only one file name is
needed to perform the analysis. The user should make sure the data file is present in the
current working directory before invoking TOAP.
2.1.4 ASCII Data Format
Time history stored in text file can be processed by TOAP. The format of the file should
contain one comment line at the beginning of the file. Only one line is allowed. If there is
no comment, an empty line is required as the first line of the file. Sampled data start from
the second line. Each channel occupies one column. For example, a data file with 4
channels has the following format.
channel 1
1.0
channel 2
1.0
channel 3
1.0
channel 4
1.0
The user will be prompted separately for the number of channels and sampling frequency
(only in the case of ASCII files). Verification of the correct reading of ASCII files is g i ~ e n
in Appendix 5.
2.2
User Options and Checking Procedures
2.2.1
Job Nameffilename
The user is asked to enter the job namelfilename which may include a path specification if
the required files are not located in the working directory. This occurs in the subroutine
get-namejl, after which it checks for the .HDR file (for the MTAS option) or the filename
itself (for other options) to make sure that the job exists. If the job does not exist the user is
warned and has the option of either entering a new job namelfilename or ending the
program. The full job name including path specification cannot be larger than 15 characrers.
where the full filename (with extension) can be as large as 20 characters.
With the GLOBAL LAB option. the DAFF (Data Acquisition File Format) header of the
source file is checked for various flags before processing can begin. This is done by the
subroutine read-daff-header as it ensures that the file is a DAFF 'Sampled Data File' having
the correct byte-order (INTEL) and character set (ASCII) as well as having at least one block
of data present.
2.2.2
Setup Information (for MTAS acquired data onl>-)
The subroutine setup-info checks the job directory (directory within which the .HDR file is
located) for any .STi files present. It also checks the .DOC file for information regarding the
setups by calling the subroutine double-check-serups. This acts as a second check to prevent
problems which may occur in the future when information needed for data processing is read
from the .DOC file. If there are no setups available for the job the user is warned and given
a chance to either enter a new job name or quit the program. If there are more than one setup
available for the job, those present are listed and the user is given a choice of any ONE of
them in the subroutine get-setup. If only one setup is present, this one is automatically
selected and the subroutine get-setup is skipped.
2.2.3 Channel Information
For MTAS acquired data, to determine which channels exist, the job directory is checked for
<jobname><i>.Djk files by the subroutine channel-seek. This routine also calls the
subroutine double-check-channels which looks at the .DOC file in search of the same
information. Once again. this second check is to ensure that information needed for each
channel is indeed given in the .DOC file.
For GLOBAL L=\B acquired data the DAFF header of the source file is scanned for
available channels by the subroutine read-daff-channels. This subroutine does so with the
help of the routine dafSgarse which searches the header for specific pieces of information.
For detail on the DAFF header refer to the GLOBAL LAB user's guide V02.01 pp 270.293.
In both cases, if no channels are available, the user is warned and can either enter a new job
namelfilename or terminate the program. If the opposite is true, the subroutine
get-chnnehdl lists the channels available and allows the user to pick any number of rhem
in any combination. As the user chooses each channel, it is checked against those available
and the user is warned if it is not on the list. If no channels are picked, the user is warned
and has the choice of re-selecting or quitting the routine.
For ASCII format, user must input the number of channels correctly during the execution of
the program.
3
PROCESSING PROCEDURES
3.1.
Processing Parameters (by Xi. Hofmeister, M.O. Al-Hunaidi)
There are four parameters, all user given. which dictate the way the signal will be processed.
The first one is the segment length or inreamtion time of the processing. This is the portion,
entered in seconds, of the time signal to be filtered and used in a single processing run. The
length of the segment in seconds is converted to a length in number of points as the number
of seconds is simply multiplied by the sampling frequency (in Hz). Due to the filtering
procedure described earlier, the number of points of this segment must be divisible by 2-1,
where n is the number of octaves of the processing range. If the number of points of the user
specified segment does not fit this criterion, the length is increased or decreased to the
nearest value which does. The user is informed of this modification and is made aware of
the new length of the segment. It ma>-appear as though the user does not have absolute
control over the integration time, howex-er, the relative change in the segment length is
usually too small to have any noticeable effect on the results.
There is another restriction on the size of the segment length. The array which holds the
segment of the raw data (array signal) has been limited in size because of memory reasons.
It follows that the segment length is also limited and cannot contain a number of points
which is greater than half the dimension of this array. Only half the array is available
because of the filtering procedure outlined earlier. Currently, the dimension of the array
signal is set to 4 096 which means that the segment length can be no larger than 2 048 points.
The user is given the largest possible se-gment (in seconds) that can be entered before this
parameter is specified. If a segment len,& larger than this maximum is entered or if a
smaller length is entered and upon modification by the program itself, as explained above,
becomes larger than the maximum, the user will be asked to enter another value which is
(after modification) less than the given limit.
If the dimension of the array signal (and the arrays b4000 and b3 150) is too small for the
processing tasks required, it can easil>-be changed. The change involves a minor
modification to the source code of the subroutine process-gl (found in fife
PROCESGL.FOR) within which is a parameter statement setting the value of the constant
dim to 4 096. All that is required is that the value 4 096 be changed to whatever is desired
and that the whole routine TOAP be re-compiled. (see section 5 on compiling)
The other processing parameters include the processing start time, the number of se-ments to
be processed, and the number of initial segments to be isored. Each segment is fully
processed, including filtering and rms calculations. inds-rmdently. Specifying the number of
segments equates to giving the number of processing mzs to contribute to the rms
calculations. Each segment is taken from the raw s i g n i starting at the point where the
previous segment left off. The first segment begins at tix user specified start point. The
number of initial segments to be ignored parameter specifies that the first n segments are to
be filtered but excluded from the rms calculations. It is important to have this option
because often, the fust few segments contain invalid resxlts stemming from the
characteristics of the filter. (see Appendix 1, Test 1)
The Snap Master plotter data files contain a short heads: that does not indicate the sampling
frequency, so if the user chooses to process plotter files. -Jle sampling frequency will be
required.
For ASCII input file, both the sampling frequency and 5 s number of channels will be
required from user input.
3.2
Processing Loop of 1/3-Octave Analysis
(by M. Hofrneister, M.O. Al-Hunaidi, W. Guan. and J. Marans)
After all of the job specifications, filtering and processkg parameters have been collected,
data processing may take place. The data is processed cne channel at a time and all of the
fifte~g
and processing parameters are the same for e x 5 channel. The main processing loop
which runs through all of the channels is found in the srr5routine process_gl. From now on,
any actions taken, any calls to subroutines, can be assunzd to occur from process-gl.
To begin with, for MTAS acquired data, the sensitivity for the current channel is read from
the .DOC file by the subroutine read-sensitivityl. This d u e is the total effective sensitivity
of the recording equipment for that particular channel. The sensitivity value read from disk
is later used to scale the raw data values read from the .Djk files. The sensitivity is the only
parameter that may differ from channel to channel.
For GLOBAL LAB acquired data, the sensitivity is r e G from the DAFF header of the data
file by the subroutine reakdaff-data. The sensitivity is in the form of a factor and offset
applied to the integral values which come straight from the A/Dboard.
For each channel there is an inner loop in which ~rocessingoccurs one segment at a time.
Starting out, the raw data of the current segment only, is read from disk by the subroutine
get-data1 for MTAS format and read-daff-data for GLOBAL LAB format. For MTAS
format the data is read from the .Djk files where jk is the current channel number. The data
exists in MTAS binary format and is converted to floating point format upon being read. In
addition, the values in the .Djk files are mukiplie3 by the sensitivity to fully reconstruct the
time signal in units of % g to be used for filtering. For GLOBAL LAB format, the ran
values off the AD board are multiplied by a factor and added to an offset to obtain the result
in the units specified by the DAFF header.
After the data is read and converted, filtering occurs in the subroutine rh3rdoct as described
in section 1 above. After the filtering has been completed for a segment of data, the rms
values for each 113-octave band pass are calculatsd by the subroutine root-mem-square.
The equation used to calculate the rms value for sach 113-octave is
rms = u. ((ln-,
I:x,2)
where xi represents the ith filtered value, in a sum which is carried out from i = 1 to N. If
more than one segment is specified for the analysis, the maximum rms values. only, for each
113-octave band are kept and then output. This is accomplished by comparing the rms value
calculated for the current segment with the previoss maximum and replacing this maximum
if the current value is greater. This is done for each 113-octave band in the range. If the
current segment is one to be ignored, the call to mttmean-square is skipped, with all the
other procedures remaining the same. In this wak-. the final result is one value for each 113octave band representing the maximum (for the band) out of all of the segments excluding
those initial ones that were ignored.
The rmq values are calculated in the same subroutine as for calculating rmsvalues,
root-mean-sqrcare. The equation used to calculart the rmq value for each 113 octave is
where xi and S are defined previously. The processing procedure for rmq value is the same
a s for rms value.
The rms value with exponential averaging is defined as:
where x(t) is the time domain signal sampled at time r, T is the integral variable, T is the time
constant for running averaging, and t is the current time. The equivalent process in digital
form is produced by using the following algorithm: -
- - x, 2 -x:_,2
x i 2 = x i-1 2 +
K
where x is the ith sample, K is an integer, K = T*f; wheref; is the sampling frequency. The
exponential averaging for 113-octave analysis is also canied out in subroutine
rms-meaxsquare. Since exponential averaging is a running averaging, the averaged result
of the last data point of current segment is passed to the calculation of next segment. The
maximum value of the exponential averaging result is outputted. Verification of exponential
averaging is given in Appendix 5.
In order to calculate statistics, all rms or rmq values are retained for subsequent processing.
After all segments have been fdtered, and before the next channel is analyzed, the statistical
subroutine, statistics2, which can be optionally invoked searches for the 3 maxima, the
minimum, the mean and the standard deviation. The mean is calculated using the formula
p=(lN)Cq
and standard deviation follows from
Cf = (l/m-1))x ( p - xi)'
No statistics result is produced for exponential avera-@ng.
3.3
Processing Loop of Frequency-Weighted Analysis (by W. Guan)
The filtering and processing of frequency-weighted analysis is similar to the one for 113octave analysis. F i t , the filter coefficients aj and bi of the band bandlimiting and frequencyweighting digital fdters are calculated. The filtering procedure is done in the timedomain by
first passing the raw time signal thou@ the band-limiting filter, and then the frequency
weighting filter. The result is a frequency-weighted time signal. By using the overlap-andadd method, the input signal can be separated into as many segments as necessary so that
there is no limitation to the length of input signal. That is to say, the last N points of raw time
signal and the last M points of the weighted signal containing the initial conditions for the next
segment are saved, and then added to the beginning of next segment. This ensures that no
information will be lost between two consecutive calls to the filter subroutine. The xveighting
filter subroutines are programmed in modular form so that only one subrourine need be called
for one segment. This also makes it sasy to add other aeighting types in the future. After the
filtering process, linear and exponential rms value of the frequency-weighted signal are
calculated in the same manner as decribed for 113-octave analysis in last section. Due to the
effect of filter rise time it is usually necessary to discard the first two to four seconds before a
valid result can be obtained. The Ion-erthe predominant frequency of interest, the longer the
result to be discarded.
3.4
Processing Loop Exit Function (by M. Hofmeister and M.O. Al-Hunaidi)
In some cases processing cannot be continued and has to be halted prematurely. This occurs
when there is not enough data in the .Djk file or source data fde to process according to
specifications. This results when a poor combination of processing parameters, such as too
many segments or a start time which is too late, is chosen. This could cause the routine to
automatically search for data beyond the end of the file possibly corning up with zeroes or
other forms of erroneous values. Fortunately, this is prevented from happening since in the
subroutines get-data1 and read-daff-data a flag is actirated when the source data has been
exhausted prematurely. When this happens, control is returned from get-data1 (or
read-daff-data) back to process_gl a-here the user is warned of the situation and given
options concerning the next course of action.
If processing is aborted as described above, depending on the situation, the user may be
presented with one of two sets of options. If absolutely no rms values for any channels have
been computed before interruption, the user is given the choice of resetting processing
parameters and starting again or quitting the program. If the former is chosen, only the
processing parameters are re-entered; the job and fdter specifications remain as they were
and processing starts from the first segment of the f m t channel. If some rms results were
calculated before the loop was exited. the user is given the number of channels processed so
far and the channel currently being processed. He is also informed as to the number of
segments that have contributed to the rms results for the current channel. With this, the user
is given the choice of seeing the results as they are or resetting the processing parameters and
starting again.
4
OUTPUT (by IM. Hofrneister. 41.0. Al-Hunaidi, W. Gum, and J. Marans)
TOAP offers two forms of ourput: to screen and to disk. The first one is optional. and if
chosen, the maximum rms values are listed beside each centre frequency of their respeztive
113-octave band. The values are viewed sequentially by channel at the user's discretion.
While viewing the results for each channel, the user has the option to quit and go to the end
of the routine at any time. The same rms values are automatically wrinen to disk in much
the same format as they are displayed to screen. They are written in ASCII format to files of
the form <jobnameA>.RMS where i is the setup character for 4fTAS format, and
cfilename root>.RMS for other formats. These files contain the rms values for all the
selected channels and are wrinen to the same directory in which the .DOC, .HDR. .STi, and
<jobname>u>.Djk files are found (for MTAS format) or simply the directory of the source
file in the case of GLOBAL LAB acquired data. If the user chooses rmq instead of rms
values, the ASCII file written out will have an .NQ
extension instead of an .mIS.
If the statistics option is chosen, another ASCLI file is output with the extension .STA. This
file contains the results of the statistical calculations. Please reisr to the sample outpur in
Appendix 4.
These .RMS files can be imported into a spreadsheet like Excel or Quattro Pro for display
purposes.
Output of peak value for frequency-weighted signals is wrinen to .RMS only.
5
HOW TO RUN TOAP
A short user's manual describing how to run T 0 . q and provide input data is given in
Appendix 6.
6
MAKEFILE AND COMPILING (by %I. Hofmeister, W. Guan, and J. Marans)
For a routine such as TOAP which is made up of source code contained in over 40 files,
compiling becomes a difficult task. To make the job easier, a utility known as a makefile is
used. The makefile contains all of the compiling and linking instructions needed to create
the desired executable file. This eliminates the chore of specifying these commands each
time the routine has to be re-compiled due to minor changes in the source code. For
example, if a change is made in one of the .FOR files of the source code, the makefile detects
this update by comparing the creation times of this file with its .OBJ (object) file. After
making this discovery the makefile re-compiles this file only, and links the new object file to
those already existing. The source code of the makefile used for TOAP.EXE, called
MAKEFILE, is included with this document in Appendix 2. MAKEFILE was constructed
for use with the Microsoft F o m Compiler Version 5.0.
The makefile links object files by using libraries. For TOAP.EXE, the object files of the
major subroutines are found in the library FILTER.LIB, with those of the utility subroutines
found in the libraries MTAS.LIB and GRAJ3X4O.LIB. The object files found in the latter
two libraries are not normally tampered with since these subroutines are standard and do not
need changing. Modifications, if needed, usually occur to source code whose object files are
found in FILTER.LIB. If a modification was performed, following a change to the source
file the old object file would be erased from the library (HLTER.LIB) and the new one
would be added. All of the libraries would be linked together and the new executable file
would be created. The libraries used by MAKEFILE for linking are specified on the line
starting with 'libs = ...' in the code for this file.
Each compile option used to compile the source code for TOAP.EXE is given a short
comment (in the MAKEFILE code) concerning its significance. If elaboration on these
comments is needed, reference can be made to the Microsoft FORTRAN Reference manual.
Two options worthy of note are the /AH and the /Gt options. The /AH specifies that the
routine upon execution is to use the huge memory model. This is important to have
especially if the arrays signal, b4000,and b3150 are made larger in size. The /Gt option sets
the data threshold to 256 bytes which means that any data item larger than this amount will
be placed in its own far address. By setting this option in this way, the danger of overwriting
sections of system memory is avoided.
If a change is made to the source code of TOAP.EXE, to re-compile it, the following must
be done. The source code of the altered file(s) must be in the working directory unless they
are in a directory included in the PATH statement of the AUTOEXEC.B.L\T file. All
libraries needed must be in the working directory or in the directory specified in the SET
LIB statement of the AUTOEXECBAT file. Finally MAKEFILE must also be in the
working directory unless it is in a directory specified in the PATH statement of the
AUTOEXEC.BAT file. After these requirements have been satisfied. s~mplytype NMAKE
ALL at the DOS prompt. The new executable file, TOAP.EXE will be created and placed in
the working directory.
A listing of the source code of TOAP is given in Appendix 7.
REFERENCES
Al-Hunaidi, M.O., 1991. Investigation of Traffic-Induced Building Vibrations on
Sherbrooke Street East, Montreal. IRC Repon (No. 607), hRC. Ottawa.
Al-Hunaidi, M.O. and Guan, \I-.,1996. Digital Frequency W-eighting Filters for Evaluation
of Human Exposure to Building Vibration. Soise Control Engineering Journal (March-April
issue).
ANSI S 1.11-1986. Specification for Octave-Band and Fractional-Octave-Band Analog and
Digital Filters. Acoustical Society of America, New York, New York.
Borland International Inc., 1989. Quattro Pro User's Guide. Borland Inc., Scotts Valley,
CA.
Data Translation Inc., 1991. GLOBAL LAB User's Guide. Data Translation Inc., Marlboro,
MA.
Otnes, R.K. and Enochson, L., 1978. Applied Time Series Analysis, Volume 1: Basic
Techniques. John Wiley and Sons, Toronto.
Rainer, J.H. et al., 1990. Useis Guide: Modal Testing and Analysis System (MTAS),
Version 2. Internal Report No. 588, IRC, NRC,Ottawa.
Rudder, F.F. Jr., 1978. En-@neering Guidelines for the Analysis of Traffic-Induced
Vibration.
Report No. FHWA-RD-78-166 prepared for the Federal Highway
Administration, Washington, D.C.
International Standard Organization 1990.
Instrumentation, IS0 804 1: 1990.
Human response to vibration - Measuring
British Standards Institution 1987. British Standard Guide to iMeasurement and Evaluation of
Human Exposure to Whole-Body Mechanical Vibration and Repeated Shock BS 6841: 1987.
Parks,T.W.,and Bums, C.S. 1987. Digital Filter Design, John Wiey & Sons, Inc.
ACKNOWLEDGMENTS
This version is based on TOAP version 2 by M. Hofmeister and M.O. Al-Hunaidi. Additions
for Snap-Master data fonnat, rmq calculations. and the feature of statistics were done by J.
Marans. Frequency weighting filters, reading of ASCII input files, and exponential averaging
were implemented by W. Guan.
APPENDIX 1
VERIFICATION OF THE PROPER FUNCTIONING OF TOAP
(by M.Hotmeister and M.O. Al-Hunaidi)
Introduction
Confidence in the working order of a program can only be gained through extensive,
exhaustive =sting. It is important to conduct a variety of tests so that several aspects of the
routine can be scrutinized. However, it is impossible to look at the program under every
possible condition. Thus, a true comprehensive series of tests cannot be achieved under
normal cirmstances involving some kind of time limit. Therefore, the following
verification runs presented below can only attempt to provide the best possible overall check
of the proper functioning of the routine under the given situation.
Sample Data Used For Testing
For the most part, sample files used for testing were generated by the program
SNBIN2EXE. This routine constructs a pure sine signal of constant amplitude, frequency,
and zero DC offset. The frequency, amplitude, sampling frequency, and effective recording
sensitivity are all user-given. With the help of the final parameter the program writes the file
in the same MTAS binary format of the actual data files intended for use in the TOAP
routine. The source code for this program is found in SINBIN2.FOR which is included with
this document
Test 1: 16 Different Pure Tones, One For Each Channel
In this test 16 files were created by SINBN2.EXE, each with a different pure tone
frequency. The amplitude and sampling kquency were the same for every fde and were ser
to 100% g and 600 Hz,respectively. The frequencies used were 2.5,3.15,4,5,8,10,12.5,
20,25,31.5,40,63,125,160,200, and 250 Hz These are all standard frequencies and
corresponded to the files SINEB.Dl...16, respectively.
The purpose of this test was to ensure that the data files were being accessed correctly and to
expose the routine to a variety of pure tones. As can be seen by the printout of this run, the
16 frequencies listed above show up as the dominant ones in each of the 16 channels in the
correct order. For example, in channel 1 the highest rms value occurs at 25 Hz and similarly
at 200 Hz for channel 15. Thus, the routine is irnpomng the correcr files into the right
Ten 1
Freq
(Hz )
C h l RMS
( X g)
C h 2 RMS
t X 9)
C h 3 RMS
( % 9)
250
200
169
125
199
80
6;
50
40
31.5
25
20
16
12.5
10
8
6.3
5
4
3.15
2.5
Ch7 RNS .
cx
9,)..
1.400~-03
1.4456-03
6.606E-04.
6.841E-04
3.125E-04'
2.867E-04
5.392E-04
5.483E-05
1 104E-03
3...37Q~g04
2.660~-03
2.471E-01
1.960E+00.
7.020E+Ol
4.234€+00
2.017E-,01
4-351E-01
1.568E-01
l.llbE+OO
1.1.00E+00
9.755E-01
.~
Ch9 RMS
(% g )
Test 1 (Continued)
Freq
Ch13 R f f i
(HZ)
(%q)
Ch14 RHS
( X 9)
channels. Also, it is processing each tone in rougNy the same way, as the highest nus valued
arc all (with a few exceptions) close to 70 which would be expected
It is evident that the li-equencies other than that of the pure tone do not have rms values of
zero as, in theory, would be expected. lhis occurs because the shape of the filter is not a
perfect rectangle. The characteristics of the %WAS digital Nter used in TOAP are given in
Figure Al. It can be seen that the filter does not drop sharply for frequencies outside the 113octave band, thus allowing for spill-over. This is why the other frequencies do have a s d
rms value associated with them. The general trend is that the rms values of frequencies
closer to the one of the sine wave are larger than those fanher away. This is because the
spill-over is greaterfor closer [email protected] would be expected, - - : .,; . . .- . -. .. ...
. !
- .
. .~
.. .. .. .
. . . .
,.
.
,
~
It was mentioned earlier that for most of the channels the rms value of their respective pure
tone ID-octave band was close.(within 1.0) to the theoretical value of-70.71. T h w we=
however, a few exceptions to @is, namely channels 1,2, and 3. .In these cpes the rms values
(55.29,55.08, and 64.61, respectively)-aresomewhat lower than the.theontica1
. .
.value.
. .This
is due to the&e time of the filter. The rise time of the filter is:theamqmt of time.neededfor
and A2c gi.y it to reach its normallevel.of response to an inpur Figures -:A2b,
i.
illusmtions of the riv rimeof the filter used in the TOAP routine. They give t& ~ p s ofe
the filter ma unit impulse at time zqo for the 113-octavebands of 25&-1-25,an*16H z 2 It is
clear that the lower the m s t a v e band, the greater the rise time of the filter. This is why the
effect of.therise &is greatest for channels 1.2, and 3.
.,
~
.
.
.
. . . . .
.
.
.
.. . . . . . . :
. . . .
.
~
.,..
k.@V$
Qne way :@isp!ue.thea@ve
. . . .
prpblem.i s. m@?e
.
the $+?gti~ionrirne
~ . . so fqat. . . . . . .
the
..
rise
.. time
: . . ..will bea&
. . . . . less signifcan~.~.com&o=. T@. ~ n w a ~ . ~ ~ G u s t
f~.-k.
I , & aad )pinga0 in4grationtime of-20 won&. insteadottwa
.
. ,
.=
:-?.
w h i c h . a r e . a .. ~. , ~ h @at.@e.~.values
oy
of the 1 t 3 ~ v~e. . ~ g . .t. . .b. . i.~:c'.:r . p ~ .
tones.~aow.@thin
. . . . .
accepta able range of the theq~ticalVatue.:.&o@~.~~lutioq,is
.~ . .
...
. m .,
. ..
perfow m?re.avepgeszsd t h g v away afew kore of the initial-, . . .3
. ,B
.i
s.W
...: CI
@ o s e . ~ g m e . nyhi&
q ~ ~ the effectof she rise *e,is preseq~~.:In.90the~,~@
&yd&xg.the
.~.::.: ,.
,
first:three
.
. ckmneb, ttie integratiop time was~.
kept at two secondsb ~ t : & e n ~ : o f s e ~ m e @ j ? :
w g . i n ~ , etgd 1l,wi*
first IQignorgL : he gsults are &ached and clearly show that
the rms values of interest are what they should be.
.
.
~
~
~
~
. . .- . . . . . . . . . .. . . . .
:
-.
.
. . . .
:. .. .:.
.... i.. .
' ...
:
. .
:
... ,. . .. . .. . .. . .. . .. . .. . .. . . . .
-
..
..~
,
..
.
. . . .
.
.. . .. . .. .
_..._. . ._ .
;
:
:
:
:
;
:
..
- . .. - .
~~
:::;:.
~
.
-.
- .. .-
......
,: . ~ .
. . ..
.
..>I.
. .
...
.. ,
_.::.....
.
.
.
. . . .
~..
..:
.. . .
.
..,. . .. . . ..
.:.. . . . ..
. . . .
.
. . .
.... .
..-.
. .
:',.
i.
.-
.
. : , . i.
. :,::.
,;.: .;:;.
. . ,
. . . . . . .. . . .
..T . .>...
. . <:.:
. . ...
. :...
. . .
.
. .
. .. .... . .. ,. ... -.... .. ......... . . :3 . * ......
.
.
.
. . .:: ;.
:.i:
. .
-.
. . . -.'I . :;is::.
. . . ..
.:..
.
.
. ..
. .<:; <.::;.:::
.: $<.~.<: ~.
..
.
~.
.
:."..'.! . . \. ;:;c,.z.::-;:,s
...
.
.
.
--:?:.:;~:.-;-.
7.
....
~.
.
."~
:.. 29 . . . . . . :
.'! : - .
.
::,
.::,
~. ~ . . , .
. . . . .. ~. .
~
.
.
...
1
.:.
*
..
...
,.<
.
. , . ~.
.
.
.
,*.
.-:
..
.:
!
--.
Frequency Ratio
Frgm Al. Fdter characteristics of digital filter used in THIRD.
Figure A2. Wlex responses to a unit impulse function at time zero for the a)250 Hq b)125
Hz, and c)16 Hz lf3-cctavebands.
Test 1 (Rcdone with a 20 seccnd integrationtime)
Frequency
(Hz)
Chl
Fins
(% g)
RNS
(% g )
Ch2
ChS
RMS
(% r '
Test 1 (Redone with 11 segments processed. thc fint 10 of which ignortd)
Frequency
(HZ)
chi
F~MS
(% g)
RMS
(% g )
Ch2
RMS
( % 9)
Ch3
Test 2: 16 Identical Pure Tones, One For Each Channel
For this test 16 purt tones each with thc same frequency of 20 Hz, amplitude of 1008 g, and
sampling frequency of 600 Hz wen written to the fdes SINEBD1..16 by SINBIN2EXE
The purpose of this was to make sure that the processing of data was exactly the same f a
each channel. The results attached show that this is indeed the case and that no processing
biases arc present for different channels.
Test 3: Differing Numbers Of SegmentslSegrnentsTo Be Ignored
This test was performed for two channels and involved kdifferent runs using three
different combiiations of the number segments processed and the number of segments to be
ignored parameters. The three cases were: one segment processed (none ignored), two
segments processed (none ignored), and again, two segments processed, but with one
ignored The purpose was to ensure that the r o u ~ was
e p m s s i n g and discarding the
correct number of segments. The input files were again created by SINBIN2EXE using the
same sampling frequency and amplitude as before. The hvo files created for each case used
the frequencies of 2 5 and 20 Hz.
In the discussion below, the thm cases mentioned above will k referred to by the number of
segments processed, followed by the number of segments ignored, all enclosed in
parentheses. The results show that for (1.0) the ME values of the tone fresuencyare low
(especially with channel 1 for the reasons discussed in test 1 above) and for the other
frequencies abnormally high. In (2,O) the rms values for the tone frequencies are larger than
those found in (1,O) bur, for the most part, those of the other frequencies are the sam. Tht
values of the tone fiequencies have increased because the effect of the rise time is oot as
great in the second segment as it is in the fmt. The high rms values for the peripheral
frequencies caused by the effects of the rise time of the filter still exist because it is thc
maximum nus values that are being displayed. A way of decreasing these values is given by
(2,l) in which the first segment, the segment where most of these values have resulted. has
been ignored Thus it can be seen that for (2,l) the high pure tone values still exist but most
of the anomalous values due to the rise time have been attenuated. This gives proof that the
routine is processing and discarding the right number of segments.
Chl Rts
( X 9)
Ch2 RHS
( X 9)
6.694E-04
4.773E-04
2.391E-04
2.825E-04
1.707E-05
7.786E-06
7.942E-06
1.184E-04
1.096E-02
9.479E-03
6.817E+00
7.004E+Ol
5.945E+OO
1.299E-02
1.677E-03
9.966E-02
2.114E-01
8.627E-02
6.528E-01
6.591E-01
5.930E-01
Freq
(Hz)
Ch7 RMS
(X g)
Ch8 RMS
( X g)
Ch9 RMS
( X g)
ChlO RnS
( X g)
C h l l RPlS
( X 9)
Ch12 Rf'
(X g)
Ten 2 (Continued)
Freq
(Hz)
C h 1 3 RMS
(Z 9)
C h 1 4 RMS
( X 9)
Chl RRS
( X g)
Frequency
(HZ)
250.00
LOO. 00
160.00
125.00
100.00
do. 00
63.00
50.00
40.00
a1.50
25.00
i0.00
16.00
12.50
10.00
d.00
6.30
a.00
4.00
A.15
2-50
Chl
RXS
(% g)
r requency
(Hz)
Chl
RMS
( X g)
Ch8
HMS
(% g )
Test 4: Access Of Raw Data Files
Here, the start point, the point in time in the raw data Ne at which processing should begin.
and the segment length parameters were put to the test A modified version of TOAP.EXE
was written so that the raw data was printed to the screen immediately after it was read from
disk In this way, the correct functioning of these parameters could be determined explicitly.
The input file used for the test contained all of the integers between zero and 100 written in
the MTAS binary format Although a meaningless parameter for this Ne, for the sake of the
operation of the r o u ~ the
e sampling frequency was set to 600 Hz. The segment length
parameter was set to 0.025 seconds (15 points) and the start point was set to 0.12 seconds
(point 72). The results show that the mutine started at 72 and lasted until 86, thus covering
the required 15 points.
Test 5: Comparison With The B 8: K Sound Intensity Analyzer
This final test was conducted as an overall check of the program using actual field data. The
data used was extracted from the Montreal vibration survey which twk place on March 14,
1991, headed by Dr. M.O.Al-Hunaidi. The data had already been analyzed by the B & K
2134 Sound Intensity Analyzer which would act as a standard of comparison for the TOAP
routine.
The data was from run 12F and was processed using 625 segments (5 ignored), each of one
second in length. nK comparison was made for seven different channels and it can be seen
that for most of them there are two variations of the results given by the B & K analyzer.
Those labelled (0s) are channels which were re-analyzed for checking purposes. It is
evident that the results given by TOAP are consistent to within a reasonable level of
tolerance with those given by the B & K analyzer. Any differences between the two are no
larger than those existing between the two different analyses performed using the B & K
equipment
There is, however, one large discrepancy between the two sets of results. ?his occurs on the
channel 8 data at the frequency of 125 H z This difference is due to a difference in start
times between the two analyses. The TOAP analysis was performed with a start time of 10
seconds whereas for the B & K analyzer this parameter cannot be accurately known. This is
one reason why the re-analysis using the B & K equipment (labelled by 0s) is not exactly the
Raw data:
72.001950
72.998050
74.003910
7 5.00000u
75.996090
77.0019561
77.998050
79.005910
80.000000
89.996090
82.001950
82.998050
84.003910
85. 000000
85.996090
Hit 0 to end.
MONTREAL VIBRATION SURVEY
RUN 12F,625 AVGS, CHANNEL 1, LO(OSAM)
lnOCTAVE FREQUENCIES, HZ
Test 5 (Continued)
MONTREAL VIBRATION SURVEY
RUN 12F, 625 AVGS, CHANNEL2,LO
Y
I
1
I I IIIII
I
I
I
I
I
I
I I IIIII
I I II l l 1
I
1
I
I
I
I
C1)
I I II l l 1
1 1 1 1111
I I II l l 1
I I I II l l 1
I I I 1 1111
I
I
I
I
I
I
I
I
I I 1 Ill
1 1 11t
I I I l Ill
I I 1 1 111
I I 1 1 111
I 1 I 1 111
1 1 1 1 111
1--r - 7 - t t f t t
I
I I 1 1 I11
I
I
2.OE-04-----
'
2
0
-
E
W
id
8
a
,.OE#-----
I
I
I
I
1 1 1 Ill
I
I I 1 I111
I I 1 1111
V)
3
O.OE+OO
I
I
1
1
1
I
I
1 11111
I 1 1 111
1 11111
1 1 1 111
I IIIII
1 11111
I
I
I
I
I
I
I
I
I
1
In OCTAVE FREQUENCIES, HZ
I
I
I
I
I l l Ill
I 1 1 111
1 1 1 111
1
1
I
I 1
1 I111
1 1 111
Il Ill
1 1 111
I I 1 1 111
1
I
f
I
1 I l l 1
1 1 1 1 1
Test 5 ( C o n t i n 4
MONTREAL VIBRATION SURVEY
RUN 12F.625 AVGS, CHANNa 4, U)
Test 5 (Continued)
MONTREAL VIBRATION SURVEY
RUN 12F, 625 AVGS, CHANNEL 5, LO
InOCTAVE FREQUENCIES, HZ
Test 5 (Continued)
MONTREAL VIBRATION SURVEY
RUN 1%. 625 AVGS, CHANNEL 6, to(-
1/3 OCTAVE FREQUENCIES, HZ
Test 5 (Continued)
MONTREAL VIBRATION SURVEY
RUN 12F, 625 AVGS, CHANNR7, U)
Test 5 (Continued)
MONTREAL VIBRATION SURVEY
RUN 12F, 625 AVGS, CHANNR8, LO
same as the original. Therefore, another mn of TOAP was canied out on channel 8 using a
start time of 99.5 seconds with all other parameters unchanged from the original ruh lhis
rime, the KUS value of the 125 Hz band was within a reasonable amount to that given by the
B & K apparatus. ?his would seem to extinguish any possibility that the abnormally high
inconsistency was due to a flaw in the TOAP program.
Test 6: Testing of GLOBAL LAB Interface
All of the above tests involved MTAS acquired data Howenr, most of the tests are not
sensitive to the rype of data used, making the choice irrelevant Thus, one more test was
needed. involving the reading of GLOBAL LAB data &om the DAFF s o w files.
The source fie used, contained data from two channels: the fmt channel was the signal of a
sinusoid and the second was that of a square wave. The data values, after being read by
read-daff-data, were written to a disk file without further precessing. These values were
then imported to Quatuo Pro where they could be put on display.
The results are shown in Test 6 as the sinusoid and square wave read by read-daff-data
match-up to those displayed by the GLOBAL LAB softwmitself. This shows that the
values read by read-daff-data are Wing read into the conect channels and scaled properly. It
also shows that the starting point, which was specified to bc the beginning of the fust peak
(for both channels), is being interpreted correctly. As well, the integration time, set at 0.5
seconds for this tesr, has been implemented properly. It should be noted at for the
GLOBAL LAB display the label for channel one is 'CHW and that for channel two is
'CHO1'.
The six tests presented above have attempted to cover most of the major aspects of the
routine. As the program was being conslructed, many of the s d functions were tested
along the way. Tbtsc tests were so trivial that they were not documnted. The tests given
above, though, provide implicit proof that these smaller functions ert in good working order.
Test 6 (Raw data read by read-daff-data)
READ DAFF DATAONSAMRJ3DAT
1
Test 6 (Actual data file as displayed by GUIBAL LAB)
[msec]
APPENDIX 2
DETAILED VERIFICATION OF THIRD OCT.4VE FILTERS
Written by: J. Marans
PROGRAM filter test DESCR1PTK)N OF OPERATION
The program filter-test is designed to test one third octave band pass filter shapes and
compare them aaainst IEC Standard 225. This test is run for a variety of sampling
. frequencies, a n i e range of filter poles.
filter-test expects a driver file named td to be present in the current working directory,
containing the following lines [see the example that follows the file format]:
an integer from 1 to 6 indicating the number of frequencies to check in the range
500.0, 1000.0,2000.0,2500.0,3W0.0,4000.0 M
an integer from 1 to 6 indicating one of2,4, 6,8, 10, 12pole filters to start at
an integer from 1 to 6 indicating one of2,4,6,8, 10, 12pole filters to end at
highest one third octave band centre frequency
centre one third octave band centre frequency
lowest one thid octave band centre frequency
Example t d File:
3
2
4
100.0
80.0
63.0
start with 500 Hz and end at 2000
start with a 4 pole filter
end with an 8 pole filter
use 100 Hz as the center frequency for the upper band
use 100 Hz as the center frequency for the center band
use 100 Hz as the center frequency for the lower band
filter-test consists of a number of subroutines located in the following files:
1ptb.f
th3rdoctf
attcumef
digfi1tm.f
lopass3.f
main.f
to-strrtrrng.f
concatenatef
hipass3.f
1psb.f
These are compiled as per the instructions in the accompanying Makefie.
Output consists of the following files:
urefatt, Irefait These contain the upper and lower reference filter shapes as
specified by IEC Standard 225. The data values are written out as
2 columns consisting of frequency ratio vs attenuation. The
frequency ratio is the input frequency normalized to the center
band frequency.
upper.xx.yyyy Output data from the upper one third octave band filter.
middle~ayyyy Output data from the middle one third octave band filter.
lower~ayyyy Output data from the lower one third octave band filter.
ar
Number of poles.
yyyy Sampling frequency.
Output data files consist of 2 ASCII columns, and should be plotted against uefatl, lrefatt
The first column is frequency ratio, the second is the attenuated rms value in db.
Attenuation for each input frequency = 20 log( RMSnW I RMS&,,t).
The associated
frequency ratio is input frequency divided by center frequency of the filter.
p-
The file main.f contains the stub program that calls attcurve with the appropriate parameters
for each desired filter, and for each desired sampling frequency. attcurve calls digfiitm each
time it's invoked in order to generate a new set of filter coefficients.
A pure tone is generated for each input frequency from 30 Hz to 300 Hz having a maximum
amplitude of 100. The duration of each input tone is 4 seconds RMSMltput is calculated fw
the last 314 of the data array to allow for filter rise time.
RESULTS
The plots that follow summarize tests that were done for 6,8,10 and 12 pole filters at 500.
1000,2000,3000, and 4000 Hz sampling frequencies. Pure input tones were filtered with 63.
80. and 100 Hz one third octave band filters. In all cases. the 12 pole filter showed best
conformation characteristics to the IEC standard up to 2000 HL At3000 M the filter skirt
was slightly non-conforming in the -10 to -15 db range.
One Third Octave Filter Characteristics vs IEC Standard 225
500 Hz Sampling Frequency, 8 Pole Filters
10.0
I
I
I
I
I
1
I
- - - - - Upper Reference
................ Lower Reference
,
Frequency Ratlo
Frequency Ratlo = Frequency ISpecltlc Center Band Frequency [63,80,1OO Hz]
Frl Jan 15 08:43:23 1993
One Third Octave Filter Characteristics vs IEC Standard 225
500 Hz Sampling Frequency, 10 Pole Fllters
10.0
I
I
-----
Upper Reference
.........
Lower Reference
I
I
I
I
I
I
Frequency Ratio
Frequency Retlo = Frequency I Speclflc Center Bend Frequency [83,80,100 Hz]
Frl Jan 15 08:47:40 1883
One Third Octave Filter Characteristics vs IEC Standard 225
500 Hz Sampling Frequency, 12 Pole Filters
10.0
I
I-
-----
I
I
I
I
I
I
Upper Reference
Lower Reference
Frequency Ratio
Frequency Ratlo = Frequency I Speclllc Center Band Frequency [63,80,100 Hz]
FrI Jan 15 08:51:48
One Thlrd Octave Filter Characteristics vs IEC Standard 225
1000 Hz Sampllng Frequency, 6 Pole Fllters
10.0
I
t
I
I
I
I
I
I
Upper Reference
--------
Lower Reference
Ftequency Ratlo
Frequency Retlo = Frequency ISpeclflc Center Band Frequency [63,W),
100 Hz]
Frl Jmn 199 9::997:17 1993
One Third Octave Filter Characteristics vs IEC Standard 225
1000 Hz Sempllng Frequency, 8 Pole Filters
10.0
I
I
1
I
I
1
I
I
Upper Reference
I
Lower Reference
Frequency Ratlo
Froquoncy Ratio Froquoncy ISpoclflc Conter Band Frequency [63,80,100 Hz]
Frl Jan 18 08:09:48 1993
One Third Octave Filter Characterlstlcs vs IEC Standard 225
1000 Hz Sampling Frequency, 10 Pole Filters
10.0
I
I
--------
I
I
I
I
I
I
I
Upper Reference
Lower Reference
Frequency Ratio
Frequency Ratlo = Frequency ISpecltlc Center Band Frequency [83,80,100 Hz]
Frl Jmn 15 09:02:23 1993
One Third Octave Filter Characteristics vs IEC Standard 225
1000 Hz Sampling Frequency, 12 Pole Fllters
10.0
----
-----
0.0
Upper Reference
Lower Reference
63 Hz Filter
80 HZ Fllter
A
100 Hz Fllter
-10.0
-20.0
-30.0
-40.0
0.2
0.4
0.6
0.8
1.O
1.2
1.4
1.6
1.8
Frequency Ratlo
Frequency Ratlo = Frequency ISpecltlc Center Band Frequency [63,BO, 100 HZ]
Frl Jan 15 09:04:41
One Third Octave Filter Characteristics vs IEC Standard 225
2000 Hz Sampling Frequency, 6 Pole Filters
10.0
I
I
----(
,:
I
I
I
I
I
Upper Reference
Lower Reference
.....................(:) 63 Hz fllter
Q---a
-
80 Hz Fllter
100 Hz Ftlter
!,Y<
- - .. ..
..
l>.:.*
$.
5
0.2
- 0.4
0.6
0.8
1.O
1.2
Frequency Ratlo
Frequency Rntlo Frequency ISpeclflc Center Band Frequency [63,80,100 Hz]
1.4
1.6
<
-
1.8
Frl .Inn 15 08308:63 1093
One Third Octave Filter Characteristics vs IEC Standard 225
2000 Hz Sampling Frequency, 8 Pole Filters
10.0
I
I
I
I ----
I
I
I
I
1.2
1A
1.6
Upper Reference
-----
0.0
-
-
Lower Reference
063 HZ Rlter
e
I--------
80 HZFllter
100 Hz Fllter
-10.0 -
-20.0
-
-30.0
/
I
/
/
/
-40.0
I
0.2
0.4
0.6
0.8
1.O
1.8
Frequency Ratio
Frequency Ratlo t. Frequency ISpeclflc Center Band Frequency [63.80,100 Hz]
Frl Jan 16 08:16:04 1003
One Third Octave Filter Characteristics vs IEC Standard 225
10.0
I
I
2000 Hz Sampling Frequency, 10 Pole Filters
I
I
I
I
I
I
I
I
Upper Reference
-----
Lower Reference
,
Frequency Ratlo
Frequency Ratlo 0 Frequency ISpeclllc Center Band Frequency [63,80,100 Hz]
Frl Jan 16 08:18:28 1003
One Third Octave Filter Characteristics vs IEC Standard 225
2000 Hz Sampling Frequency, 12 Pole Alters
10.0
I
I
I
I
I
I
I
I
Upper Reference
-. . . -.
----
--
Lower Reference
Frequency Ratlo
-
Frequency Retlo Frequency 1 Speclflc Center Band Frequency [63,80,100 Hz]
Frl Jan 16 08:17:38 l9Ba
One Third Octave Filter Characteristics vs IEC Standard 225
3000 Hz Sampling Frequency, 6 Pole Filters
10.0
I
I
1
I
1
Upper Reference
- - . - - - Lower Reference
----
Frequency Ratlo
Frequency Ratlo = Frequency ISpecific Center Band Frequency [63,80,100 Hz]
I
I
I
One Third Octave Filter Characteristics vs IEC Standard 225
3000 Hz Sampling Frequency, '8 Pole Alters
10.0
I
I
I
I
I
I
I
I
Upper Reference
-----
Lower Reference
Frequency Ratio
Frequency Ratlo IFrequency 1 Speclflc Center Band Frequency 163,80,100 Hz]
Frl Jan 16 00:20:39 1999
10.0
,
I
One Third Octave Filter Characteristics vs IEC Standard 225
3000 Hz Sampling Frequency, 10 Pole Filters
I
I
I
I
I
I
I
#
Upper Reference
- - - - - Lower Reference
----
Frequency Ratio
Frequency Retlo = Frequency I Speclflc Center Band Frequency [63,80,100 Hz]
Frl Jan 15 00:21:37 1998
One Third Octave Filter Characteristics vs IEC Standard 225
3000 Hz Sampling Frequency, 12 Pole Fllters
10.0
I
I
I
I
I
I
I
I
Upper Reference
----- - - - Lower Reference
Frequency Ratlo
Frequency Ratlo = Frequency ISpeclflc Center Band Frequency [63,80,100 Hz]
Frl Jan 15 0fi:24:18 1803
One Third Octave Filter Characteristics vs IEC Standard 225
4000 Hz Sampling Frequency, 6 Pole fliters
10.0
I
I
I
I
I
Upper Reference
-- --- -- - -
Lower Relerence
Frequency Ratlo
Frequency Ratlo IFrequency ISpeclflc Center Band Frequency [63,80.100 Hz]
I
I
I
One Third Octave Filter Characteristics vs IEC Standard 225
4000 Hz Sampling Frequency, 8 Pole fllters
--------
Upper Reference
Lower Reference
63 Hz Rlter
80 Hz fllter
100 Hz Fllter
s
0.2
OA
0.6
0.8
1.O
1.2
Frequency Ratio
Frequency Ratlo 0 Frequency ISpeclflc Center Band Frequency [63,80,100
Hz]
1.4
1.6
Frl Jan 16 09:27:24 1003
One Third Octave Filter Characteristics vs IEC Standard 225
4000 Hz Sampling Frequency, 10 Pole Rlters
10.0
I
t
--------
I
I
I
I
I
I
1
Upper Reference
Lower Reference
Frequency Ratlo
Frequency Ratlo = Frequency I Speclflc Center Band Frequency [63,80,100 Hz]
Frl Jan 15 00:28:29 1993
#
Makefile for proqram fitler test
#
use -r4 for single predslon floating polnt
cc
=m
CFLAGS
FFLAGS
= -0
= -g -cg89 -r4
UBS =
OW = ma1n.o th3rdoct.o lopass3.o hipass3.0 d1gfiltm.o a1tcurve.o lptb.o\
concatenate.0 to-string.0
all:
S(0BJ)
S(CC) $(-LAGS)
$(OBJ) $(LIBS) $&FLAGS) third
ma1n.o: mainf
th3rdoct.o: th3rdoct.f
iopass3.o: lopass3.f
hipass3.o: hipass3.f
d1gfittm.o:
digfi1tm.f
attcurve-o: attcurvef
Iptb.0:
1ptb.f
c0ncatenate.o: concatenatef
to-string-o: to-stringf
1
td
6
3
.
6
100.0
80.0
63.0
Driver file for proqram filter test
number of frequencies to check
first fitter to start at
end filter
highest centre frequency
centre centre frequency
lowest centre frequency
c
cStubprogrsmt0caU~urre.f
c
program mer-test
c
c
lmplkit undefined@-z)
Integer I,j, end-filter, poles(6), p, nurn-frequencies,
integer staft-fltter
real segment-length
real u-centre-frequency, 1-centre-frequency
real u-ref-vM8). 1-ref-val(lO), centre-centre-frequency
real u-ref- M a ) , 1-ref--10)
real sampflng-fq(6), sf
character'l0 blanks
charecterY0 1-ref-attenuation-file,
+
+
+
+
data u-ret_val140.0, 4.0.4.0, -1.0, -1.0,6.0,
4.0.40.0 1'
data u-ref-freq 10.8909, O m , 0.9439,0.9439,1.0595,1.0595,
1.1225,l .I225 1
data 1~mf~val1-60.0,-50.0,-13.0,0.5,0.5,0.5,0.5,
-13.0,50.0,40.0
1
data 1-ref-freq 10.125,0.25,0.7937,0.8909,0.9439,1.0595,
1.1225,12599,4.0,8.0
I
data poles 12,4,6,8,10,12
c
u-ref-attenuation-fib
blanks = '
end-filter = 6
nurn = 8
1
.
c create the fitter reference files.
open (21, file = u-ref-attenuation-file )
dol=l,num
write(21. ) u_ref-freq(i), u-mf-vaKi)
end do
close( a
open (21, flle r:I-ref-attenuation-fib
)
c read soma parameters
open (21, file = ?dm)
read (21, ') nurn-frequencies
read (21, ') start-filter
read (21, ') end-filter
read (21, *) u-cantm-trequency
read (21, ') centre_centr~-tresuenCy
read (21, *) LcentFe-frequency
close ( 21 )
u-centrentrefrequency
= 100.0
centre-centre-frequency = 80.0
1-centre-frequency = 63.0
c
c
c
segment-length
= 4.0
do i= start-filter, end-fibr
P = Poles0
do j = 1, num-irequencies
+
sf = sampling-freqa)
prinV, 'Poles:', p, blanks, "Sampling Frequency:', sf
call attcurve( u-centre-frequency, 1-centre-bquency,
centre-centre-frequency, st, p, segment-length )
end do
end do
call system( 'rm *.clan)
stop
end
c
C
c
c
c
c
c
c
c
this program performs lBoctave band analysk on an input time
slgnal. the s l g d Is divided Into user specilied ll3-octave
bands by repeatedly low- and highpassing the data the coeflkients of the Wten are calculatedbv the called subroutine
digfiitm (whkh its& caiis iptb).
actual filtering occun
in the submutino th3rdoct whkh intum calls the subprograms
.
lopass3 and h i m . tinally,the Information in each i ~ v e
band is averagedto give an nns value correspondingto each centre
frequency of intersst
the
-
c
C
P
-
P
52Mm4
C
c Increased Idimto 4%
C
c read input parameters fmm driver file named td
c driver file constructed as folkws..
c
100
highest centre frequency
c
30.0
lowest centre frequency
c
600.0
Sampling frequency
c
6
Number of pdss
c
4
Time (see) length for each segment
C
c modified hlghest fmq inputto filter to be
c
fiigh = sfreq 1256
c to avoid folding past Nyquist freq.
C
c changed reference output to IEC 225 Standard Values
C
c changed thetal, theta2 to be normalizedwrt sampling frequency Iupper
c corner frequency.
c
c changed thls into a submutine catled from maimf so 1 could loop
c through dilferent frequencies, poles, etc.
C
c Removed cheekto see if a who@octave, or integral number of
c octaves is being examined. Now it is assumed that's the case
- - c
c ufaf upper filter attenuation file
c mfaf middle filter attenuation file
c lfaf lower filter attenuationfile
- - c
implicit und&ned(a-z)
Parameter (Idim = 80000)
lnteset 1,1, k. nbot, num-act, Rop, m,hum, mfac, npts
Integer num-freq, itreq, nptsl, lpts, loop-Index, I
real slgnal(idlm), b4000(ldim), b3150(7dlm)
real freqn, twogl, omega, fhlgh, flnc, segment-length
-1 -22),
bedge(0:6), lu, fl
real top-centre-freq, bot-centre-freq, last, streq,Row
real freq, sum, slgnal-sum, tl, mrsout
real aloglo, valuel, filatt, wal, cenfre-centreCBtreq
real W000_rmsin, signal-rmsln, b3150-win
parameter (tu = 1.12246, fi = 0.89090)
character dot
character% hlpass(0:6)
characteZ10cst, cpoles
charactef40 name, ufaf. mfat, ibf
+
data ( hlpasgk), k z 9 6 ) 1'5000hda', '50001.da'. '4000h.da',
'40001.da', '3150hAa: '31501.da'.Y500h.da' I
+
+
data (sthq(9, 1 =I. 22)1250.0,200.0,160~0,125.0,100.0,
80.0,63.0,50.0,40.0,315,25.0,20.0,16.0,12.5,10.0,
8.0,6.3,5.0,4.0,3.15,25,2.0/
c determine band edge fmquencb for f h r s
c
c
c
doicl,?
if ( top-centre-fraq I 2 0 * iA. bot-cantre-hq ) goto 20
end bo
c
plinr, 'Not an integral number of octaves.'
got0 999
C
20
continue
num-oct = i
Isst=22-num-oct*3
pdnV, ' '
prlnr. 'hequency of highest lRoctave b not a standard one.'
nbot = 1
got0 999
40
itop=j
dok=O,3
bedge(2W = fu 'sffreq(itop+k)
M (k sq.3) goto 60
bedge(2%+1) = ffsUraq(itop+k)
end do
c compute filter coelficientsand write them to disk
60
c
C
c
!
continue
prlnt*, 'Enter* sampling frequency (in hz) of the data. It sho
+uld be at least twice that of the upper limit of the highest 1/50
tctave.'
if( sfreq .A. r n s e ( 0 ) ) then
print*,'Oooops, this frequency won't work?, sfreq
got0 99s
end W
C create
output f a a n a m
dot = '.'
ufat = 'upper-'
mfaf = ~rniddle_'
Ifaf = 'low~r-'
d =m
d l = sfreq
call to-s$ing(d, cpoles, 10)
call totostring(dl. cst,10)
.
name=.
call concatenate( name, 40. ufaf, 40. .false. )
call concatenate( name, 40, cpoles, 10, .raise. )
call concatenate( name, 40, dot. 1, .false. )
call concatenate( name, 40,csf. 10, .false. )
open (13, file = name )
call concatenate( name, 40, mfaf, 40,.ids.)
call concatenate( Mme, 40, cpoles, 10, Alse. )
call concatemte( name, 40,dot, 1. .false. )
call conkatenate( name, 40,tst, 10, .false. )
name=' '
call concetsnate( name, 40, W, 40. .taka)
call concatenate( name, 40,cpolfhs, 10, .false. )
call concatenate( name, 40,dot, 1, .false. )
call concatenate( name, 40. csf, 10, .false. )
open (15, file = name)
inum = mod(Q) + I
call d W i W inum, m, bedge(i),sfreq, hlpawi) )
end do
npts = segment-length sfreq
mfac = nlnt( npts 120 * ( num-oct
npts = mfac 2"( num-oct 1 )
-
- 1))
If ( Mim .It. 2'npts) then
print*, 'm~:
must change Mim to P npts'
go to 999
endM
c
print*. 'For precessing purposesthe length of the signal segment
c ni (+ sac.) has been slghtly modified so that it now is',
C
+nptslsfreq
c
PriW,'High&
c
print*,'lowest frquency input to filter [Hz]:'. flow
c
plinP,'Frequeffiy increment ftiz]:', finc
frequency input to filter
piz]:', thigh
doifreq=i,num-freq+l
fmq=flow+(waq-1)*fine
nptsl = npts
do ipts=l, npts
omega n twogl (req Roat(tpts I)ti
rvd = 100.0* sin( omega )
s i g w p w = fvd
-
stgnal-sum = 0.0
do bop-index = 1, npts
signal-sum = signal-sum + signayloop-Index) * 2
end do
MgnaLrmsin= sqq signel-sum Inpts )
w - r m s l n = signal-min
b3150-rmsin = signal-dn
c filter slgnal into j,3-ocraves
Call t h 3 ~ s l g n a 1b4000,
,
b3150, nptsl, num-oct)
C calculate rms values for top lrroctave
sum = 0.0
do bop-Index = npW4 + 1, npts
sum =sum + signayloop-index) * 2
end do
-
rmsout = sqq sum I( npts npW4 ) )
valuel = rmsoutl signal-dn
filatt = 20.0 * alogl0 ( valuel )
freqn = freq 1top-centre-ffq
if ( filatt .ge. 40.0 )then
writ8(13, '(28124)' ) freqn, filatt
end if
c cakulate rms values for centre 1-ve
sum = 0.0
do loop-index = npW4 + 1, npts
sum = sum + --index)
*2
enddo
-
rmsout = qrt( sum 1( npts nptsl4 ) )
value1 = rmsoutl b4000-msln
filatt = 20.0 alog10 ( valuel )
freqn = freq 1centre-centre-treq
if ( filalt .ge. 40.0) then
write(l4, '(2e124)')
end if
freqn, filatt
c c a ~ ~ v a l u o s * b o t t o m l ~ w
sum = 0.0
do loop-Index = nptd4 + 1, npta
sum Isum + b3150(kop-lndex]
end do
-
nnsout = sqrd( su-mI ( npts nptsl4 ) )
if ( filatt .ge. -60.0 )then
write(l5, '(2e12.4)') freqn, Matt
end if
end do
999
continue
close (13)
close (14)
clo~e
(15)
return
end
2
C
c
/-
c
C
C
c
lh3nio&br
27-my81
curbmutlne to f i b the thepk slgnei Into prespedRed iR
octaves. this subprogram calk the subroutines hipass3 and
kpass3 to perform the liiteringoperatkna the coeflkients for
the filters are obtained from disk files written by d I g f l b the
mutts of th3Fdoct are sent backto Its master program, control.
subroutine t h 3 r ~ s l g n a l , ~ 6 3 1 5 0 , n p t f t f n o c t )
implicit undefined (a-z)
Integer mm,pl, p2.1, j, k, npts, no* kk
+
real B_5h, bOSh, bISh, bWI, alSh(12), a25Y12), bwsh,
f3c5h, fc5h, sfmq5h
+
real B-5, b05, bl5, b25, alS(12). a25(12), bw5, sfreq5,
t3c5, fc5
+
real B_4h, W h , b14h. b24h, a14h(12), a24M12). bw4h,
sfreq4h, f3c4h. W h
+
real B-4L, b041 b14L, b24L. a14L(12), a24l(12), bw4L,
sfreq&, f3c4Lfc4L
+
real B-3h. W3h, b13h, b23h, a13h(12), a23M12), b-h,
sfreq3h, W h , fc3h
+
real B_3L, W3L, b13L, b23L, a13U12). a23L(12), bw3L,
sfres3L. 13c3L,fc3L
+
real B_2h, b02h, b12h b22h. alZh(12), a22h(12), bwzh,
streq2h, t3c2h, f d h
real signalC), b4000(X b3150C)
C
-retrieve
coefficients from disk filesp
c "-'-+-initial
c
lowpass of data at hlghest frequency of i n t e e
print*. 'initial call to lowpass'
call lopa~signal,pl~gnaI~l,n~srl5h,a25h,mm,B-5h)
repeated lo- and hipassingto divide data into l & x t a v e s .
c the process occurs once for each cctavep
C~
call lopass3( signal, pl, signal, p2, npts, a12h, a22h, mm, B-2h )
call lopass3(signal,plWooo,~npts,al4ha24h,m B 9 h )
call krpass3(signal,pl~150,p2nptsr13h~,mm,
8-3h)
call hipass3(signal,pl~gnal,pl,npts,al5&5mm, 8-5)
calf hip-,@,
W 0 0 a . ~ l , n p C s # lB-a)
call hlpsss3@3150,pZ b 3 1 5 0 , p l , , n p t s # l ~ , m m B-a)
,
do 4 i=l.npts
j=p2+I
kp2-1+2*1
signalU)=slgnaYk)
continue
c
99
P l=p2
@=P*+nP@
prinr. 'octave',ldc
continue
C
C - - n - - n u . . . . . c n n ~ -
C
C
900
print?, 'th3rdoct is finished'
return
end
c
dlglllhhfor
27my-M
subroutine to determine the coefflclents for a tangent
Implementationof a butternorthflitor wfth an even
number of pder
c
c
c
C
c
92/W07
changed call from lptb to lpsb
subroutine digfiitm( inum, m, bw,sfreq, hlpass )
implicit undefined ( 8 2 )
integer inum, m, I.Ih, mm
real a1(12), a2(12), bw, sfreq, W , bl, b2, time, bzero
real f3c, fc
charader'8 hipass
character '10 ten-b
goto (100,2W),lnum
C
c-----"
c
100
kmpass butterworth f i I t e 7 - - - " - - -
ih=l
-1.
m a
b24.
goto=
t
c F i g h p a s s butteworth
-bi f
c
200
ih=O
-1.
bls2.
&I.
got0 250
C
C
-generate
coefficients for hi- and lopass tangent filters*
C
250
time=llsfreq
if(Ih .eq. 0 ) bwsfreq/2.-bw
call lptb(m, time, bw, at, a2, bzem. Ih)
*=O.o
m.0
C
c ?rite
C
coefficients to disk e
lifp
-
JPM
return
end
fptb-for
8845-10
subroutine to generate coefficients for hlgtihkw pa=
tangent ff~tero.
Inputs am: mm-number of poles whlch must be even
t -sampling p e w
b -passband width
ihl for lowpass ;0 for highpass
subroutine lptb( mm, 1, b, a l , a2, bzero,lh)
dimension al('),a2(')
doubb precision ang,tact,sector,wedge,fn~m,bm,ams,den
doSi=l.ml
%=I4
angdn*sector+wedge
am=fa&Qin(ang)
bm=facttdas(ang)
ams=am*am
den* .dO+bm)c2+ams
al~22cYP((l.dObm'bm)-amsyden
a2@=((1 .&bm)'?Z+amsyden
f a 1.+a1O+s2(w4.
continue
continue
bzero=f
return
end
rn
c
c
c
c
inputs are: mm = number of poles which must be even
t = sampling period
b t passband width
!kg = 1tor lowpass, 0 tor highpass
implicit undefined (a-z)
real a1(6), a2(6), t, bw,bzem
double precision r. a, b, c, d, e, 1, g, h, fn,tact, wedge, sector
integer m, mm, mi, m3, I,it, m2, flag
fact = 3.14159265d0 t bw
fact = dsin( fact)
t = l.dO
m=mm
ml=mR
m3 = m l
if( m l .eq. 0) go to 10
m2rm
a=m2
sector = 3.141592&%01a
wedge = sector 12.d0
do i = l , m l
fn=i-1
r=fn*sector+wedge
b=fact*dsin(r)
c=l.dO-fact'W
d=O.5d0*(c+dsqrt(c*c+4.dO*bYZ))
e = d s q q d + 1.m) + dsqrt(d)
gL.2dO'((2.dO'bWd)-l.dOY(8~)
h=-1aol(~-4)
f=r(i .dog4l)
a1O=¶
end do
10
continue
kmrml
n(iteq.0) go to 15
rn3=ml+1
azfact'fact
g=2.d(Pa+l.~~do.faCrdsqrt(a+ldO)
al(m3)---g
a2(m3)=0.
f=w.W)
15
contlnue
#:(nag sq.l)got020
do I = l , m l
a 1 0 = -al(j)
end do
20
contlnue
a=m3
b z e r O ( 1.dWa)
return
end
C
-
c
c
h-*
8845-1 0
thls arbmutlm mplemenua dlgbl Rltw wfth rgto
12 poles ;3 nononrecurshre and 2 rearrshre terms are allowed
subroutine h i p a ~ p l , y o u t g 2 , n i ~ l ~ m , b z e m )
Integer pl, p2, k, I, nl, mm, kl
real YC), a1(6), a2(6), yOm,ylm, flm
reel youtr), barn, yit, yl
20
do 30 tl,nl
Yo(lby(kpl)
do 20 k=l,mm
kl=k+l
ykyOFF2.0Yl F)+flF)
*=*-a* (k)'yogcl)-a2(k)'Yl F1)
n(abs(yi).n.i.oen) YI=O.O
Y2(kl)=yrFl)
yl(kl)=@(kl)
rn)=yl
contlnue
H*)=yl(l)
yl(*)=yO(l)
30
yow+P2bYrcontinue
return
end
C
c
c
-.*
8805.10
thfssubmutlnebnplemenisablglmlalWterupto
12 poles ;3 nonrecurstve and 2 recursive tenns are allowed
Implicit undefined (a-z)
integer pl, p2, k, i, nl, mm, kl
do 30 i=l,nl
Yo(l)=Y(P1+9
do 20 k=l ,mm
kl=k+l
vit=yO(k)+2.03lwhY2F)
20
30
yLyn-a~wmlta2mrvlw)
lf(abs(yr).n.l.oM7) ym.o
Y2(kl)=V(kl)
yl(kl)=YO(kl)
Yo(kl)=Yl
continue
P(lkyl(1)
yl(l)=yO(l)
yout@2+i)=yrbzero
contlnue
return
end
r
peter h. wllson
national research axrndl Canada
1n-e
for research In constructbn
c
C
c
c
october 1990
c...tm.nnnt..tmmt.mnm_o.m_o.mmnn~..
this mutlne concatenates two chamclef strings Into one
character Wng.
C
C
cn-mf...u.tmmt.-.~-rm.-.*
c
I've changedthis so that two strings are flrst concatenated
and then the output string is searched f@xthe symbol iY, whlch
IS then replaced wfth a blink ~ w n space].
e
C
c
c..t"ft-""."..t.m.mt.mmmmt~_rrm.
-
c
c
c
I counter
n the number of charzcters in string 1
m -the number of characters In string 2
count counts the number of characters in strlng umll a blank
-
c
C
c
c
strl Isthe Vp character strlng 1
-
c
C
('
--
st12 Isthe Up character slrlng 2
bhnk is equal to a blank space
ch Is a dummy charader
c
-
c
flag changes the # to a whne space when equal to true
,y*.mmn-=tmm~mnmrnm-mmm*
.
subroutine concatenatNstr1, n, std, m, flag)
integer I,n, m, count
character sm (n), str2(m)
character1 b, blank, ch
logical flag
blank = ' '
count = o
b='#
c
look for the end of the flmstrlng.
doI=n,i,-I
if(strI(9 fie. blank)then
awnt=l
go to 10
end If
end do
c
add string2 to string1 If Rs chamem aren't blank
10
contlnue
r
d01=1,m
Ch = StT2(1)
If( ch. ne. blank )then
cwnt = count t 1
Strl(count) = ch
end n
end do
If (flag ) then
doI=l,n
If ( an(I) .eq. b ) strl') = bmnk
end do
end II
return
end
wbmutlne @-string( value, strlng, n )
~
I-
-
"
m
.
.
~
-
"
"
-
-
.
.
m
m
C This convetis an integer to a string
C Na leadlng zeros allowed.
C VALUE = lntegef4
~~.t~tmmt~m-mr+mtt.*~--mm-~
integer I,n, count
Imqef4 value, dlglt, rwnalnder, dlvisor
character strfng(n)
remainder = value
count = o
doi=l,n
strfngm = ' '
end do
do I=8,0,
-1
dhrlsot = I&(10.0 *' 1 )
dlglt = remalnder IdMsor
If( dlglt .gt. 0 .or. digit .eq. 0 and. coum .gt. 0 )then
count = count + I
remalnder = remalnder ( 10.0 * i ) 'dlglt
string( coum ) = achar( digit + 48 )
end if
end do
-
return
end
1
SUM'MARY OF ONE THIRD OCTAVE FILTER CHARACFERISTIQ
..
High and low pass transfer function filter characterstics were first determined Britb the program
Wansferfwtction test located in file rransf. The purpose of this test was to examine the difference
between ideal filter behaviour, and the behaviour implemented for a variable number poles. Ideal
filter shape is shown in figure 1 below'. In this case, B is the band edge 3 dB point, also referred
(b) Ideal H
i
g
b Pass Filter
(a) Ideal Lowpas Filter
Figure 1 The Absolute Value Spared of Ideal Filter Transfer Functions
to as the cutofffrequency,and F is the folding frequency [sampling frequency / 21.
The first implementation of nansferfunction test used equation 4.195' to generate the high and
low pass ater m s f e r function coefficients. These are as follows:
Lowpass:
where
0, =xBT
= KBEF
=
(m(Bm
M =number of poles
transfer-function-test was wrHten to test hlghand lopaw filter transfer function chamderI6tlc1
for a number of plea, and a variety of sampling frequency to cutoff trequemy ratios [FBJ
the ratlos chosen were 2.001.3.44.0, and 6.0, whlle 4 and 10 pole filters were examined. There
are no Input parameters to thls program, and output was to flles named
+ole2
4pokrl
4poIe6
4pole3
1Opole2 lopole3 lopole4 1Opole6
The flb contained 3 columns: omega, low pass value, hlgh pass value. Omega was normalized
to the ratlo Fj& lhe equations used are described In the next sectlon whlch surnmarbes one
thlrd octave filter characterlstlcs.
Examlnlng the flrst 2 plots that follow, one notfcscr that regardless of the number of poles,
lncreaslng the ratio F a lengthens the fllter sMrts, thereby allowing more leakage at frequencies
beyond the cut off, 8. Also, for a flxed ratlo, decreasing the number of poles also lengthens the
fllter sklrts, agaln allowing leakage beyond 6. mese 2 characterldcs explaln why thb filter's
response Improveswith the number of poles used, and as the fatlo FJB approaches 2
One Third Transfer Function Characteristics
-
* LP, Ratlo
-
2
HP, Ratlo 3 2
o-----oLP, Ratlo er 3
-
LP, Ratlo - 4
HP, Ratlo - 4
t-----t LP, Ratlo r 6
HP, Ratlo I6
Frequency to Cut Off Frequency Ratlo
Frl Jan 16 12:69:06 1883
One Third Transfer Function Characteristics
-
4 Pole LP, Ratlo 1 4
-
4 Pole HP, Ratlo E 4
-
...o10 Pole LP. Ratlo = 4
10 Pole HP, Ratlo 4
Fmquency to Cut Off Frequency Ratlo
Frl Jan 15 13:10:47 1893
References
1. Applied Tune Series Analysis, Vol 1.. Omes and Enochson, John Wiley, 1978, page 134.
2. ibid, p 161
c Thts note r o h to Apptlod Time Series Anafysk by Obis8
c and Enochson, Voiunw 1.
c fn
equatkns, B is the cutoff frequency of the fittc and NOT the bandwidth as mlgM one might thlnk Confusion
c might eldst between exit between equations 4.175 and 4.193.
C The LP transfer function equatlon used hem can be derived
C by wbstituttng qcut] for B in equation 4.175.
c The HP transfer function equation used here can be derived
c by srtbstlhRing F Ftcut] lor B in equation 4.1 W.
-
Irnplkit undefined (a-z)
Integer upper
parameter (upper = 8)
real ratlo, raUos(upper), thetal, theta2. pl
real ip, hp, poles, a, b, omega
real finc, num-poks, upper-llmtt, max, mln
data ratios12.w1,3.O,4.o,6.o0, 2.001,3.O,4.O0,6.0I
data filena-
+
r4pole2'. '4poie3". "4po)e4', '4pde6"~
-jopoie2", "10poW'. 'lOpoWW,'lopde' I
pi = 3.141!592654
max = 1.0e10
min = 0.0
d o i =l,upper
open (7, file = fibnameso )
numgoles = 4
if(i.gt4)numgolag=lO
ratk = ratios( l)
upper-limn = ratio 12.0
finc = 0.02
numgdnts = mx( upper-ilrnlt Ifinc )
thetal = pi Iratlo
dol=O,nwxpolnts
omega = lloata) nm
theta;! = theta1 'omega
a =(sln(thetal)~co8(th&2))~(num_polerk2)
b=(cos(thetal)* ~in(theta2))~(nurn_pde,'2)
if( lp hp .gt min nr. hp Ip .kmax) then
writW,.) omega, IP, hp
end if
end do
close (7)
end do
&OP
end
f'
#
#
Makefilelor program tiansfer~functiohtest
#
#
#
use -r4 lor alngte preclskn tkating point
use -r8 for double preclskn floating point
cc
=m
CFLAGS
=-a
SFLAGS
= -02 cg89 -r4
ALAGS
= g cg89 -r4
all:
s(oB4
qCC) t(FFLAGS) $(Ow
YLIBS) gCFLAGS) trans
APPENDIX 3
VERIFICATION O F FREQUENCY WEIGHTING FILTERS
(by W. Gum)
Tolerance requirements as specified in BS 6841:1987 standard are: within the n o ~ m a l
frequencx limits, the tolerance of the combined freqriency weighting and band 1inz:ring
should be less than I dB, outside this range the tolerance should be less than 2 dB, amTone
octave outside the nominal frequency bands the attenuation mqv extend to infinity. For
weighting B and D, whose nominal frequency bands are from 0.5 Hz to 80 Hz, and a-hose
lower and upper frequency limits are 0.4 Hz and 100 Hz, respectively, these requiremew can
be interpreted as: for frequency range from 0.449 Hz to 89.09 Hz the tolerance is k1 dB. %om
0.25 Hz to 0.449 Hz and from 89.09 Hz to 160 Hz is & dB, and for the rest of freqwncy
bands is +2 dB/-- dB.
In IS0 8041:1990, the tolerance requirements for weighting W.B.x-y and W.B.z zrs as
follows: 0 dB at 8 Hz, 21 dB for frequency range from 1.25 Hz to 63 Hz, G dB for frequsncy
ranges from 0.5 Hz to 1 Hz and from 80 Hz to 160 Hz, and +2 dB/-- dB for the rest.
Tests for venfylng the tolerance requirements have been made extensively by passing & h n t
pure tone sine signals of unity peak value one at a time through both band-limiting filter and
frequency weighting filter for sampling rates from 300 Hz to 2000 Hz. Test results siow
excellent agreement between digital filters simulated in software and the analog Eters
specified in the standards. All digital fdters presented here conform to the requirements iz the
BS and IS0 standards. Tolerances obtained from tests are shown in
5 to 8. In these
figures, tests for sampling rate of 2000 Hz are also included, and will be discussed in next
paragraphs.
When a filter is simulated digitally it approaches its analog prototype when the sampling rate
goes to infity. Theoretically, the higher the sampling rate, the smaller the error between
digital and analog filters. However, care must be taken in practice when the sampling m e is
very high. It is not necessary that better results are obtained with higher sampling rates. This
can be seen from Figure A5-1 to A5-4 in which test results for sampling rate of 2000 Hz ELOW
poorer agreement in some frequency ranges than at lower frequencies. This is caused b!- the
accumulated numerical error due to the finite word length in the computer. From d e ~ d e d
tests we found that the numerical error emerges when the sampling rate is larger than 1200
Hz, but fiters stay within tolerance requirements for a sampling rate up to 1500 Hz. In fact,
for the filters presented in this paper which have an upper cut-off frequency of 100 Hz in the
band-limiting filter, a sampling rate of 1000 Hz is more than adequate and is in most cases
already too expensive.
With the selectivity Q values of 0.71 specified in the BS standard for band-limiting filters we
were not able to obtain the exact values of attenuation given by the standard. These
attenuations were, bows\-er, achieved by using 0.707 as Q values. This suggests that it would
be better if more decimal points were used in specifying the selectivities, resonance
frequencies, and constant gains in the standard.
Some difficulty was encountered in meeting the tolerance requirements at the lower frequency
end for BS weighting B for a sampling rate equal to or lower than 600 Hz. The dB errors for
the frequency range lower than 1.6 Hz for a sampling rate of 600 Hz are slightly larger than 1
dB. This makes the filter exceed the 1 dB requirement in the frequency range from 0.449 Hz
to 1.6 Hz. In most cases this can be neglectable because the chance of having predominant
frequency component in this range is small. However, BS requirements can still be achieved
by applying a constant factor 0.905 to the filter response. This decreases the positive
percentage error at the lower frequency end and makes positive percentage errors in the
middle frequency range negative, and makes the filter in the full frequency range stay within
the tolerance requirements even for a sampling rate of 300 Hz. This adjustment has been
A5-1 are with this
implemented in TOAP software. The results shown in Figure 2 and Fie0.905 adjustment.
Frequency (Hz)
Figure A5-1 Deviation of Digital Filter Response irom z-axis Acceleration FrequencyWeighting as Defined in IS0 8041
.--.........
-
----
---
-loook :, 1\ ,,
--I
1
I
10
Frequency fdz)
2000Hz (z;
1
100
1.
I.I.
. . ..,
1000
Figure A5-2 Deviation of Digital Filter Response from x,y-axis Accelerauon rrsquencyWeighting as Defined in I S 0 8041
Figure A5-3 Deviation of Digital Filter Response frcm Acceleration Frequency-Weighting
W, as Defmed in BS 6841
. 4
.-.
2
::
.:
?
'1'
'r-
\
1 ,
0
.
'I '.,'
,
:
=8
I
I
.'~
\
,
-1
C
/
-9
i
Q)
- ........... mHz i
- - - - S O o H z ~\ ' ,
i
4 -
---
;
700Hz
-- - 1
m
H
z
i
2mHz
i
-8
I
I
t
1
10
100
-
i 1 %
1 I
:;
I:.\.!,
I \ '
...,
_
1000
Frequency (Hz)
Figure AS-4 Deviation of Digital Filter Response from Acceleration Frequency-Weighting
W, as Defined in I S 0 8041
Appendix 4
VERIFICATION OF ADDING STATISTICS AND SNAP-MASTER DATA FOR%LIT
Written by: J. Marans
A4-1. Example .STA File
1993/03/09
14:46:36
S s t a t i s t i c a l r e s u l t s f o r jab: jmtas
Nw3e:
of segments ?rOCessed:
&.(i.(ibezO f points
:I=?jer
FPZ
s1
-:
of i n i c i a l srmnents iymared:
Second nax
T h i r d Max
rinirm
S t d Dev
,38248-03
,34003-03
-26138-03
-43223-04
.1390E-02
-13763-02
.1362E-02
,1242E-04
.4651E-01
,46501-01
.C630E-01
.1092E-03
.5500
,5499
.5457
.2179E-02
.I243
.I242
-1230
.5314E-03
.1821E-02
,182OE-02
.1792E-02
.12463-04
-17733-03
.1662E-03
.1316E-03
.1767E-04
.1728E-03
.ll47E-03
-7687E-04
.5376E-04
.2393E-03
,14493-03
-5646E-04
-56831-04
.8195E-03
.1583E-03
-5791E-04
.2956E-03
.2750E-02
,25098-03
.3893E-04
.3067E-02
.4394E-03
.131lE-03
.8308E-04
.8859E-03
The columns of numbers that follow were created with PLT2ASC.EXE to determine if the
algorithm that reads HEM binary plotter files works as expected. The test files were
constructed by the SnapMaster demo program which generates 4 channels of data and \<-ill
write them out to disk files. Two output file formats were used - ASCII plotter and binary
plotter, both containing the same values. The binary data was read in by PLT2ASC.EXE one
channel at a time, and written out as an ASCII file. All 4 channels a-ere converted and the
results are listed below for points 111 to 142. The 9 columns below consist of the following:
the fmt is the data point number, the next 4 are the ASCII data values supplied by
SnapMaster as an ASCII output plot file, and the last 4 are the ASCII output from
PLT2ASC.EXE. Kote the precision difference between the SnapMaster ASCII and the
PLT2ASC.EXE ASCII. The binary plotter file contains 4 byte floating point numbers. but the
ASCII plotter file is restricted to 4 digit precision. The PLT2ASC.EXE ASCII uses g16.6
formatting.
Point CS 1 CH 2
111 2.143 -0.352
112 2.:63 -0.332
113 2.L55 -0.312
114 2.227 -0.293
115 2.227 -0.273
116 2.245 -0.254
117 2.266 -0.234
118
119
120
121
122
2.285
2.305
2.324
2.344
2.363
CX 3
CH4
CH 1
CA 2
CH 3
CE.;
0.1384 -2.85 2.148438 -3.515625E-11 8.9843755-01 -2.551553
0.2130 -2.83 2.167958 -3.320313E-31 9.1796882-01 -:.a32031
0.$375 -2.81 2.1875C2 -3.125000E-31 9.3750003-01 -:.a12500
O.?I?O -2.79 2.207031 -2.929688E-:1 9.5703135-01 -:.792969
0.2-66 -2.77 2.226563 -2.734375E-21 9.765625E-01 -2.773438
0.9361 -2.75 2.245094 -2.539063E-21 9,9609385-01 -:.753906
1.316 -2.73 2.265625 -2.34375OE-il 1.015625 -2.734275
-0.215 1.:55
-0.195 1.:55
-0.176 1.374
-0.156 1.:34
-0.137 3
:
.
1
-2.71
-2.70
-2.68
-2.66
-2.64
2.285156
2.304688
2.324219
2.343750
2.363281
-2.143438E-::
-1.9531255-:1
-1.7378138-:I
-1.562500E-21
-1.367188E-01
1.035156
1.054688
1.074219
1.093750
1.113281
-2.7145-1
-2.695213
-2.675-E:
-2.655250
-2.635-19
123 2.383 -0.117 L l 3 3 -2.62 2.382813 -1.171875E-Cl 1.132813 -2.617:38
124 2.402 -0.098 1.152 -2.60 2.402344 -9.765625E-t2 1.152344 -2.597656
125 2.422 -0.078 1.2-2 -2.58 2.421875 -7.812500E-C2 1.171875 -2.578=25
126 2.441 -0.059 1 . 3 1 -2.56 2.441406 -5.8593753-C2 1.191406 -2.558534
127 2.461 -0.039 1.211 -2.54 2.460938 -3.906250E-02 1.210938 -2.539:53
128 2.480 -0.020 1.230 -2.52 2.480469 -1.953125E-02 1.230469 -2.519531
129 2.500 0.0000 1.250 -2.50 2.500000 0.000000E*00 1.250000 -2.5000C3
130 2.520 0.0195 1.270 -2.48 2.519531 1.953125E-02 1.269531 -2.480459
131
132
133
134
135
136
137
138
139
140
2.539
2.559
2.578
2.598
2.617
2.537
2.656
2.676
2.695
2.715
0.0391
0.0586
0.0781
0.0977
0.1172
0.1367
0.1562
0.1758
0.1953
0.2148
1.239
1.3?9
1.228
1.248
1.Z57
1.337
1.426
1.426
1.445
1.455
-2.46 2.539062
-2.44 2.558594
-2.42 2.57812:
-2.40 2.597656
-2.38 2.617188
-2.36, 2.636719
-2.34 2.656250
-2.32 2.675781
-2.30 2.695313
-2.29 2.714844
3.9G6250E-02 1.289063 -2.460355
5.859375E-02 1.308594 -2.4414::
7.812500E-02 1.328125 -2.4213-5
9.755525E-Ci 1.347656 -2.402244
l.17l87SE-GL 1.367188 -2.382813
1.3ET188E-0: 1.386719 -2.3632::
1.5i2500E-01 1.406250 -2.343752
1.757813E-01 1.425781 -2.324213
1.953125E-01 1.445313 -2.3045-3
2.1CZ438E-01 1.464844 -2.2851:s
inpliz::
none
in:ec-r'2
time-flag. ::
isceghr'2 j. nc, cn
intei-ex-4dm-. rn. srzrtpoint. dl. s y z , numpts, i, end-ooir:
charac=er*20 infile, f
charac=er'l ch
i
e binary. fozatted. direct
n 3 = .?eading data fzzr:"
-714
m5
-
=
channels."
= .3eading time r
~ and
s data from.:'
close the file so it c u be reopenxi:
5orrrat.
'la,\)' I " Z22ut file:
I ' 1 infils
' a ,\ ' i
:-:raui
file: *
(a1 ' i outfilt
' a ,\ 1 ' I " Ezart point, number af poir:s:
"
I spz. s
:
n
' a ,I ' I
z=amel number: "
I cn
c Read ;he header and =;en
c in %:other
write!',
read(-, '
write:-.
read(', '
writel*.
read('.
urritel*,
r
e
open ( 6 . file = infile
open(9, file = outfi:-.
.
form = binary i
form = formatted )
c Read in the HEM deft;:: file type marker.
read181 ch
c The hex possibilities are
vse time lata ( = 15 decimal)
c 10 no time chbmel. ~ ~ l i t u d
c SO time channel pres-r:.
anplitude vs tixe data
read181 ch
j = ichar( ch 1
if ( j .es. 0 i time-<lag = 1
c Read the number of cri-els
read(81 nc
c Reopen Eke data iile for 4 byte ransom access reads.
openla. file = r.r.r:-e, form = binary, access = direct. ~ e z i= ; i
i = 1
if I time-flac .eq. 3 1 then
startgoi2t = nc ' sgt + cx + nc
+ n;~mpts' ac
endgoir.; = start-coin:
do m = startqoint. endgoint, nc
dl r rr. I nc
readl8, end
10. rec = m , iostat = io 1 Y
wr::el9.
+) dl, y
end do
else
startqo=r.: = nc + (nc + 1) ' spt + cn + 1
endsoir: = szart-aoint + nmwcs ' ( nc T 1 )
do rn = s=ar:-ooir:.
endqoint. nc + 1
dl = rr i nc
y
rec+l8, end = 10, rec = rn. iostat = io
wrlrel?, )
dl, y
end do
-
end if
10 continue
s:op
end
A1-2. Verification of Changes to TOAP
In order to verify that TOAP still runs as originally intended, the following test was carried
out. A 30 Hz sine wave was generated and digitized with M A S . Gloabal Lab, and Snap
blaster. All 3 digitized files we sampled at 200 Hz for 10 seconds, and in all cases the input
s i p a l was -c 0.79 Bg full scale fed into 2 channels.
Analysis was carried out for RMS, and RMQ calculations, as well as statistical and nonstatistical output options. These were done using an 8 second se-gment, that started at time
equal to 0.0 seconds, and no points were ignored.
Calculation without statistical output.
MTAS
Hre=aency CH 1
Global Lab
C? 2
CH
1
;rag X a s t ~ r. P l y
-
;
CH 2
CH 2
Szap ??aster STD
CH
1
CH 2
RMQ Calculation without statistical output.
Global Lab
MTAS
r f q a e n c y CH 1
CE 2
CH 1
M 2
S - 1 2 ~Master
ze
1
.PLT
CH 2
Snap Master STD
CH
1
m 2
.$A-3. Verification of Standard Binary Read Subroutine Algorithm
The SNAP MASTER standard binary file, HEM30STD.SMA, was also written out in
szponential ASCII formar. and the first column below is a sample of those values. The
~ibroutinein TOAP that reads HEM30STD.SMA was modified to write out the .-\SCII values
c F n input, and they are in the second column. Their appearing to be the same leads one to
conclude the TOAP algorithm is correct.
TOAP ASCII
8.7141083-01
3.600411%-01
-3.504800%-01
-6.755466%-01
-3.479103E-01
3.638957E-01
8.778350%-01
7.6213861-01
1.184896E-01
-5.213649%-01
-6.318618E-01
-1.217770%-01
5.874593E-01
9.073865E-01
5.7846538-01
-1.346255E-01
-6.382861E-01
-5.1494063-01
1.2491393-01
7.621986%-01
8.726956E-01
3.587563E-01
-3.5176493-01
-6.755466%-01
.A44 Changes to TOAP
TOAP has been modified to read Snap Master stzdard binary, and binary plotter file formats
(HEM), offer RiMQ or RMS calculations. perfor_ staustical calculations that create a file with
the extension .STA, and allow a maximum segnxnt size contairung 16k data points.
HEM file headers contain a bit pattern which in&;ates if the data is amplitude versus time, and
whether or not the time values are included. The data fonnat variable, DATA-FORMAT
value range was extended from 1 - 2, to 1 - 5. 1 >till indicates MTAS, and 2 Global Lab, but
3 means HEM plotter without time values. and 4 is with. The value 5 is for HEM standard
o ntime, not frequency domain
binary. It is assumed the data values are a c c e l e r ~ ~ vs
information.
The mainline p r o m T O M , now calls subroufrie PROCESS-GL with 2 new parameters,
RMQFLAG, and STATS-FLAG. A zero value indicates RMQ or statistics are not to be
done, a 1 indicates they are.
PROCESS-GL is the main processing module arJ it contains the following changes. The
parameter DIM was changed from 4096 to 163% so that segment sizes can now
accommodate up to 8k data points. If HEM file format was chosen, subroutine
decode-HEM-bin-plt is called to determine the exact file format, the number of channels, and
the sampling frequency. Also, the "get data" spezific subroutine, read-HEM-data, is invoked
to retrieve the segments.
Calculations proceed as in the previous version of TOAP until root-mea~squareis called.
RMQ and statistically pertinent variables have bssn added to the call list Since the RMQ
calculation differs from the RMS in only the v a l of
~ the exponent and surd, very little change
was needed there. If statistics are indicated, the Sequency band maxima are saved to disk for
later processing. Initially, the first max, min, anc rmslrmq sum is calculated. The mean,
standard deviation and subsequent maxima are cdculated after all segments have been
processed.
Finally, if statistics are to be done, PROCESS-GL calls subroutine statistics2 which computes
the Last 2 maximx mean and standard deviation, and writes them to the .STA file . If that fde
existed from an earlier run, it will be appended to, with the run specific parameters si-rittenout
first.
AF'PENDM 5
VERIFICATION OF ADDING ASCII DATA FORMAT
AND EXPONENTIAL AVERAGIXG
(by W. Guan)
The verification for ASCII data format and exponential averaging was done simultaneously by
processing a text data file, sin3chan.txt. This file contains three pure tone signals of
frequencies 8Hz, 12.5Hz, and 20.OHz, respectively. Each signal occupies one column.
Amplitude is 1, sampling rate is 500 Hz, and data length is 16383 data point which is about 32
seconds. This test signals are generated from Globalab, saved to disk file, imported into Excel
to combine three signals into one file in three columns.
Validation of exponential avera-@ng algorithm can be verified by enabling the "ifvenfy" flag in
subroutines root-meaxsquare and human-r-m-s.
To reproduce the verification, set
ifverify=l in those two subroutines, recompile and make toap.exe. The squared result of
exponential averaged rms value will be output to file thirdrms.ex1, .ex2, ..., and
humannns.exp in ASCII format. The f m t column in these fdss is channel number. Fde
thirdrms.ex1 contains the result of three frequencies of the highest octave of 113 octave
analysis, .ex2 contains frequencies of the next highest octave, etc. File humannns.exp is for
frequency-weighted overall analysis. Due to the large size of the test data file and the result
files,none of them are saved in diskette. However, the can be reproduced with the procedure
discussed above.
The test results given in this verification is obtained by doing 113 octave analysis and overall
analysis for rms value with exponential averaging for the test data file sin3chan.txt. For 113octave analysis, frequency range required is from 5 Hz to 31.5 Hz, and for overall analysis all
three channels are assumed to be in x-y direction using I S 0 8041:1990 standard. T i
constant is 1 second. Results of 8Hz signal obtained in humanxms.exp are given in Figure A61. As for comparison, the result from formula
for a 8 Hz signal is given in Figure A6-2. This figure is plotted nith Maple V, and the time
interval used in plotting is 0.02 second which corresponds to a sampliig rate of 50 Hz in
digital system. The smaller sampling rate is for reducing the size of the plot, and has no effect
to the accuracy of the plot. Because the gain for IS0 8041 frequency weighting filter at 8 Hz
for x-y direction is 0.254, the result shown in Figure A6-2 is also multiplied by 0.254 so thar it
is easy to compare with Figure A6-1 and A6-2.
Result from 113-octave analyis for 8 Hz signal is also given in Figure A6-3. The following
calculation can help to compare the result in Figure A6-3 with the results in Figure A6-1 and
X6-2. The squared averaging result in Figure A6-1 and A6-2 at time greater than 6 seconds is
about 0.032. If the amplitude of the pure tone is equal to 1, rather than being adjusted to
0.254 as for overall analysis, the squared averaging result is suppose to be equal to
0.03210.254' = 0.496. This confirms that the result in Figure A6-3 is correct.
The following is the output file sin3chan.m.
'1/3 Octave RMS Output ear Job (Using V6.0 dated 96-03-15): SIN3CPm
-1996/04/02
09:55:32'
"Number of ses.ents processed:
20"
"Number of poi3r-s per segment:
500
Segment length: 1.00 seconds."
5
Start tize: .OO seconds."
"Number of initial segments ignored:
-
-
Averaging Type: exponer."_ialaveraging, time constant =
"Frequency"," C h 1 " ,"c:1 2 * , " C h 3
H Z " ,"
".
a
"
5,
6.3.
.1220E-01,
.1472E+00.
.3149E-02,
.3722E-02.
.1748E-02,
.1902E-02.
overall,
Of
weighted,
.1806E+00,
.1137E+00,
.7077E-01,
.3287E+00,
.2418E+00,
.1670E+00,
max.
1.000 seconds
Figure A6-1 Exponential Averaging Verification Result from TOAP, Overall Analysis
8Hz, time constant = 1.0 second, pure tone amplitude = 1.0. IS0 8041 x-y direction
Figure A6-2 Algorithm Test Result of Exponential Averaging from Maple V
8Hz, time constant = 1.0 second, pure tone amplitude = 0.254
I
I
Figure A6-3 Exponential Averaging Verification Result from TOAP,113-Octave Analysis
8Hz, time constant = 1.0 second, pure tone amplitude = 1.0
APPENDIX 6
SHORT USER'S GUIDE TO TOAP
Guan)
(by M. Hofmeister, M.O. Al-Hunaidi, and Ur.
1
Before Starting
Before the program is run, the following must be observed:
-TOAP.EXE must be in the working directory or in the PATH statement of the
AUTOEXEC.BAT file,
-for MTAS acquired data, the files <jobname>.KDR, <jobnarne>.STi,
<jobname>.DOC, and <jobnamexb.Djk (where i = setup character and jk = channel
numbers) must all be in the same directory which does not necessarily have to be the
working directory,
-for GLOBAL LAB acquired data, only the source file must be present, and it can
be in any directory.
Note: the current version was tested for DT2821 board only. It is not clear yet
whether this version works with DT2801A board anymore after the modification on
Nov. 12, 1993. To make sure that this version works correctly with the board that
you are using, run a known pure tone signal to see whether you can get the correct
rrns value, i.e., 0.707 of the peak value of the known pure tone signal.
- for Snap Master acquired data, if it is standard binary, only the data file is
needed, not the .SMA file. If it is plotter binary file, extension .PLT is the default.
- for ASCII data fde, only one file is needed. The default extension of the file name
is .TXT.
2
Running TOAP.EXE
To run the program simply type TOAP at the DOS prompt. The title screen along with the
fust prompt should appear immediately on the screen.
3
Prompt by Prompt Guide Through the Routine
The following will present each prompt (in bold font), in order, as it appears on the screen.
A brief note will be given on each one to elaborate on any specifics which may help clear
any confusion the user may encounter. The three numbers in parentheses which may follow
a description, give, in this order, the default of the prompt, the .ininimum,and the maximum
values accepted as input. When in the routine, for numeral inputs, the default will appear
just to the left of the cursor, and for character inputs, the default will appear as the only
capitalized option in the list.
Choose format of sampled data files. - This allows the user to specify the tvpe of sampled
data files to be processed: M A S acquired, GLOBAL LAB acquired. Snap Master acquired
standard binary. Snap Master acquired plotter binary, or ASCII data file. The user is also
allowed to quit at this point if that is desired.
Job name [Q to quit] - For hfTAS format only. This is the root of the job name only; do
not include the setup character. Include the path if the job files are not in the working
directory. Including the path specification, the job name cannot be larger than 15 characters.
By entering 'q'. which is also the default, the routine will be terminated.
Produce
1. Root mean square values.
2. Root mean quad values.
3. Root mean square values with exponential averaging.
4. Quit.
- Select one of three result type to be produced. i.e., rms value, rmq value, or nns value with
exponential averaging. Linear averaging is used in producing rms value, rmq value. (1, 1,4)
Produce segment statistics [max, min, mean, standard deviation] &/N/quit]- Select
whether you want calculate statistics data or not Only valid for rms value or rmq value.
Statistics results will not be produced if rms value with exponential averaging is selected
even a "yes" answer is given to this prompt,
what type of analysis do you want to do?
1. U3 Octave
2. Overall values (Freq-weighting BS 6841:1987 or IS0 8041:1990)
3. Both
- Select what type of analysis to be performed. (1, 1,3)
Enter Hename. [Q to quit] (.DAT will be the default extension) - For GLOBAL LAB
format only. This is the filename of the source data file to be used for processing. An
extension can be given, but if it is left out, the default .DAT will automatically be
augmented. The length of the filename, including path specification (if necessary) and
extension can be no more than 20 characters.
Enter data file name: - For Snap Master standard binary, plotter binary, and .ASCII data
file. This is the filename of the source data file to be used for processing. The default
filename extension for ASCII data file is .TXT. ASCII data file should have one and only
one comment line as the first line of the data file. For the rest of the lines. each channel
occupies one column.
Sampling Frequency - For ASCII file only. This prompts input for sampling frequency of
the data stored in the input ASCII data file. (0.0,0.0, 100000.0)
Number of Channels - For ASCII file only. This prompts user input for the number of
channels. Only ASCII data file requires user to input this parameter. The number of
channels should be equal to the number of columns in the data file. Default is 1.
Using the above legend, enter the no. of the setup of your choice. - For MTAS data
format only. This prompt will not appear if only one setup is available. Only ONE setup
can be chosen. (1, 1, no. of setups available)
Which channels? - Any number of channels in any combination may be chosen. If a
channel which is not on the ax-ailability list is chosen, a warning will be given along with
another chance to pick. When the selection is complete, simply hit Enter] to move on. (0. 1, 16)
input the direction of the picked channels
1. = vertical ( 2 ) BS 6841:1987
2. = horizontal (x&y) BS 6841:1987
3. = horizontal (x&y) IS0 8041:1990
4. = vertical (2) IS0 8041:1990
- This appears only when analysis for overall values (i.e. frequency weighted) is required.
This information need to be assigned for each channel, depends on the transducer direction
and the standard to be used. (1, 1,4)
The following parameters are entered once, after which time they apply to all channels to be
processed.
Specify fdtering information and processing parameters. - Appear only when ID-octave
analysis is selected.
centre frequency of HIGHEST Y3-octave (no greater than 250 Hz) - Appear only when
113-octave anabsis is selected. (250.0,4.0,250.0) Followed by:
...LOWEST Y3-octave (no less than 2.5 Hz) - Appeal only when 113-octave analysis is
selected. Referring to this prompt and the previous one, the frequency range entered must be
an integral number of octaves. Also, the limits entered must be from the list of ANSI
standard 113-octave centre frequencies which is found in Table 1. Poor entries which violate
the above conditions will bring on warning messages and a chance to enter again. (2.5,2.5,
160.0)
Enter the length (in sec.) of each segment. - Othenvise known as the integration time: the
portion of the raw signal used for each filtering run. The length can be no greater than that
of the warning given because of the limit on the array sizes. (1.0,0.0,200.0)
Note: the se,qent length is modified to the stated amount for processing reasons (see main
manual, section 3).
Enter the start time (in sec.). - The point in time in the raw signal from which point on the
data used for processing will be extracted. (0.0,0.0,200.0)
...number of segments - The number of filtering runs to be performed per channel. This is
also the maximum number of trials to contribute towards the rms calculations (per channel).
(1, 1,2000)
...number of initial segments to be ignored - This specifies that the first n segments
processed are to be excluded from the rms calculations. This can be entered as 0 (simply hit
Pnter] since it is the default) if desired. (0,0,2000)
select the time constant for exponential averaging
1.1 second
2. V8 second
3.8 second
- Time constant of the exponential averaging. In most cases the default 1.0 second should be
used. Appear only if calculation for rms value with exponential averaging is selected.
do you want output frequency weighted time signal to ASCII fde? b/Nl-If selected,
frequency weighted time signal, i.e., after passing the band limiting filter and frequency
weighting filter, will be saved in disk file in ASCII format. Every channel takes one data file
with file extension .Fxx where xx is the channel number. Default is no.
do you want output the maximum of the frequency weighted time signal? [y/N] - If
selected, the maximum of the time signal after passing the frequency weighting filter and
band limitins filter are output to file *.rms for each channel.
Specification of processing parameters is complete. A pause will occur while data
processing takes place. For estimated run times refer to the main manual, section 6.
Display rms values on screen? [yflril-This allows the user to display the results one
channel at a time. The channels are displayed sequentially and the user has the option to quit
after any number of channels. If the N option is chosen, the results will still automatically be
written to disk, specifically, to the same directory in which the .DOC, .HDR, .STi, and
cjobnamee>.Djk files are found. The form of the file name will be <jobnamexi>.RMS
and it will contain the results from all of the channels selected. This file can be imported
into a spreadsheet for display purposes. For details on this refer to the main manual, section
4.
Display values for next channel? yUIn~quit]- By entering 'n' or 'q' for quit, theprogram
will be automatically terminated.
No more channels remaining. Hit Enter] to end routine. - h o , m will terminate
normally, returning control to the DOS environment.
APPEhBM 7
SOURCE CODE OF W O R SUBROUTINES
The listings of the source code of the following major subroutines (and mainline
program), found in the libraq FILTER.LIB, are attached in the following order:
Mainline program: toap (TOAP.FOR)
processgl (PROCESGL.FOR)
ASCIIREA.FOR:
subroutine read-ASCII-data
ASCII-IN.FOR:
subroutine input-ASCII
CHAN-SK.FOR:
subroutine channel-seek
subroutine check-channel1
CK-CHAN 1.FOR:
DAFFDATA.FOR:
subroutine read-daff-data
DAFFPARS.FOR:
subroutine daffgarse
DCK-CXNS.FOR:
subroutine double-check-channels
DCK-SETS.FOR:
subroutine double-check-setups
DIGFILTM.FOR:
SUBROUTINE DIGFILTM
FILTER.FOR:
subroutine FILTER
FILTER.FOR:
subroutine RINGBUFFER
FILTINGL.FOR:
subroutine filter-info21
FNPR0BDF.FOR:
subroutine filename-probe
GETSFREQ.FOR:
subroutine get-sfreq
GET-CHGL.FOR:
subroutine get-channels-gl
GET-DAT I .FOR:
subroutine get-data1
GET-NMGL.FOR:
Subroutine get-name21
GET-SET.FOR:
subroutine get-setup
HEADERDF.FOR:
subroutine read-daff-header
HEMSFREQ.FOR:
subroutine get-sfreq-HEM
HEM_DEC.FOR:
subroutine decode-HEMbin
HEM-STD.FOR:
subroutine HEM-standardbinary
HIPASS3.FOR:
SUBROUTINE hipass3
HUMANCOF.FOR:
subroutine HUMANCOEF
-.FOR:
subroutine HWAANFLTER
HUMANOUT.FOR:
subroutine humaxout
HUMANRMS.FOR.
subroutine HUMAN-R-M-S
LOPASS3.FOR:
LFTB.FOR:
PROCESGL.FOR:
PROCMISC.FOR:
PROPARMS.FOR:
PRTRMSGL.FOR:
READCHDF.FOR:
READHEM.FOR:
READSENI .FOR:
READSZDF.FOR:
ROOTMNSQ.FOR:
SErnS.FOR:
STATS2.FOR:
TH3RDOCT.FOR:
UTILS.FOR:
UTILS.FOR:
UTILS.FOR:
UTTLS.FOR:
UTILS.FOR:
UTILS.FOR:
UTLS .FOR:
UTILS.FOR:
UTILS .FOR:
UTILS.FOR:
WRTRMSGL.FOR:
SUBROUTINE lopass3
SUBROUTINE LPTB
subroutine processzl
subroutine processing-rnisc
subroutine p r o c e s s i n ~ a r m s
subroutine print-rms_gl
subroutine read-daff-channels
subroutine read-HEM-data
subroutine read-sensitivity 1
subroutine read-size
subroutine root-mean-square
subroutine setup-info
subroutine statistics2
subroutine th3rdoct
subroutine new-page
subroutine parse
subroutine to-int
subroutine concatenate
subroutine get-sfreq-HEM
subroutine save-processingparameters
subroutine tirne-starnp
subroutine strip-blanks
subroutine my-to-upper
subroutine to-units
subroutine write-rms-gl
Also included is the listing of the source code of sinbin2 (found in SINBINZ.FOR), the
routine used to generate the test data involved in the verification of TOAP. Ln addition to
this, the listing of the source code for MAKEFILE is also included.
Pro-gram Toap
........................................................................
C Main propam that houses the major subroutine, processql (found
C in the file PRO€ESGL.FOR) which contains sections of data acquisition,
C filtering, statistical analysis and output procedures. Sections from
C the previously designed pro-,
CONTROL.FOR (written in June 1931 by
C M.R. Hofmeister) were implemented to perform the chore of l13-octav2
C filtering in the time domain. The preliminary section regarding the
C retrieval of job specifications was written by M.R. Hofmeister and
C used utility subroutines found in the MTAS library. The final se,qent
C of the routine prncess calculates the maximum rms values in each 113C octave and writes them to disk. At the moment, the subroutine proces_gl
C is the only major subpro-mam in Toap.
Although this mainline pro=C may be relatively empty, it was created with the anticipation of
C the addition of extra modules in the future.
C*****************************rr********************************
C Note for Version 6.0
This version is based on version 5, and with the following
C new features:
RMS value with exponential averaging is added. (rmq-tlag = 1!
C
C
ASCII input format is supported. (data-format = 6 )
Option for outputing frequency weighted signal is added.
C
C
C***********r**********************s********************~***************
C Note for Version 5
C This version is a modified version which can calculate overall
C vibration level by applying frequency weighting filters based on IS0
C 8041:1990 and BS 6841: 1987. Data f o m t s of Snap-Master standard
C binary and plot binary have been supported since version 4.
C**********i*******ff************************************=~*************
C Note for Version 2
C This version, Toap (from TOAP.FOR) is a modified version
C which can accept both MTAS and Global Lab formatted data. New
C subroutines had to be written and some of the existing ones had to be
C changed slightly to accomodate the processing of Global Lab data. Any
C of the previous subroutines that had to be changed have 'ql'added to
C their names and %L' put at the end of their DOS filenames.
C*************************************f*********************************
C The data which are read from disk in MTAS format are done so by
C routines which are modificationsof existing MTAS library
C counterparts. For the purpose of data recovery, the MTAS files with
C the following extensions must be present in the working directory:
C .HDR, .STi (i =setup character), .DOC, in addition to the .Di (i =
C channel number) fies for each channel.
C All routines which read data in Global Lab format had to be
C written specially for this task fie. none were previously in
C existance). To process Global Lab formatted data, only one file is
C needed, the source data file. This is because for Global Lab all the
C header information and raw data are included in the same file.
C The output files containing the maximum rms values for each 113C octave are a~ittento disk in ASCII format with filenames:
C
<namexsetup-characte~.RMSfor MTAS fonnat
C
d i e n a m e roo6.RMS
for Global Lab format
C where 'name' is the user given jobname, and 'filename' is the Global
C Lab source tile.
C***********************************************************************
C Found throughout the subroutines comprising Toap is the flas
C 'data-format'. This flag assumes one of two values depending on which
C type of data is being processed:
data-format = 1 for MTAS formatted data
C
data-format = 2 for Global Lab formated data.
C
.....................................................................
C COMPILE AND UNK OFTONS:
fl Ic /AH 14Yd 14Nt I412 /Zi IOd lG2 /mi87
C
C
(debug information included)
C
fl IC/AH 14Yd 14Nt 1412 /Ox lG2 /mi87
C
(no debug information included)
link ICO thiid.obj, third,, filter llibfor7 mtas pIouns4
C
C
grafex4O ISE:256
C**********************************rf*******t***********************%
C To perform the 113-octave filtering, ponions of CONTROL.FOR, the
C latest version being CONJN12.FOQ were imported into the subroutine
C process. The filter coefficients are calculated in the subroutine
C LFTB which comes straight out of 'Applied Time Series Analysis:Vol 1'
C by Otnes and Enochson. This routine is used to generate LowPass
It can also be used to generate hipass
C Tangent Butterworth filters.
C filters of the same type.
C In the subroutine processing-parms [PROPARMS.FOR] the user is
C asked to enter the length of the segment of the original time signal
C to be used for averaging. This length is restricted by the size of
C the arrays SIGNAL. 84000 and B3150 which are used to store and
C manipulate the filtered data. The dimensions of these arrays are all
C set to 4096 in the major subroutine process.
This allows 2048 points
C to be processed since only half of the array SIGNAL is available to
If the user requires a longer segment length
C hold the raw signal.
C than that currently available, the dimensions of these arrays can be
C changed by altering the value of the variable DIM which is curently
C assigned, via a PARAMETER statement, to 4096.
C Within the routine process are subroutines which check how many
C setups are available for the given job and then give the user an
C opportunity to chose one of these setups. With this done, the user is
C then given a l i t of channels from which to choose from for the given
C job and setup. The user may choose any number and any combination of
C these channels.
C The calculated m values are automatically written to disk and
C if he wishes, the user may also have them printed out on the screen.
C*********************************************t*************************
C Below is alisting of all the subroutines used in Third. Those
C labelled major subroutines are ones which accomplish sizeable tasks
C in the development leading to the final results. Those labelled as
C utility, are ones which, in general, take care of one small job like
C reading an integer or real as input from the user or concatenating a
C set of strings. Each of these utility subroutines may be used more
C than once and they are predominantly found in the MTAS library
C (MTAS.LIB).
~***************++t******t***:*t***************:******t**********t**:***
C Subroutine Index @OS filenames in parentheses, f = function)
L
C major subroutines(all found in FILTER.LIB)
C
prccessgl (PROCESGL.FOR)
C
get-names1 (GET-NMGL.FOR)
C
setup-info (SETUE'S.FOR)
C
get-setup (GET-SET.FOR)
C
channel-seek (CHAV-SKFOR)
C
get-channels-gl (GET-CHGL.FOR)
C
check-channel 1 (CK-CHAN1 .FOR)
C
filter-infogl (FILTINGL.FOR)
C
digfiltm @IGFETM.FOR)
C
lptb &FlB.FOR)
C
get-sfreq (GETSFREQ.FOR)
C
processingparms (PROPAfLMS.FOR)
C
read-sensitivity1 (READSEN1.FOR)
C
get-data1 (GET-DAT1.FOR)
C
th3rdoct (TH3RDOCT.FOR)
C
lopasd (LOPASS3.FOR)
C
hipass3 (HIPASS3.FOR)
C
root-mean-square (ROOTMNSQ.FOR)
C
print-rmssg (PRTRMSGL.FCR)
C
write-mgl (WRTRMSGL.FOR!
C
double-check-setups (LICK-SETSEOR)
C
double~check~channels
(DCK-CHXS.FOR)
C
submutines to accomodate Global Lab formatted data:
C
tilename-probe (FNpROBDF.FOR)
C
read-daff-header (HEADERDF.FOR)
C
daff-parse (DAFFPARS.FOR)
C
read-size (READSZDF.FOR)
C
read-daff-channels (READCHDF.FOR)
C
read-daff-data (DAFR)ATA.FOR)
C utility subroutines (found in MTAS.LIB except where noted)
C
cc (CCJOR) f
C
cc3 (CC3.FOR) f
C
get-int (GET-INT.FOR) f
C
lcuc (LCUCZOR)
C
query (QUERY.FOR) f
C
setup-char (STUPCHAlLFOR) f
C
the-end (THJ-ENDJOR)
C
cc40 (CC4OEOR) f
C
cc4 (CC4JOR) f
C
number-char (NUMCHAR.FOR) f
C
qsmcde (found in G W 4 O . L I B )
C
qrmode (found in GRAFEX4O.LIB)
C
get-real (GET-REAL.FOR) f
C
read-some-lines (READLN-FOR)
C************************************t*f************~****%**********%***
implicit none
integerf2 default-mode, i, get-inr. data-fonnaf rmq-flag
integer*2 stars-flag, choice
integef2 aria-flag
characteF20 blank, ml, dformat
blank = ' .
m l = "Choice"
d f o m t = "Data Format"
rmptlag = 0
stas-flag = 0
m2 = ' Produce segment statistics "
m3 = "[max, rnin, mean, standard deviation] [y/h'/quit]: "
call qmode(default-mode, i)
c
c
call new-pa~e(defau1t-mode)
prinr*, 'Choose format of sampled data files.'
print*
printx, 'Enter the number of your choice.'
print*, 'I. MTAS (default)'
print*, '2. Global Lab'
print*. '3. Snap-Master Plotter Binary'
prinr'. '4. Snap-Master Standard Binary'
print'. '5. ASCII file'
print*. '6. Quit'
print*
data-format = get-int( dformai 1, 1,6)
if ( &[a-format .eq. 6 )call the-end(defau1t-mode)
if ( &ta-format .eq. 5 ) data-format = 6
if ( datxformat .eq. 4 ) data-format = 5
**spxial notice for possible problem with different AID b o d
**for Globalab format
if ( data-format .eq. 2) then
print*, ' '
print*, ' '
print*,' You have selected Global Lab data format.'
print*, ' '
print* ,' Please be warned that the current version was tested'
prior*,' for DT2821 board only. It is not clear yet whether.
print*,' this version works with DT28OlA board anymore after'
print*,' modification on Nov 12, 1993. To make sure thar chis'
print*,' version works correctly with the board that you are.
print*,' using, run a known pure tone signal to see whether you'
prinr*,' can get the correct rms value, i.e., 0.707 of the peai-'
print*,' value of the known pure tone signal.'
prict*, ' '
pacsc 'press ENTER key to continue ...'
end if
+
c
call new-page(default-mode)
prini*, 'Produce 1. Root mean square values.'
prin;*, '
2. Root mean quad values.'
prinr*, '
3. */I
Root mean square values with exponential averaging.'
print*, '
3. Both.'
print*, '
4. Quit.'
rmq-flag = geiint( ml, 1, 1 , J ) 1
if ( rmq-flas .eq. 3 ) call the-end(default-mode
-
i
if (rmq-tlag.eq.0 .or. rmq-flag.eq.1, then
call new~page(defau1t-mode)
write(*. '(a, a.\Y m2, m3
read(*. '(a)' ) ch
if ( ch .eq. 'q' .or. ch .eq. 'Q' ) call the-end(default-mode)
if ( ch .eq. 'y' .or. ch .eq. 'Y' ) stars-flag = 1
end if
if (mq-flag.eq.2) then
stars-flag = 0
end if
+
+
SWP
end
call newgage(defau1t-mcde)
print *, 'what type of analysis do you want to do'?
print *. ' 1. 113 Octave'
print *. ' 2. Overall values'//
' (Freq-weighzing BS 6841:1987 or IS0 8041:1990)'
print *. ' 3. B o w
ana-flag = set-int( ml, 1, 1,3)
call new-page(defau1tLmcde)
call processsl( default-mode. data-format, m a f l a g ,
stats-flag, ana-flag)
C***rr*************t*f**f*f******tt***f*~**~******~~~~******************
subroutine process_gl( default-mode, data-format, r m ~ f l a g ,
stats-flag. ana-flag )
C***xi*************ir*******1;*****~~********=~*****==********************
C Major subroutine which acquires job specifications, reads the data
C from disk, filters the data into 1:3-oswves, performs a starisC tical analysis of the data and writes this information to disk.
C This routine can handle both MTAS and Global Lab data formats.
C The selection of the data format is done in the mainline program
C toap-gl (TOAP-GL.FOR) where the parameter datkfomat is assigned
C as follows: data-format = 1 for MT'.AS format,
data-format = 2 for Global Lab format.
C
C Modifications to implement Global Lab format include alterations to
C the existing subroutines of get-name-l, get-channels, filter-info,
C and write-rms. In addition, the follouing new subroutines were
C created to allow for the processing of Global Lab data:
C read-daff-header, read-daff-channels. and read-daff-data. Upon
C making these modifications. the name of the subroutine was changed
C from 'process' (PROCESS.FOR) to 'process-gl' (PROCFSGL.FOR).
C These modifications were completed on December 10, 1991 by Martin
C Hofmeister.
C Xote: If more than 2048 point., for each processing segment are
C needed, the value of the constant 'dim'. declared in a parameter
C statement below, can be changed by simply modifying this
C stalement. Remember that the amount of useable points is equal to
C half the value of the constant dim.
C***+L*********************=*****=**************************************
c JPM 93/02/02
added HEM file support, which means allowing for
c
a data-type = 3. Now, HEM files have the option
c
of containing or not, time axis values. so I'm
c
going to allow subsequent subroutines to use a
c
data-format = 3 for no time values, and a data-format
c
= 4 when time values are included
c
Added rmq calcs.
c
Added statistical calculations.
c
data-format = 5 now indicates HEM std bm files.
c
93/02/16
changed stats to sums to avoid having too much
c
memory tied up with segment values. Segment mans
c
are now written to disk and recalled if stats are
c
required.
c
93/02YU)
made both nns and nnq an option.
..............................................................
c WG 93/04/13
Added option for frequency weighting analysis.
c
Major new variables added. ana-flag (flag of the
c
type of analysis) and channels-weigtype(l6).
c
ana-flag = 1, 1/3 octave analysis
c
ana-flag = 2, overall value (freq. weighting)
c
ana-flag = 3, both
c
channels-wei~type(i) = 2, vertical (2)
c
channels-weigtype(i) = 4, horizontal (x & y)
c
93/06/25
modified for adding ana-flag to the call to
c
subroutine filter-info&
c
96/02/19
Modified for adding ASCII formaf data_format=6
c
last-se~flag is added for this nmliication,
+
c
and is used for rsading ASCII h 2:e only.
last-segflag = I , this is the last s x n t
c
96103107
Modified for adding exponential av:-.-ging. Variables
c
sumexp (human:. iumexpl23 (one LL5rii) are added as
c
intermediate storages for keeping axsrz~edresuits
c
between segmecz. For exponenti2 rlsraging only.
C*********************************~-************=X~~***************~~~**
implicit none
c
c
integeri4 dim
parameter (dim = 32768 )
parameter ( dim = 16384 )
real*4 samplingfreq, sensitivity. rmq(l6,ZI)
real*4 signd(dim), WXO(dim), b3 150(dim), rms(16.2! )
real*4 stand_freqs(22), starLtime
real*4 sums(21), mins(21), maxli21), m 2 ( 2 1 ) , mzx? 21)
characterS20name, blank, filenams. root, extension. 5:2i(21)
character*7 units(l6)
character*8 dos-name
character*13 m4
characteP77 ml
characterf4OmZ
characterf% m3
character*24 m12
character*20 ml 1, segfites(21)
integer*2 default-mode, nSeNpS, SeNpnO, rep, nchani-tcked
integeP2 setups(32), channels(l61.channels-picked 15). nchan
integeP2 nuu-octaves, num-segments, num-ignors_st$s, channel
i n t e g e 2 chanloop, segpo, k, end-flag, cho~cel,skip-re~eve '
i n t e g d 2 get-inf nchan-done, 1, top-freq, rms-results. choice2
integeP2 nu-segs, data-format, un, skip-daffjrelim
integeil2 -flag,
fi-channel-flag, stats-flag
integeP2 &'st-flag, last-segilag
integer*4 numpoints, nptsl, stangoinr, start45 km-sum
integeP2 ana-flag, channels-weigtype(l6) human-rn-segs
real*4 human-rms(l6)
real*4 human-mins, human-maxl. human-max2, h u m n m a x 3
real*4 human-mean, human-stddev
reai*4 sumexp, sumexp123(21)
integer*2 Kexp, human-weighted-out-flag, s u m e x p i e
logical query
+
+
data (stand-freqso), 1 = I, 22)1250.0, 200.0, 160.0, !25.9,
100.0, 80.0,63.0, 50.0,40.0,31.5, 25.0, 2rJ.O. 16.0,
12.5, 10.0, 8.0,6.3,5.0.-1.0, 3.15, 2.5,2.0.'
name = "
blank = ' '
ml = "No[#enough~ta#1eft#in#sipal#to#proccss~
m2 = "according#to#your#specificatio~~~."
call concatenate( ml, 77, m2, 40, .true. )
mi 1 = " Processing Channel:"
m12 = "
Segment Number:"
m3 = "#Processing#job:#"
m4 = "#####Channel:"
C Ask user to input job name
C*****************************************Y*************************=*~*
10
+
call get-name-gl(narne, default-mode, data-format,
filename, root, extension, first-flag ]
C Determine which setups exist and how many of them there are.
C For MTAS format only, and skipped for Global Lab format.
........................................................................
if (data-format .gt. 1) goto 50
call setup-info(name, setups, nsetups, setupno)
if (nsetups .eq. 0) then
print*, mere are no SeNpS present.'
print*, Enter a new job name? Yylquit]'
if (query(blank, 'y', default-mode)) then
call qsmode(default-mode)
got0 10
end if
call the_end(default-mode)
end if
........................................................................
C Ask user to choose a setup. W A S only)
c******************************f*sft********************************=*******
if (nsetups .gr I) call ger_setup(setups, setupno)
C Determine which channels are available (for MTAS).
C For Global Lab famatted data, extract information from the DAFF
C header including which channels are available.
C*t*f****************f***t******LI******************************=****~**
call channel-seek(name, setupno, channels, rep, nchzn)
50
+
continue
if (data-format .eq. 2) then
call read-d&-header(fi1ename. sampling-freq, rep]
if (rep .ne. 1) call read-daff-channels(frlename, channels,
nchan, rep)
if (rep .eq. 1) then
print'. 'Enter a new job nmelfilename? [Yfquit]'
if (quer). (blank, 'y', default-mode)) then
call qsmode(defau1t-mode)
got0 10
end if
call the-end(d?fault-modq
end if
end if
C****frr***********************ff*~=*****************~***********
c decode the HEM file header.
C+**.**********f*******X*********+********************************
+
if ( data-format .gt. 2 .and. data-format.lt.6 J then
call decode-EU-bin( filename, data-format, nchan, n u m p i n t s ,
hem-sum, samplingfreq, default-mode, units )
end if
........................................................................
C Get information for ASCII d m format from user Input
C***xxr************************~*********~=**~*************~~***********
if ( data-format .eq.6) then
call input-ASCII(samplingfreq, nchan, units )
end if
C***x***************z*****=***************~****************~************
C Ask user to select channels for processing
C**fr**************************x**********=*****************************
call get-channels_gl(name. SsNpnO. channels, nchan, default-mode,
channels-pick?& nchaxpicked, channels-weigtype,
+
ana-flag, data-format. filename)
t
..................................................................
C Get information to calculate fdter coefficients, perform the calculC ations and write the coefficients to disk.
C**************+*********Z**********Z*************************Z*********
call filterinfogl(name, samplingeeq, top-freq. num-octaves,
stand-fress, default-mode, darn-format, files,segfiles,
ana-flag)
+
+
C Ask user to input parameters needed to process the segment(s) of data.
C****************************************zz*************************
100 call processin&pms( nuxpoints, stm-poinl num-segments,
+
num-ignore-segs, dim, samplingfreq, num-octaves)
C Ask user to input rnisc. parameters.
~************zz******************************************%**=*******%***
-
call processingrnis~(defau1t~mode.rmq-flag, ana-flag,
samplingfreq. Kexp, human-weighted-out-flag)
+
........................................................................
C Process the data associated wirh each channel.
C*****************i~~***********=f*~**********~~************************
skip-retrieve = 0
nchan-done = O
un = l
start-time = tlo~ristart-pint ) / samplin~freq
dos-name = roo8 1 :8)
call my-to-upper( dos-name. 8 J
call concatenate(m3,38, dos-name. Y. .false. )
call concatenateim.3, 38, m4. 13. .mc.)
do chanloop = 1. 16
call qsmode(default-mode)
if (channelsqicked(chan1oop) .eq. 0) c)-cle
channel = chanloop
first-channel-flag = 0
if ( nchan-done .eq. 0 j fir-channel-tlzs = 1
dok=l.21
rms( channel. k ) = 0.0
rmq( channel. k ) = 0.0
if ( stats-flag .eq. 0 ) cycle
sums(k) = 0.0
maxl(k) = 0.0
max2@) = 0.0
max3(k) = 0.0
mins(k) = l.Oe23
end do
if (ana-flag.ne.1.and.stats-tlag.eq. I) thc2
human-maxl = 0.0
human-max2 = 0.0
human-max3 = 0.0
human-mins = l.Oe23
human-mean = 0.0
humaxstddev = 0.0
end if
C Read sensitivity from .DOC f i e for MTAS only.
if ( data-fonnat .eq. I )call read-sensiti~iryl(sensitivity,
+
name, serupno, channel)
C Pracess each segment of data
last-se~flag= 0
do s e z n o = 1, num_sements
if(segno.eq.num-segments) I&:-segflag = 1
start-pt = stan_point + ( s e g n o - I) * numqoints
write(*, '(a, i3. a 5)')
m3, chzziel, m12, seg-no
C Get the data from disk
if (data_format .eq. I) then
call get-datal(signa1. rumqoints,
name, setupno, channel, end-flas.
start-pt, sensitiviy!
end if
if (data-format .eq. 2) then
call read-daff-data(fi1enmz. channel.
sinal, num-points, end-flrg.
start-pt. units, un,
skip-retrieve, skip-daff-przlim)
end if
if (data_format .gt. 2 .and. data-format.lt.6) then
call read-HEM-data( filename, channel,
num-points, signal, end-flag,
star-pt, data-format, nchan. hem-sum )
end if
if (data-fomat.eq.6) then
call read_ASCn-data( filename, channel,
last-segflq.
nchan, num-points, start-int,
sipal, end-flag )
end if
skip-daffqrelim = 1
if (end-flag .eq. 1) then
print*, ml
ncha~don=
e nchan-done + m ~ r e s u l t s
if (nchan-done .eq.0)then
print*, 'No rms results have been cexputed.'
print*, 'Hit [I]: Restart and reset prxessing '
//
parameters'
print*, ' [Z]: Quit program'
choice2 = get-intmlank, 1, 1.2)
goto (100,300) choice2
end if
print*,'No. of channels processed so far (inclnding'
I/ ' the current one): ',nchao_done
print*,'Channel currently king processed: '.=hamel
print*,'For current channel. RMS results for .
rms-segs, ' segments are available.'
printf,'Hit [I]: View the results.'
print*,' [Z]: Resrart and reset processing FZ'
// 'meters for all channels.'
choicel = get-intmlank, 1. 1.2)
got0 (200, 100) choicel
end if
nptsl = num-points
C ***** for frequency weighting *****
if (ana-flag.eq.2.or.ana-flag.eq.3) then
c filter the data
call humanfilter(signal(I), npts 1,
+
+
channels-aeigtype(channel), sampling-freq,
segno, W ( 1 ) )
c output frequency weighted time signal to disk file, if requested
if(human-weighted-out-flag.eq. 1)
+
call human-out(channe1, s e ~ n oname.
,
setupno,
+
root. data-formar npts I, MMX)(I))
s find the se,ment with the maximum rmslrmq values, and all the statistics
c except the standard deviation.
if (mq-flag.eq.2 .and. segno.eq.1) sumexp = 0.0
if ([email protected]) then
human-rms-segs = human-rms-segs + 1
call human-r-m-s(b4000, numqoints, human-rms,
+
channel, rmq-flag, human-rms-segs,
+
stats-flag. human-maxl, humaxmax2. human-max3,
+
human-mins, humaxmean, sumexp. Kexp)
ms-results = 1
end if
end if
C ***** for 113 octave analysis *****
if (ana-flag.eq. 1.or.ana-flag.eq.3) then
C Filter the data
call th3rdoct(signal. M000, b3150, nptsl, num-octaves,
+
skip-retrieve, s e g n o )
skip-retrieve = 1
C Compute the maximum rms/mq values in each 113-octave
if (rmq-flag.eq.2 .and. segno.eq.1) then
do sumexploop = 1,21
sumexpl23(sumexploop) = 0.0
end do
end if
if (segno .gt. num-ignore-segs) then
rms-segs = r m ~ s e g +
s 1
call root-mean_square(signal, b4W, b3154
numumpoints,
num-octaves, rms, channel,
rmcflag, sums, rms-segs, statstsflag,
segfiles, maxl, mins, rmq, sumexpl23, Kexp)
rms-results = 1
end if
end if
end do
if ( slats-flag .eq.0 ) cycle
call statistics2f m s e g s , rms. rmq-flag, sums,
channel, stand-freqs, fust-channel-flag, num-segments,
num-points, num-ignore-segs, root, filename, data_fomat,
num-octaves, top-freq, samphgfreq, start-time,
segfiles, maxl, max2, max3, mins, first-flag, ma-flag,
human-nns-segs, human-maxl, human-max2, human-max3,
+
human-mins, human-mean)
end do
200 continue
C Write rms values to disk
C*******************************X**************~*****************%******
+
+
+
call ~ r i t e - ~ l ( m nchm-done.
s,
channels-picked, num-octaves.
top-freq, name, setupno, data-format, root, units.
rmq-flag, num-se-,gents, num-points, num-ignore-segs,
start-time, samplincfreq, &fault-mode, ma-flag. human-nns )
C Printout rms values at user's discretion
c*****************i*****************************************************
call qsmode(defau1t-mcde)
print*, 'Display rmsirmq values on screen? [y/Nl'
if ( query(blank, 'n', default-mode) )
+
call print-rms_gl( rms, nchaxdone, channels-picked,
+
num-octaves, stand-freqs, top-freq, &fault-mode,
+
data-format, units. rmqflag, ma-flag, human-rms )
300 continue
return
end
Cf*******************************************************-*******
subroutine read_ASCII-data( filename, chan, nchan, numgoints,
star-point, last-se~flag.x, end-flag )
C********************************==****************************T=*******
c filename =
data file name
c nchan =
number of chans
cchan =
current channnel
c num-points = number of points to be read for the current segment
c star-point = s t a r p i n t , as calculated from signal starting time.
c
start-point = start time sampling frequency
c last-se~flagindicate whether this is last segment for current channel
c
=I. this is the last segment to he read for this channel
c
file unit 8 can be closed and file should be reopened
c
for reading next channel
cx
arrary of signal of current segment and channel
c end-flag
=I, indicate end of file is reached before enough data
c
is read from data file
+
C
c WG 96/02/25 read ASCII data file; according to the channel number,
c
s t a r point, and number of points as specified.
........................................................................
implicit none
integerf2 nchan, io
integer*2 chan, end-flag, ichan. last-segflag
integer*4 num-pints, start-point
integerf4 i, j
real*4 x(*), durn
logical ifopen
character*20 filename
character*80 comment
end-flag = 0
c Open the dara file
inquire(8, opened = ifopen)
if( .not. ifopen) then
open(& file=filename, form='formaned')
read(8, '(a)') comment
c
skip over first serveal seconds as required
do j = 1, start-point
read(8, *) durn
end do
end if
c move to the correct segment
c20
doj=l,start-pt-1
c
read(8, *, iosrat = io, end = 30) (durn, ichan=l, nchan)
c
read(8, *, iostat = io, err=25,end = 30) (durn, ichan=l, nchan)
c
c
c 25
C
c 30
end do
goto 40
printy, 'error happened in reading data file'
stop
print*, 'unexpected eof is reached in reading data file'
C
c read in data, and keep monitoring if eof is reached
i=O
c40
c
do j = start-pt. start-pt + num-points - I
c
read@, *, iostat = io, end = 50) (durn, ichan=l, chan-I).
c +
xfi), fdum. ichan=chan+l, nchan)
c
i=i+l
c
end do
+
i=O
do j = I, numqoints
read(8, *) (dum. ichan=l, chan- I),
x(i+l), (dum. ichan=chan+l, nchan)
i=i+l
.s
end do
50
continue
c
if (i.lt.num-points .or. io.eq.-1 .or. last-seg-flag.eq. 1) then
if (i.lt.num-points .or. io.eq.-1) then
if (i.lt.num-points .or. last-segflag.eq. 1) then
if (i.lt.num-points) then
end-tlag = 1
numqoints = i
end if
close(8)
end if
c
open(9,file='mp.out',fom='fomatted',access=~ap~nd')
write(9,'(a)') 'hum-points chan end-flag filename'
write(9,*) numgoints. chan, end-flag, filename
write(9,*) (x(i), i=l,num-points)
close(9)
return
end
subroutine input-ASCII( samplingfreq, nchan. :-its )
C*********YY******~*****Y****Y*****Y**Y***Y**=*~************~~****YY****
c WG
96/02/20
Ask user input for ASCII data ?:mat.
C**Y******Y******l*****************Y**~-**Y****Y****~*~~*YYYYYYY
implicit none
integer*? i, nchan, get-int
red*4 samplingfreq, get-real
character*7 units(*)
character*38 m3
characterf 20 ml, blank
nchan = 0
m l = " Sampling Frequency "
m3 = " Number of Channels "
printf, ' '
smplingffreeq= get-red( ml, 0.0,0.0, 100000.0
do i = 1, nchan
units@ = ' '
end do
return
end
,
Ci****************+***t*****~***i.i.*******~************~*******~*==~*****
subrout~nechannel-seek(narne. setupno, channels. rep. nchan)
Checks how many channels are a%a~lable
and finds out which ones
they are. Also warns the user if there are absolutely no channels
present for the given job.
C***************************ff***t*******************=*****=******
characterS20 name, setc, cc
character* 1 setup-char
integer i, setupno, channels(l6). nchan, rep, channels2(16)
logical ex
C
C
C
C***+***t***********************~~******************************~=~*****
C
Check the .DOC file for the channels available.
call double-check-channels(name, setupno, channels2)
..........................................................................
C*****Check for the .Di (i = channel no.)files
setc = setup-char(setupn0)
nchan = 0
d o i = l,16
call check-channell(i. ex. sew. name)
if (ex) then
channeIs(i) = 1 * channsls2(i)
nchan = nchan + 1 * channels2(i)
else
channels(i) = 0
end if
end do
if (nchan .eq. 0) then
print*, There are no channels available for the job:',
+
=(name, setc)
rep = 1
else
rep = 0
end if
return
end
C**************************P********************************~*~*********
C
C
C
C
subroutine check-channcll(i, ex. setc, infile)
Oripindly called check-channel from the file CK-CHAN.FOR found
in JPM's SRC library. The filename was changed to CK-CHAN1.FOR
for use in the main progarn THIRD. This, the only change to the
subroutine, was done by MRH on June 27, 1991.
C**********f******************ff******************************%*********
integer i
logical ex
character'20 cc4, setc, d, infile. ch-nun, number-char
character*20 filename
ch-num = number_char(i)
filename = cc4(infile, setc, d, ch-num)
inquire( file = filename. exist = ex)
return
end
Cpage break
SDECLARE
SXOTRUNCATE
SST0RAGE:Z
......................................................................
subroutine reacdaff-data(fi1ename. channel. signs. num-points;
+ end-flag, stan-pt, units, un, skip-retrieve. skip-kt-prelim)
C For Global Lab data files only.
C Routine to read the raw data directly from the GlokA Lab DAFF
C file. Along with the raw data, the scaling factor and offset are
C also retrieved from the DAFF file and these are usxi to convert
C the raw data into the workable values. This conversion is also
C done in this subroutine.
C WG modified on Aug. 13, 1993. The only change is s follows
C
statement "offset = offsetl + offsett" is changed to
C
"offset = offsetl*factor2 + offset2".
C***************fx*********************~****~*****************~*********
character*20 filename
character*7 units(16)
integere4 num-points, start-pt. position, data-adks. st
integerf4 factorl-man, factor2-man, offsetl-man. ~3set2-man
integer*4 blkoffs, demux, data-type, raw2, B3 i
integer channel, context-id, ref. factorl-exp, factor:-sxp
integer offsetl-exp, offset2-exp, i, un, end-flag, raw
integer skip-retrieve, skip-daffsrelim
real*4 signal(*), factorl, fanor2. factor, offsetl, offet2
reals4 offset
open (7, file =filename, form = 'binary', status = 'urhown',
access = 'direct', r e d = 2)
if (skip-retrieve .eq. 0) read (7, rec = 9) data-address
if (skip-daffqrelm .eq. 1) goto 100
+
C*****Reading and constructing scaling factor and off~t***************
context-id = -32763
call dafqarse(l5, context-id, channel, -1, -1, psieon)
ref = position
call daff-parse(ref, -1, -1, #82. 2, position)
read (7, rec =position + 4) factor2-man, factor2-ex;
factor2 = ((factor2-mad2.0) I B31) * (2.0**factor2-sxp)
call dafLparse(ref, -1, -1, #83,2, position)
read (7, rec =position + 4) offset2-man, offsea-exp
offset2 = ((offset2-mad2.0) I B3l) * (2.0f *offset2_exp)
call daff-pm(ref, -1, -1, #85. 2, position)
read (7, rec = p i t i o n + 4) factorl-man, factorl-exp
factorl = ((fi::orl-md2.0)
IB31) * (2.0f*factorl-exp)
offset1 = fact~rllfactor2
factorl = -2.P*offset1/4096
factor = factorl * factor2
offset = offset I 'factor2 + offset2
call daffgarsqref, -1, -I, #84,2, position)
read (7, rec = position + 4) units(un)
un=un+l
C*****Retrieving demultiplex and data type information needed to read
C ~erawdata*****f*t**ff****************ff*Xt***:***:S*****~*:***
call daf€-pars?<l5, -32765, channel, -1, -1, position)
ref = position
call daff-parse(ref, -1, -1, #AO, -1, position)
read (7, rec = ,psition + 4) blkoffs
call daff-parsetref, -I, -1, #Al, -1, position)
read (7, rec = position + 4) demux
call daffgarsc(ref, -1, -1, #A2, -1, position)
read (7, rec = kwsition + 4) data-type
raw data.**f*****Y*$*+****t**********f**$$$%%
Ct****Readin.. = .&,d converting
100 end-flag = 2
st = (data-adfiess + blkoffs + star-pt * demux) / 2 + 1
do i = 1, numgoints
read (7.rec = st + (demux/Z)*(i-I), end = 200) raw
if (dam-type .eq. 6) raw2 = raw + (1 - sign(1, raw))*32768
if (dam-type .eq.7) raw2 = raw
signal(i) = raw2*factor + offset
end do
200 continue
if (i .It. num-ints)
close (7)
return
end
end-flag = I
subroutine daffgarseiref, context-id. context-num, tagid,
tag-nurn, position)
C Routine to scan the DAFF file header and retum the location of a
C specific block of information.
+
........................................................................
integer ref, context-id, context-num. tagid, tacnum
integer id, num
integert4 size, position
C**** reference (ref) must be set on a iontext id .....................
position =ref
if (context-id .eq. -1) goto 100
read (7, rec =position) id
do while (id .ne. context-id)
call read-sizeiposition, size)
position = position + 8 + sizd2
read (7, rec =position) id
end do
if (context-num .eq. -1) soto 100
position =position + 8
read (7, rec =position) id, nurn
do while ((id .ne.context-id) .or. (num .ne. context-num))
call read_size(position, size)
position = position + 8 + sizef2
read (7, rec =position) id. nurn
end do
I00 if (tagid .eq. -1) goto 200
position =position + 8
read (7, rec =position) id, nurn
if ( t a ~ n u m
.eq. -1) nurn = tagnum
do while ((id .ne. tagid) .or. (num .ne. tagnum))
call read_size@osition, size)
position = position + 8 + sizef2
read (7, rec =position) id. nurn
if (tagnum .eq. -1) nurn = t a c n u m
end do
200 return
end
C
C
C
C
C
subroutine double-check-channelsiname, setupno, ctanels2)
Routine to check which channels exist by lwking as &e .DOC file.
This is a double check to the subroutine channelseek
[CHAN-SKFOR] which looks for .Di (i = channel rmber) files to
determine which channels are available. Refer to READSENI.FOR for
a description of the .DOC file strucrure.
.....................................................................
character*21 dummy
character*20 name, doc, doc-file, ur
character*l ch, asterisk
integer channels2(16), setupno, endchannel, sn, chamel-num. i
doc = '.doc'
asterisk = '*'
doc-file = cc(name, doc)
do i = 1, 16
channeld(i) = 0
end do
open(5, file = doc-file, form = 'formatted', status = '=known')
call read-some-lines(5.6 + 2*(setupno-I))
read(5, '(ilO)') endchannel
C ***Look for the asterisk which marks the beginning of a setup+****
10 continue
read(5, '(a)') ch
if (ch me. asterisk) go to 10
read(5, '(a21,i3Y) dummy, sn
if (setupno .ne. sn) go to 10
channel-num = 0
do while (channel-num .It. endchannel)
read(5, '(i10)') channel-num
channels2(channei-num) = 1
if (channel-num .It. endchannel) call read_some_lines(5, 9)
end do
close(5)
return
end
C***f*f********************************~=************~*****~=***********
subroutine double-check-setups(name, setups3
Routine to check the .DOC files to determine which setups are
available. This acts as a double check to the subroutine
C sehlp-info [SETU?S.FORI which does the s m e job by finding out
C which .STi (i = setup character) files exist. Refer to file
C READSEN1.FOR for a summary of the .DOC file suuchire.
C
C
C*f****f****************************************************************
character*Z 1 dummy
character'20 name, doc, doc-file, cc
character*l ch, asterisk
integer setups2(32), so, num-setups, i
doc = '.docq
asterisk = '*'
doc-file = cc(name, doc)
doi=1,32
setupsZ(i) = 0
end do
open(4, file = doc-tile, form = 'formatted', status = 'unknown')
call read-some_lines(4,2)
read(4, '(i 10)') num-setups
C ****Look for the asterisk which marks the beginning of a setup****
do i = 1, num-setups
10
continue
read(4. '(a)') ch
if (ch .ne. asterisk) go to 10
read(4, ' ( d l , i3)') dummy, sn
setupsZ(sn) = 1
end do
close(4)
retum
end
C
C
C
C
C
-
100
DIGFILTMFOR
27-MY-9!
SUBROCTINE TO DETERbIINE THE COEFF'ICIENTS FOR .A TANGENT
WLEMENTATION OF A BUTIERWORTH FILTER Wfl?I ;\NEVEN
NUMBER OF POLES
Modified by M.R. Hofrneister on May 27, 1991
real*4 bw, sfreq. bO, bl, b2, time, bzero, al(l2), a2(12)
realf4 Oc, fc
integer inum, m. Ih, mm
CHARACTER*S HLPASS
GOT0 (100,20O).INUM
LH=1
BO=1.
B1=2.
B2=1
GOT0 250
C
C ":**********HIGHPASS B U T m W O R T H FILTERS*****I*****-****+****I:******f
*
C
200
LH=O
BO=1.
B1=2.
B2=1.
GOT0 250
C
C ************GENERATE COEFFICIENTS FOR HI- AND LOPASS TANGENT FILTERS**
C
TIME=IJSFREQ
250
IF(LH.EQ.0) BW=SFREQn.-BW
CALL LPTB(M,TIMEBWAI,A2,BZERO,LH)
F'C=O.O
FCS.0
C
C ***********fm
COEFFICIENTS TO DISKFILE*********+-*+*******f******
C
MM=MI;!
OPEN(O,FILE=HLPASS)
WRITE(0,S) MX,B~O,BO,Bl,B2,Al.A2,BW,SFREQ,F3C.FC
5
FORMAT(I3.32E16.8)
CLOSE(0)
RETURN
END
f
SDECLARE
S~omuNcA-IE
SSTORAGE:2
subroutine FILTER(x,npoint,m,n,coefacwtb.xi~t.yinit,y)
C This is a generic filter program (in time domain) u hizh implements
C the following filter,
5
C
y(i) = sum(k=O..M)b(k)*x(i-k)] - sum(k=l ..X[qk)*y(i-k)]
n
C.
C
bO+ bl*zA(-1)+ b2*zA(-2)+ ... c bhl*zA(JI)
C or H(z) =
C
I + al*zA(-I)+ a2*zA(-2) + ... + aV*zA(-X?
C
C When N=O, this is a FIR filter,
C
N>O, this is a W filter.
L
C Written by W. Guan, Structures, IRC/NRC. March 19. 1993.
C
C input: ~(npoint) input signal
C
npoint
number of data points
C
m
constant M, highest order of HizYs numerator
C
n
constant N, highest order of H(z1.s denominator
C
coefa(N+l) coeffients array a, aO, al. .... a\.
C
(a0 is stored in coefa(l), a0=1)
C
coefb(M+l) coeffients array b, b0, bl. .... bll.
C
xinit(M) last N points of input data of last = p e n t .
5
yinit(N) previous output results saved by last call of
C
this subroutine. yinit(n) is the lasrest point.
C output: y(npoint) output signal. In order to save memory space,
C
this output signal can be stored in the same
C
array as input ~(npoint)without causing my
C
confilction. This is achieved by v i n g a same
C
anay name in actual argument to both x and y.
C
In this case, the input data in arm>-x is
C
overwritten by the output data after this
C
subroutine is invoked.
C
y i n i t o saved last N data points of ourput y for the
C
calculation of next segment.
C common block: humanring1for calling s u b r o u ~ ringbuffer.
e
Uesd
C
by subroutine FILTER and RIXGBLTFER only.
C Note: this filter is implemented by using a ring buffer as a storage
C for input and output data points at previous sampling times. The
C arrays xinitw) and yinitw are only for filtering a long signal by
C cutting it into several segments. This subroutine u-ill take the
C initial input and output values from arrays xinit(l\f) and yi~t(N),
C even when the signal has only one segment. So. the arrays xinitw)
C and yinit(N) must be all zero when the the input signal is the fmt
C or the only segment. Before leaving this subroutine. the last M data
C points of input x, and the last N data points of output y, are saved
C in xinit(M) and yinit(N) respectively for initialing the calculation
C of next segment.
C***********i*****'~***********i*******************=~-********
C
real*4 xit).y(*)
realf4 coefa(*).coefi(*).xi~lit(* ),yinit(*)
integer'? m,n,nringsize
parameter (nringsize=128)
realel sbuffer(nringsize).ybuffer(aringsize)
integef2 i, j,n v p ' x , nrpux, nwptry, Nptry
real'4 result, xdelayed, ydelayed
integer*4 npoint. dataloop
common ~umanring/xbuffer,yb~ffer,nwptn:,nrptn:,nwp
C ****** initialize ring buffers xbufand ybuf.
call rin$uffer('xbuff, ' init', 0.0.0)
call ringbuffer('>-buff, ' init', 0,O.O)
C ****** put initial data into ring buffers, for save & add method.
do 40 i=l,m
call rinbuffer('xbuff, 'write', 0, xinit(i))
4 0 continue
d o 4 1 i=l,n
call ringbuffer('ybuff. 'write', 0, yinit(i)f
41 continue
C ****** save last M pts of x in array xinitfM).
do 50 i=l,m
xinit(i1 = x(i+npoint-m)
50 continue
C ****** main calculation of the filtering in time domain
do 10 &taloop=l,npoint
result = 0.0
call ringbuffer('xbuff, 'write', 0, datalo loop))
do 20 j d , m
call ringbufferf'xbuff, ' read', (-j), xdelayed)
result =result + coefb(j+l)*xdelayed
20 continue
do 30 j=l,n
call ringbuffer('ybuff, ' read'. (-j+l), ydelayed)
result =result - coefa(j+l)*ydelayed
3 0 continue
call ringbuffefybuff, 'write', 0, result)
y(data1oop) =result
10 continue
C ****** save last N pts of y in array y i n i t o
do 60 i=l,n
yinit(i) = y(i+npoint-n)
6 0 continue
return
end
C
C
C ....................................................................
subroutine R l h T G B ~ ~ u f . d o w h a t j d x , v a l u )
C This is a ring buffer subroutine.
C
C Written by W. Guan, Structures. I R W C , March 19, 1993.
C.
CL********t****f*********Y*~*t******************************==*******
C
integer*2 nwpm.nrptrx,n~~puy,nrptry,idx.Mngsize
character'5 buf, dowhat
parameter (nringsize=128)
real*-l xbuffefinringsize), !buffer(nringsize)
reaI'4 valu
integer'2 i
common /humanrin~xbuffer,ybuffer,nwptrx,nrp~,nwptry,nrptry
10
12
if (dowhat.eq.' init') then
if (buf.eq.'xbuff) then
do 10 i=l,nringsize
xbuffer(i)=O.O
n~ptrx=l
continue
else if (buf.eq.'ybuff) then
do 12 i=l,nringsize
ybuffer(i)=O.O
nuptxy=l
continue
esdif
else if (dowhat.eq.'write') then
if (buf.eq.'xbuff) then
xbuffer(nwpm)=valu
nuptrx = n w p m + 1
if (nwptrx.gt.nringsize) nwptrx=l
else if @uf.eq.'ybuff) then
ybuffer(nwptry)=valu
nwptry = nwpny + 1
if (nwptq.gt.nringsize) nwptry=l
endif
else if (dowhat.eq.' read') then
if (buf.eq.'xbuff) then
nrptrx = nwptrx -1 + idx
if (nrptrx.gt.nringsize) nrptrx = nrptrx - nringsize
if (nrptrx.lt.1) nrpm = nrptrx + nringsize
valu = xbuffer(nrptrx)
else if (buf.eq.'ybuff) then
nrpuy = nwptry -1 + idx
if (nrptry.gt.nringsize) nrptry = nrptry - Mngsize
if (nrptry.lt.1) nrpuy = nrptry + nringsize
valu = ybuffeflnrptry)
endif
endif
return
end
C***************t*********f******************************~~****-**~******
subroutine filter-infogl( name, samplingfreq, top-freq,
+
num-octaves, stand-freqs, default-mode,
+
data-format, files, seLfiles. ma-flag
C*************************************f*****************==**************
C Routine to acquire the upper and lower frequency limits along wir;.
C the sampling frequency (for MTAS format only), which are then
C used to calculate the filter coefficients. The coefficients are
C computed and written to disk by a call to di~filtm.
C Tbis subroutine services both MTAS and Global Lab data forma.
C Upon modification to do so. the name was changed from filter-inia
C (FILTLNF0.FOR) to filter-info21 on December 10, 1991.
C**f****************************************************~X**************
c 93/02/03 JPM added HEM file support and requisite sampting frequency
c
and nurn points questions.
C*******************************************************=*****~**~~*****
c 93/06/25 WG ana-flag is added to avoid askng user to input upper
c
and lower frequency limits which are not necessary when
c
only overall value (anaaflag=7) is required.
........................................................................
implicit none
real*4 samplin~freq,stand_freqs(22), bandLedges(0:6)
real*4 top, bot, fu, fl, get-real
characterf20 files(*), se~tiles(*)
characteri20 name, blank
characterf8 coeff-files(0:6)
integer num-octaves, k, i, valid, last, hilo. num-poles, top-freq
integer default-mde, datxformat
integer ana-flag
parameter (fu = 1.12246, fl = 0.89090, numqoles = 12)
C*****Number of poles has been set to 12, this can be changed*****'****
+
+
data (coeff-files@), k = 0,6Y5000H.DA', '~OOOL.DA',
'4000KDA', '4000L.DA', '3ljOH.DA', '3150L.DA',
'2500H.DA'l
blank = ' '
C
Read sampling kequency from .DOC fde for MTAS format only.
C******f*************************************************~**************
if (data-fotmat .eq. I) call get-sfreq(name, samplingfreq)
C Get sampling frequency and number of points for HEM files.
........................................................................
if ( data-format .eq. 3 .or. data-format .eq. 4
1
+
call get-sfreq-HEW samplinefreq )
c
c
c
c
c
c
For calculating overall value ONLY. The variable 'num-cxtaves'
is assigned a value 1 which will be used in subroutine
processingparms to calculate the num-points. This subroutine
exits here to avoid asking user to input the upper and lo\vsr
frequency limits which are not necessary for calculating the
overall value.
if(ana-flag.eq.2) then
num-octaves = 1
return
end if
C***************************************************=*****===*~-~*******
C***************************************************-*******=***********
C
C
C
C
Ask user for upper and lower frequency limits and use these to
calculate the number of octaves to process as well as the 7 bandedge frequencies needed for the calculation of the filter coeffients.
C**********************************************~*************************
call newqage(defau1t-mcde)
print*, 'Specify filtering information and processing parameters.
print*
valid = 0
do while (valid .eq. 0)
print*
print*, 'Centre frequency of HIGHEST 1;3dcta\e (no ~ s a t e i
11' than 250 Hz)'
top = get-real(blank, 250.0,4.0,250.0)
if ( (fu*top) .gL (samplingfreql2) ) then.
print 10,'Upper limit frequency must k LESS TXLX OR EQ'
11
'UAL TO: ', sampling-freql2. ' Hz'
cycle
end if
print*
print*, '...LOWEST 113-octave (no kss than 2.5 Hz)'
bot = get-real(blank, 2.5, 2.5, 160.0)
if (bot .ge. top) then
print*, 'Poorenmes. Try again.
cycle
end if
doi=l,7
if (top/2.0f*i .It. bot) then
num-octaves = i
exit
end if
end do
last = 22 - num-octaves*3
do k = 1, last
if ( abs(top stand-freqs(k)) .le. 0.1 ) e.ut
end do
-
if (k .gt. last) then
print*, 'Usestandard frequencies spanning an integral '
/I
'number of octaves.'
cycle
end if
top-freq = k
valid = 1
end do
format (lX, a, f7.1, a)
10
dok=0,3
band-edges(2'k) = fu*standdfreqs(top_freq+k)
if (k .eq. 3) exit
band_edges(2*k+1) = fl*stand-freqs(top-freq+k)
end do
C Calculate filter coefficients and write them to disk
C************************************************************************
doi=O,6
hi-lo = mod(i,2) + 1
call d i g f i l t m ( h i l o , n u m _ p o l e s , b a n d _ e d g e s ( i ) , s ~ ,
+
cceff-files(i))
end do
C
skim out the file names to bs used for the segment data files.
C****************************f************************************%******
k=O
do i = top-freq, top-freq + num-octaves * 3
k=k+l
segfiles( k ) = files(i)
end do
return
end
C*************r**********L**+********************************************
C
C
C
C
subroutine filename-probe(filename, root, extension, data-format)
For Global Lab data files only.
Routine which splices the user given filename into its root and
extension. If rhe user does not give an extension. this subroutine attaches the default '.DAT.
C
c 93/02/05
c
E'M
added HEM filename parsing. .PLTis fed in as
extension in this case.
C
c OK, this will decide if there's an extension or not and grab
c the filename's root. If there's no extension, the appropriate
c one will be appended.
C
c 96/02/20
c
WG
added ASCII filename parsing. .TXT is fed in as
extension in this case.
.........................................................................
characterr20 filename, root extension, cc
character* 1 backslash, period
integer i, j, k, data-format
backslash = 1'
period = '.'
j = index( filename, backslash )
k = index( filename, period )
if ( data-format .eq. 2 ) then
extension = '.DAT
if ( k .eq. 0 ) rhen
root = filename
filename = cc(root, extension)
else
root = filename(1:k-1)
end if
end if
if ( dau-format .gt. 2 .and. data-format.le.6 ) then
if ( k .eq. 0 ) then
root = filename
filename = cc(roof extension)
else
root = filename(1:k-1)
end if
end if
return
end
C***********************************).*****************-*****************
subroutine set-sfreq(name, sampling-freq)
C***********************************=****%******************************
real*4 samplinz-freq
character*20 name, doc. cc. formatted, unknown, dm-file
integer durn
doc = '.doc'
formatted = 'formatted'
unknown = 'unknown'
doc-file = cc(name, doc)
open (19. file = doc-file, form = formatted status = unknown)
C*****Document files begin at line 3 , f * * * * * * * * f * * + * * ; ~ * x * * * * * * t f * * * * * % * * ~ ~ ~
call read-sorneJines(l9.2)
read (19. '(i10)') durn
read (19, '(f10.3)') samplingfreq
close (19)
return
end
C***********************~***********-**************************~********
subroutine get-channelssl(name, scmpno, channels, nchan,
+
default-male. chancels-picked, nchanqicked,
+
channels-direction. ma-flag,
+
data-fonn~t. f i l e n a ~ c )
Cz***'************************f****i=i**************~**********=~*******
C
C
C
C
C
C
C
Allows the user to select any number, in any combination, of the
channels available for the job. If no channels are chosen the
user is warned and given achance to repi~k.
This routine is compatible with both MT.%S and Global Lab data
formats.
The name was changed from get-channels (GET_CHNS.FOR)
after modifications to accomcdate Global Lab data format were made
on December 10, 1991.
C************************************f**********************************
c \VG 93/04/12
Added selection for I S 0 8041:1990 weighting,
c
whole body vibrations.
c
channels-direction(i) = 11, I S 0 horizontal
c
channels-direction~i)= 12, IS0 vertical
c W G 93/04/13
Added option for frequency weighting analysis.
c
New variables addcd: ana-flag (flag of the type
c
of analysis) and channels-diuection(l6).
c
ana-flag = 1, 113 wtave analysis
c
aria-flag = 2, overall value (freq. weighting)
c
ana-flag = 3, both
c
channels-directionti) = 2, vertical (z)
c
channels-directionii) =4, horizontal (x & y)
Cff**************f*t***ttf~****tf******f***********************~*=~******
implicit none
character*20 name, cc, setc, blank. filename
character*l setup-char
integer*2 get-int, nchanqicked, nchan, default-mcde
integef 2 channels(l6). channeIs_picked(l6), setupno, chno, i
integer*2 chan-disp(l6). j, half, data-format
integer*2 channels-direction(16), ana-flag
logical query
blank = ' '
call qsmode(default-mode)
d o i = l , 16
channels-picked(i) = 0
channels-direction(i1 = 0
end do
if (data-format .eq. 1) then
setc = setup-char(setupn0)
print '(1X.2 a)','Channels available for the job: ',cc(name,setc)
end if
+
if (data-format .g.1) print '(lX, 2 a)',
'Channels available in the file: ', filename
j= 1
do i = 1, 16
if ( data-format .gt. 2 ) channels(i) = l
if (channels(i) .eq. 1) then
chan-disp(j) = i
j=j+l
if (j .gt. nchan) exit
end if
end do
half = nchan12 + mod(nchan, 2)
do i = 1, nchanl2
print '(lX, I2,15X, I2Y, chan-disp(i), chan-disp(i +half)
end do
if ( mod(nchan, 2) .eq. 1 ) print '(lX, I2)', chan-disp(i)
print*
print*, 'Which channels? (hit [Enter] after each numberi'
print*, '[O] =finished, [-1] = all'
10
continue
chno = 1
nchan-picked = 0
do while (chno .ne. 0)
chno = get-intmlank, 0, -1, 16)
if (chno .eq. 0) exit
if (chno .eq. -1) then
doi=l,16
channels-picked(i) = channels(i)
end do
nchan-picked = nchan
exit
end if
if (channels-picked(chn0) .eq. 1) then
print*, 'That channel already picked. Enter again.'
cycle
end if
if (channels(chno) .eq. 1) then
channelsgicked(chno) = 1
nchangicked = nchangicked + 1
if (nchanqicked .eq. nchan) exit
else
print*, 'Channel not available. Enter again.'
end if
end do
if (nchan-picked .eq. 0 ) then
print*, 'No channels were chosed.'
print*, 'Repick? [ylquit]'
if (query@lank, 'y', default-mode)) goto 10
call the-md(default-mode)
end if
C ......................................................................
C Ask user to input channel direction information. This information is
C then used to select the weighting type of the human filter. The results
C are stored in array channels-weigtypeo and passed to the dummy
C argument iwtype (weighting type) of the subroutine humanfilter. Only
C weighting types B and D of BS 6841:1987, and weighting for whole body
C x or y, and z are available at persent. The following are the
C the final results of channels-direction() when leave this subroutine.
C
channels-direction(i) = 2, using weighting B, vertical.
C
channels-direction(i) = 4, using weighting D, horizontal.
C
channels-direction(i) =I 1, IS0 weighting, whole body, x or y.
C
channels-direction(i) =12, IS0 weighting, whole body, z.
C .......................................................................
if (ma-flag.eq.2.or.ana-flag.eq.3) then
c ask user to input channel diection information
20
continue
print *
print *, 'the following channels are picked'
j= 1
do i = 1, 16
chan-dispo) = 0
if (channelsqicked(i).ne.O) then
chan-disp(i) = i
j = j+l
end if
end do
half = n c h a n g i c k d 2 + mod(nchan-picked.2)
do i = 1, nchangickd2
print '(lX,I2,15X,I2)', chan-disp(i), chan-disp(i+half)
end do
if (mod(nchan-picked,2).eq.l)
+
print '(iX,I2,15X,IZ)', chan-disp(i)
print *
print *, 'input the direction of the picked channels'
print *, ' I. = vertical ( 2 ) BS 6841:1987'
print *, ' 2. = horizontal (x&y) BS 6841:1987'
print *, ' 3. =horizontal (x&y) IS0 8041:1990'
print *, ' 4. =vertical (z) IS0 8041:1990'
do i = 1. nchan-picked
print '(lX, 20Hdirection of channel,D)', chan-disp(i)
channels-direction(chan-disp(i)) =
+
get-int(b1ank. 1, 1.4)
end do
print *
print *, 'the picked channels and their directions are:'
do i = 1, nchangicked
print '(1X,7HChannel,U,lX,lOHdirection:,12)',
+
chan-disp(i), channels-duation(chan-disp(i))
end do
print *, 'Any corntion for the directions? Iym'
if (querymlank, 'n', default-mode)) goto 20
c convert channel direction i~onnationsinto weixhting type
do i = 1, 16
if (channels-direction(i).eq. I ) then
channels-direction(i)=Z
else if (chznnels-dimtion(i).eq.2) then
channels-diiection(i)=4
else if (channels-direction(i).eq.3) then
channels-direction(i)=l 1
else if (chmels-direction(i).eq.4) then
channels-direction(i)=12
end if
end do
end if
return
end
submutine get-btalfy, nurn-points, name, setupno, channel,
end-flag, stanqoint, sensitivity)
C
Originally called get-data from the MTAS librap file
GET_DAT.FOR. Upon modification (by MRHI for use in THRD.FOR
C
C
the filename was changed to GET-DAT1.FOR. The changes include
C
the omission of the parameter 'last' from the call list and the
C
addition of the variables setupno and channel.
R e s e were
C
needed to conswct the filename from which to read the data.
C
Other changes include the addition of the construction of this
C
filename as well as the way the variable end-flag was determined.
C
Changes were finalized on July 5.1991
.........................................................................
real sensitivity, y(*)
+
integer k, end-flas, setupno, channel
integer*4 i, j, zero; numgoints. il, start-point
character*20 inf, binary, unknown, blank, direct. cc4, name
character*20 setc. d, num, number-char
character*l setup-char
zero = 0
binary = 'binary'
unknown = 'unknown'
direct = 'direct'
blank = ' '
d = '.d
setc = setupPchar(setupno)
num = number-charfchannel)
inf = cc4(name, sew, 4 num)
j = start-point
end-flag = 0
+
open (29, file = inf,form = binary, st= unknown,
access =direct, r e d = 2)
do i = 1, nun-points
il=i+j
read (29. rec = i I, end = 20) k
y(i) = floar(k - 2048) * sensitivity
end do
20
continue
.if (i .It num-points) end-flag = 1
return
end
C****************************f****ttt************=~*********************
Subroutine get-name-gl(name, &5ult-mode, dam-format, filename,
root. c.r:ension, fust-flag )
Accomodates both MTAS and GIc?d Lab data f o r m .
prompts for a job name
If the header filelfilename doesn': ?xist, the user is waned,
and offered some options.
Originally called get-name from 2 tile GET-NAME..FOR found in
the MTAS library. The filename =-iichanged to GFT-N.4III.FOR for
use in the main module THlRD.FL7R and then later changed to
GET-NMGL for use with the Glc-d Lab accomodating version of
TOM.
Global Lab related modifications &>ne by Martin Hofmeister on
December 10, 1991.
Modified by JM for HEM data fiic format in 1993.
WG Added get filename for ASCII dxz format. 96/02/20.
+
C
C
C
C
C
C
C
C
C
C
C
C
C
C********************************tt**************~**********************
implicit none
character*20 cc. name, header-fiexame, hdr, blank. filename
character*20 root, extension. plt c:J-name, txt
logical ex, query
integer default-mode, d a t a - f o m first-flag
data hdrr.hdr'l
data blank/' 'I
plt = '.pit'
txt = '.txt8
1
+
continue
if (datxformat .eq. 1)
write(*, '(a, \)') ' Job n a r r [Q to quit]: '
+.
if (data-format .eq. 2) print*, 'En:-- filename. [Q to
11 '(.DAT will be the deflult extension)'
+
if ( data-format .gL 2 )
write(*, '(a, \)') ' Enter &a file name:
+
read (*, '(a20)' )name
if (name(1:l) .eq. 'Q' .or. name(1:l I .eq. 'q')
call the-end(def3lt-mode)
'
if (data-format .eq. 1) then
header-filename = cc(nme. hdr)
exist = ex)
inquire (file = header-fi!-ame,
root = name
end if
if (data-format .eq. 2) then
filename = name
call filenameqrobe (file-ae, root, extension, data-format)
inquire (file = filename, exist = ex)
end if
if (data-format .ge. 3 .and. data-format.lt6 ) then
filename = name
extension = plt
call filename-probe (filename, root, extension. data-format)
inquire (file = filename, exist = ex)
end if
if (data-format.eq.6) then
filename = name
extension = txt
call filename-probe (filename, root, extension. dam-fonnat)
inquire (file = filename, exist = ex)
end if
if (.not. ex) then
if (datxformat .eq. 1)
print '(IX,3 a)', 'The header file '.header-filename,
' does not exist in this directo~.'
if ( data-format .ge. 2 )
print '( 3 a )',' The filename ',filename; does not',
' exist in this directory.'
print *, lnput a new name [Y/n/quit]: '
if (query@lank,'yq,default-mcde)) go to i
call the-end(default-mcde)
return
end if
call lcuc(name, 20)
return
end
C*************+*****************************~=~*************************
subrouune get-setup(setups,setupno)
C Lists the different setups available for the job ard asks the user
C to choose one of them.
........................................................................
character*20 blank
character*l setup-char
integer setups(32), setupno, get-int, index
integer default, min, max, i, k
default = 1
min= 1
blank = ' '
print*
print*
print*
print*. '
Choice', ' Setup character'
k=O
d o i = 1.32
if (setups(i) .eq. 1) then
k=k+l
', semp-char(i)
print*, k, '
end if
end d o
max = k
print*. 'Using the above legend, enter the no. of the setup o f '
+
11 'yow choice.'
index = get-int(blank, default, min, max)
k =0
doi=1,32
if (setups(i) .eq. 1) then
k=k+l
if (k .eq. index) exit
end if
end do
setupno = i
return
end
subroutine read-daff-header(fi1enme. sampling-freq, rep)
C Routine to read the header of the user specified data file to
C check that it meets certain requirements needed for further
C processing. If these requirements are met, the routine thcn reads
C the sampling frequency from the DAFF header.
C***********************************************==**********************
character*20 filename
character*9 daff-signature
character*2 byte-order
integer rep, block, ref, context-id, t a ~ i dfile-type
,
integer context-nun samp-frq-exp
integee4 samp-freq-man, B3 1. position
real*4 sampling-freq
open (7, file = filename, form = 'binary', status = 'unknoun',
access = 'direct'. recl = 2 )
rep = 0
.+
read (7, rec = I ) daff-signature
if (d&signature .ne. 'SWGBSMBWS') then
print*, 'Given file is not a Global Lab DAFF file.
rep = 1
retum
end if
read (7) byte-order
if (byte-order .ne. ZIT) then
print*, 'Byte order of data file is not compatible with '
+
I1 'this program.'
rep= 1
return
end if
read (7, rec = 8) block
if ( abs( mod(hlock, 2) ) .ne. 1 ) then
printf, 'There is no data available in this file.'
rep = 1
return
end if
ref = 15
context-id = -32766
t a g i d = #80
call da£f~arse(ref,context-id -1, tag-id, -1, position)
read (7, rec =position + 1) file-type
if (file-type .ne. 0) then
print*, 'Ele must be a DAFF "Sapled Data Fils":
rep = 1
return
end if
ref= 15
sontext-id = -32763
s~~ntext-num
=0
rx~id
= #8A
cdl daff-parse(ref, context-id, context-num, tag-id. -1.position)
r=ad (7, rec =position + 4) sarnp-freq-man, sarnp-freq-sxp
umplingfreq = ( (samp-freq-rnanC?.O)/B31 ) * (2**sampPfrqPrxp)
close (7)
return
end
C****************li******************************=**************~%******
subroutine gec-sfreq-HEM( samplingfrequency )
C*************************************************Z*************~*******
reaIt4 sarnplin~frequency,get-real
rnl = "Frequency"
m3 = "At what frequency was the data sampled"
print*, "
print*, m3
samplingfrequency = get-real(m1, 200.0, 10.0,2000.0)
return
end
+
subroutine decode-HEM-bin( filename, data-formar nchan,
numqoints. hem-sum. samplingfreq. default-mode, units )
~**'************fi=******************************=********~*************
cJPM 93/02/02
added HEM file support, which means allowin,o for
c
a data-format = 3. Now, =\I
files have the option
c
of containing or not, time axis values, so I'm
c
going to allow subsequent subroutines to use a
c
data-format = 3 for no time values. and a data-fonnat
c
= -1 when time values are included.
c
This is called from subroutine process~l.
c JF'M 93/02/15 added data format = 5 for std bin files.
...........................................................................
implicit none
integer*2 i, j, data-format, nchan. num-words, my-length-counter
integer'2 default-mode
integer*4 numgoints, hem-sum. dummy
real*4 samplingfreq
character*20 formaued, bin, dir, filename
character*80 header(l6)
characteri20 word(20)
character* 13 cl
character* I0 npt
character*8 act
character*7 units(*)
characteP5 nch, outfile
character*l aa, a-char
bin = "binary"
dir = "direct"
formatted = "formatted
nch = " N C W
npt = "NUM.POINTS"
act = "ACT.FREQ"
cl = "CHANNEL.LABEL"
nchan = 0
num-points = 0
aa = char(l70)
hem-sum = 0
open(8, file = filename, form = bin )
c Read in the HEM default file type marker.
read(8) a-char
j = ichar( a-char )
c The hex possibilities are
c
10
no time channel, amplitude vs time data
c
M)
time channel present, amplitude vs time dara
if ( j .ne. 34 ) then
read(8) a-char
j = ichar( a-char )
if (j .eq. 0 ) data-format = data-format
end if
i
l
c The thing is, this might be a standard binary file. in which case
c the fmt character will be an ascii quote. ",which has a de2imaI
c value of 34. In that case, open the file as text and read in the
c fust 15 lines from which one can determine the number of channels
c and the number of data points per frame, among other things.
if ( j .eq. 34 ) then
data_fonnat = 5
close(8)
open(8, file =filename, fonn = formatted )
doi=1,15
read(8, '(a)' ) header(i)
j = my-lensh-counter( headerti$. 80 )
hem-sum = hem-sum + j
end do
close(8)
c Find the lines that contain the number of channels, the number of points,
c and the sampIing frrequency. I'm assuming the sampling frequency is disguised
c as an integer in floating point format.
d o i = l , 15
j = index( headefli), nch )
i f f j .gt. 0 ) then
call parse( headefli), ward, num-words )
call to-int( word(num-*-or&), 20, dummy )
nchan = int( dummy )
end if
j = index( header(& npt )
i f ( j .gt.O)then
call parse( header(i), word, nun-words )
call to-&( word(num-words), 20, num-points )
end if
j = index( header(i), act )
i f ( j .gt.O)then
call parse( header(i), word, nun-words )
call to-in%(word(num-words), 20, dummy )
samplingfreq = float( dummy )
end if
j = index( header(i), cl )
if ( j .gt. 0 ) then
call parse( header(i), word, num-words
end if
end do
if ( nchan * num-pints
* samplingfreq .eq. 0 ) then
call newja~e(defau1t-mode)
print*,"Error decoding data file: "
stop
end if
j=j+l
call to-units( u-ord(i). 20, units(j), 7 )
end do
c Find the data stan character.
o ~ n ( 8file
, =filename, form = bin, access = dir, recl = 1
do i = 1, 10000
read( 8, rec = hem-sum + i ) a-char
if ( a-char .eq. aa) then
hem-sum = hem-sum + i
exit
end if
end do
else
read@) nchan
do i = 1, nchan
unitsfi) = ' '
end do
end if
return
end
pro_-
read-std-bin
characterf5 files(l0)
integer i
doi=1,8.2
files(i) = char(48 + i)
cail HEM-standard-binary(
end d o
SOP
end
fdes(i), i )
)
c************Y**=x**********f**~=*********************Y*******Y%*******
subroutine HEM-standar&bkxy( outfile, cn )
C***************ri**:******+iff********=-~*********%**********
character*ZO infile
character*20 formatted. bin. 2:
character'80 beader(75)
characteP2O word(20)
characterL5 nch, outfile
character* 10 npt
character*I aa, a-char
integer*2 i, j. ch, num-channs3, num-words, cn
integerY numpoints, dumm?. sum, frameelen,@.
integerr4 data-start-point, rn. h-
start-point
infile = '3stdbin.smc"
bin = "binary"
dir = "direct"
formatted = -formatted
nch = "Nf2W.N"
npt = "NUM.POINTS"
open( 14, ffle = infile )
doi=l,15
read(l4, '(a)', err = 1' ) hea&r(i)
sum = sum + len( he&er(i) )
end do
10
continue
close(l4)
c Find the line that contains the number of channels, and the number of points.
num-channels = 0
num-points = 0
doi=1,23
j =index( header(& r i b )
if(j.gt.O)theu
call parse( h&er(i), word, num-u-ords )
call to-int( u~rd(num-words), 20. dummy )
num-channslj = int( dummy )
end if
j =index( header(i);~t )
if ( j .gt. 0 ) then
call parse( hader(i), word, num-words )
call to-int( word(num-words). 10, numqoints )
end if
end do
closet 14)
print*. ' k h a n : ",num-channels, " npts: ", nu,-points
frame-length = numgoints * num-channels
c now find the beginning of the data
open( 14, file = infile, form =bin, access = dir, reil = l
1
d o i = 1,1OOOO
read( 14, rec =sum + i ) a-char
if ( a-char .eq. aa ) then
printc, "Found the data at byte: ', i + sum
exit
end if
end do
close( 14)
c open an output file
open(l5, file = outfile )
c Having found the beginning of the data, let's read it. So look, the
c character that indicates the beginning of a data frame is 1 byte
c long. That meant I could open the file with a longer recl. and
c scan for a sinzle character, or open it with r e d = 1, and rzad
c in 4 bytes at a time. I've chosen to do the latter, which means
c I've got to keep uack of the number of bytes upto and iniludeing
c the start of the data, as well as the number I've read in. That
c requires using the factor of 4 as a multiplier.
open( 14, file = infile, form = bin, access = du,r e d = l
1
data-start-point = i + l +sum
dok=O,48
rn = data-start-int
+ ( cn - l + k * nunchannels ) * 4
read(l4, rec = rn) x
write(l5, *) x
end do
return
end
c
C
C
THIS S U B R O L ~ N E
IMPLEMENTS A DIGITAL F I L WITH
~ UP TO
12 POLES : 3 SONRECURSIVE AND 2 RECURSIVE TERMS ARE ALLOWED
integer*4 ~ 1 . ~nl,
2 ,i
real*4 Y(*). a1(6), a2(6), y0(7), y1(7), y2(7), yout(*), bzero
realf4 yit >i
integer mm. iseg, k, kt
IF OSEG-EQ.1) THEN
DO 10 K=1.7
Y2(K)=0.0
Y I (K)=0.0
YO(K)=0.0
10
CONTEvLiE
ELSE
READ(99) YO. Y 1, Y2
ENDIF
DO 30 I=1-NL
YO(l)=Y(I+pl)
DO 20 K= 1.MM
KI=K+I
YlT=Yo(Kb2.0iY1(K)+Y2(K)
YI=YlT-Al(K)*YO(KI)-A2(K)*Yl(Kl)
IF(ABS(yf).LT.l.OE-37) YI=O.O
Y2(KI)=Y 1 6 1 )
Y l(Kl)=YO(Kl)
20
yosi)=n
Y2(1)=Yl(l)
Yl(l)=YO(l)
30
Yout(I+p2kYI*BZERO
IF OSEG.NE.1) BACKSPACE (99)
WRITE(99) YO, Y1, Y2
.
RETURN
END
C ********************************************x***********************
subroutine ~COEF(iwtyps.fsample,ibpfw,coefa,coetb,rn,n)
C Generate the coefficients for the band-limiting or frequency-weighting
C filters specified by British Standard 6841: 1987, Guide to Measurement
C and Evaluation of Human Exposure to Whole-Body Mechanical Vibrarion
C and Repeated Shock.
C
C Modified on April 11,1994. Filters for IS0 8041:1990 are added.
C
C Written by W. Gum, Structures, I R W C . March 19,1993.
C
C input: iwtype
weighting type
C
iwtype = 2, Wb
C
iwtype = 4. Wd
C
iwtype = 11, IS0 x and y directions (Table 5)
iwtype = 12, I S 0 z direction (Table 6)
C
C
fsample sampling frequency (Hz)
C
ibpfw
bandpass or frequency-weighting
C
bpfw = 1, bandpass filter
C
bpfw = 2, frequency-weighting
C output: coefa(5) coefficients of denominator terms
C
coefb(5) coefficients of nomerator tenns
C
n
highest order of denominator terms (a)
C
m
highest order of numerator terms @)
C
C********************************************************************
C
integeF2 iwtype, ibpfw, n, m
real*4 coefa(5), coefb(5)
realf4 fsample
realf8 PI
parameter (pI=3.1415926)
realf8 ul,u2,u3,u4,u5,u6,u7,u8,u9,ulO,ull,u12,a0
real*8 vl,v2,v3,ve91,ve13,ve182,ve26
realf8 wl,w2,w3,w4,w5,u5,w6,w7.~8,w9,w10,wll,w12,w13,w14,al5.wl6
realf8 w1413,~76,~21,~22,w23,~24
real*8 gainodb, ag, gain8Hz. gain8HzDigi
C
if (ibpfw.eq.1) then
C
.....................................................................
C Generate Coefficients for Band-Limiting Filter
C****************'************f**************************************
C
if (iwtype.eq.Z.or.iwty~e.eq.4)then
C
c ******for weighting wb, wc, wd, we.
C
+
+
+
+
+
+
+
+
+
+
+
+
+
vl = tan(lC€I*PYfsample)
u1 = tan(100'PYfsample)
u2 = tan(0.4*PYfsample)
+
a0 = 0.4946781854*(~2*~1)
0.3512215116*(~1+u2 + u2*ulful + u2*u:'ul)
+
0.2493672732*(~2*~2
+ ulrul + u2*~3*ul*ul+1)
coefb(1)= 0.2493672732 'v l * v I 130
coefb(2) = 0.0
coefb(3) = -0.4987345464 * vl * vl l a0
coefb(4) = 0.0
coefb(5) = 0.2493672732 * vl * vl / 30
coefa(1) = 1.0
coefa(2) = (0.001e-7*(~2+~2)
- 0.002e-7*(ul*ul) +
0.9974690931*(~2*~2*ul*ul- 1) +
0.7024430232*.(u2*u1*u1- u7 ul +
uZfu2*ul) ) / a0
coefa(3) = ( -0.4987345464*(~2*~2
+ u 1*ul) +
1.496203640+(~2*~2*~1*ul
+1) 0.9893563708*(~2*~1
J ) / a0
- 0.002e-7*(ul*u: ) +
coefa(4) = ( 0.001e-7*(~2*~2)
0.9974690931*(u2*u2*u1*u1 - 1) 0.7024430232*(u2*u1*u1- u7 u l +
u2*u2*ul) ) / a0
coefa(5) = ( 0.4946781854*(~2*~1)
0.3512215116*(~1+~2
+ u2*ul*ul + ul'u2*ul) +
0.2493672732*(~2*~2
+ ul*ul +
u2*u2*ul*ul+l) ) / a0
else if (iwtype.eq. 11.or.iwtype.eq.l?) then
-
-
C
c ****** for I S 0 weighting, whole body x and y diiectiori. and z directions.
C
+
+
+
+
+
+
+
n=4
m =4
vl = tan(lOO.O*PUfsarnple)
ul = tan(2.49536704474637/fsample)
u2 = tan(100.O*PUfsample)
a0 = 0.983305794766386*(~2*~2
+ u l * u l f d * u 2 + ul*ul + 1)+
1.390604390918679*(u1*ul*u2 + ul'uZ*u2 + ul + u2) +
1.966611589532773*(ul*u2)
coefb(1) = 0.983305794766386 * vl * vl l a0
coefb(2) = 0.0
~ 0 e M 3=-1.966611589532773
)
* v l * vl l a g
~oefb(4)= 0.0
coefb(5) = 0.983305794766386 * vl * v l l a43
coefa(1) = 1.0
coefa(2) = ( 2.781208781837358-(u l+u2)*(- l+ul *u2) +
.
3.933223179065546*(-1+(~1~~2)*(ul*u2))
) / a0
coefa(3) = ( -1.96661 1589532773*(111*u2 + 31*ul) +
5.899834768598319*(~2*~2*~1*~1
+1) 3.933223179065546*(u2*ul) : / a0
coefa(4) = ( 2.781208781837358*(~1
+u2)*( i-ul *u2) +
3.933223179065546*(- l+(u 1*u2)*(ul *u2)) ) 1 a0
coefa(5) = ( 1.96661158953277*ul*u2 +
0.983305794766386'
+
+
+
(I +u2*u2+u1*u1*u2*u2 + ul*ul) 1.390604390918679*
(ul*ul*u2 + ul*u2*u2 + ul + u2) ) / a0
else
write(*.'(a)') ' not available yet'
end if
else if (ibpfw.eq.2) then
C
......................................................................
C Generate Coefficients for Frequency-Weighting Filter
Ct****************************++******************************
C
if (iwtype.eq.2) then
C
c ****** for weighting wb
C
n=4
m=3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
ull = sin(41.88W7775/fsaq~le)
1112= sinh(91.39178632fsample)
coefb(1) = 102.9437082
coefb(2) = -15.79902519*u3*u4+ 15.79902519*~3*~2
213.3792149*~5*~-:
- 22.38043313*ull*u1295.45190967*uS*u-i 22.38043313*ull*u7+
44.76086626*ull*c12*u5*u2110.4355067*~6- 31.59805039*~3*~4*~8*~12
+
7.491798513*~1
- J-1.76086626*ull*u7W*u4+
31.59805039*3*u4*u8*u7 + 110.4355067*~9
31.59805039*~3*u3*~8*~7
205.8874164*u8*u17*u5'fu4-u2) +
44.76086626*u11*u7*u5*u2-7.491798513*ul0+
31.59805039*u3*u:*u8*u12+
205.8874164*~8*~7*
u5*(u4-u2)
coefb(4) = 7.491798513*u5'~4*(~10-u 1) +
110.4355067*~8*~12*(~9-~6)
22.38043313*u11*u12*(u9-u6)+
22.38043313*~11*~7*
(u9-u6)7.491798513*u5*u3*(u10-u1)15.79902519*~3*~i'(~lO-~l)
+
15.79902519*u3*uIf(u10-ul)110.4355067*~8*~7*
(u9-u6)
coefb(1) = coefb(1)1gainWc
coem(;?)= coefb(2) I gaiS
coefb(3) = coefb(3) I gain@&
coefb(4) = coefb(4)IgainW
else if (iwtype.eq.4)then
C
c ****** for weighting wd
C
n=2
m=2
vl = exp(-9.97331001 llfsample)
v2 = cos(7.64504793O/fsample)
v3 = sin(7.645047930lfsample)
u 1 = exp(- l9.94662002ffsample)
a0 = 1.0
wl = sin(8.71053 1638lfsarnple)
w2 = cos(8.7105316381fsamp1e)
w3 = cos(7.6450479;Olfsample)
w4 = exp(-9.97331001 llfsample)
w5 = -2.O*wl*w4+3 + 2.0ew2*wl
w6 = -2.0fw2*w4*w3 + w2*w2 - l.O*wlfwl
exp(-19.9466200Ufsampte)
w7 = sin(7.645047930lfsample)
w8 = w6*w6 + w5*w5
+
w9 = 20.0*(-0.6283 18531*w4*w3+ 0.628318531tw2
+
0.213114168*~7*~4)
gain0db = sqrt( (w9*(u.2*w6+wl*w5)lw8 12.56637062*wlf(-w2*~5+wi*w6)1~8)**2
+
( w 9 * ( - ~ 2 * ~ 5 + w l * w 6 )+/ ~ 8
12.56637062*~1
*(w2*w6+w1*w5)lw8)**2 )
ag = a0 * gain0db
coefb(1) = 12.56637062 1ag
coefb(2) = (-12.56637062*~1*~2
+ 4.262283360tv3*v1) l a g
coefb(3) = 0.0 1ag
coefa(l)= 1.01a0
coefa(2) = -2.O*vl*v2 1a0
coefa(3) = ul 1a0
else if (iwtypeeq. 11) then
'* for IS0 weighting, whole body, x and y directions (table 5)
coefb(2) = ag * (-12.5*exp(-9.765625lfsample)*
cos(7.80272826384304lfsample)+
4.38047902531539*exp(-9.765625lfsample)*
sin(7.80272826384301/fsample))
coefh(3) = ag * 0.0
coefql) = 1.0Ia0
coefa(2) = -2.0 * exp(-9.765625/fsample)*
cos(7.802728263843Wfsample)1 a0
coefq3) = exp(-19.53125lfsample) I a0
+
+
+
+
C
else if (iwtype.eq.12) then
C
c ****** for I S 0 weighting, whole body, z direction (table 6)
C
+
+
+
+
+
+
+
+
+
+
+
n=2
m =2
aO= 1.0
w 1 = 19.9073408949275lfsample
w2 = e x p ( - 2 4 . ~ 1 f s a m p l e )
w3 = 12.6623089493013lfsample
w4 = -7.0*sin(wl)*w2*cos(w3) + 2.0*cos(wl)*sin(wl)
w5 = -10*c0s(w1)*w2*c0s(w3) + 2.0*cos(wl)*cos(wl) - 1.0
+ exp(48.8888888888889If~ample)
w6 = -L~O.O*W~*COS(W~)
+ 250.0*cos(wl)
- 166.698714867456*sin(w3)*~2
gain8HzDigi = 0.2 " sqrt(
( (cos(wl)*w6 - 250.O*sin(wl)*sin(wl))*w5 +
( sin(wl)*w6 + 250.0*cos(wl)*sin(wl))*w4 )**2 +
( (sin(wl)*w6 + 250.0*cos(wl)*sin(wl))*w5 ( cos(wl)*w6 - 250.O*sin(wl)*sin(wl))*w4 )'*2 )
gain8HzDigi = gain8HzDigi I (wS'a5 + w4*W4)
gain8Hz = 0.905633362802681
ag = igain8Hz I gain8HzDigi) I a0
coefb(1) = ag * 50.0
coefbt2) = ag * (-33.3397429734913*
exp(-24.~1fsarnple)'
sin(22.6623089493013lfsample) 50.0 * exp(-24.4444414444444/fsample)*
cos(22.6623089493013lfsample) )
coeW3) = ag * 0.0
coefa(1) = 1.0 I a0
coefa(2) = -2.0 * exp(-24.-Ifsample)*
cos(22.6623089493013lfsample)1 a0
coefai3) = exp([email protected]/fsample) 1a0
C
else
=rite(*,'(a!')
ecd if
ead if
retuii
end
' wrong code of weighting type'
SDECLARE
SNOTRLJNCATE
STORAGE::!
subroutine HUMANRLTER(anpintiwtype,fs&npIe.iseg,aout)
C Apply the band-limiting and frequency-weighting filtm specified
C by British Standard 6841:1987. Guide to Measurement and Evaluation
C of Human Exposure to %%ole-Body Mechanical Vibrarion and Repeated
C Shock.
L
C Modified on April 12, 1994. Weighting filters of IS0 8041:1990
C for whole body vibrations, x and y directions, and z diectio
C are added.
C
C Written by W. Guan, Structures. IRWNRC. March 18,1993.
C
C input: a(npoint) raw time simal
C
npoint
number of data p i n t s
C
iwtype
type of frequency-u-righting
C
iwtype = 2: Wb
C
iwtype=-l: Wd
C
iwtype = 11: whole body x & y, IS0
C
iwtype = 12: whole body r IS0
C
fsample sampling frequency of the raw time signal
C
iseg
flag of number of segment
C
iseg = 1, first se-ment
C output: aout(npoint) filtered time si-aal
C***************************************************************=****
C
real*4 a(*),aout(*)
real*4 fsample
integer'2 iwtype,npoint
integer*2 i
integeF2 mbpb,nbpb,mfwb,nfwb
1&*4 coetbpba(5),coefbpbb(5),coeffwba(5),coeffw~5)
real*4 savebpbx(5),savebpbv(j),savefwbx(5),sa\.(S)
integeF2 mbpdpbpdmfwdnfwd
real*4 coefbpda(5),coe~pdb(5),coeffw&(5),coe~db(5)
real*4 savebpdx(5)gavebpdS-(5),savefwdx(5)~~-e~dy(5)
C
C ****** WeightingWb ****+*
C
if (iwtype.eq.2) then
if (iseg.eq.1) then
C ****** Generate Coefficients for Band-limiting Filter
call humanmf(iuqpe,fsample, l,coefbpbacoefbpbb,
+
mbpbnbpb)
C ****** Generate Coefficients for Frequency-Weighting Filter
call humancoef(iwtype,fsample,2,coeffWbacoeRwbb,
+
mhvb,nfwb)
C ****** Clean Initial Data Arrays
do 10 k1.5
savebpbx(i1= 0.0
savebpby(i) = 0.0
savefwbx(ij = 0.0
savefwby(i) = 0.0
10
continue
end if
C * ***** Pass Signal through Band-limiting Filter
call filter(a(1). npoint, mbpb, nbpb, coefbpba, c.w%pbb,
+
savebpbxfl), savebpby(1). aout)
C ****** Pass Signal through Frequency-Weighting Firer
call filter(aout, npoinS mfwb, nfwb, coeffwba c-wffwbb,
+
savefwbx(l), savefwby(1). aout)
C
C **f *** Weighting Wd ***+**
C
else if (iwtype.eq.4) then
if (iseg.eq.1) then
C ****** Generate Coefficients for Band-limiting Fii'ii--r
call humancwf(iwfype,fsampte.I,coefi~car:bpdh,
+
mbpd,nbpd)
C ****** Generate Coefficients for Frequency-Weighxg Filter
call humancwf(iwtype.fsample.2,coeffwdac~rl~db,
+
mfwd,nfwd)
C
****** Clean Initial Data Arrays
d o 20 i=1,5
savebpdx(i) = 0.0
savebpdyfi) = 0.0
savefwdx(i) = 0.0
savefwdy(i) = 0.0
20
continue
end if
C ****** Pass Signal through Band-limiting Filter
call filter(a(l), npoint, mbpd, nbpd, coefbpda, ccrfbpdb,
+
savebpdx(l), savebpdy(l), aout)
C ****** Pass Signal through Frequency-WeightingFJter
call filter(aout, npoint, mfwd, ofw4 coeffwda, mffwdb,
i
savefwdx(l), savefwdy(l), aout)
C
*****+
C ****** IS0 Weighting for whole body, x or y direcdan
C
else if (iwtype.eq.11) then
if (iseg.eq.1) then
C ****** Generate Coefficients for Band-liiting F i n
call humancoef(i~fsample.I,coefbpboc~5pbb,
i
mbpb,nbpb)
C ****** Generate Coefficientsfor Frequency-Weigh-2g Filter
call humancoef(i~,fsample.2.~ffwba,c~%bb,
+
mfwb,nfwb)
C ****** Clean Initial Data Arrays
do 110 i=1,5
savebpbx(i) = 0.0
savebpby(i) = 0.0
savefwbx(i) = 0.0
savefwby(i) = 0.0
110
continue
end if
C ****** Pass Signal through Band-limiting Filter
call filter(a(1). npoint, mbpb, nbpb, coefbpba, cwfbpbb,
+
savebpbx(l), savebpby(1). aout)
C "* ** * Pass Signal through Frequency-Weighting Filter
call filter(aout, npoint, mfwb. nfwb, coeffwba, coeffwbb.
+
savefwbx(l), savefwby(l), aout)
C
C ****** I S 0 Weighting for whole body, z d i c t i o ******
~
C
else if (iwtype.eq.12) then
if (iseg.eq.1) then
C ****** Generate Coefficients for Band-limiting Filter
call humancoef(i~ype.fsample,l,coefbpbocoefbpbb,
+
mbpbabpb)
C ****** Generate Coefficients for Frequency-Weighting Filter
call humaocoef(iwtype,fsample,2,coeffwba,cwffWbb,
+
mfwb,nfwb)
C ****** Clean Initial Data Arrays
do 120 i=1,5
savebpbx(i) = 0.0
savebpby(i) = 0.0
savefwbx(i) = 0.0
savefwby(i) = 0.0
120
continue
end if
C ****** Pass Signal through Band-limiting Filter
call filtec(a(l), npoint, mbpb, nbpb, coefbpba, coefbpbb,
+
savebpbx(l), savebpby(l), aout)
C ****** Pass Signal through Frequency-Weighting Filter
call filter(aout, npoint, mfwb, nfwb, coeffwba, coeffwbb,
+
savefwbx(l), savefwby(l), aout)
else
write (*,'(a)') ' not available yet, "humanfil"'
end if
C
return
end
subroutine hum-out(channe1.
seg-no, name, setupno. root,
data-format, npoint, weighted-signal)
C****ii*****************************~*******************~~***~*~~~******
C Routine to write frequency weighted time signal to the disk tile:
C
<namexsetupihars.Fxx W A S format),
C
or
<filename rooo.Fsx (Global Lab format)
C in ASCII format.
C WG Added on March 12, 1996.
+
C*****************i****t************************************~~*~********
implicit none
integeP2 channel, seeno. setupno, data-format, npoint
rea1*4 weighted-signal(*)
charactert80 title
character'20 name, setc, file-ext, cc3, cc, comma-file. root
character*l setup-char
integerf2 location-flag
integer*2 i
+
+
title =
"'Weighted Signal Output For Job (Using V6.0 dated 96-03-15): '
I/ name
location-flag = 0
setc = setup-char(setupno)
if (channel.eq. I) file-ext = '.F0lS
if (channel.eq.2) file-ext = '.FOX
if (channel.eq.3) file-ext = '.F03'
if (channel.eq.4) file-ext = '.F04'
if (channel.eq.5) file-ext = '.FIE+
if (channel.eq.6) file-ext = '.FOG
if (channel.eq.7) He-ext = '.F07'
if (channel.eq.8) file-ext = '.FO.Y
if (channel.eq.9) file-ext = '.F09'
if (channel.eq.10) file-ext = '310'
if (channel.eq.11) file-ext = ' 3 1 1'
if (channel.eq.l2) file-ext = '312'
if (channel.eq.13) file-ext = '313'
if (channel.eq.14) file-ext = '314'
if (channel.eq.15) file-exx '.F15'
if (channel.eq. 16) file-ext = '.F16'
if (&fafaformat .eq. 1) comma-file = cc3( name, setc, file-ext )
if (data-format .gt. 1) comma-file = cc( root, file-ext )
if (sezno.eq.1) then
open(31, file=commaafile, status='unknown')
wrire(31, '(a80,al)') titie
call time-stamp(location-flag, 31)
else
open(31, file = comma-file, status='old', access='append')
end if
100
110
write(3 1, 100) channel, s e ~ n o
format(lx, 'channel ', i2, ', ', 'segment .. i3)
do i = 1, npoint
write(31, 110) weighted-sigdii)
end do
format(lx, E15.6)
return
end
C
******f***************t*******************t*************************
subroutine HUMAN-RRMMS(datanum-poincs. rms, channel,
-flag,
rnt-segs, stas-flag, maxi. max2, max3,
mins, mean. sumexp, Kexp)
C Calculating the rms value for the s~gnalarray DATA. This is modified
C based on the subroutine root-mean-square so that they are compariable
C each ocher, which is easy for the code maintenance in the future.
C Statistics results are also calculated, including fust
maximum
C rms vdues, the minimum rnt value, and the mean of the rms values over
C all the se-ments. The rms values of each se-gnent arc stored in file
C humannns.seg, and can be used to calculate the standvd deviation.
C WG created on April 14.1993.
C WG modified on March 8.1996 for doing exponential averaging.
C ....................................................................
+
+
L
real*4 data(*), rms(*)
real*4 sum, rm~current-seg
real*4 maxl, max2, max3, mins, mean
integere2 channel, rmq-flag, rms-segs, stats-flag
real*4 exponent
integeF2 Kexp
rzal*4 sumexp, sum-exp-max
exponent = 2.0
if (rmq-flag.eq.1) exponent = 4.0
if (rmq-flag.eq.0 .or. rmaflag.eq. 1) then
sum = 0.0
d o j = I, numqoints
sum = sum + data(j)**expnent
end do
rms-current-seg = sqn(surn/num~ints)
if (rmpflag.eq.1) rms_currentLsep = sqrt(nns-current-seg)
rms(channe1) = max(rms(channel), nus-current-seg)
end if
c
c
*** for exponential averaging ***
if (rm~flag.eq.2)then
sum-exp-ma = 0.0
do j = I, nun-points
sumexp = sumexp + (data(i)*'2-sumexp)/Kexp
sum-exp-max = max(sun--espPmax, sumexp)
end do
rms(channe1) = max(rms(channel), sqrt(sum-exp-max)j
cnd if
if (stat.-flag.eq.1) then
*** find first three maximums, and minimum.
c
c
if (ms-current-szg.g.max3) then
if (rms-cu1~ent_xg.lt.mar2) then
max3 = rm-current-seg
else if (rrns-current-seg.lt.max1 j then
max3 = max2
max2 = ms-current-seg
else
max3 = max2
max2 = max 1
max 1 = rms-current-seg
end if
end if
if (m-current-seg.lt.mins) mins = -current-seg
*'* averaging nns values between all calculated segments
mean = ((rms-xgs-l)*mean + rm~current-seg)/nns_segs
*** save the
value of current segment
if (m-segs.eq.1) then
open(21. file='humanrms.seg',s~'new')
else
open(21. file='hu-.seg',access='append')
end if
write (21, *) r-current-seg
close (21)
end if
return
end
C
c
C
C
C
lopasd.FOR
88-05-10
THIS SUBROUTINE IMPLEMENTS .a DIGITAL FILTERn m UPTO
12 POLES ;3 NONRECURSIVE Ah?) 2 RECURSIVE TER.\IS ARE ALLOWED
SUBROUTINE lopass3(Y,pl,yout,p2.hX..Al,A2,MM,BZEROJSEG)
integeP4 ~ 1 . ~nl,
2 ,i
real*4 y(*), a1(6), a2(6), y0(7), y l(7). y2(7), you(*), bzero
real*4 yit, yi
integer mm,iseg, k, kl
IF (ISEG.EQ. 1) THEN
DO 10 K=1,7
Y2(K)=O.O
Y l(K)=O.O
YO(K)=O.O
I0
CONTINUE
ELSE
READ(99) YO, Y 1, Y2
ENDIF
DO 30 I=l,NL
YO(l)=Y(pl+I)
W 20 K=l,MM
KI=K+l
YlT=YO(K)+2.O*Y 1(K)+Y2(K)
YI=YTT-Al(K)*YqKl)-A2(K)*YI0(1)
IF(ABS(YI).LT.l.OE-37) YId.0
Y2(Kl)=Yl(Kl)
Yl(Kl)=YO(Kl)
20
YO(Kl)=YI
Y2(1)=Yl(l)
Yl(I)=Yql)
30
Yout(pZ+I)=YI*B2WO
IF (ISEG.NE.1) BACKSPACE (99)
WRITE(99) YO, Y1, Y2
RETURN
.
END
C
C
C
C
C
C
C
C
C
LPTB.FOR
88-05-10
SUBROUTINE TO GENERATE COEFFICIENTS FOR HIGHkLOW P-GS
TANGENT FILTERS.
INPUTS ARE: MNNUMBER OF POLES WHICH MUST BE Em
T -SAMPLISG PERIOD
B -PASSBAW WIDTH
LH-1 FOR LOWPASS ;0 FOR HIGHPASS
SUBROUTINELPTBW,T,B,AI,AZBZERO,LK)
integer mm,m, ml, i, ih
realf4 t, b, al(12). aZ(12). bzem, fang, f
DOUBLE PRECISION ANGFACT,SECTOR,WEDGE~~BM,A\lS.DEN
M=MM
FANG=3. 14159265*BfT
.4NG=DBLE(FANG)
FACT=DSIN(ANG)/DCOS(ANG)
Ml=M-MI;!
F=l.
FN=M
SECTOR=3.14159265W/FN
WEDGE=SECTORI;?.W
DO 5 I=l,MI
FN=I- I
.4NG=FN*SECTOR+WEDGE
AM=FACTDSIN(ANG)
BM=FACT*DCOS(ANG)
AMs=AM*AM
DEN=(I DO+BM)**2+AMS
.4l Ok-2.Do*((l.WBM*BM)-AMS)/DEN
5
18
20
AZ(T)=((l.WBM)* *2+AMS)/DEN
F=F*(l .+Al(T)+AZ(T))/4.
CONTINUE
IF(LH.EQ.1) GOT0 20
DO 18 I=l,Ml
AlO)=-Al(I)
CONTINUE
BZERO=F
RETURN
END
subroutine processingmisc(defauIt-mde, rmq-flag, ana-flag,
c
samplingfreq, Kexp, human-weighted-out-flag)
C*****r****************fff****f************f*********T***********************
C Routine to gather information for:
C
for exponential averaging
C
-averaging constant Kexp based on the input of time constant tao,
C
for human frequency weighting filter
C
-flag human_weighted-out-flag.
C
C
Added on March 12, 1996.
........................................................................
implicit none
real'4 samplingfreq, tao
integer rmkflag, ma-flag
integer*2 get-int, default-mode
logical query
character*20 blank
integerf2 Kexp, human-weighted-out-flag,
tacinpur
blank = ' '
call qsrnode(default-mode)
c
c***** input time constant for exponential averaging
if (mq-flag.eq.2) then
print *, 'select the time constant for exponential averaging'
1. 1 second'
print *, '
2. 118 second'
print *, '
3.8 second'
print * , '
tao-input = get-int(blank, 1, 1, 3)
if (tao-input.eq.1) tao = 1.0
if (tao-input.eq.2) tao = 0.125
if (tao-input.eq.3) tao = 8.0
Kexp = tao 'samplingfreq
end if
c***f*
+
input selection of outputing frequency weighted signal
if (ana-flag.eq.2 .or. ana-flag.eq.3) then
print *,' '
print *, 'do you want output frequency weighted'//
' time signal to ASCII file? @/Nl'
if (query(blank, h', defaultmode)) then
human-weighted-out-flag = 1
else
human-weighted-out-flag = 0
end if
end if
return
end
subroutine processin~arms(num-poinrj. stutpoint,num-segments,
nurnignore_segs, dim, sam?lin~freq.n~m~octaves)
C******fr******************++L*****L***~=~****************************%*****
C Routine to gather information such as:
C
-the length of the seemen& of the time signal to be used for
C
each run of the average,
C
-the number of such segments to be ~ e r a g e d ,
C
-the number of initial segments to k ignored. and
C
- h e point in time within the signal 2: which these portions
C
should be taken.
C***********************************************************************
implicit none
+
real*4 samplingfreq, limit
real'4 sample, start, get-real
integerf4 num-points, startqoint, dim. f x
integer num-segments, num-ignore-segs. n~m~octaves,
rep
integer get-int
character*20 blank
blank = ' '
limit = dim/(2*samplin~freq)
rep = 1
do while (rep .eq. 1)
rep = 0
print*
print*, 'Enter the length (in sec.) of each segment.'
print 10, 'fNO GREATER THAK . limit, ' SEC.)'
sample = get-realmlank, 1.0, 0.0. 333.0)
numgoints = nint(sample*samplin~freq)
fac = nint( numqoints/2.0*L(numum~taves-l)
)
numqoints = fac * 2**(num-octaves-1)
if (dim .It (2*num_points)) rep = 1
end do
prim 20, Tk segment length has been modified to: ',
+
num-poiau/samplingh.eq. ' sec.'
print*
print*, 'Enter the start time (in sec.).'
start = get-real@lank, 0.0, 0.0,200.0)
startqoint = nint(start*samplingfreq)
print*, '... number of segments'
num-serpents = get-intmlank, 1, 1,2000 1
print*, '... number of initial segments to k ignored'
num-ignore-segs = get-mt@lank, 0,0,7000)
10 format ( l X a, f6.2, a)
20 format ( l X a, f8.4, a)
.
return
end
subroutine print-rmsgl(rms, nchan-done, channels-picked,
num-octaves, stand-freqs, top-freq, default-mode,
data-format, units, rmq-flag, ana-flag, human-rms)
C Routine to print out rms values one channel at a time
C Note: the units of the rms values have been set to 9c g but this
C
can be changed by simply altering the assignment of the
C
character constant 'header2'.
C WG 93/04/15 Option for output freq-weighting results added.
...................................................................
implicit none
+
+
integer nchan-done, channelsgicked(l6), num-octaves, default-mode
integer i, j, k, m channel, top-freq, add, data-format, rmq-flag
integer ana-flag
realf4 human-rms(l6)
character*69 d.
rmq2
characteP20 blank, h21, h22, h23, cc3, rmq
character* 16 headerl
character* 12 headerZ(l6)
character*11 nn-message, rml
characterf7 units(*)
logical query
blank = ' '
headerl = 'Cenne Freq.(Hz)'
h21= 'RMS('
rmq = 'RMQ('
h23 = ')'
+
+
rm2 = The maximum RMS values of the selected 113-octaves are as'
11
' follows:'
rmq2 = 'The maximumRMQ values of the selected 1/3-octaves are as'
/I
' follows:'
rm-message = ' RMS (% g)'
r m l = ' RMQ(% g)'
if ( rmq-flag .eq. 1 ) then
nn-message = rml
rm2 = rmq2
end if
if ( data-format .eq.1 ) then
d o m = 1,16
headerZ(rn) = rm-message
end do
end if
if ( d m f o r m a t .ne. 1 ) then
do m = 1, n c h a ~ d o n e
h22 = units(m)
headed(m) = cc3fi21, h2L h23)
end do
end if
call qsmode(dsfau1t-mode)
printf, rm2
channel = 0
m=O
do i = 1, nchan-done
m=m+l
do j = channel+l, 16
if (channels-picked@ .eq. 1) exit
end do
channel = j
if (i . g t 1) call qsmode(def3ult-mode)
print '(lX, a, i2)', 'Channel '. channel
if (ma-flag.q.l.or.ma-fle.q.3)then
if (num-octaves .eq. 7) then
print 5, headerl, hzaderZ(m), headerl, header2(m)
dok=l,3
print 10, smd-freqs(top-freq+k-I), rms(channelk),
stand-freqs(top-freq+k+17), rms(channel,k+l8)
end do
add = l
else
print 5, headerl, hcaderZ(m)
add = 0
end if
do k = 1 + 3*ad4 3*(num-octaves-add)
print 10, stand-freqs(top-freqi-k-I), rms(channe1, k)
end do
end if
if (an~flag.eq.2.or.ma-flq.eq.3)then
print *
print 11, humanumanrms(channel)
print *
end if
if (i .eq.ncha~done)exit
print*, Display values for next channel? fllnlquit]'
if (query(b1ank 'y', default-mode)) cycle
exit
end do
print*, 'No more channels remaining. Hit Enter] to end routine.'
if ( query(blank, 'y', default-mode) ) return
10
11
formaf(1X €11.2,lIX,e9.4, 13X, f11.2, l l X , e9.4)
h a t (lX, ' overall', 11X, e9.4)
subroutine read-daff-:hannels(filename.
channels, nchan, rep)
For Global Lab data files only.
Routine to determine xhich channels are availble for the job by
C reading the DAFF file header.
C*******************~*******+t******************************Y**************
C
C
characteP20 filename
integer channels(l6). nchan, rep, context-id, chan-id, i
integerf4 size, position
open (7,file = filename. form = 'binary', sfatus = 'unknown',
access ='direct', recl = 2)
context-id = -32763
call daff~arse(l5,context-id, -1, -1, -1, position)
read (7,rec = position + 1) nchan
if (nchan .eq. 0) then
print '(IX, a, C O Y , There are no channels available for '
+
N
'the file: ', filename
rep = 1
return
end if
+
d o i = l , 16
channels(i) = 0
end do
position =position + P
d o i = l,nchan+ 1
read (7, rec = psition + 1) chaxid
if ((than-id .ge. I) .and ( c h a i d .le. 16))
+
channeis(chan-id) = 1
call read-size(psition, size)
position = position + 8 + size12
end do
close (7)
retun
end
........................................................................
subroutine read-HEF.1-data( filename, chan, n m p i n t s , x,
end-flag, spt, data-format. nc, hem-sum )
........................................................................
c nc
=
number of chans
c chan =
current channnel
c spt =
start point as opposed to effective stan p i n t in
c
multiplexed data file.
c st-point
= effective start point which is a function af number
c
of channnels, time trace, last point read
+
........................................................................
implicit none
integer*2 data-format nc, io
integerS2 i, chan, end-flag, record-length
integer*4 numgoints, m, end-point, spt
integer*4 start-point hem-sum, j, increment
real'4 x(*)
logical ouven
character*20 filename, binary, direct
end-flag = 0
binary = "binary"
direct = "direct"
record-length = 4
c Open the data file for 4 byte random access reads.
inquire( 8, opened = ouven )
if ( .not ouven ) then
if ( data-format .gt. 4 ) record-length = 1
open(8, file = filename, form = binary, s c e s s =direct,
+
reel= record-length )
end if
c Clear the header. The header length = ( 4 * nc ) bytes
c of which bytes 0, 1, 2', and 3 were used. i b e rest shoul6 contain 0-value bytes.
c
doi=l,nc
c
dummy
c
end do
c If the first column is not time values, take that into accwnt. Also
c the first point is located at the point number offset plus rhe number
c of channels.
data-format = 3 means no time values. data-format = 4
c means time values are there, so the effective channel oEset is
c number of channels + 1.
i=1
if ( data-format .eq. 3) then
start-point = nc * ( spt+ 1 ) + chan
endqoint = startpint + num-points nc
do rn = start-int,
endgoint, nc
read( 8, rec = rn, iostat = io, end = 10 ) x(i)
i=i+l
end do
end if
if ( data-format .eq. 4) then
stan-paint = nc + (nc + 1) * spt + chan + 1
end-point = stanqoint + numqoints * ( nc + 1 )
do m = s m q o i n t . end-point, nc + 1
read(8, rec = m, iosmt = io, end = I0 ) x(i)
i=i+l
end do
end if
if ( data-format .eq. 5) then
rn=hem-sum+(spt*nc+(chan1))*4+ 1
increment = nc * 4
do j = 1, numqoints
read(8, rec = m, iostat = io, end = 10 ) x(i)
i=i+l
m = m + increment
end do
end if
10
continue
if ( i .It. numqoints .or. io .eq. -I ) then
end-flag = 1
num-points = i
close(8)
end if
retum
end
C****************************ft*tXUft***~***%*****--*****************=**%***
C
C
C
C
C
C
C
subroutine read_sensitivityl(sensiti~-i~,inf~le,ser~.channel)
Originally called read-sensitivity from the file RE.-\DSENS.FOR
found in the MTAS library. The file was moditkd (and name
changed to READSEN1.FOR) for use in THIRDFOR written by MRH.
This version of the routine no longer reads the -piing
frequency from the .DOC file. Thus, the paramsrer deltat is no
longer calculated nor included in the call list. hfcdifications
were made on July 3, 1991.
C*t******************L*+******************Y******=*************************
C Check the MTAS USER'S MANUAL for an example cfa .WC
C file (APPENDIXD) so the code in this subroutine will make sense.
C The document file, .DOC, is smctwed as follows:
C Line Number
Contents
C 1,2
commentan.
C3
i10 - number of set ups
C4
sampling rate
number of stations
C5
C6
number of data points
C7
end channel, set up 1
C8
digital gain, set up 1
C.
C.
C.
C k = 8 + [(num-setups-l)*2] + 1
an asterix, *. ahich marks the
C
be,$nning of a set up
C k+l
i l 0 - channel number
C k+7
i l 0 - units
C k+8
i l 0 - signal (+I-)
C k+9
f10.3 -sensitivity
f10.3 - analoggain
C k+10
C START-CHANNJ3, ENDENDuser defined
C STARTCHANNEL, ENM-'HANNEL
read from DOC tile.
CINTENT
0 =only get sampling rate
C********************************************==************************
character*21 dummy
characteil20 infile, doc, doc-file, cc, formatted. mknown
character*l ch, asterix
intezer setup, endchannel
integer sn, units, signal, num-serups, i
integer dg, digitalzain, channel
integer startchannel, channel-num
real sens, sensitivity, r, analog-gain
doc = '.doc'
asterk = '*'
formaned = 'formatted'
unknown = 'unknown'
doc-file = cc( infile, doc )
startchannel = 1
open(9, file = doc-file, form = formatted. status = u&own)
call read-some-lines(9, 2)
read(9, '(i 10)') num-setups
call read-some-lines(9, 3)
do i = 1, num-setups
read(9, '(i10)') endchannel
read(9, '(i10)') dg
if (i .eq. setup) digital-pin = dg
end do
.......................................................................
C Read the first character from each line until a start of set up. *,
C i s encountered.
C Then check the set up, and channel numkrs until the right pair is
C found.
.......................................................................
10
continue
read(9, '(a)') ch
if (ch .ne. asterix) go to 10
read(9, '(a21, i3)') dummy, sn
if (setup .ne. sn) go to 10
c********************************==***************=****************
C Find the right channel number and get it's st&. Then
C reconstruct the channel sensitivity multiplier.
Cr***t**.****i*i*...I*******T******f*************===*=******************
do i = startchannel, channel - 1
call read-some-lines(9. 10)
end do
read(9, '(i 10)') channel-num
call read_some_lines(9,4)
read (9, '(i 10)' ) units
read(9, '(i10)') signal
read(9, '(g10.3)') sens
read(9, '(g10.3)') analoggain
read(9, '(a)') ch
r = analoggain * digita12ain * 2048. * sens
sensitivity =signal * 1000. / r
return
end
Cpage break
C***********************L******************i****************************
subroutine read-size(position, size)
Called by the submutine daff-parse, this routine reads the size
of DAFF contexts and tags. It is able to decode sizes contained
in the two bytes normally reserved for size, and if need be in the
next four bytes for sizes that exceed 65534 bytes. Due to the
MS FORTRAN compiler, this routine can handle sizes up to 7FFEFFFF
C hex, only. If sizes exist that are g r a t a than this, problems
C may arise. Sizes above this amount, however, are extremely
C unlikely and no problems should be encountered.
C
C
C
C
C
C*************************************Y***********Y*~*******************
integer size-small
integere4 size, position
read (7, rec = position + 3) size-small
if (size-small .eq. -1) then
read (7) size
else
size = size-small + (I - sign(1, size-small))
end if
size = size + mod~size,2)
if ((size .le. 8) .and. (size .ge. 0)) size = 0
return
end
* 32768
C****i*******************************************~**********************
subroutim root-mean_square(signal, b4000, b3 150. numqoints,
num-octaves, rms, channel, rmq-flag, sum. ms-segs,
s t a ~ f l a gsegfiles,
,
maxl, mins. rmq, sumsxpl23, Kexp)
C***********************************f************=*********************
c W G modified on March 8,1996 for adding exponential aaaging.
C********************t*****************f**********=-*********************
implicit none
+
+
characteP20 segfiles(*), append, direct, binap
real*4 signal(*), b4000(*),b3150(*), m ( l 6 , 2 l )
real'4 suml, sum2, sum3, r l , r2,r3, exponent, rmqil6.21)
real*4 sums(21). mins(21), max l(21)
integer*4 num-points, begmark, end-mark.!
integera2 nun-octaves, channel, i, rmpflag, rms-ws, stars-flag
integer'2 t, m, b
integeP2 Kexp
real*4 sumexp123(21), sumexpl, sumexp2, sumexp3
real*4 sum_exp-maxi, sum-exp-max2, sum-exp-m3
end-mark = num-points
begmark = 1
binary = "binary"
append = "append"
direct = "direct"
exponent = 2.0
if ( rmcflag .eq. 1 )
exponent = 4.0
do i = I, num-octaves
if (rmq-flag.eq.0 .or. rmq-flag.eq. 1) then
suml = 0.0
sum2 = 0.0
sum3 = 0.0
do j = begmark, end-mark
suml = sum1 + signal(j)**exponent
Sum2 = sum2 + b4000(i)**exponent
sum3 = sum3 + b3150(j)**exponent
end do
begmark = end-mark
end-mark = end-mark
+1
+ num-pointsl2* *i
if ( rmq-flag .eq. 1 ) then
rl = sqn( r l )
12 = sqrt( r2 )
r3 = sqn( 13 )
end if
channel, t ) = max( mu( channel, t ). 11)
IKS( channel, m ) = max( rms( channel. m 1, r2 )
-(
charnel, b ) = max( nns( channel, b 1%
r3 )
-(
end if
if (mq-flag.eq.2) then
t=3*i-2
m=3*i-1
b=3*i
sumexpl = sumexpl23(t)
sumexp2 = sumexpl23(m)
sumexp3 = sumexpl23(b)
do j = begmark, end-mark
sumexpl = sumexpl + (signalti)**2 - sumexp1)Kexp
sumexp2 = sumexp2 c @4000(j)**2 sumexp2)Kexp
sumexp3 = sumexp3 + (b315W)**2 - sumexp3)Kexp
rms(channe1.t) = max(rms(channel,t), sqrt(sumexp1))
rms(channe1.m) = max(rms(channel,m), sqrt(sumexp2))
rms(channe1,b) = max(r&(channel,b), sqrt(sumexp3))
end do
begmark = end-mark + 1
end-mark = end-mark + num_points/2**i
sumexpl23(t) = sumexpl
sumexpl23(m) = sumexp2
sumexplU(b) = sumexp3
end if
-
if ( rms_segs .gt. 1 )then
open (21, file = seg_files( t ), access = append )
open (22, file = segfiles( m ), access =append )
open (23, file = segfiles( b ), access = append )
else
open (21, file = seg_liles( t ) )
open (22, file = segfiles( m ) )
open (Z,file = segfiles( b ) )
end if
end do
return
end
C*****************t**************f************************************~*
subroutine setup-info(name. setups. nsetups. setupno)
C Determines which setups exist and how many of them there are
C*****r+****t**r**r****:f***c*****r*******************:************
character*20 cc3, name, st. ch, filename
character*l setup-char
integer setups(32), setups2(32), nsetups, setupno, i
logical ex
........................................................................
C Check .DOC files for which setups are available.
call double-check-setups(name, setups2)
C**************f********************************************************
C+t**+L**Check how many .STi (i = setup character) files there are******
nsetups = 0
do i = I, 32
ch = setup-char(i)
filename = cc3(name, st, ch)
inquire (file = filename, exist = ex)
if (ex) then
setups(i) = 1 * setups2(i)
nsetups = nsetups + 1 * setups2(i)
if (setups2(i) .eq. 1) setupno = i
else
setups(i) = 0
end if
end do
return
end
subroutine statistics2( rms-segs, rms, rmqflag. sums, channel,
stand-freqs, first-channel-flag, num-scgnents,
num-points, num-ignore-segs, root, filename,
data-format, num-octaves, top-freq, samplingfreq,
start-time, seg-files, maxl, max2, ma;. mins,
first-flag, ana-flag, human-rms-segs. human-maxl,
human-max2, human-max3, human-mins. human-mean)
........................................................................
implicit none
+
+
+
+
+
+
realr4 rms(l6,21)
realf4 sum, mean, std-dev, stand-freqs(22)
realt4 N, sampling_freq, start-time
real'4 sums(21), mins(21). maxl(21). maxZ(21). max3(2 1)
real*4 ext(1000), r, rl, r2, r3
.
integer mq-flag, rms_segs, channel, i, j, k, fust-flag
integer fust-channel-flag, num-segments, num-inore-segs
integer dataformat num-octaves, top-freq, loc&on-flag
integer ana-flag, human-tms-segs
realr4 human-maxl, human-max2, human-mar?. human-mins
real*4 human-mean, human-stddev
integere4 num-points
character*79 line, line1
characterf75 m-star40, m-star30
characteir33 mla, mlh
characteir15 m2a, blank m6, m7
characteir29 m3,m4
character*22 m4a
character*9 m4h
character*35 m5
characteP20 fout, ap, root, filename, formatted. seg-files(*)
charactere20 sta, cc
character*8 m8, bin
character*l9 m10
character5 m9, ch, m l l
characteF47 11
character*53 12
character*21 m5a
logical existence
ap = "append
formatted = "formatted
bin = "binary"
blank = ' '
sta = ".stam
mla = "RMS statistical results forjob: "
mlb = "RMQ statistical results for job: "
m2a = "Channel number:"
m-star40
m-star30 = "
m6 = "Frequency &I: "
m7 = "First 3 maxima: "
m8 = "Minimum: "
m9 = "Mean: ''
m10 = "Standard deviation: "
mil=" "
location-flag = 1
call concatenate( m_star40,75, m-star30,75, .me. )
I1 = " Frequency
12 = "Third Max
Fist Max
Minimum
Second Max "
Mean
Std Dev"
c If this is the last se-ment of data for this channel, open the
c results file STATS. do some stats, and save them. I'm going to
c assume the file isn't opened already, I've merely got to check
c for its existence. and append to what's already k e .
four = cc(root, sta)
inquire ( file = fout, exist = existence )
if ( .not. existence ) then
open (1 1, file = fout, fonn = fonnatted )
else
open (1 1, file = fout, access = ap, form = formatted )
end if
c If this is the first pass through the stats routine, write
c out the parameten under which the analysis was done.
if ( fmt-channel-flag .eq. 1 )then
write(l I. '(a,
) m-star40
call time-stamp( location-flag, 11 )
if ( -flag
.eq. 0 ) then
if ( data-format .eq. 1 ) then
write(l1, '(a)') mlaNroot
else
write(1 I, '(a)' ) mla// fdename
end if
else
if ( data-format .eq. 1 )then
write(] 1, '(a)' ) mlb /I root
else
write(l1, '(a)' ) mlb 11 filename
end if
end if
call save-processingparameters( num-segments, numqoints.
num-ignore-segs, samplingfreq, stan-time,
damformat, location-flag, 11 )
end if
write(11, '(a)' ) ml 1
write(l1, '(a, lx, i2.2)' ) m2a channel
write(ll,'(a)')Il 1/12
if ( ana-flag.eq.l.or.ana-flag.eq.3) then
if ( rms-segs .eq. I ) then
N = 1.0e30
else
N = 1.O 1 sqrt( float( rms-segs - 1 ) )
end if
do i = 1 , 3 * num-mtaves
open ( 21, file = sepfilesfi))
mean = sums(i) 1 rms-segs
k = top-freq + i - 1
rl = maxl(i)
r2 = max2(i)
sum = 0.0
do j = I, rms-segs
read(21, *) r
exto) = r
sum=sum+(mean-r)*(mean-r)
if ( r2 .It. r .and. r .It. r l ) 12 = r
end do
max2(i) = r2
r3 = max3(i)
do j = 1, rms-segs
r = exto)
if ( r3 .It. r .and. r .It. r2 ) 13 = r
end do
max3(i) = r3
std-dev = N * sqrt( sum )
cIose(21)
write (1 1, '( 3x, fg.2,6(3~,g12.4) )' ) ~rand_freq~(k),
m=l(i), max2(i), max3(i), mins(i), mean, std-dev
+
end do
end if
c
c
if ( ana-flag.eq.2.or.ana-flag.eq.3) then
*** calculate standard deviation for frequency aeighted results,
and output it togather all other statistic results.
if (human-ms-segs.eq. 1) then
N = 1.0e30
else
N = l.O/sqrt(float(humananm-segs-1))
end if
open (21, file='humanrm.segS)
+
do j=l, human-rms-segs
read (21.9 r
sum =sum + (human-mean - r)**2
end do
human-stddev = N * sqrt(sum)
close (21,srarus='delete7)
write (I 1.:)
write (11. '(3~.8H overall, q3x, g12.4))' ) humanmaxl.
human-max2, human-max3, huma~mins,human-mean. k~rnan-stddev
end if
return
end
C*******************************=***************************************
subroutine th3rdoct( signal, b4000,b j 150, nprs, noct,
skip-reuieve, iseg)
C*****************f*************=***%*********-~************************
C
TK7RDOCr.FOR
27-MY-9 1
C SUBROUTINE TO FILTER THE S.%?LE SIGNAL INTO PRESPECIFIED lf3C OCTAVES. THIS SUBPROGRAhl CALLS THE SLTTR0UIUE-S HIPASS3 AND
C LOPASS3 TO PERFORM THE FILTERING OPERATIOXS. THE COEFFICIENTS FOR
C THE FILTERS ARE OBTAINED FROM DISK FILES WRITEIY BY DIGFILTM. THE
C RESULTS OF TH3ARE SENT BACK TO ITS MASTER PROGRXM, PROCESS
C WHICH ITSELF IS FOUND IN THE MAIN MODULE THIRD.FOR.
i
........................................................................
C The version of th3rdoct written on May 27, 1991 was modified on
July 4, 1991 by MRH, who finalized the May 27th version.
The
changes included the addition of the parameters skip-retrieve and
iseg to the call list. The former was used to skip the part of
C routine which reads the coefticienrs from disk, after the fmt
C segment has been processed. The latter was used to send to the
C subroutines l o p s 3 and hipass3.
C*******************************~********************%******************
C
C
C
C ************DECLARA~~NOF V O m L j ? S
C
integer*4 nun. pl, p2, npts, i, j. k
ARRAYS** ****tf
if
*******f*f
f*f
real *4 signal(*), b4000(*),b3150(*)
integer skip-retrieve, noct, iseg, kk
character* 12 filnile
L
C ****** **+***REC O - m
C
if (skip-reuieve .eq. 0) then
C
FROM DISK FILES*********
*++*+*******
3
format(i3,32e16.8)
P~=O
pZ=npts
C
C ************INITIAL LOWPASS OF DATA .4T HIGHEST FREQUENCY OF INTERESTL*
C
C **Open Ne to which trailing coeffs will be wrinen.**************
open(unit = 99, file = 'DUM.DAT, access ='direct', r e d = 240,
+
form = 'unformatted')
rewind(99)
call lopasd(signal,pl,signal,pl,npts,al5h,a25h.mm,bzero5h.i~)
C
C ****"******REPEATED LO- AND HIPASSING TO DIVIDE DATA INTO 113-OCTAVES.
PROCESS OCCURS ONCE FOR EACH OC-JAm**%f **+*tf*f f f***f***f f f f+ff f
C
C
DO98, KK= 1, NOCT
call lopasd(signal,pl,signal,p2,npts.al2h.a2U,mm,bzero2h.iseg)
call lopasd(signal,p1,b4000,p2,npts,al4h.aZ-1hhm,bzer~h,iseg)
call lopass3(signal,pl,b3150,p2,npts,al3hb~hm,bzero3h,iseg)
.
call hi~ass3(signal,pl,signal,pl.npts,ai5.~mm.bzero5.iseg)
call hipass3(b4000,p2, b4000,pl ,npts,al-11.2-ll.mm.bzerdl,iseg)
call hipass3(b3150,p2, b3150,pl.npts,a13l.~lm,hzero3l,iseg)
npts=pptsl;!
4
do 4 i=l,npts
j=p2+i
k=p2-1+2* i
signal(j)=signal(k)
continue
pl=P2
p27- l+npts
98
C O h m
close (99)
C
C********i****************f************=*******************************
C
900 return
end
c Having n utilities file that contains a number of subroutkes somewhat
c defeats the purpose of using a makefile, but DOS limits 5 e number of
c characters that will live on the commmand line, so I ha>-: to conserve
c command line space by limiting the number of object files listed
c in makefile variable $(objs). Hence, this file.
subroutine newgage(defau1t-mode)
..................................................................
integer default-mode
call qsmode(defau1t-mode)
print '(3lX, a)', 'Routine to Perform'
a)', 'In-OCTAVEA~ALYSISOF TIME DOMAIN DATA'
print '(1?1X,
print*
print*
print*
rerum
end
C******
c
subroutine parseoine, word, n)
changes sentence to word vector
C*********************************************~*****************************
c returns number of words, n in array of words, word.
implicit none
integeri2 n, flag, nl, nr, i, j, nlet, nw
characteP20 word(20)
character*(*) line
d o i=1,20
word(i)=' '
end do
2
do i = 1 , 8 0
j=80-i+l
if ((nl.eq.O).and.(line(i:i).ne.'
if ((nr.y.O).aod.(line(i:j).ne.'
if ((nrfnl).ne.O) goto 2
eod do
continue
')) nl = i
')) N =j
do i=l,n
if (flag.eq.0) then
if (line(i:i).ne.' ') then
nw=nu+l
word(nw)(l: t)=line(i:i)
nlet=l
flag=l
endif
else
if (line(i:i).ne.' ? then
nlet=nlrt+l
word(nw)(nlet:nlet)=line(~i)
else
flag=O
endif
endif
end do
return
end
subroutine to-int( word, n, number )
C******L**********************************:********************************
implicit none
integer n, i, j, k, 1
integer'4 number
character word(n), blank, comma
blank = ' '
comma = ','
j=O
number = 0
d o i = n , 1,-1
if ( wordfi) .ne. blank .and. word(i) .ne. comma ) then
I = ichar( word(i) )
if ( 1 .It. 48 .or. 1 .gt 57 ) cycle
k=l-48
number = number + k * 10 ** j
j=j+l
end if
end do
return
end
C***********************************************************************
c
c
peter h. wilson
national research council canada
c
c
institute for research in construction
october 1990
C*********************************x*************************************
c
c
this routine concatenates two character strings into one
character string.
C********t******************:************************************~****~*
c modifications:
c
jpm 9 1/07/25
c
i've changed this so that two strings are first concatenated
c
and then the output suing is searched for the symbol #, which
c
is then replaced with a blank [white space].
.......................................................................
c
c
c
c
i -counter
n -the number of characters in string 1
m - the number of characters in string 2
count - counts the number of characters in string until a blank
C
c
c
c
c
strl - is the i/p character suing 1
str2 - is the i/p character suing 2
blank is equal to a blank space
ch - is a dummy character
-
C
c
flag - changes the blank space when equai to uue
C*************f************~********t********************************
subroutine concatenate(str1, n, str2, m, flag)
integer i, n, m, count
character strl(n). str2(m)
character*l b, blank, ch
logical flag
blank = ' '
count = 0
b = '#'
c
look for the end of the first suing.
d o i = n , 1, -1
if(strl(i) .ne. blank) then
count = i
go to 10
end if
end do
c
add suing2 to string1 if its characters aren't blank
10
continue
doi=l,m
ch = str2(i)
if ( ch. ne. blank ) then
count = count + l
strl(count)= ch
end if
end do
if ( flag ) then
doi=I,n
if ( strl(i) .eq. b ) strl(i) =blank
end do
end if
return
end
subroutine get-sfreq-HEM( samplingfrequency)
C*********************t**************************************************
real*4 samplingfrequency, get-real
charactert38 m3
character*20 rnl
rnl = "Frequency"
m3 = "At what frequency was the data sampled
print*, ' '
print*, m3
sampling_frequency = get-real( rnl, 200.0, 10.0,2000.0 )
return
end
integerf2 function my-length-counter( str, len )
C******t****************************************************************
c ignore blanks and carriage returns
implicit none
integer len, i, j
character s w e n )
doi=len, 1,-1
j = ichar( swi) )
if ( j .eq. 32 .or. j .eq. 13 ) cycle
my-length-counter = i
exit
end do
return
end
........................................................................
+
+
subroutine save-pmcessin&parameters( nun-segments, num-points.
num-ignore-segs, samplin~freq,stantime. data-format,
location-flag, unit)
........................................................................
implicit none
realY4r, N. sampling-freq, stan-time, duration
integera4 numgoints
integer num-segments, nun-ignore-segs, location-flag, stats-file
integer data-formar unit
characteF29 m3, m4
characteP22 m4a
charactef 9 m4b
characteP35 m5
character* 19 m10
charactef5 m l 1
character*21 m5a
character* l slash, quotes
m3 = "Number of wgments processed: "
m4 = "Number of points per segment: "
m4a = "
Segment length: "
m4b = " seconds."
m5 = "Number of initial segments ignored:
m5a= "
Stan rime: "
mil=" "
slash = char(47)
quotes = char(34)
stats-file = 1
duration = nurn-ints
+
+
+
+
+
I samplingfreq
if ( location-flag .eq.stats-file ) then
writdunk '(lox, a, i6)' ) m3,num-segments
write(uni~'(lox, a, i6, a, f7.2, a)' ) m4, numgoints, m4a,
duration, m4b
writefunit '(lox, a, i6, a, f7.2a)' ) m5, num-igno~-segs,
m5a. stan-tirne, m4b
write(unit '(a)' ) m l l
else
write(unit '(lox, 2a,i6, a)' ) quotes. m3,
num-segments, quotes
writefunit. '(lox, 2a, i6, a, fl.2,2a)' ) quotes, m4,
numqoints, m4a duration, m4b, quotes
write(unit '(lox, Za, i6, a, f7.2.2a)') quotes, m5,
num-ignc~re-segs, m5a, start-time. m4b, quotes
writefunit '(a)' ) ml 1
end if
return
end
subroutine time-stamp( location-flag, unit )
1
C*******************************************i***************************
implicit none
integer hour, min, sec, hund, yr, mon, day
integer location-flag, unit
character*l slash, colon, quotes
slash =char( 47 )
colon =char( 58 )
quotes = char( 34 )
call gettim( hour, min, sec, hund )
call getdat( yr, mon, day )
+
+
+
if (location-flag .eq. 1 ) then
write( unit, '(i4,a,i2.2,a,i2.2,5x.i2.2,a,i2.2,a,i2.2)')
yr, slash, mon, slash, day, hour. colon, min, colon, sec
else
write( unit, '(a,i4,a,i2.2,ai2.2,5x,i2.2,ai2.2,a.i2.2,a)')
quotes, yr, slash, mon, slash, day, hour. colon, min,
colon, Sec, quotes
end if
return
end
C***************************f*********************************************
subroutine stripPblanks( sl, n, default-rncde )
C***********************************************************************
integer n, i, j, default-mode
character*l sl(n), s2(256), ch, blank
blank = "
if ( n .gt 256 ) then
n=256
call new-page( default-mcde )
print*, "Character fed to strip-blanks too long."
end if
j=O
doi=l,n
ch = sl(i)
if ( ch .ne. blauk ) then
j=j+l
s20) = ch
s i (i) = blank
end if
end do
doi=l,j
sl(i) = s2(i)
end do
return
end
subroutine my-to-upper( word, len )
C***************************z*********%*********************************
implicit none
integerf2 len, i, j
character*l wordoen), ch
d o i = 1,len
ch = word(i)
j = ichar( ch )
if ( j .le. 122 .and. j .ge. 97 ) then
j=j-32
word(i) = c h d )
end if
end do
return
end
.........................................................................
subroutine to-units( word, n, units, m )
C************************************************************************
implicit none
integer*2 n, m, i, j, k
character* 1 word(n), units(m), ch
+
doi=l,n
ch = word(i)
j = ichar(ch)
if (j .le. 122 .and. j .ge. 97 .or. j .le. 90
.and. j .ge. 65) then
k=k+l
if(k.gt.m)exit
units&) = ch
end if
end do
return
end
C***********************************t***********************************
subroutine write-rms-gl(rms, ncha~done,channelsqicked,
num-octaves, top-freq, name. setupno,
+
data-format, root, units, q f l a g , num-segments,
+
num-points, num_ipore_segs, start-time,
+
samplin~freq,default-mods. aria-flag. human-m)
C***********************************************************************
C Routine to write rms values to the disk tile:
C
atamexsetup-char>.RMS (MTAS format),
C
or
dilename root>.RMS (Global Lab format)
C in ASCII format.
C Note: the units of the rms values have been set to % g but this
C
can be changed by simply adjusting the statement within the
C
do loop which assigns the character array 'units'. This
C
note applies only to MTAS form& for Global h b format the
C
units are imported through the parameter 'units'.
C WG 93/04/15 Option for output freq-weighting results added.
C WG 93/08/16 Output titles are modified to include version and
C
date of the version in the output *.rms file.
C WG 94/04/28 Output titles are modified for version 5.0.
C WG 96103111 Added output for averagining type, diedtiUe to v6
+
c********************************tf**********************************
implicit none
real*4 rms(l6,21), f(16.21). start-time. samplingfreq
integerf2 ncban-done, channelsgicked(l6), n~m~octaves,
top-freq
integeP2 setupno, chg(16), sf, sf, ef. data-format
integer*2 rmpflag, num-ignore-segs. num-segments, 1-flag
integer*2 default-mode, i, j, il, i2
real*4 humanmannns(16)
integer"2 aria-flag
integer*4 nun-points
character*190 line
characteP80 title
character*20 name, setc, fae_ext, cc3
characteP20 cc, comma-file, quoteZ root, rmq
character* 12 frequency
characW7 units(l6)
character*5 ~(16).v(16)
character*4 freqJist(22)
character*2 hz
character*l setup-char, comma, quore, blank
setc = setup-char(setupn0)
frequency = ' "Frequency"'
hz = 'Hz'
title=
+
"'113 Octave RMS Output For Job (Using V6.0 dated 96-03-15): '
+ 11 name
I-flag = 0
+
+
file-ext = '.rms'
rmq = '.rmq'
if ( rmq-flag .eq. 1 ) then
file-ext = rmq
title =
'"113 Octave RMQ Output For Job (Using V6.0 dated 96-03-15): '
11name
end if
if (dat~format.eq. 1) comma-file = cc3( name. setc, file-ext )
if (data-fomt .gt. 1) comma-fde = cc( root, file-ext )
comma = ','
quote = ""
quote2 =
blaA = ' '
'1-*
i=l
st=l
do while (i .le. nchan-done)
do j =st, 16
if (channelsgickedCj) .eq. 1) then
chg(i) =j
exit
end if
end do
st=j+l
i=i+l
end do
c
d o i = l , 16
chno = number-char(ch-p(i))
if ( i .lt. 10) then
write( v(i), '(6, il)' ) 'Ch ', i
else
write( v(i), ' ( 6 , i2)' ) 'Ch ', i
end if
end do
if ( data_forrnat .eq. 1 ) then
do i = 1, nchan-done
units(i) = '(% g)'
end do
end if
do i = 1, nchan-done
u(i) = units(i)
end do
i2 = 1
do i = 3*num-octaves, 1, -1
do j = 1, nchan-done
f(i, i2) = rms( ch-PO), i )
end do
i2=i2+1
end do
10 format (al0, 16 al2)
20 format (fS.2, 2X, 16 e12.4)
open(31, file = comma-file, form = 'formatted' )
write(31, '( a80, al)') title, quote
+
+
call time-stamp(l-flag, 31 )
call save-processin:darameten(
num-segments, numqoints,
num-ignore-segs, sarnplingfreq, start-time, data-fomrat
1-flag, 31 )
if (rmq-flag.eq.0 .or. rmq-flag.eq.1) then
write(31. '(a)') 'Averaging Type: linear averaging'
else if (rmq-flag.eq.2) then
write(3 1, '(a)') 'Averaging Type: exponential averaging'
end if
c insert conditions here
write(3 1,401 frequency,
(comma, quote, v(ch-p(i)), quote, i = 1, nchaxdone)
+
format( a12, 16(2al, as. al) )
40
write(31.50) quote, hz, quote,
(comma, quote, u(i), quote, i = 1, nchan-done)
+
50
format( al, a3, al, 16(2al, as, al) )
c OK, look, the frequency list goes small to large, and that's the
c way it's got to be written to disk; however MH origjdly wrote
c this to use an inverted list, so things have to be remapped.
c top-freq refers to the topmost frequency band in the inverted
c list, so a smaller number is closer to the top.
c
ef = 22 - top-freq + 1
c
sf = 22 - ( num-octaves * 3 ) - top-freq + 2
c
ef = 22 - top-freq + 1
c
sf = ef - 3 * num-octaves + 1
C
c
i2= 1
C
c
c
c
c
c
do i = sf, ef
write (31, 60) freq_list(i),
( blank, f( ch-PO), i2), j = 1, nchan-done )
+
i2 = i2 + 1
end do
fomat(a5, 16( al, e10.4 ) )
do i =sf, ef
line = ' '
il = 1
write(line(il:), '(a.5, al)' ) freq-list(i), comma
il=7
do j = 1, nchan-done
write(line(i1:). '(e10.4, al)' ) f( chq(j). i2), comma
il=il+ll
end do
i2 = i2 + 1
call strip-blanksfline, 190, default-mcde)
write (31, '(a)' ) line
end do
if (ma-flag.eq.1 .or.ana-flag.eq.3) then
ef = 22 - top-freq + 1
sf = ef - 3*num-octaves + 1
i2=1
do i =sf, ef
write(3 1,60) freq_list(i), (f(j,i2), j = 1, nchan-done)
i2 = i2 + 1
end do
end if
if (ana-flag.eq.2.0r.anaaflag.eq.3).then
do j = 1, nchan-done
f(i,l) = human_rms(chg(j))
end do
write (3 1, '(a)') blank
write (3 1,643) 'overall', (f(j,l), j = 1, nchan-done)
end if
fomt(a8, 16(',',e11.4))
close (31)
return
end
C
C
C
PROGRAM TO GEhERATE A PURE SINE SIGNAL TO BE USED TO TEST THE
113-OCTAVE ANALYSIS PROGRAM, THIRD.
THE SINE SIGNAL IS WRITlEN TO DISK IN BINARY FORM
L
E % * 4 SINWV(15000)
FE%Lt4 SFREQ,FREQAMP,SENS
C K W C E R * 2 0 SNFILE
PRC'JT*, 'Enter the frequency (in Hz), the amplitude (arbitrary uni
9tsL and the sampling frequency (in Hz), in that order, of the sin
9e wave to be generated'
RE.4De, FREQ, AMP, SFREQ
print*, 'Enter the sensitivity.'
read*, sens
DO 10, I = 1,15000
SlNWV(T) = AMP*SIN(2*3.141592654*EREQ*0-1)lSFREQ)
10
CONTINUE
PRINT*, 'Enter the name of the disk file to which the data will be
9 written.'
RE.U)(*,'(a)') SNFILE
OPEN(l,FILE?SNEILE,fom='b'u~ary~,status=~t',
+
recl=2)
DO 100, I = 1, 15000
WRITE(1,recl) hW(SINWV@)/SENS)+ 2048
100
CONTINUE
CLOSE(1)
STOP
LXD
.
#Comment lines begin with a pound sign
# Options: lc = no link
#
/AH = huge memory model
#
14Yd = all variables must be declared
#
14Nt = do not truncate variable names
#
14U = 2 byte integers
#
/Zi =debug information
#
/Od =disables optimization
#
lG2 = 80287 instruction set - the fuckers don't yet use 386
#
lEPi87 = in line 80287 instructions
#
/Ox = max optimization
#
lSE:256 = set the number of segments to 256
#
IGt = sets the data threshold to 256 bytes
dflags = lc /AH l4Yd 14Nt I412 IZi IOd lG2 /FPi87 IGt #debug info included
oflags = Ic /AH 14Yd 14Nt I412 /Ox lG2 /FPi87 IGt
#debug info excluded
debug = ICO
nodebug =
libs = filter.lib llibfor7.lib mtas.lib grafex40.lib;
compile = $(CC) $(oflags)
In = link lSE:256 $(nodebug)
objs = toap.obj p m g l . o b j get-nmg1.obj setups.obj \
get-set.obj chan_sk.obj ck-chanl.obj get-chg1.obj filtingl.obj \
disfilmobj 1ptb.obj getsfreq.obj proparms.obj readsenl.obj \
get-&tl.obj th3rdoct.obj lopass3.obj hipm3.obj mtmnsq.obj \
ptInnsgl.obj wrtrmsgl.obj dck-sets.obj dck-chns.obj fnpmbdf.obj \
headerdf.obj daffpars.obj &zdf.obj readchdf.obj daff&taobj \
hem-dec.obj readhemobj stats2.obj utils.obj humanf11.obj \
bumancof.obj filter.obj hurnannns.obj ascii-in.obj asciirea.obj \
pmmisc.obj humanoutobj
procesgl.obj:
procesgl.for
$(compile)pnxzsgl.for >> er
lib fitter -+ procesgl.obj;
get-nmgl.obj:
get-nmgl.for
$(compile) get-nmgl.for >> er
lib filter -+ get-nmgl.obj;
setups.obj: setups.for
$(compile) setups.for >> er
lib filter -+ setups.obj;
get-serobj:
get-xt.for
$ ( c q i l e ) get-set-for >> er
lib filter -+ get-set.obj:
chan-sk.obj:
chan-sk.for
$(compile) cban-sk.for >> er
lib filter -+cban-sk.obj:
ck-cbml.obj:
ck-chanl.for
$(compile) ck-chanl.for >> er
lib filter -+ ck-cban 1.obj;
get-ch<l.obj:
get-chgl.for
$(compile) get-chgl.for >> er
lib filter -+get-chglobj;
filtinglobj:
filtingl.for
$(compile) filtingl.for >> er
lib filter -+ filtingl.obj:
digfilmobj:
digfxltm.for
$(compile) digiillm.for >> er
lib filter -+ digKltm.obj:
1ptb.obj:
Iptb.for
$(compile) Iptb.for>> er
lib filter 4 lptb.obj;
getsfreq.obj:
getsfreq.for
$(compile) getsfreq.for >> er
lib filter -+ getsfreq.obj:
proparms.obj:
pparms.for
$(compile) proparms.for >> er
lib filter -+propanns.obj;
readsenl.obj:
readsenl.for
$(compile) readsenl.for >> er
lib filter 4 readsenl.obj;
get-&I .obj:
get-datl.for
$(compile) get-datl.for >> er
lib filter -+ get_datl.obj;
th3rdcct.obj:
th3rdoctfor
$(compile) th3rdoctfor >> er
lib filter -t th3rdoct.obj;
lopass3.obj:
lopasd.for
$(compile) lopass3.for >> er
lib filter -+ 1opasd.obj:
lib filter
-+ hipass3.obj;
rootmnsq.obj:
rootmnsq.for
%(compile)roounnsq.for >> er
lib filter -t roormnsq.obj;
pnrmsgl.obj:
prtrmsgl.for
%(compile)pmmsgl.for >> er
lib filter -+ prtmugl.obj;
wrtrmsgl.obj:
wrtrmsgl.for
$(compile) m s g l . f o r >> er
lib filter -+ wrtrmsgl.obj;
dck-s+rs.obj:
dck-sers.for
$(compile) dck-setsfor >> er
lib filter -+ dck-sers.obj;
dck-chns.obj:
dck-chns.for
%(compile)dck-chns.for >> er
lib fitter -+ dck-chns.obj;
fnprobdf.obj:
fnprobdf.for
%(compile)fnprobdf.for >> er
lib filter -+ fnprobdf.obj;
headerdf.obj:
headerdf.for
$(compile) headerdtfor >> er
lib filter -+ beaderdf.obj;
daffpars.obj:
-.for
$(compile) daffpars.for >> er
lib filter -+ [email protected];
readszdf.obj:
readszdf.for
S(compi1e) readszdffor >> er
lib filter -+ readszdf.obj;
readchdf.obj:
readchdf.for
%(compile)readchdf.for >> er
lib filter -+ readcbdf.obj;
daffdaraobj:
daffdatafor
S(compi1e) daffdatafor z> er
lib filter -+ daffdataobj;
hem-dec.obj: hem-dec.for
S(compi1e) hem-dm.for >> er
lib filter -+ hem-dec.obj;
hemsireq.obj: hemsfreq.for
S(compi1e) hems£req.for >> er
lib filter -+ hemsfreq.obj;
readhem.obj: readhem.for
$(compile) readhem.for >> er
lib filter -+ readhem.obj;
stats2.obj:
stats2.for
$(compile) stats2.for >> er
lib filter -+ stats2.objr
utils.obj:
utils.for
$(compile) utils.for >> er
lib filter -+ utils.obj:
hurnanfil.obj: h-d.for
$(compile) humanfil.for >> er
lib filter -+ bumanfil.obj;
lib filter
-+ humancof.obj;
filte~obj: filter.for
$(compile) filter.for >> er
lib filter -+ filter.obj;
.
bumanrms.obj: bumanrms.for
$(compile) humanmu.for 7> er
lib filter -+ humanrms.obj;
asciiin.obj: ascii-in.for
$(compile) ascii-in.for >> er
lib filter -+ ascii-in.obj;
asciiiea.obj:
asciireafor
$(compile) asciirea.for >> er
lib filter -+ asciireaobj;
procmisc.obj:
procmisc.for
$(compile) procmisc.for >> er
lib filter -+ procmisc.obj;
humanout.obj:
humanoutfor
$(compile) bumanout.for >7 er
lib filter -+ humanout.obj;
all: $(objs)
$(In) toap.obj ,toap., $Oibs)