source: trunk/src/seismic_processing/gmew/gm.h @ 8019

Revision 8019, 12.7 KB checked in by kevin, 3 months ago (diff)

Added Arias Intensity and ColorPGA option

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/*
2 *   THIS FILE IS UNDER RCS - DO NOT MODIFY UNLESS YOU HAVE
3 *   CHECKED IT OUT USING THE COMMAND CHECKOUT.
4 *
5 *    $Id$
6 *
7 *    Revision history:
8 *     $Log$
9 *     Revision 1.6  2009/08/25 00:10:40  paulf
10 *     added extraDelay parameter go gmew
11 *
12 *     Revision 1.5  2006/03/15 14:21:54  paulf
13 *     SCNL version of gmew v0.2.0
14 *
15 *     Revision 1.4  2001/07/18 19:41:36  lombard
16 *     Changed XMLDir, TempDir and MappingFile in GMPARAMS struct from string
17 *     arrays to string pointers. Changed gm_config.c and gm_util.c to support thes
18 *     changes. This solved a problem where the GMPARAMS structure was getting
19 *     corrupted when a pointer to it was passed into getGMFromTrace().
20 *     It's not clear why this was necessary; purify didn't complain.
21 *
22 *     Revision 1.3  2001/06/11 01:27:27  lombard
23 *     cleanup
24 *
25 *     Revision 1.2  2001/06/10 21:27:36  lombard
26 *     Changed single transport ring to input and output rings.
27 *     Added ability to handle multiple getEventsFrom commands.
28 *     Fixed handling of waveservers in config file.
29 *
30 *     Revision 1.1  2001/03/30 19:14:25  lombard
31 *     Initial revision
32 *
33 *
34 *
35 */
36/*
37 * gm.h
38 */
39
40#ifndef LM_H
41#define LM_H
42
43#include <earthworm.h>
44#include <mem_circ_queue.h>
45#include <trace_buf.h>
46#include <rw_strongmotionII.h>
47#include <trace_buf.h>
48#include <transfer.h>
49
50/* Various macros */
51/*                  Length of the component name including null terminator */
52#define GM_COMP_LEN 4
53/*                  Value to indicate no magnitude has been calculated */
54#define MAX_TRACE_SEC 600
55#define MAX_SAMPRATE 200
56
57#define EVENTID_SIZE 50
58#define GM_SM_LEN 600
59#ifndef PATH_MAX
60#define PATH_MAX 512
61#endif
62
63/*
64 * Description of a data gap.
65 * Note: if a gap would be declared at end of data, the data must be
66 * truncated instead of adding another GAP structure. A gap may be
67 * declared at the start of the data, however.
68 */
69typedef struct _GAP *PGAP;
70typedef struct _GAP
71{
72  double starttime;  /* time of first sample in the gap                      */
73  double gapLen;     /* time from first gap sample to first sample after gap */
74  long firstSamp;    /* index of first gap sample in data buffer             */
75  long lastSamp;     /* index of last gap sample in data buffer              */
76  PGAP next;         /* The next gap structure in the list                   */
77} GAP;
78
79/* Structure for keeping track of buffer of trace data */
80typedef struct _DATABUF
81{
82  double *rawData;   /* The raw trace data; native byte order                */
83  double *procData;  /* the processed data                                   */
84  double delta;      /* The nominal time between sample points               */
85  double starttime;  /* time of first sample in raw data buffer              */
86  double endtime;    /* time of last sample in raw data buffer               */
87  long nRaw;         /* number of samples in raw data buffer, including gaps */
88  long lenRaw;       /* length of the rawData array                          */
89  long nProc;        /* number of samples in processed data buffer           */
90  long lenProc;      /* length of one partition the procData array           */
91  long numProc;      /* number of partitions of the procData array           */
92  long padLen;       /* Number of padded samples due to convolution          */
93  GAP *gapList;      /* linked list of gaps in raw data                      */
94  int nGaps;         /* number of gaps found in raw data                     */
95} DATABUF;
96
97/* Macros for the three component directions */
98#define GM_E 0
99#define GM_N 1
100#define GM_Z 2
101
102typedef struct _SCNLPAR {
103  double fTaper[4];
104  double clipLimit;
105  double taperTime; 
106  char sta[TRACE_STA_LEN];
107  char comp[TRACE_CHAN_LEN];
108  char net[TRACE_NET_LEN];
109  char loc[TRACE_LOC_LEN];
110} SCNLPAR;
111
112/* The direction part of the component structure */
113typedef struct _COMP3
114{
115  double peakWinStart; /* starttime of peak-search window                  */
116  double peakWinEnd;  /* end time of peak-search window                    */
117  int BadBitmap;      /* bitmap to indicate why this component is bad      */
118  SCNLPAR *pSCNLPar;    /* parameters for this SCN                           */
119  char name[4];       /* The full 3-character component name               */
120  char loc[3];       /* The full 2-character location code                 */
121  double RSAPeakTime[SM_MAX_RSA];  /* Time of the peak RSA value, mising   *
122                                    * from the SM_INFO structure           */
123} COMP3;
124
125/*
126 * The non-directional part of the component structure;
127 *  zero or more per station.
128 */
129typedef struct _COMP1 *PCOMP1;
130typedef struct _COMP1
131{
132  COMP3 c3[3];        /* The three direction structures                   */
133  PCOMP1 next;         /* The next component in linked list; NULL if none */
134  char n2[GM_COMP_LEN];  /* First 2 chars of component name, the C in SCN */
135} COMP1;
136
137/* The station structure, one or more per event */
138typedef struct _STA
139{
140  double lat;         /* Station latitude; south is negative */
141  double lon;         /* Station longitude; west is negative */
142  double dist;        /* Epicentral distance in kilometers   */
143  double p_est;       /* Estimated P arrival                 */
144  double s_est;       /* Estimated S arrival                 */
145  COMP1 *comp;        /* List of components for this station */
146  char sta[TRACE_STA_LEN];     /* Station name, the S in SCN */
147  char net[TRACE_NET_LEN];     /* Network name, the N in SCN */
148} STA;
149
150/*
151 * The event structure, one per event. Note this structure holds only the
152 * information needed by the localmag module!
153 */
154typedef struct _EVT
155{
156  char eventId[EVENTID_SIZE];    /* The event ID string                      */
157  char authorId[AUTHOR_FIELD_SIZE]; /* The author ID string                  */
158  double origin_time; /* The origin time, seconds since midnight, 1 Jan 1970 */
159  double lat;         /* Hypocenter latitude; south is negative              */
160  double lon;         /* Hypocenter longitude; west is negative              */
161  double depth;       /* Hypocenter depth in kilometers                      */
162  STA *Sta;           /* Array of stations for this event                    */
163  int numSta;         /* Number of filled STA structures                     */
164} EVENT;
165 
166
167/* a link describing a singe wave_server */
168typedef struct _SERVER *PSERVER;
169typedef struct _SERVER {
170  char IPAddr[16];
171  char port[6];
172  PSERVER next;
173} SERVER;
174
175/* Description of all wave_servers */
176typedef struct _WS_ACCESS {
177  char *serverFile;      /* a file listing wave_servers     */
178  SERVER *pList;         /* the linked list of wave_servers */
179} WS_ACCESS;
180
181/* A link for SCNL selection */
182typedef struct _SCNLSEL *PSCNLSEL;
183typedef struct _SCNLSEL {
184  char sta[TRACE_STA_LEN];
185  char comp[TRACE_CHAN_LEN];
186  char net[TRACE_NET_LEN];
187  char loc[TRACE_LOC_LEN];
188  PSCNLSEL next;
189} SCNLSEL;
190
191/* Earthworm transport stuff for ground-motion */
192typedef struct _GMEW {
193  pid_t myPid;
194  long RingInKey;              /* key of transport ring for input    */
195  long RingOutKey;             /* key of transport ring for output   */
196  SHM_INFO InRegion;           /* shared memory region to use for i/o */
197  SHM_INFO OutRegion;          /* shared memory region to use for i/o */
198  QUEUE msgQ;
199  mutex_t Qmutex;
200  int nGetLogo;
201  MSG_LOGO *GetLogo;        /* array of logos to get */
202  MSG_LOGO hrtLogo;         /* heartbeat message logo */
203  MSG_LOGO errLogo;         /* error message logo */
204  MSG_LOGO gmLogo;          /* gmew message logo */
205  int terminate;
206  MSG_LOGO amLogo;          /* activate module message logo */
207  MSG_LOGO ha2kLogo;        /* HYPOARC2000 message logo */
208  MSG_LOGO threshLogo;      /* Thresh ALARM message logo */
209} GMEW;
210
211enum Version {vAll = -1, vPrelim, vRapid, vFinal};
212
213typedef struct _GMPARAMS {
214  double maxDist;         /* Maximum epicentral distance for a station       */
215  double peakSearchStart; /* Fraction of P - S to search for peak before S   */
216  double peakSearchStartMin; /* Minimum number of seconds to search before S */
217  double peakSearchEnd;   /* Fraction of P - S to search for peak after S    */
218  double peakSearchEndMin; /* Minimum numberr of seconds to search after S   */
219  double traceStart;      /* Seconds before P_est to start trace             */
220  double traceEnd;        /* Seconds after S_est to end trace                */
221  double snrThresh;       /* Signal-to-noize ratio threshold to pick amps    */
222  SCNLSEL *pAdd;           /* SCN selections lists                            */
223  SCNLSEL *pDel;           /* SCN deletion lists                              */
224  SCNLPAR *pSCNLPar;        /* Array of SCN parameter structures               */
225  WS_ACCESS *pWSV;        /* wave_server access information                  */
226  GMEW *pEW;              /* Earthworm transport structure                   */
227  long maxTrace;          /* Maximum number of trace data points             */
228  int debug;              /* debug level                                     */
229  int HeartBeatInterval;  /* Earthworm heartbeat interval in seconds         */
230  int maxSCNLPar;          /* How many SCN parameter entries allocated        */
231  int maxSta;             /* How many stations to use                        */
232  int numSCNLPar;          /* Number of SCNL parameter entries used            */
233  int respSource;         /* Where to get response information               */
234  int saveTrace;          /* whether and how to save synthetic traces        */
235  int staLoc;             /* Where to find station locations                 */
236  int traceSource;        /* source for trace data                           */
237  int wsTimeout;          /* wave_server timeout in milliseconds             */
238  int waitTime;          /* time to wait before hitting wave_server after arc message received */
239  enum Version LookAtVersion; /* Which version to look at, default is vAll */
240  char *eventID;          /* event ID, for accessing event from EW databese  */
241  char *respDir;          /* directory for response files, if needed         */
242  char *respNameFormat;   /* format of response filename                     */
243  char *sacOutDir;        /* Where to write SAC output files                 */
244  char *saveNameFormat;   /* format ground-motion saved file names           */
245  char *saveDirFormat;    /* format string for SAC output directory          */
246  char *staLocFile;       /* station location filename, if needed            */
247  char *TempDir;
248  char *XMLDir;
249  char *MappingFile;
250  int alarmDuration;     /* when activated by alarm, use this duration for snapshot */
251  int allowDuplicates;   /* set to 1 to allow duplicate SCNL's, otherwise just first location code gets reported */
252  int sendActivate;      /* set to 1 to send ACTIVATE messages when XML completes */
253  int threshDuration;    /* when activated by threshold, use this duration for snapshot */
254  long preTriggerSeconds;  /* Used to compute start time, P and S           */
255  char ChannelNumberMap[5];     /* map channel numbers to GM_ orientation codes */
256  int  ariasIntensity;   /* set to 1 to calculate the arias intensity */
257} GMPARAMS;
258
259#define GM_UNDEF -1
260
261/* Trace Source */
262/*                Wave_serverV         */
263#define GM_TS_WS   11
264#ifdef EWDB
265/*                Earthworm Database   */
266#define GM_TS_EWDB 12
267#endif
268
269
270/* Station Location Source */
271/*                Hyp2000 station file */
272#define GM_SL_HYP  21
273#ifdef EWDB
274/*                Earthworm Database   */
275#define GM_SL_EWDB 22
276#endif
277
278/* Instrument Response Source */
279#ifdef EWDB
280/*                Earthworm Database   */
281#define GM_RS_EWDB 31
282#endif
283/*                SAC file on other directory */
284#define GM_RS_FILE 33
285
286/* Save ground-motion Traces */
287/*                Don't Save                  */
288#define GM_ST_NO   41
289/*                Save in SAC files           */
290#define GM_ST_SAC  42
291
292/* Debug options */
293/*                trace/search and estimated arrival times */
294#define GM_DBG_TIME  1<<0
295/*                SCN selection */
296#define GM_DBG_SEL   1<<1
297/*                ws_client debug */
298#define GM_DBG_WSC   1<<4
299/* Keep the following three aligned with debug settings in transfer.h */
300/*                response poles, zeros, gain */
301#define GM_DBG_PZG   1<<5
302/*                trial response function */
303#define GM_DBG_TRS   1<<6
304/*                actual response function */
305#define GM_DBG_ARS   1<<7
306/*                input and output traces */
307#define GM_DBG_TRC   1<<8
308
309/* Bad Bits: used to indicate why a component trace should not be used */
310/*                        Trace is clipped and clipping is not allowed */
311#define GM_BAD_CLIP  1<<0
312/*                       Trace has a gap within the peak-search window */
313#define GM_BAD_GAP   1<<1
314/*             Trace has insufficient event signal for pre-event noise */
315#define GM_LOW_SNR   1<<2
316
317/* Function prototypes */
318int send_gm( SM_INFO *, GMEW * );
319int Configure( GMPARAMS *, int, char **, EVENT *, char *);
320
321
322#endif
Note: See TracBrowser for help on using the repository browser.