#include "brttutil.h" BUSac * busac_create(char *tag, char *handle) BUSac * busac_read_from_file_busac(char *filename, char *tag, char *handle) BUSac * busac_get_busac(char *handle) void busac_free_busac (BUSac *busac) long busac_free(char *handle) long busac_free_tag(char *tag) long busac_puthdr_busac(BUSac *busac, ...) long busac_gethdr_busac(BUSac *busac, ...) long busac_putdata_busac(BUSac *busac, int nsamp, double tstart, double samprate, float *data, char *segtype) long busac_getreftime_busac (BUSac *busac, double *rtime) long busac_getdata_busac(BUSac *busac, int *nsamp, double *tstart, double *samprate, float **data, char *segtype) long busac_putevent_busac(BUSac *busac, Dbptr dbtrace, Dbptr dborigin) long busac_getevent_busac(BUSac *busac, Dbptr *dbtrace, Dbptr *dborigin) long busac_write_to_file_busac(BUSac *busac, char *filename)
These subroutines can read/write SAC files to/from internal binary SAC file image representations and provide for rudimentary manipulations of the internal SAC file images, such as parsing and writing the various SAC file header values.
busac_create will create an empty BUSac object and return a pointer to the object, or NULL if there is an error. tag can be used to specify a character string tag associated with the new object. An object handle is returned in handle and this handle is used for most subsequent calls to the new object.
busac_read_from_file_busac will read a SAC file, specified by file name filename, put its contents into a new BUSac object and return a pointer to the object, or NULL if there is an error. tag can be used to specify a character string tag associated with the new object. An object handle is returned in handle and this handle is used for most subsequent calls to the new object.
busac_free will free the resources associated with the BUSac object referenced by handle.
busac_free_tag will free the resources associated with all of the BUSac objects whose tag is tag.
busac_free_busac will free the resources associated with the BUSac object pointer busac.
busac_get_busac will return the BUSac object pointer referenced by handle.
busac_puthdr_busac will put SAC header values into the header of the object referenced by busac. The specification of the header values are in a variable argument list consisting of pairs of header name strings and their corresponding values, with a NULL value to end the variable argument list. The names of the SAC header values come from the SAC file format documentation. For example the name "DELTA" corresponds to the time sampling increment. The header values must be appropriate for the particular value name. For instance, the "DELTA" header value should be specified as a floating double value. All integers, including booleans should be specified as long ints.
busac_gethdr_busac will get SAC header values from the header of the object referenced by busac. The specification of the header values are in a variable argument list consisting of pairs of header name strings and pointers to their corresponding values, with a NULL value to end the variable argument list. The names of the SAC header values come from the SAC file format documentation. For example the name "DELTA" corresponds to the time sampling increment. The header value pointers must be appropriate for the particular value name. For instance, the "DELTA" header value pointer should be specified as a pointer to a floating double value. All integers, including booleans should be specified as pointers to long ints.
busac_putdata_busac will put waveform data sample values into the SAC object referenced by busac. The waveform data consists of nsamp number of sample values with the first sample starting at time tstart epoch time and with a sample rate of samprate samples per second. The waveform sample values are stored in the floating array referenced by data. The data sample units and type are specified by segtype which is consistent with the segtype field in the wfdisc database table. The "IDEP" field of the SAC header is set according to segtype. The SAC header values "DEPMIN", "DEPMAX", "DEPMEN" are all computed automatically.
busac_getdata_busac will get waveform data sample values from the SAC object referenced by busac. The waveform data consists of *nsamp number of sample values with the first sample starting at time *tstart epoch time and with a sample rate of *samprate samples per second. The waveform sample values are stored in the floating array referenced by *data, which is allocated in this subroutine (i.e. it is the responsibility of the programmer to free *data when it is no longer needed). The data sample units and type are returned in segtype, which is consistent with the segtype field in the wfdisc database table, which is based upon the "IDEP" field of the SAC header.
busac_getreftime_busac will return in *rtime the reference time from the SAC object referenced by busac.
busac_putevent_busac will put event information and the waveform data sample values corresponding to the event into the SAC object referenced by busac. The event information is specified through a pointer to a row in an origin database table through the dborigin Datascope pointer. The station information and waveform data is specified through a pointer to a row in a trace database table (see trintro(3) and the trace4.0 schema description) through the dbtrace Datascope pointer. The "KNETWK", "KSTNM", "KCMPNM", "STLA", "STLO", "STEL", "STDP", "CMPAZ", "CMPINC", "O", "EVLA", "EVLO", "EVDP", "GCARG", "DIST", "AZ", "BAZ", "NORID" SAC header fields are all automatically populated based upon the database values.
busac_getevent_busac will get event information and the waveform data sample values corresponding to the event from the SAC object referenced by busac. The event information is written as a new row to an origin database table through the *dborigin Datascope pointer with the new record number returned in *dborigin. The station information and waveform data is written as a new row to a trace database table (see trintro(3) and the trace4.0 schema description) through the *dbtrace Datascope pointer with the new record number returned in *dbtrace. Note gthat there is no sophisticated event merging done, such as that done in orb2dbt(1). The "KNETWK", "KSTNM", "KCMPNM", "STLA", "STLO", "STEL", "STDP", "CMPAZ", "CMPINC", "O", "EVLA", "EVLO", "EVDP", "GCARG", "DIST", "AZ", "BAZ", "NORID" SAC header fields used to determine the various database fields.
busac_write_to_file_busac will write a SAC file specified by file name filename using the object referenced by busac. The new SAC file will overwrite any data in existing files by that name.