source: SH_SHM/trunk/source/seed_io/seedcfg.h @ 45

Revision 45, 16.3 KB checked in by marcus, 15 years ago (diff)

r30 | svn | 2008-02-23 23:36:22 +0100 (Sa, 23 Feb 2008) | 1 line

read output file of ingres database

Line 
1
2/* file seedcfg.h
3 *      =========
4 *
5 * $Revision: 30 $, $Date: 2008-02-23 23:36:22 +0100 (Sa, 23 Feb 2008) $
6 *
7 * SEED basic constants and types
8 * K. Stammler, 25-Dec-93
9 */
10
11
12#ifndef __TCUSRDEF
13#include BC_TCUSRDEF
14#endif
15
16
17/* temporary */
18/* #define err_writemsg(a,b,c) printf("status %d\n",a) */
19
20
21
22
23/*
24 * error codes
25 * -----------
26 */
27
28#define SeedERR_OFFSET       7000
29#define SeedERR_OPENINPUT    (SeedERR_OFFSET+1)   /* error opening input file */
30#define SeedERR_NOSETUP      (SeedERR_OFFSET+2)   /* no setup file read */
31#define SeedERR_EOF_FOUND    (SeedERR_OFFSET+3)   /* EOF found */
32#define SeedERR_ILLSTREAM    (SeedERR_OFFSET+4)   /* illegal stream name */
33#define SeedERR_NOTIMELIST   (SeedERR_OFFSET+5)   /* no time list specified */
34#define SeedERR_TWLOVFL      (SeedERR_OFFSET+6)   /* too many time lists */
35#define SeedERR_TWLLTH       (SeedERR_OFFSET+7)   /* time list too long */
36#define SeedERR_ILLTWL       (SeedERR_OFFSET+8)   /* illegal time window */
37#define SeedERR_STREAMOVFL   (SeedERR_OFFSET+9)   /* too many streams */
38#define SeedERR_ILLRECSIZE   (SeedERR_OFFSET+10)  /* illegal record size */
39#define SeedERR_SFD_READ     (SeedERR_OFFSET+11)  /* error reading sfd-file */
40#define SeedERR_SFD_NOTFOUND (SeedERR_OFFSET+12)  /* stream not found in sfd */
41#define SeedERR_SFD_NEXT     (SeedERR_OFFSET+13)  /* next file returned */
42#define SeedERR_CHAN_OOR     (SeedERR_OFFSET+14)  /* SEED channel out of range*/
43#define SeedERR_STROVFL      (SeedERR_OFFSET+15)  /* string overflow */
44#define SeedERR_SEEDREAD     (SeedERR_OFFSET+16)  /* read error on SEED file */
45#define SeedERR_SEEDSEEK     (SeedERR_OFFSET+17)  /* seek error on SEED file */
46#define SeedERR_BUG          (SeedERR_OFFSET+18)  /* program bug */
47#define SeedERR_NOT_OPEN     (SeedERR_OFFSET+19)  /* channel not opened */
48#define SeedERR_TIMEGAP      (SeedERR_OFFSET+20)  /* time gap */
49#define SeedERR_OPENOUTPUT   (SeedERR_OFFSET+21)  /* error opening outp. file */
50#define SeedERR_SEEDWRITE    (SeedERR_OFFSET+22)  /* error writing SEED file */
51#define SeedERR_ZEROLTH      (SeedERR_OFFSET+23)  /* zero length trace quested*/
52#define SeedERR_NEXTTIMEPOS  (SeedERR_OFFSET+24)  /* next possible time positioned */
53#define SeedERR_DOUBLEDATA   (SeedERR_OFFSET+25)  /* double data in SEED file */
54#define SeedERR_DATA_UNAVAIL (SeedERR_OFFSET+26)  /* data not available */
55#define SeedERR_ILLCUT       (SeedERR_OFFSET+27)  /* illegal cut command */
56#define SeedERR_DECODE_ERR   (SeedERR_OFFSET+28)  /* error decoding record */
57#define SeedERR_READ_LOOKUP  (SeedERR_OFFSET+29)  /* error reading CD lookup */
58#define SeedERR_ILL_COMPRS   (SeedERR_OFFSET+30)  /* illegal compression */
59#define SeedERR_NOCALIB      (SeedERR_OFFSET+31)  /* no calibration gain found */
60
61
62
63/*
64 * constants
65 * ---------
66 */
67
68#define Seed_C_SHORTSTRLTH 7
69#define Seed_C_SFDLINELTH 512
70#define Seed_C_MAX_RECLTH 8192
71
72/* set flags for setup parameters */
73#define Seed_F_SET_MAX_NO_OF_STREAMS      0x00000001L
74#define Seed_F_SET_MAX_NO_OF_TWL          0x00000002L
75#define Seed_F_SET_MAX_LTH_OF_TWL         0x00000004L
76#define Seed_F_SET_PHYS_REC_SIZE          0x00000008L
77#define Seed_F_SET_SEED_REC_SIZE          0x00000010L
78#define Seed_F_SET_NEW_SEED_NAMES         0x00000020L
79#define Seed_F_SET_DUMP_ILL_RECS          0x00000040L
80#define Seed_F_SET_EOM_EOF_CNT            0x00000080L
81#define Seed_F_SET_MAX_ERRCNT_ILLEGAL     0x00000100L
82#define Seed_F_SET_MAX_ERRCNT_INCOMPLETE  0x00000200L
83#define Seed_F_SET_MAX_ERRCNT_READERR     0x00000400L
84#define Seed_F_SET_COPY_BUF_LTH           0x00000800L
85
86#define Seed_C_ILLEGAL -1
87
88/* SEED data record activity flags */
89#define Seed_F_ACT_CALIBRATION            0x01
90#define Seed_F_ACT_TIMECORRAPP            0x02
91#define Seed_F_ACT_TRIGSTART              0x04
92#define Seed_F_ACT_TRIGEND                0x08
93#define Seed_F_ACT_PLEAP                  0x10
94#define Seed_F_ACT_NLEAP                  0x20
95#define Seed_F_ACT_EVENT                  0x40
96
97/* SEED data record I/O flags */
98#define Seed_F_IO_PARITY                  0x01
99#define Seed_F_IO_LONGREC                 0x02
100#define Seed_F_IO_SHORTREC                0x04
101#define Seed_F_IO_SERIESSTART             0x08
102#define Seed_F_IO_SERIESEND               0x10
103#define Seed_F_IO_CLOCKLOCKED             0x20
104
105/* SEED data record quality flags */
106#define Seed_F_QUAL_SATURATED             0x01
107#define Seed_F_QUAL_CLIPPED               0x02
108#define Seed_F_QUAL_SPIKES                0x04
109#define Seed_F_QUAL_GLITCHES              0x08
110#define Seed_F_QUAL_MISSING_PADDED        0x10
111#define Seed_F_QUAL_SYNCERR               0x20
112#define Seed_F_QUAL_FILTERCHARGING        0x40
113#define Seed_F_QUAL_TIMETAG               0x80
114/* private flag */
115#define Seed_F_QUAL_NOCALIB               0x1000
116#define Seed_F_QUAL_DATA_LOCKED           0x2000
117
118/* SeedNextStream modes */
119#define Seed_C_NSM_RESET 0
120#define Seed_C_NSM_NEXT_STREAM 1
121#define Seed_C_NSM_NEXT_SELECTED 2
122#define Seed_C_NSM_TOTAL_NUMBER 3
123
124#define Seed_C_MAXCHAN 10
125
126/* Steim1 compression format */
127#define Seed_C_FRAMELTH 64     /* frame length in bytes */
128#define Seed_C_MAXFRAMESMP 120 /* maximum number of samples/frame */
129#define Seed_C_FRAMEDIFFS 16   /* number of difference longwords in one frame */
130
131/* SFD file item identification characters */
132#define Seed_C_SfdTStart 'b'
133#define Seed_C_SfdTEnd   'e'
134#define Seed_C_SfdName   'n'
135#define Seed_C_SfdRecno  'r'
136#define Seed_C_SfdStream 's'
137#define Seed_C_SfdCalib  'c'
138#define Seed_C_SfdSwapH  'h'
139#define Seed_C_SfdOffset 'o'
140#define Seed_C_SfdReclth 'l'
141#define Seed_C_SfdAddinf 'a'
142
143/* return values to stream selection requests */
144#define Seed_C_IsSelected 0
145#define Seed_C_TimeNotSelected 1
146#define Seed_C_StreamNotSelected 2
147
148/* data compression types for blockette 1000 */
149#define Seed_C_DcmpSteim1 10
150#define Seed_C_DcmpSteim2 11
151
152/* length of netcode and locid together */
153#define Seed_C_AddinfLth 4
154#define Seed_C_EmptyAddinfStr "...."
155
156/* data formats (should not be here ...) */
157#define Seed_C_FORMAT_MSEED 1
158
159
160
161/*
162 * types
163 * -----
164 */
165
166#define SeedSbyteT signed char
167
168typedef struct {
169        char      setupfile[BC_FILELTH+1]; /* name of setup file */
170        int       max_no_of_streams;    /* maximum number of streams */
171        int       max_no_of_twl;        /* maximum number of time window lists */
172        int       max_lth_of_twl;       /* maximum length of a time window list */
173        int       phys_rec_size;        /* physical record size in bytes */
174        int       seed_rec_size;        /* SEED record size */
175        int       seed_phys_recs;       /* physical records per SEED records */
176        BOOLEAN   new_seed_names;       /* use new names for SEED files (with "_") */
177        BOOLEAN   dump_ill_recs;        /* dump unknown records to file */
178        int       eom_eof_cnt;          /* number of consecutive EOF's for EOM */
179        int       max_errcnt_illegal;   /* maximum number of illegal records */
180        int       max_errcnt_incomplete;/* maximum number of incomplete records */
181        int       max_errcnt_readerr;   /* maximum number of read errors */
182        long      copy_buf_lth;         /* length of copy SEED buffer (in long's) */
183} SeedSetupParT;
184
185/* stream identifier */
186typedef struct {
187        char     array[Seed_C_SHORTSTRLTH+1];      /* array name or "none" */
188        char     station[Seed_C_SHORTSTRLTH+1];    /* station name */
189        char     channel[Seed_C_SHORTSTRLTH+1];    /* channel name, e.g. VBB */
190        char     comp;                             /* component */
191} SeedStreamT;
192
193/* time type */
194typedef TIME SeedTimeT;
195
196/* time window lists */
197typedef struct {
198        SeedTimeT    *tw_begin;      /* start of time window */
199        SeedTimeT    *tw_end;        /* end of time window */
200        int          twl_length;     /* length of list */
201} SeedTwlT;
202
203/* SEED file descriptor */
204typedef struct {
205        char     stream[BC_SHORTSTRLTH+1];  /* stream string */
206        char     t_start[BC_TIMELTH+1];     /* start time of file */
207        char     t_end[BC_TIMELTH+1];       /* end time of file */
208        char     name[BC_FILELTH+1];        /* file name */
209        char     sfdfile[BC_FILELTH+1];     /* corresponding sfd-file */
210        int      recno;                     /* number of SEED records in file */
211        int      ufd;                       /* UNIX file descr. or Seed_C_ILLEGAL */
212        int      pos;                       /* current read position in records */
213        int      sample;                    /* sample position in record */
214        float    calib;                     /* calibration of channel */
215        int      dataflags;                 /* flags set on data Seed_F_QUAL_... */
216        BOOLEAN  swap_hdr;                  /* swap header after read */
217        int      reclth;                    /* SEED file record length */
218        int      byteoff;                   /* byte offset in SEED file */
219        int      pri;                       /* priority of entry */
220        int      dataformat;                /* data format ID */
221        char     addinf[Seed_C_AddinfLth+1];/* netcode+locid */
222} SeedFileDescrT;
223
224#define UBYTE unsigned char
225#define WORD  short
226#define UWORD unsigned short
227#define INT32 int
228#define UINT32 unsigned int
229
230typedef struct {
231    UWORD year ;             /* e.g. 1991 */
232    UWORD day ;              /* 1..366 */
233    UBYTE hours ;            /* 0..23 */
234    UBYTE minutes ;          /* 0..59 */
235    UBYTE seconds ;          /* 0..59, 60 for leap */
236    UBYTE alignment_1 ;
237    UWORD frac_secs ;           /* 0.0001 seconds, 0..9999 */
238} SeedBtimeT ;
239
240typedef struct {
241        char   seqno[6];                      /* sequence number */
242        char   indicator;                     /* type of record */
243        char   Reserved_bytes_A;              /* not used */
244        char   statcode[5];                   /* station name */
245        char   locid[2];                      /* location identifier */
246        char   channel[3];                    /* channel */
247        char   network[2];                    /* network code */
248        SeedBtimeT  starttime;                /* start time of record */
249        UWORD  no_of_samples;                 /* number of samples in record */
250        WORD   smprate_fact;                  /* sample rate factor */
251        WORD   smprate_mult;                  /* sample rate multiplier */
252        UBYTE  activity;                      /* activity flags */
253        UBYTE  ioflags;                       /* IO flags */
254        UBYTE  quality;                       /* data quality flags */
255        UBYTE  no_of_blockettes;              /* number of blockettes to follow */
256        INT32  timecorr;                      /* time correction in ms */
257        UWORD  databegin;                     /* beginning of data */
258        UWORD  first;                         /* first blockette */
259} SeedDataHeaderT;
260
261
262typedef struct {
263        UWORD  type;                          /* blockette type (1000) */
264        WORD   nextblock;                     /* byte number of next blockette */
265        UBYTE  format;                        /* encoding format */
266        UBYTE  wordorder;                     /* word order */
267        UBYTE  reclthexp;                     /* record length (power of 2) */
268        UBYTE  reserved;                      /* not used */
269} SeedBlockette1000T;
270
271typedef struct {
272        UWORD  type;                          /* blockette type (1001) */
273        WORD   nextblock;                     /* byte number of next blockette */
274        UBYTE  timequal;                      /* time quality */
275        UBYTE  reserved;                      /* ... */
276} SeedBlockette1001T;
277
278
279/* SeedDecodeSteim1 can also read Steim2 */
280#define SeedDecodeSteim SeedDecodeSteim1
281
282
283/*
284 * prototypes
285 * ----------
286 */
287
288/*--------------------------------------------------------------------*/
289
290
291void SeedReadSetupFile( char fname[], STATUS *status );
292
293/* Reads setup file (file containing basic constants) of SEED
294 * processing.  Parameters are read to seedv_setup structure.
295 *
296 * parameters of routine
297 * char       fname[];        input; name of setup file
298 * STATUS     *status;        output; return status
299 */
300
301
302/*--------------------------------------------------------------------*/
303
304
305void SeedChangeSetup( SeedSetupParT *par, long setflags, STATUS *status );
306
307/* Changes setup values.  Only these values are copied whose setup-bit
308 * is set in 'setflags'.
309 *
310 * parameters of routine
311 * SeedSetupParT *par;          input; new values of setup parameters
312 * long          setflags;      input; setup flags (Seed_F_SET_... - Bits)
313 * STATUS        *status;       output; return status
314 */
315
316
317/*--------------------------------------------------------------------*/
318
319
320void SeedSetup( SeedSetupParT *setup, STATUS *status );
321
322/* Gets setup file.
323 *
324 * parameters of routine
325 * SeedSetupParT *setup;     output; SEED setup
326 * STATUS     *status;       output; return status
327 */
328
329
330/*--------------------------------------------------------------------*/
331
332
333void SeedSetupF( STATUS *status );
334
335/* Fortran interface to SeedSetup.
336 *
337 * parameters of routine
338 * STATUS     *status;       output; return status
339 */
340
341
342/*--------------------------------------------------------------------*/
343
344
345void SeedInitialize( STATUS *status );
346
347/* Allocates memory for stream lists and time window lists.
348 * Routine SeedReadSetupFile must be called before.
349 *
350 * parameters of routine
351 * STATUS     *status;      output; return status
352 */
353
354
355/*--------------------------------------------------------------------*/
356
357
358void SeedFinish( void );
359
360/* Frees memory of time lists and stream lists
361 *
362 * no parameters
363 */
364
365
366/*--------------------------------------------------------------------*/
367
368
369void SeedReadSelections( char fname[], STATUS *status );
370
371/* Reads selections of streams and time windows from
372 * given file.
373 *
374 * parameters of routine
375 * char       fname[];        input; name of setup file
376 */
377
378
379/*--------------------------------------------------------------------*/
380
381
382void SeedPrintSelections( void );
383
384/* Prints selections read by SeedReadSelections to standard output
385 *
386 * no parameters
387 */
388
389
390/*--------------------------------------------------------------------*/
391
392
393void SeedGetSetup( SeedSetupParT *setup );
394
395/* Returns SEED setup parameters.  The values are copied to a passed
396 * structure.  Changes to the parameters are not possible.
397 *
398 * parameters of routine
399 * SeedSetupParT *setup;     output; setup parameters
400 */
401
402
403/*--------------------------------------------------------------------*/
404
405
406BOOLEAN SeedIsSelected( SeedStreamT *str, char timestr[], STATUS *status );
407
408/* Checks whether specified stream and time is in selection list
409 *
410 * parameters of routine
411 * SeedStreamT   *str;        input; stream to check
412 * SeedTimeT     *time;       input; time to check
413 * STATUS        *status;     output; return status
414 */
415
416
417/*--------------------------------------------------------------------*/
418
419
420BOOLEAN SeedWindowIsSelected( SeedStreamT *str, char t_start[],
421        char t_end[], STATUS *status );
422
423/* Checks whether specified time window is selected on any stream.
424 *
425 * parameters of routine
426 * SeedStreamT   *str;        input; stream to check
427 * char          t_start[];   input; start of time window
428 * char          t_end[];       input; time to check
429 * STATUS        *status;     output; return status
430 */
431
432
433/*--------------------------------------------------------------------*/
434
435
436int SeedNextStream( int mode );
437
438/* Returns index next stream or next selected stream depending on 'mode'
439 * Possible values of 'mode' are:
440 *    Seed_C_NSM_RESET:           start new list, returns illegal value
441 *    Seed_C_NSM_NEXT_STREAM:     next stream, whether or not selected
442 *    Seed_C_NSM_NEXT_SELECTED:   next selected stream
443 *    Seed_C_NSM_TOTAL_NUMBER:    total number of streams
444 * If no more stream is available, Seed_C_ILLEGAL is returned
445 *
446 * parameters of routine
447 * int        mode;            input; controls returned value
448 *                             returns requested stream index
449 */
450
451
452/*--------------------------------------------------------------------*/
453
454
455int SeedIdentifyStreamString( char str[] );
456
457/* Returns stream index.  'str' is stream string like "bfo-vbb-z".
458 *
459 * parameters of routine
460 * char       str[];           input; stream string
461 *                             returns stream index or Seed_C_ILLEGAL
462 */
463
464
465/*--------------------------------------------------------------------*/
466
467
468void SeedGetStreamString( int stream_idx, char str[] );
469
470/* Returns tream string from stream index.  'str' must be long
471 * enough, i.e. 2*Seed_C_SHORTSTRLTH+3+1.
472 *
473 * parameters of routine
474 * int        stream_idx;      input; stream index number
475 * char       str[];           output; stream string
476 */
477
478
479/*--------------------------------------------------------------------*/
480
481
482void SeedPrepareStreamString( char str[] );
483
484/* replaces the characters "-","/","_" by blanks in given string
485 *
486 * parameters of routine
487 * char       str[];        modify; string to be modified
488 */
489
490
491/*--------------------------------------------------------------------*/
Note: See TracBrowser for help on using the repository browser.