Main Page Class Hierarchy Compound List File List Compound Members File Members

# sudshead.h

Go to the documentation of this file.

    00001
    00002 /*
    00003  *   THIS FILE IS UNDER RCS - DO NOT MODIFY UNLESS YOU HAVE
    00004  *   CHECKED IT OUT USING THE COMMAND CHECKOUT.
    00005  *
    00006  *    $Id: sudshead_8h-source.html 2161 2006-05-19 16:55:03Z paulf $
    00007  *
    00008  *    Revision history:
    00009  *     $Log$
    00009  *     Revision 1.1  2006/05/19 16:55:02  paulf
    00009  *     first inclusion
    00009  *
    00010  *     Revision 1.2  2001/04/12 03:03:08  lombard
    00011  *     reorgainized to put the format-specific header items in *head.h
    00012  *     and the putaway-specific items in *putaway.h, of which there
    00013  *     currently is only sacputaway.h
    00014  *     Function protoypes used by putaway.c moved to pa_subs.h
    00015  *
    00016  *
    00017  *
    00018  */
    00019
    00020 #ifndef SUDSPUTAWAY_H
    00021 #define SUDSPUTAWAY_H
    00022 /*
    00023 // suds.h -- General include for SUDS library
    00024 */
    00025 #define _SUDS_VERSION "1.44"
    00026 /*
    00027 // Revision History:
    00028
    00029 // Version 1.31 - Thu 30-Jan-1992 11:19, RB
    00030 //    Added SUDS_INSTRUMENT structure and expanded datatype in SUDS_DESCRIPTRACE
    00031 //    and MUXDATA to include 12 bit unsigned, 12 bit signed, 16 unsigned and
    00032 //    16 bit signed data stored as short integers.
    00033
    00034 // Version 1.32 - 20-Aug-1992 RLB
    00035 //    Cleaned up considerably.
    00036
    00037 // Version 1.40 - 01-Oct-1992 RLB
    00038 //    Complete rebuild of I/O functions, overhaul of everything else.
    00039
    00040 // Version 1.41 - 21-Dec-1992 RLB
    00041 //    Fixed file access problems, added datatype '2', minor cleanup.
    00042
    00043 // Version 1.42 - 14-Feb-1993 RLB
    00044 //    Fixed problem when first struct in file has data following it.
    00045 //    Added suds_abs_pos( ) function and other minor cleanup.
    00046
    00047 // Version 1.43 02-Jun-1993, RLB
    00048 //    Fixed seek problems when working with multiple files.
    00049 //    Added suds_update( ) function.
    00050
    00051 // Version 1.44 23-Aug-1993, RLB
    00052 //    Added SUDS_CHANSET struct.
    00053
    00054 // Dec 1999, Tom Murray
    00055 //    Added #pragma pack's to correct padding of structures
    00056
    00057 //---------------------------------------------------------------------
    00058
    00059 //---------------------------------------------------------------------
    00060 // DEFINES
    00061
    00062 // Define code for type of machine suds is being compiled on.
    00063 // '6' is 80x86 machine
    00064 */
    00065 #define MACHINE         '6'
    00066
    00067 /* // Define symbols for missing data. */
    00068 #define NODATA          "-32767."
    00069 #define NOTIME          "-2147472000" /* // Dec 14, 1901 00:00 00 GMT, near largest long */
    00070 #define NOCHAR          "_"
    00071 #define NOSTRG          ""
    00072 #define NOLIST          "0"
    00073
    00074 /* // Integer defines for standard variable types */
    00075 #define CHR             1       /* // char 1 byte */
    00076 #define MIN             2       /* // char number 1 byte */
    00077 #define STR             3       /* // string */
    00078 #define BTS             4       /* // char 1 byte */
    00079 #define SHT             5       /* // short 2 bytes */
    00080 #define LNG             6       /* // long 4 bytes */
    00081 #define FLT             7       /* // float 4 bytes */
    00082 #define DBL             8       /* // double 8 bytes */
    00083 #define STI             9       /* // struct stat_ident 8 bytes */
    00084 #define STT             10      /* // st_time 4 bytes */
    00085 #define MST             11      /* // ms_time 8 bytes */
    00086 #define LLT             12      /* // lon_lat 8 bytes */
    00087 #define CAL             13      /* // struct calib 500 bytes */
    00088 #define CPX             14      /* // struct complex 16 bytes */
    00089 #define BTW             15      /* // unsigned short 2 bytes */
    00090
    00091 /* // Structure types or identifiers */
    00092 #define NO_STRUCT       0
    00093 #define STAT_IDENT      1
    00094 #define STRUCTTAG       2
    00095 #define TERMINATOR      3
    00096 #define EQUIPMENT       4
    00097 #define STATIONCOMP     5
    00098 #define MUXDATA         6
    00099 #define DESCRIPTRACE    7
    00100 #define LOCTRACE        8
    00101 #define CALIBRATION     9
    00102 #define FEATURE         10
    00103 #define RESIDUAL        11
    00104 #define EVENT           12
    00105 #define EV_DESCRIPT     13
    00106 #define ORIGIN          14
    00107 #ifdef ERROR
    00108 #undef ERROR   /* stupid NT */
    00109 #endif
    00110 #define ERROR           15
    00111 #define FOCALMECH       16
    00112 #define MOMENT          17
    00113 #define VELMODEL        18
    00114 #define LAYERS          19
    00115 #define COMMENT         20
    00116 #define PROFILE         21
    00117 #define SHOTGATHER      22
    00118 #define CALIB           23
    00119 #define COMPLEX         24
    00120 #define TRIGGERS        25
    00121 #define TRIGSETTING     26
    00122 #define EVENTSETTING    27
    00123 #define DETECTOR        28
    00124 #define ATODINFO        29
    00125 #define TIMECORRECTION  30
    00126 #define INSTRUMENT      31
    00127 #define CHANSET         32
    00128
    00129 #define TOTAL_STRUCTS   32
    00130
    00131 /* // Standard variable types redefined for portability and clarity */
    00132 /* //typedef void            VOID; */
    00133 typedef char            CHAR;   /* // A single ascii character */
    00134 typedef char            MINI;   /* // A 1 byte integer (0 to 255) */
    00135 typedef char            STRING; /* // A character string, null byte terminated */
    00136 typedef unsigned char   BITS8;  /* // An 8 bit field */
    00137 typedef unsigned short  BITS16; /* // A 16 bit field */
    00138 typedef short           SH_INT; /* // A 16 bit signed integer */
    00139 typedef long            LG_INT; /* // A 32 bit signed integer */
    00140 typedef float           FLOAT;  /* // A 32 bit floating point number, IEEE */
    00141 typedef double          DOUBLE; /* // A 64 bit double precision number, IEEE */
    00142 typedef struct {
    00143    FLOAT   fx;
    00144    FLOAT   fy;
    00145 } VECTOR;
    00146 typedef struct {
    00147    FLOAT   cr;
    00148    FLOAT   ci;
    00149 } COMPLEXX;
    00150 typedef struct {
    00151    DOUBLE  dr;
    00152    DOUBLE  di;
    00153 } D_COMPLEX;
    00154 typedef struct {
    00155    FLOAT   xx;
    00156    FLOAT   yy;
    00157    FLOAT   xy;
    00158 } TENSOR;
    00159 typedef LG_INT  ST_TIME;     /* // Stamp GMT time in seconds before or after Jan 1, */
    00160 /* //      1970, resolution is one second */
    00161 typedef DOUBLE  MS_TIME;     /* // GMT time in seconds before or after Jan 1, */
    00162 /* //      1970, resolution finer than microseconds */
    00163 typedef DOUBLE  LONLAT;      /* // Latitude or longitude in degrees, N and E positive */
    00164
    00165 /*
    00166 //---------------------------------------------------------------------
    00167 // STRUCTURE DEFINITIONS
    00168
    00169 // SUDS_FORM:  Information on each suds structure used for input from ascii,
    00170 //             output to ascii, loading or unloading the database, etc.
    00171
    00172 // antipadding
    00173 */
    00174 #pragma pack(1)
    00175
    00176 typedef struct {
    00177    LG_INT num;
    00178    STRING *meaning;
    00179 } SUDS_CODES;
    00180
    00181 typedef struct {
    00182   LG_INT  fstype;           /* // Structure types or identifiers */
    00183   STRING  *fname;           /* // Name used to identify structure item */
    00184   LG_INT  ftype;            /* // Type of variable in field */
    00185   LG_INT  flength;          /* // Length of variable in the field */
    00186   LG_INT  offset;           /* // Offset of variable pointer from beginning of */
    00187   /* // structure measured in bytes, where first byte */
    00188   /* // of structure=0. */
    00189   STRING  *initval;         /* // Value to initialize structure */
    00190   STRING  *fformat;         /* // Printf type format to read + write field */
    00191   LG_INT  nextfstype;       /* // If structure, this is fstype */
    00192 } SUDS_FORM;
    00193
    00194
    00195 /* // SUDS_STRUCTTAG:  Structure to identify structures when archived together */
    00196
    00197 #define ST_MAGIC   'S'       /* // magic character for sync in structtag */
    00198
    00199 typedef struct {
    00200   CHAR sync;                /* // The letter S. If not present, error exists. */
    00201   /* // Use to unscramble damaged files or tapes. */
    00202   CHAR machine;             /* // code for machine writing binary file for use */
    00203   /* // in identifying byte order and encoding. */
    00204   SH_INT id_struct;         /* // structure identifier: numbers defined above */
    00205   LG_INT len_struct;        /* // structure length in bytes for fast reading */
    00206   /* // and to identify new versions of the structure */
    00207   LG_INT len_data;          /* // length of data following structure in bytes */
    00208 } SUDS_STRUCTTAG;
    00209
    00210
    00211 /* // SUDS_STATIDENT:  Station identification. */
    00212
    00213 typedef struct {             /* // station component identifier */
    00214   STRING  network[4];       /* // network name */
    00215   STRING  st_name[5];       /* // name of station where equipment is located */
    00216   CHAR    component;        /* // component v,n,e */
    00217   SH_INT  inst_type;        /* // instrument type */
    00218 } SUDS_STATIDENT;
    00219
    00220
    00221 /* // SUDS_ATODINFO: Information on the A to D converter */
    00222
    00223 typedef struct {
    00224   SH_INT  base_address;     /* // base I/O address of this device */
    00225   SH_INT  device_id;        /* // device identifier */
    00226   BITS16  device_flags;     /* // device flags */
    00227   SH_INT  extended_bufs;    /* // number of extended buffers used */
    00228   SH_INT  external_mux;     /* // AtoD external mux control word */
    00229   CHAR    timing_source;    /* // AtoD timing source: i=internal, e=external */
    00230   CHAR    trigger_source;   /* // AtoD trigger source: i=internal, e=external */
    00231 } SUDS_ATODINFO;
    00232
    00233
    00234 /* // SUDS_CALIBRATION: Calibration information for a station component */
    00235
    00236 #define NOCALPTS 30
    00237
    00238 typedef struct {
    00239   COMPLEXX   pole;          /* // pole */
    00240   COMPLEXX   zero;          /* // zero */
    00241 } SUDS_CALIBR;
    00242
    00243 typedef struct {
    00244   SUDS_STATIDENT ca_name;   /* // station component identification */
    00245   FLOAT maxgain;            /* // maximum gain of calibration curve */
    00246   FLOAT normaliz;           /* // factor to multiply standard calib by to make */
    00247   /* // peak at given frequency=1 */
    00248   SUDS_CALIBR cal[NOCALPTS]; /* // calibration info */
    00249   ST_TIME   begint;         /* // time this calibration becomes effective */
    00250   ST_TIME   endt;           /* // time this calibration is no longer effective */
    00251 } SUDS_CALIBRATION;
    00252
    00253
    00254 /* // SUDS_COMMENT:  Comment tag to be followed by the bytes of comment */
    00255
    00256 typedef struct {
    00257   SH_INT   refer;           /* // structure identifier comment refers to */
    00258   SH_INT   item;            /* // item in structure comment refers to */
    00259   SH_INT   length;          /* // number of bytes in comment */
    00260    SH_INT   unused;
    00261 } SUDS_COMMENT;
    00262
    00263
    00264 /* // SUDS_CHANSET:  Associate station/components into sets. */
    00265
    00266 typedef struct {
    00267   SH_INT  type;             /* // Set type; 0=single channel(s), 1=orthogonal vector */
    00268   SH_INT  entries;          /* // Number of entries in set (these follow as data) */
    00269   STRING  network[4];       /* // Network name */
    00270   STRING  name[5];          /* // Set name */
    00271   ST_TIME active;           /* // Set is defined after this time */
    00272   ST_TIME inactive;         /* // Set is not defined after this time */
    00273 } SUDS_CHANSET;
    00274
    00275 /* // Entries of this form follow SUDS_CHANSET struct. */
    00276 typedef struct _CHANSETENTRY {
    00277   LG_INT  inst_num;         /* // Instrument serial number */
    00278   SH_INT  stream_num;       /* // Stream of instrument */
    00279   SH_INT  chan_num;         /* // Channel of stream */
    00280   SUDS_STATIDENT st;        /* // Station/component identifier */
    00281 } CHANSETENTRY;
    00282
    00283
    00284 /* // SUDS_DESCRIPTRACE:  Descriptive information about a seismic trace. */
    00285 /* //                     Normally followed by waveform. */
    00286
    00287 typedef struct {
    00288   SUDS_STATIDENT dt_name;   /* // station component identification */
    00289   MS_TIME begintime;        /* // time of first data sample */
    00290   SH_INT  localtime;        /* // minutes to add to GMT to get local time */
    00291   CHAR    datatype;         /* // s = 12 bit unsigned stored as short int, 0 to 4096, */
    00292   /* // q = 12 bit signed stored as short int, -2048 to 2048, */
    00293   /* // u = 16 bit unsigned stored as short int, 0 to 65536 */
    00294   /* // i = 16 bit signed stored as short int, -32767 to 32767, */
    00295   /* // 2 = 24 bit signed integer stored as long, */
    00296   /* // l = 32 bit signed integer stored as long, */
    00297   /* // r = 12 bit data, 4 lsb time stored as short int, */
    00298   /* // f = float (32 bit IEEE real), */
    00299   /* // d = double (64 bit IEEE real), */
    00300   /* // c = complex, */
    00301   /* // v = vector, */
    00302   /* // t = tensor */
    00303   CHAR    descriptor;       /* // g=good, t=telemetry noise, c=calibration, etc */
    00304   SH_INT  digi_by;          /* // agency code who digitized record; 0=original */
    00305   SH_INT  processed;        /* // processing done on this waveform */
    00306   LG_INT  length;           /* // number of samples in trace */
    00307   FLOAT   rate;             /* // samples per second */
    00308   FLOAT   mindata;          /* // minimum value of data (type s,l,f only) */
    00309   FLOAT   maxdata;          /* // maximum value of data (type s,l,f only) */
    00310   FLOAT   avenoise;         /* // average value of first 200 samples (type s,l,f only) */
    00311   LG_INT  numclip;          /* // number of clipped datapoints */
    00312   MS_TIME time_correct;     /* // time correction to be added to begintime */
    00313   FLOAT   rate_correct;     /* // rate correction to be added to rate */
    00314 } SUDS_DESCRIPTRACE;
    00315
    00316
    00317 /* // SUDS_DETECTOR:  Information on detector program being used */
    00318
    00319 typedef struct {
    00320   CHAR    dalgorithm;       /* // triggering algorithm: x=xdetect, m=mdetect */
    00321   /* // e=eqdetect */
    00322   CHAR    event_type;       /* // c=calibration, e=earthquake, E=explosion, */
    00323   /* // f=free run, n=noise, etc. */
    00324   CHAR    net_node_id[10];  /* // network node identification */
    00325   FLOAT   versionnum;       /* // software version number */
    00326   LG_INT  event_number;     /* // unique event number assigned locally. */
    00327   LG_INT  spareL;           /* // spare */
    00328 } SUDS_DETECTOR;
    00329
    00330
    00331 /* // SUDS_EQUIPMENT:  Equipment making up a station/component. Primarily used for */
    00332 /* //                  maintenance but may be referenced by researcher. One or more */
    00333 /* //                  structures exist for each piece of equipment making up a */
    00334 /* //                  station/component. */
    00335
    00336 typedef struct {
    00337   SUDS_STATIDENT this;      /* // identifier of this piece of equipment */
    00338   SUDS_STATIDENT previous;  /* // next piece of equipment toward sensor */
    00339   SUDS_STATIDENT next;      /* // next piece of equipment toward recorder */
    00340   STRING  serial[8];        /* // serial number */
    00341   SH_INT  model;            /* // model such as L4, HS10, etc. */
    00342   SH_INT  knob1;            /* // knob setting or series resistor value of Lpad */
    00343   SH_INT  knob2;            /* // knob setting or shunt  resistor value of Lpad */
    00344   SH_INT  reason;           /* // reason change was made */
    00345   FLOAT   frequency;        /* // sensor corner frequency, vco freq, transmitter */
    00346   /* // frequency, etc. */
    00347   ST_TIME effective;        /* // date/time these values became effective */
    00348 } SUDS_EQUIPMENT;
    00349
    00350
    00351 /* // SUDS_ERROR:  Error matrix */
    00352
    00353 typedef struct {
    00354   FLOAT   covarr[10];       /* // covariance matrix */
    00355 } SUDS_ERROR;
    00356
    00357
    00358 /* // SUDS_EVENT:  General information about an event. */
    00359
    00360 typedef struct {
    00361   SH_INT  authority;        /* // organization processing the data */
    00362   LG_INT  number;           /* // unique event number assigned by organization */
    00363   SH_INT  felt;             /* // number of felt reports */
    00364   CHAR    mintensity;       /* // maximum Modified Mercali Intensity */
    00365   CHAR    ev_type;          /* // e=earthquake, E=explosion, n=nuclear, */
    00366   /* // i=icequake, b=b_type, n=net, r=regional, */
    00367   /* // t=teleseism, c=calibration, n=noise */
    00368   CHAR    tectonism;        /* // observed u=uplift, s=subsidence, S=strikeslip */
    00369   /* // faulting, N=normal faulting, T=thrust */
    00370   CHAR    waterwave;        /* // seiche, tsunami, etc. */
    00371   CHAR    mechanism;        /* // t=thrust, s=strike-slip, n=normal, e=explosive */
    00372   CHAR    medium;           /* // medium containing explosion or event */
    00373   FLOAT   size;             /* // magnitude or pounds TNT for explosions */
    00374 } SUDS_EVENT;
    00375
    00376
    00377 /* // SUDS_EVENTSETTING:  Settings for earthquake trigger system */
    00378
    00379 typedef struct {
    00380   STRING  netwname[4];      /* // network name */
    00381   MS_TIME beginttime;       /* // time these values in effect */
    00382   SH_INT  const1;           /* // trigger constant 1 */
    00383   SH_INT  const2;           /* // trigger constant 2 */
    00384   SH_INT  threshold;        /* // trigger threshold */
    00385   SH_INT  const3;           /* // trigger constant 3 */
    00386   FLOAT   minduration;      /* // minimum duration for event */
    00387   FLOAT   maxduration;      /* // maximum duration for event */
    00388   CHAR    algorithm;        /* // triggering algorithm: x=xdetect, m=mdetect */
    00389   /* // e=eqdetect */
    00390   CHAR    spareK;           /* // spare */
    00391   SH_INT  spareI;           /* // spare */
    00392 } SUDS_EVENTSETTING;
    00393
    00394
    00395 /* // SUDS_EVDESCR:  Descriptive information about an event typically used for */
    00396 /* //                major, destructive earthquakes. This structure is typically */
    00397 /* //                associated with EVENT structure. */
    00398
    00399 typedef struct {
    00400   STRING  eqname[20];  /* // Popular name used to refer to this earthquake */
    00401   STRING  country[16]; /* // country of earthquake */
    00402   STRING  state[16];   /* // state, province or other political subdivision */
    00403   SH_INT  localtime;   /* // hours to add to GMT to get local time */
    00404    SH_INT  spareB;
    00405 } SUDS_EVDESCR;
    00406
    00407
    00408 /* // SUDS_FEATURE:  Observed phase arrival time, amplitude, and period. */
    00409
    00410 typedef struct {
    00411   SUDS_STATIDENT fe_name;   /* // station component identification */
    00412   SH_INT  obs_phase;        /* // observed phase code */
    00413   CHAR    onset;            /* // wave onset descriptor, i or e */
    00414   CHAR    direction;        /* // first motion: U,D,+,- */
    00415   SH_INT  sig_noise;        /* // ratio ampl. of first peak or trough to noise */
    00416   CHAR    data_source;      /* // i=interactive,a=automatic,r=rtp, or user code */
    00417   CHAR    tim_qual;         /* // timing quality given by analyst: 0-4, etc. */
    00418   /* //      n=ignore timing */
    00419   CHAR    amp_qual;         /* // amplitude quality given by analyst: 0-4, etc. */
    00420   /* //      n=ignor amplitude information */
    00421   CHAR    ampunits;         /* // units amplitude measured in: d=digital counts */
    00422   /* //      m=mm on develocorder, etc. */
    00423   SH_INT  gain_range;       /* // 1 or gain multiplier if gain range in effect */
    00424   MS_TIME time;             /* // phase time, x value where pick was made */
    00425   FLOAT   amplitude;        /* // peak-to-peak amplitude of phase */
    00426   FLOAT   period;           /* // period of waveform measured */
    00427   ST_TIME time_of_pick;     /* // time this pick was made */
    00428   SH_INT  pick_authority;   /* // organization processing the data */
    00429   SH_INT  pick_reader;      /* // person making this pick */
    00430 } SUDS_FEATURE;
    00431
    00432
    00433 /* // SUDS_FOCALMECH:  General information about a focal mechanism. */
    00434
    00435 typedef struct {
    00436   FLOAT   astrike;          /* // strike of plane a */
    00437   FLOAT   adip;             /* // dip of plane a */
    00438   FLOAT   arake;            /* // rake of plane a */
    00439   FLOAT   bstrike;          /* // strike of plane b */
    00440   FLOAT   bdip;             /* // dip of plane b */
    00441   FLOAT   brake;            /* // rake of plane b */
    00442   CHAR    prefplane;        /* // preferred plane a or b or blank */
    00443    CHAR    spareC[3];
    00444 } SUDS_FOCALMECH;
    00445
    00446 /* // SUDS_INSTRUMENT: Instrument hardware settings, mainly PADS related */
    00447 /* //                  added by R. Banfill, Jan 1991 */
    00448
    00449 typedef struct {
    00450   SUDS_STATIDENT in_name;   /* // Station component identification */
    00451   SH_INT  in_serial;        /* // Instrument serial number */
    00452   SH_INT  comps;            /* // Number of components recorded by instrument */
    00453   SH_INT  channel;          /* // Actual channel number on recorder */
    00454   CHAR    sens_type;        /* // Sensor type; a=accel, v=vel, d=disp... */
    00455   CHAR    datatype;         /* // see SUDS_DESCRIPTRACE.datatype */
    00456   LG_INT  void_samp;        /* // Invalid or void sample value */
    00457   FLOAT   dig_con;          /* // Digitizing constant (counts / volt) */
    00458   FLOAT   aa_corner;        /* // Anti-alias filter corner frequency (Hz) */
    00459   FLOAT   aa_poles;         /* // Anti-alias filter poles */
    00460   FLOAT   nat_freq;         /* // Transducer natural frequency (Hz) */
    00461   FLOAT   damping;          /* // Transducer damping coeff. */
    00462   FLOAT   mot_con;          /* // Transducer motion constant (volts / GMU) */
    00463   FLOAT   gain;             /* // Amplifier gain (dB) */
    00464   FLOAT   local_x;          /* // Local coordinate X (meters) */
    00465   FLOAT   local_y;          /* // Local coordinate Y (meters) */
    00466   FLOAT   local_z;          /* // Local coordinate Z (meters) */
    00467   ST_TIME effective;        /* // Time these setting took effect */
    00468   FLOAT   pre_event;        /* // Pre-event length (IST+pre_event=trigger time) */
    00469   SH_INT  trig_num;         /* // Trigger number on instrument */
    00470   STRING  study[6];         /* // Study name, used to insure unique station names */
    00471   SH_INT  sn_serial;        /* // Sensor serial number */
    00472 } SUDS_INSTRUMENT;
    00473
    00474 /* // SUDS_LAYERS:  Velocity layers. */
    00475
    00476 typedef struct {
    00477   FLOAT   thickness;        /* // thickness in kilometers */
    00478   FLOAT   pveltop;          /* // p velocity at top of layer */
    00479   FLOAT   pvelbase;         /* // p velocity at base of layer */
    00480   FLOAT   sveltop;          /* // s velocity at top of layer */
    00481   FLOAT   svelbase;         /* // s velocity at base of layer */
    00482   SH_INT  function;         /* // velocity function in layer: 0=constant, */
    00483   /* //    1=linear, 2=exponential, etc. */
    00484    SH_INT  spareF;
    00485 } SUDS_LAYERS;
    00486
    00487
    00488 /* // SUDS_LOCTRACE:  Location of trace. */
    00489
    00490 typedef struct {
    00491   SUDS_STATIDENT lt_name;   /* // station component identification */
    00492   STRING  *fileloc;         /* // pointer to pathname in file system */
    00493   STRING  *tapeloc;         /* // pointer to name of tape or offline storage */
    00494   LG_INT  beginloc;         /* // bytes from begining of file to trace */
    00495 } SUDS_LOCTRACE;
    00496
    00497
    00498 /* // SUDS_MOMENT:  Moment tensor information. */
    00499
    00500 typedef struct {
    00501   BITS8   datatypes;        /* // sum of: 1=polarities, 2=amplitudes, */
    00502   /* // 4=waveforms, etc. */
    00503   CHAR    constraints;      /* // solution constrained: d=deviatoric, */
    00504   /* // c=double couple */
    00505    CHAR    spareD[2];
    00506   FLOAT   sc_moment;        /* // scalar moment */
    00507   FLOAT   norm_ten[6];      /* // normalized moment tensor */
    00508 } SUDS_MOMENT;
    00509
    00510
    00511 /* // SUDS_MUXDATA:  Header for multiplexed data */
    00512
    00513 typedef struct {
    00514   STRING  netname[4];       /* // network name */
    00515   MS_TIME begintime;        /* // time of first data sample */
    00516   SH_INT  loctime;          /* // minutes to add to GMT to get local time */
    00517   SH_INT  numchans;         /* // number of channels: if !=1 then multiplexed */
    00518   FLOAT   dig_rate;         /* // samples per second */
    00519   CHAR    typedata;         /* // see SUDS_DESCRIPTRACE.datatype */
    00520   CHAR    descript;         /* // g=good, t=telemetry noise, c=calibration, etc */
    00521   SH_INT  spareG;           /* // spare */
    00522   LG_INT  numsamps;         /* // number of sample sweeps. Typically not known */
    00523   /* // when header is written, but can be added later */
    00524   LG_INT  blocksize;        /* // number of demultiplexed samples per channel if */
    00525   /* // data is partially demultiplexed, otherwise=0 */
    00526 } SUDS_MUXDATA;
    00527
    00528
    00529 /* // SUDS_ORIGIN: Information about a specific solution for a given event */
    00530
    00531 typedef struct {
    00532   LG_INT  number;           /* // unique event number assigned by organization */
    00533   SH_INT  authority;        /* // organization processing the data */
    00534   CHAR    version;          /* // version of solution within organization */
    00535   CHAR    or_status;        /* // processing status: f=final, a=automatic, etc */
    00536   CHAR    preferred;        /* // p=preferred location */
    00537   CHAR    program;          /* // name of processing program  h=hypo71, */
    00538   /* // l=hypolayer, i=isc, c=centroid, etc. */
    00539   CHAR    depcontrl;        /* // depth control: f=fixed, etc. */
    00540   CHAR    convergence;      /* // hypocentral convergence character */
    00541   LG_INT  region;           /* // geographic region code assigned locally */
    00542   MS_TIME orgtime;          /* // origin time */
    00543   LONLAT  or_lat;           /* // latitude, north is plus */
    00544   LONLAT  or_long;          /* // longitude, east is plus */
    00545   FLOAT   depth;            /* // depth in kilometers, + down */
    00546   FLOAT   err_horiz;        /* // horizontal error in km */
    00547   FLOAT   err_depth;        /* // vertical error in km */
    00548   FLOAT   res_rms;          /* // rms of residuals */
    00549   STRING  crustmodel[6];    /* // code for model used in this location */
    00550   SH_INT  gap;              /* // azimuthal gap in degrees */
    00551   FLOAT   nearstat;         /* // distance in km to nearest station */
    00552   SH_INT  num_stats;        /* // number of stations reporting phases */
    00553   SH_INT  rep_p;            /* // number of p phases reported */
    00554   SH_INT  used_p;           /* // number of p times used in the solution */
    00555   SH_INT  rep_s;            /* // number of s phases reported */
    00556   SH_INT  used_s;           /* // number of s times used in the solution */
    00557   SH_INT  mag_type;         /* // magnitude type: coda,tau,xmag ml,mb,ms,mw */
    00558   SH_INT  rep_m;            /* // number of magnitude readings reported */
    00559   SH_INT  used_m;           /* // number of magnitude readings used */
    00560   FLOAT   magnitude;        /* // magnitude value */
    00561   FLOAT   weight;           /* // average magnitude weight */
    00562   FLOAT   mag_rms;          /* // rms of magnitude */
    00563   ST_TIME effective;        /* // time this solution was calculated */
    00564 } SUDS_ORIGIN;
    00565
    00566
    00567 /* // SUDS_PROFILE:  Grouping of shotgathers by profile. */
    00568
    00569 typedef struct {
    00570    int junk1;
    00571   /* // What is your suggestion? */
    00572 } SUDS_PROFILE;
    00573
    00574
    00575 /* // SUDS_RESIDUAL:  Calculated residuals for arrival times, magnitudes, etc. */
    00576
    00577 typedef struct {
    00578   LG_INT  event_num;        /* // unique event number */
    00579   SUDS_STATIDENT re_name;   /* // station component identification */
    00580   SH_INT  set_phase;        /* // phase code set for this solution */
    00581   CHAR    set_tim_qual;     /* // timing quality assigned for this soln: 0-4 */
    00582   CHAR    set_amp_qual;     /* // amplitude quality assigned for this soln: 0-4 */
    00583   FLOAT   residual;         /* // traveltime residual or phase magnitude */
    00584   FLOAT   weight_used;      /* // weight used in this solution */
    00585   FLOAT   delay;            /* // delay time or station correction used */
    00586   FLOAT   azimuth;          /* // azimuth event to station, 0 north */
    00587   FLOAT   distance;         /* // distance in km event to station */
    00588   FLOAT   emergence;        /* // angle of emergence from source, 0=down,180=up */
    00589 } SUDS_RESIDUAL;
    00590
    00591
    00592 /* // SUDS_SHOTGATHER:  Grouping of waveforms by source event */
    00593
    00594 typedef struct {
    00595    int junk2;
    00596   /* // What is your suggestion? */
    00597 } SUDS_SHOTGATHER;
    00598
    00599
    00600 /* // SUDS_STATIONCOMP:  Generic station component information */
    00601
    00602 typedef struct {
    00603   SUDS_STATIDENT sc_name;   /* // station component identification */
    00604   SH_INT  azim;             /* // component azimuth clockwise from north */
    00605   SH_INT  incid;            /* // component angle of incidence from vertical */
    00606   /* //      0 is vertical, 90 is horizontal */
    00607   LONLAT  st_lat;           /* // latitude, north is plus */
    00608   LONLAT  st_long;          /* // longitude, east is plus */
    00609   FLOAT   elev;             /* // elevation in meters */
    00610   CHAR    enclosure;        /* // d=dam, n=nuclear power plant, v=underground */
    00611   /* //      vault, b=buried, s=on surface, etc. */
    00612   CHAR    annotation;       /* // annotated comment code */
    00613   CHAR    recorder;         /* // type device data recorded on */
    00614   CHAR    rockclass;        /* // i=igneous, m=metamorphic, s=sedimentary */
    00615   SH_INT  rocktype;         /* // code for type of rock */
    00616   CHAR    sitecondition;    /* // p=permafrost, etc. */
    00617   CHAR    sensor_type;      /* // sensor type: d=displacement, v=velocity, */
    00618   /* // a=acceleration, t=time code */
    00619   CHAR    data_type;        /* // see SUDS_DESCRIPTRACE.datatype */
    00620   CHAR    data_units;       /* // data units: d=digital counts, v=millivolts, */
    00621   /* // n=nanometers (/sec or /sec/sec) */
    00622   CHAR    polarity;         /* // n=normal, r=reversed */
    00623   CHAR    st_status;        /* // d=dead, g=good */
    00624   FLOAT   max_gain;         /* // maximum gain of the amplifier */
    00625   FLOAT   clip_value;       /* // +-value of data where clipping begins */
    00626   FLOAT   con_mvolts;       /* // conversion factor to millivolts: mv per counts */
    00627   /* //      0 means not defined or not appropriate */
    00628   /* // max_ground_motion=digital_sample*con_mvolts* */
    00629   /* // max_gain */
    00630   SH_INT  channel;          /* // a2d channel number */
    00631   SH_INT  atod_gain;        /* // gain of analog to digital converter */
    00632   ST_TIME effective;        /* // date/time these values became effective */
    00633   FLOAT   clock_correct;    /* // clock correction in seconds. */
    00634   FLOAT   station_delay;    /* // seismological station delay. */
    00635 } SUDS_STATIONCOMP;
    00636
    00637
    00638 /* // SUDS_TERMINATOR:  Structure to end a sequence of related structures when */
    00639 /* //                   loaded in a serial file or on a serial device. */
    00640
    00641 typedef struct {
    00642   SH_INT  structid;         /* // id for structure at beginning of this sequence */
    00643    SH_INT  spareA;
    00644 } SUDS_TERMINATOR;
    00645
    00646
    00647 /* // SUDS_TIMECORRECTION:  Time correction information. */
    00648
    00649 typedef struct {
    00650   SUDS_STATIDENT tm_name;   /* // time trace station id used to determine */
    00651   /* // correction. */
    00652   MS_TIME time_correct;     /* // time correction to be added to begintime */
    00653   FLOAT   rate_correct;     /* // rate correction to be added to rate */
    00654   CHAR    sync_code;        /* // synchronization code as follows: */
    00655   /* //   0 = total failure,   1 = 1 second synch, */
    00656   /* //   2 = 10 second synch, 3 = minute synch, */
    00657   /* //   4, 5 = successful decode. */
    00658   CHAR    program;          /* // program used to decode time: */
    00659   /* //   e = irige, c = irigc */
    00660   ST_TIME effective_time;   /* // time this correction was calculated */
    00661    SH_INT  spareM;
    00662 } SUDS_TIMECORRECTION;
    00663
    00664
    00665 /* // SUDS_TRIGGERS:  Earthquake detector trigger statistics */
    00666
    00667 typedef struct {
    00668   SUDS_STATIDENT tr_name;   /* // station component identification */
    00669   SH_INT  sta;              /* // short term average */
    00670   SH_INT  lta;              /* // long term average; pre_lta for xdetect */
    00671   SH_INT  abs_sta;          /* // short term absolute average */
    00672   SH_INT  abs_lta;          /* // long term absolute average */
    00673   SH_INT  trig_value;       /* // value of trigger level (eta) */
    00674   SH_INT  num_triggers;     /* // number of times triggered during this event */
    00675   MS_TIME trig_time;        /* // time of first trigger */
    00676 } SUDS_TRIGGERS;
    00677
    00678
    00679 /* // SUDS_TRIGSETTING:  Settings for earthquake trigger system */
    00680
    00681 typedef struct {
    00682   STRING  netwname[4];      /* // network name */
    00683   MS_TIME beginttime;       /* // time these values in effect */
    00684   SH_INT  const1;           /* // trigger constant 1 */
    00685   SH_INT  const2;           /* // trigger constant 2 */
    00686   SH_INT  threshold;        /* // trigger threshold */
    00687   SH_INT  const3;           /* // trigger constant 3 */
    00688   SH_INT  const4;           /* // trigger constant 4 */
    00689   SH_INT  wav_inc;          /* // weighted average increment */
    00690   FLOAT   sweep;            /* // trigger sweep time in seconds */
    00691   FLOAT   aperture;         /* // seconds for coincident station triggers */
    00692   CHAR    algorithm;        /* // triggering algorithm: x=xdetect, m=mdetect */
    00693   /* // e=eqdetect */
    00694   CHAR    spareJ;           /* // spare */
    00695   SH_INT  spareI;           /* // spare */
    00696 } SUDS_TRIGSETTING;
    00697
    00698
    00699 /* // SUDS_VELMODEL:  Velocity model */
    00700
    00701 typedef struct {
    00702   STRING  netname[4];       /* // network name */
    00703   STRING  modelname[6];     /* // model name */
    00704    CHAR    spareE;
    00705   CHAR    modeltype;        /* // p=profile A to B, a=area within corners A B */
    00706   LONLAT  latA;             /* // latitude of point A, north is plus */
    00707   LONLAT  longA;            /* // longitude of point A, east is plus */
    00708   LONLAT  latB;             /* // latitude of point B, north is plus */
    00709   LONLAT  longB;            /* // longitude of point B, east is plus */
    00710   ST_TIME time_effective;   /* // time this model was created */
    00711 } SUDS_VELMODEL;
    00712
    00713 /* //--------------------------------------------------------------------- */
    00714 /* // SUDS structure */
    00715
    00716 typedef struct _SUDS {
    00717    int type;
    00718    long data_len;
    00719    union {
    00720       SUDS_STATIDENT st;
    00721       SUDS_ATODINFO ad;
    00722       SUDS_CALIBRATION ca;
    00723       SUDS_COMMENT co;
    00724       SUDS_CHANSET cs;
    00725       SUDS_DESCRIPTRACE dt;
    00726       SUDS_DETECTOR de;
    00727       SUDS_EQUIPMENT eq;
    00728       SUDS_ERROR er;
    00729       SUDS_EVENT ev;
    00730       SUDS_EVENTSETTING es;
    00731       SUDS_EVDESCR ed;
    00732       SUDS_FEATURE fe;
    00733       SUDS_FOCALMECH fo;
    00734       SUDS_INSTRUMENT in;
    00735       SUDS_LAYERS la;
    00736       SUDS_LOCTRACE lo;
    00737       SUDS_MOMENT mo;
    00738       SUDS_MUXDATA mu;
    00739       SUDS_ORIGIN or;
    00740       SUDS_PROFILE pr;
    00741       SUDS_RESIDUAL re;
    00742       SUDS_SHOTGATHER sh;
    00743       SUDS_STATIONCOMP sc;
    00744       SUDS_TERMINATOR te;
    00745       SUDS_TIMECORRECTION tc;
    00746       SUDS_TRIGGERS tr;
    00747       SUDS_TRIGSETTING ts;
    00748       SUDS_VELMODEL vm;
    00749    } stype;
    00750 } SUDS;
    00751
    00752
    00753 /* // remove anti-padding */
    00754 /* // syntax may be wrong - might be #pragma pack instead */
    00755
    00756 #pragma pack()
    00757
    00758 /* //--------------------------------------------------------------------- */
    00759 /* // Function prototypes for SUDS library functions */
    00760
    00761 /* // Manifest constants ------------------------------------------------- */
    00762 #define SUDS_EOF      -1
    00763 #define SUDS_READONLY  1
    00764 #define SUDS_READWRITE 2
    00765 #define SUDS_APPEND    3
    00766 #define SUDS_CREATE    4
    00767
    00768 #ifndef TRUE
    00769 #define TRUE           1
    00770 #endif
    00771 #ifndef FALSE
    00772 #define FALSE          0
    00773 #endif
    00774
    00775 /* // Input / output functions ------------------------------------------- */
    00776 #ifndef _SUDS_IO_
    00777
    00778 /* // Open and close functions */
    00779 extern int suds_open( char *filespec, int mode );
    00780 extern int suds_close( int fd );
    00781
    00782 /* // Read functions */
    00783 extern int suds_read( int fd, SUDS *suds );
    00784 extern int suds_read_data( int fd, void *ptr, long len );
    00785
    00786 /* // Write functions */
    00787 extern int suds_write( int fd, SUDS *suds );
    00788 extern int suds_write_data( int fd, void  *ptr, long len );
    00789 extern int suds_update( int fd, SUDS *suds );
    00790 extern int suds_flush( int fd );
    00791
    00792 /* // Navigation functions */
    00793 extern long suds_pos( int fd );
    00794 extern long suds_abs_pos( int fd );
    00795 extern int suds_seek( int fd, long pos );
    00796 extern int suds_rewind( int fd );
    00797
    00798 /* // Retrieve error messages */
    00799 extern char *suds_get_err( void );
    00800
    00801 #endif
    00802
    00803 /* // Structure initialization ------------------------------------------- */
    00804 #ifndef _SUDS_INIT_
    00805
    00806 extern void suds_init( SUDS *suds );
    00807
    00808 #endif
    00809
    00810 /* // Time functions ----------------------------------------------------- */
    00811 #ifndef _SUDS_TIME_
    00812
    00813 extern double get_mstime( void );
    00814 extern double make_mstime( int year, int month, int day, int hour,
    00815                            int minute, double second );
    00816 extern int decode_mstime( double mstime, int *year, int *month, int *day,
    00817                           int *hour, int *minute, double *second );
    00818 extern char *list_mstime( double mstime, int format );
    00819 extern int yrday( int month, int day, int leap );
    00820 extern void mnday( int doy, int leap, int *month, int *day );
    00821 extern int isleap( int year, int cal );
    00822
    00823 #endif
    00824
    00825 /* //--------------------------------------------------------------------- */
    00826
    00827 #endif