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

# init_ewevent.c

Go to the documentation of this file.

    00001 /*
    00002  *   THIS FILE IS UNDER RCS - DO NOT MODIFY UNLESS YOU HAVE
    00003  *   CHECKED IT OUT USING THE COMMAND CHECKOUT.
    00004  *
    00005  *    $Id: init__ewevent_8c-source.html 2161 2006-05-19 16:55:03Z paulf $
    00006  *
    00007  *    Revision history:
    00008  *     $Log$
    00008  *     Revision 1.1  2006/05/19 16:55:02  paulf
    00008  *     first inclusion
    00008  *
    00009  *     Revision 1.3  2001/06/18 18:42:30  lucky
    00010  *     Changed Ml to ML
    00011  *
    00012  *     Revision 1.2  2001/06/06 20:54:46  lucky
    00013  *     Changes made to support multitude magnitudes, as well as amplitude picks. This is w
    00014  *     in progress - checkin in for the sake of safety.
    00015  *
    00016  *     Revision 1.1  2001/05/15 02:15:27  davidk
    00017  *     Initial revision
    00018  *
    00019  *     Revision 1.2  2001/04/17 17:49:28  lucky
    00020  *     *** empty log message ***
    00021  *
    00022  *     Revision 1.1  2000/12/18 18:55:12  lucky
    00023  *     Initial revision
    00024  *
    00025  *     Revision 1.6  2000/12/06 17:50:47  lucky
    00026  *     We now correctly keep track of the pick onset
    00027  *
    00028  *     Revision 1.5  2000/09/07 21:17:45  lucky
    00029  *     Final version after the Review pages have been demonstrated.
    00030  *
    00031  *     Revision 1.3  2000/08/30 17:41:57  lucky
    00032  *     InitEWEvent has been changed to include optional allocation of
    00033  *     pChanInfo space. This must be optional because GetEWEventInfo mallocs
    00034  *     space on the fly.
    00035  *
    00036  *     Revision 1.2  2000/08/30 14:56:28  lucky
    00037  *     pChanInfo will be allocated dynamically - no need to initialize
    00038  *     statically allocated pChanInfo structures any more.
    00039  *
    00040  *     Revision 1.1  2000/08/29 18:09:31  lucky
    00041  *     Initial revision
    00042  *
    00043  *
    00044  *
    00045  */
    00046
    00047
    00048 #include <stdio.h>
    00049 #include <stdlib.h>
    00050 #include <string.h>
    00051 #include <errno.h>
    00052 #include <sys/types.h>
    00053 #include <earthworm.h>
    00054 #include <ew_event_info.h>
    00055
    00056 /******************************************************************
    00057 *
    00058 * Initialize the EventInfo struct -- set everything to NULL.
    00059 *  Initialize the first chunk of pChan structs.
    00060 *
    00061 * WARNING!! This function uses the EW return codes not EWDB return codes!
    00062 *
    00063 ******************************************************************/
    00064 int             InitEWEvent (EWEventInfoStruct *pEventInfo)
    00065 {
    00066
    00067         int             i;
    00068
    00069         if (pEventInfo == NULL)
    00070         {
    00071                 logit ("", "Invalid arguments passed in\n");
    00072                 return EW_FAILURE;
    00073         }
    00074
    00075         pEventInfo->GotLocation = FALSE;
    00076         pEventInfo->GotTrigger = FALSE;
    00077
    00078         pEventInfo->iNumChans = 0;
    00079         pEventInfo->iNumMags = 0;
    00080         pEventInfo->iPrefMag = -10;
    00081         pEventInfo->iMd = -1;
    00082         pEventInfo->iML = -1;
    00083         memset (&pEventInfo->Event, 0, sizeof(EWDB_EventStruct));
    00084         memset (&pEventInfo->Mags, 0, MAX_MAGS_PER_ORIGIN * sizeof(EWDB_MagStruct));
    00085         memset (&pEventInfo->PrefOrigin, 0, sizeof(EWDB_OriginStruct));
    00086         memset (&pEventInfo->CoincEvt, 0, sizeof(EWDB_CoincEventStruct));
    00087
    00088
    00089         if ((pEventInfo->pChanInfo = (EWChannelDataStruct *) malloc
    00090                                 (INIT_NUM_CHANS * sizeof (EWChannelDataStruct))) == NULL)
    00091         {
    00092                 logit ("",  "Could not malloc %d pChanInfo entries.\n", INIT_NUM_CHANS);
    00093                 return  (EW_FAILURE);
    00094         }
    00095
    00096         pEventInfo->iNumAllocChans = INIT_NUM_CHANS;
    00097         for (i = 0; i < INIT_NUM_CHANS; i++)
    00098         {
    00099                 InitEWChan(&pEventInfo->pChanInfo[i]);
    00100         }
    00101
    00102         return EW_SUCCESS;
    00103
    00104 }  /* end InitEWEvent() */
    00105
    00106
    00107 /***********************************************************
    00108 *
    00109 * Initialize a single EWChannelDataStruct structure.
    00110 *
    00111 * WARNING!! This function uses the EW return codes not EWDB return codes!
    00112 *
    00113 ***********************************************************/
    00114 int     InitEWChan(EWChannelDataStruct *pChan)
    00115 {
    00116         int             i;
    00117
    00118         if (pChan == NULL)
    00119         {
    00120                 logit ("", "Invalid argument passed in.\n");
    00121                 return EW_FAILURE;
    00122         }
    00123
    00124         pChan->idChan = 0;
    00125         pChan->iNumArrivals = 0;
    00126         pChan->iNumStaMags = 0;
    00127         pChan->iNumTriggers = 0;
    00128         pChan->iNumWaveforms = 0;
    00129         pChan->bResponseIsValid = 0;
    00130
    00131         memset (&pChan->Station, 0, sizeof(EWDB_StationStruct));
    00132         memset (&pChan->ResponseInfo, 0, sizeof(EWDB_ChanTCTFStruct));
    00133
    00134         for (i = 0; i < MDPCPE; i++)
    00135         {
    00136                 memset (&pChan->Waveforms[i], 0, sizeof(EWDB_WaveformStruct));
    00137                 memset (&pChan->Arrivals[i], 0, sizeof(EWDB_ArrivalStruct));
    00138                 memset (&pChan->Stamags[i], 0, sizeof(EWDB_StationMagStruct));
    00139                 memset (&pChan->Triggers[i], 0, sizeof(EWDB_TriggerStruct));
    00140         }
    00141
    00142         return EW_SUCCESS;
    00143 }  /* end InitEWChan() */