#include "brttpkt.h" PktChannelCalib * pktchannelcalib_new (char *dbname, int need_calib, int need_response, int need_site) int pktchannelcalib_free (PktChannelCalib *ch) int pktchannelcalib_get (PktChannelCalib *ch, char *snet, char *ssta, char *schan, char *sloc, double time, int check, char *sta, char *chan, double *lat, double *lon, double *elev, double *calib, double *calper, char *segtype, Response **response)
pktchannelcalib_new creates a new packet channel calib object and returns a pointer to the object. This pointer is used as a handle for subsequent operations. The need_calib flag should be set of the calib, calper and segtype parameters are desired in subsequent calls to pktchannelcalib_get. Note that the calib, calper and segtype values are obtained from the calibration table. The need_response flag should be set of the instrument response function is desired in subsequent calls to pktchannelcalib_get. A Response structure is returned in the *response pointer and this structure is obtained by reading and parsing the external response file referenced in the joined view of sensor->instrument. The need_site flag should be set if the site latitude, longitude and elevation are desired in subsequent calls to pktchannelcalib_get. These parameters are obtained from the site table.
pktchannelcalib_free frees all resources associated with a packet channel calib object.
pktchannelcalib_get is used to retrieve the parameters from either the cached values or from new database views. This switching is done automatically. The subject station-channel is specified through the SEED snet, ssta, schan and sloc codes. The sloc code can be set to a NULL string (not to a NULL pointer). Translation from SEED to css3.0 naming conventions for station-channel names is done automatically using the foreign(3) routines. The packet start time is specified by time which is used to form views and determine if cached views are no longer valid. The application programmer can control how often the database table files are checked for modification time with the check argument. If this argument is set, then the table modification times are determined, otherwise the table modification times are not determined (they are always determined when the database is first opened regardless of the check argument). This allows the application programmer to prevent excessive calls to the system stat(2) routine. The css3.0 station and channel codes are returned in sta and chan. The station latitude, longitude and elevation are returned in *lat, *lon and *elev (only if the need_site flag was set in pktchannelcalib_new). The instrument calib, calper and segtype are returned in *calib, *calib and segtype (only if the need_calib flag was set in pktchannelcalib_new). The instrument response function is returned in *response (only if the need_response flag was set in pktchannelcalib_new).
pktchannelcalib_get returns an integer bitmap that indicates which of the output values were successfully returned or -1 if there is an error. If there is an error, then messages are left on the error register. The bitmap masks for each returned value are as follows.