next up previous contents
Next: Example: gwoutput program Up: GRASP Routines: Reading/using Caltech Previous: Example: locklist program   Contents


Function: get_data()

0 int get_data(FILE *fp,FILE *fplock,float *tstart,int npoint,short *location,int *rem,float *srate,int seek)
This high-level function is an easy way to get the IFO output (gravity wave signal) during periods when the IFO is locked. When called, it returns the next locked data section of a user-specified length. It also specifies if the section of data is part of a continuous locked stream, or the beginning of a new locked section.

The arguments are:

fp: Input. Pointer to a file (typically channel.0) containing the channel 0 data.
fplock: Input. Pointer to a file (typically "channel.10") containing the TTL lock signal.
tstart: Output. The time of the zeroth point in the returned data.
npoint: Input. The number of data points requested by the user.
location: Input. Pointer to the location where the data should be put.
rem: Output. The number of points of data remaining in this locked segment of data.
srate: Output. The sample rate of the fast data channel, in Hz.
seek: Input. If this is zero, then the data is returned in the array location[ ]. However if this input is non-zero, then get_data performs exactly as described, except that it does not actually read any data from the file or write to location[ ]. This is useful to quickly skip over un-interesting regions of the data, for example the first several minutes after the interferometer acquires lock.

This function returns 0 if there is no remaining locked data stream of the requested length. It returns 1 if it is just starting on a new locked section of the data stream, and it returns 2 if the data is part of an on-going locked sequence.

WARNING: The get_data() function contains internal (static) variables which mean that you can not use it as follows:

  1. Open a file pointer fp
  2. Call get_data(fp,$\cdots$) some number of times
  3. Close the file pointer fp and then (say) open it again
  4. Call get_data(fp,$\cdots$) some number of times.
This sequence will leave you and the code very confused: it does not correspond to ``rewinding" the file. If this is desired then you will have to modify the get_data() function by adding a helper ``reset()" function.

Author: Bruce Allen, ballen@dirac.phys.uwm.edu
Comments: This function was designed for variable-length blocks. It is possible to simplify it for fixed-length block sizes. It should also be modified to return a complete set of different channels, by adding additional arguments to specify which channels are desired and where the data should be placed. This could also be used to eliminate the seek argument.


next up previous contents
Next: Example: gwoutput program Up: GRASP Routines: Reading/using Caltech Previous: Example: locklist program   Contents
Bruce Allen 2000-11-19