Changeset 3212


Ignore:
Timestamp:
12/27/07 13:05:23 (11 years ago)
Author:
paulf
Message:

sync from hydra_proj circa Oct 2007

Location:
trunk/src/seismic_processing/glass/src
Files:
4 added
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/seismic_processing/glass/src/lib/array.h

    r2058 r3212  
    33#define ARRAY_H 
    44 
    5 #define MAX_ARRAY       1000 
     5#define MAX_ARRAY       100000 
    66class CArray { 
    77public: 
  • trunk/src/seismic_processing/glass/src/lib/opcalc.h

    r2174 r3212  
    107107_OPCALC_SO_EXPORT  void   OPCalc_SetTravelTimePointer(ITravelTime * pTravTime); 
    108108_OPCALC_SO_EXPORT  int    OPCalc_CalculateOriginPickParams(PICK * pPick, ORIGIN * pOrg); 
     109_OPCALC_SO_EXPORT  int    OPCalc_ProcessOrigin(ORIGIN * pOrg, PICK ** pPick, int nPck); 
     110 
     111 
     112 
    109113 
    110114#endif //#ifndef OPCALC_H 
  • trunk/src/seismic_processing/glass/src/lib/opcalc_const.h

    r2174 r3212  
    3636                                             // 2400 seconds = 40 minutes, enough to pull in P'P' 
    3737 
     38#define RAD2DEG  57.29577951308 
     39#define DEG2RAD 0.01745329251994 
     40#define OPCALC_MAX_BELIEVABLE_DISTANCE_FOR_P_PHASE 110.0 
     41 
    3842 
    3943/* THIS VALUE IS NOT USED */ 
  • trunk/src/seismic_processing/glass/src/lib/str.cpp

    r2775 r3212  
    573573        int nbuf = strlen(sBuf); 
    574574        // Find first non white space 
    575         for(int i=iBuf; i<nbuf; i++) { 
     575        for(i=iBuf; i<nbuf; i++) { 
    576576                switch(sBuf[i]) { 
    577577                case ' ': 
  • trunk/src/seismic_processing/glass/src/modules/Catalog/CatalogScroll.cpp

    r2175 r3212  
    3333        nX = 800; 
    3434        nY = 400; 
    35  
    3635} 
    3736 
     
    4443 
    4544//---------------------------------------------------------------------------------------Init 
    46 void CScroll::Init(HINSTANCE hinst, char *title) { 
     45void CScroll::Init(HINSTANCE hinst, char *title)  
     46{ 
    4747        iStyle |= WS_VSCROLL; 
    4848        CWin::Init(hinst, title); 
     
    144144    iCat = -1; 
    145145 
    146     CDebug::Log(DEBUG_MAJOR_INFO,"Deleting Quake nCat/MC/i1/i2 = %d/%d/%d/%d\n", 
     146    CDebug::Log(DEBUG_MINOR_INFO,"Deleting Quake nCat/MC/i1/i2 = %d/%d/%d/%d\n", 
    147147                nCat,MAXCAT,i1,i2); 
    148148 
     
    183183        int nNumRecords; 
    184184        CAT     * TempCat; 
     185        CDebug::Log(DEBUG_MINOR_INFO,"Using Delete Method 2.  jcat/nCat = %d/%d\n", 
     186                    jcat,nCat); 
    185187 
    186188        TempCat = (CAT *) malloc(MAXCAT * sizeof(CAT)); 
     
    240242      }  // end else    (nCat >= MAXCAT) 
    241243 
    242       CDebug::Log(DEBUG_MINOR_INFO,"End1: Deleting Quake nCat/iCat = %d/%d\n", 
    243                 nCat,iCat); 
    244  
    245244      sprintf(txt, "Origin %s deleted!\n", ent); 
    246245      LogOrigin(-1,txt); 
    247246      ScrollBar(); 
    248247      Refresh(); 
    249  
    250       CDebug::Log(DEBUG_MINOR_INFO,"End2: Deleting Quake nCat/iCat = %d/%d\n", 
    251                 nCat,iCat); 
    252248 
    253249      return; 
     
    269265    iIDOrigin = -1; 
    270266 
    271         sprintf(txt, "%4d %s %9.4f %10.4f %6.2f%4d %4d %4.2f %5.2f %3d %5d", org->iOrigin, 
     267        _snprintf(txt, sizeof(txt)-1, "%4d %s %9.4f %10.4f %6.2f%4d %4d %4.2f %5.2f %3d %5d", org->iOrigin, 
    272268                dt.Date20().GetBuffer(), org->dLat, org->dLon, org->dZ, 
    273269                org->nEq, org->nPh, org->dRms, org->dAff, (int)org->dGap, iIDOrigin); 
     270  txt[sizeof(txt)-1] = 0x00; 
    274271        i1 = nCat - MAXCAT; 
    275272        if(i1 < 0) 
     
    281278                if(Cat[jcat].iOrigin != org->iOrigin) 
    282279                        continue; 
    283                 strcpy(Cat[jcat].sCat, txt); 
     280                strncpy(Cat[jcat].sCat, txt, sizeof(Cat[jcat].sCat)-1); 
     281    Cat[jcat].sCat[sizeof(Cat[jcat].sCat)-1] = 0x00; 
    284282                iCat = i; 
    285283                break; 
     
    289287                icat = nCat%MAXCAT; 
    290288                Cat[icat].iOrigin = org->iOrigin; 
    291                 strcpy(Cat[icat].idQuake, ent); 
    292                 strcpy(Cat[icat].sCat, txt); 
     289                strncpy(Cat[icat].idQuake, ent, sizeof(Cat[icat].idQuake)-1); 
     290    Cat[icat].idQuake[sizeof(Cat[icat].idQuake)-1] = 0x00; 
     291                strncpy(Cat[icat].sCat, txt, sizeof(Cat[icat].sCat)-1); 
     292    Cat[icat].sCat[sizeof(Cat[icat].sCat)-1] = 0x00; 
    293293                nCat++; 
    294294        } 
  • trunk/src/seismic_processing/glass/src/modules/EarthWorm/EarthwormMod.cpp

    r2176 r3212  
    77 *    Revision history: 
    88 *     $Log$ 
    9  *     Revision 1.2  2006/05/22 16:01:25  paulf 
    10  *     added from hydra_proj, new version 
     9 *     Revision 1.3  2007/12/27 18:05:23  paulf 
     10 *     sync from hydra_proj circa Oct 2007 
     11 * 
     12 *     Revision 1.7  2006/05/04 17:16:19  davidk 
     13 *     removed unneccessary windows.h include, as it was causing winsock issues. 
    1114 * 
    1215 *     Revision 1.6  2006/01/24 00:05:01  davidk 
     
    9699 
    97100// Generally, windows.h and util.h need only be included if TRACE functionality is desired. 
    98 #include <windows.h> 
     101//#include <windows.h> 
    99102#include <time.h> 
    100103#include <stdio.h> 
  • trunk/src/seismic_processing/glass/src/modules/Glass/GlassState.cpp

    r2176 r3212  
    77 *    Revision history: 
    88 *     $Log$ 
    9  *     Revision 1.1  2006/05/22 16:02:54  paulf 
    10  *     added from hydra_proj, new version 
     9 *     Revision 1.2  2007/12/27 18:05:23  paulf 
     10 *     sync from hydra_proj circa Oct 2007 
     11 * 
     12 *     Revision 1.2  2006/12/13 17:15:01  davidk 
     13 *     Fixed "Heavy Handed" code in glass state manager, so that it gets heavy handed 
     14 *     with all of the currently scheduled tasks, instead of just the first one in the list. 
    1115 * 
    1216 *     Revision 1.1.1.1  2005/06/22 19:30:48  michelle 
     
    162166        for(i=0; i < nScheduledActions; i++) 
    163167        { 
    164           if(Act[0].iAct  == STATE_NEW_UNASSIGNED_PICK || 
    165             Act[0].iAct  == STATE_PICK_UNASSIGNABLE || 
    166             Act[0].iAct  == STATE_PICK_UNASSOCIABLE) 
     168          if(Act[i].iAct  == STATE_NEW_UNASSIGNED_PICK || 
     169            Act[i].iAct  == STATE_PICK_UNASSIGNABLE || 
     170            Act[i].iAct  == STATE_PICK_UNASSOCIABLE) 
    167171          { 
    168             Act[0].iAct  = STATE_PICK_UNASSOCIABLE; 
     172            Act[i].iAct  = STATE_PICK_UNASSOCIABLE; 
    169173          } 
    170174          else 
    171175          { 
    172             Act[0].iAct  = STATE_ORIGIN_STABILIZED; 
     176            Act[i].iAct  = STATE_ORIGIN_STABILIZED; 
    173177          } 
    174178        } 
  • trunk/src/seismic_processing/glass/src/modules/Glass/glass.cpp

    r2176 r3212  
    77 *    Revision history: 
    88 *     $Log$ 
    9  *     Revision 1.2  2006/05/22 16:01:25  paulf 
    10  *     added from hydra_proj, new version 
     9 *     Revision 1.3  2007/12/27 18:05:23  paulf 
     10 *     sync from hydra_proj circa Oct 2007 
     11 * 
     12 *     Revision 1.6  2006/09/11 15:40:52  davidk 
     13 *     Added/Fixed debugging for cases where the nucleator generates a location 
     14 *     that doesn't generate nCut number of phase associations. 
     15 * 
     16 *     Revision 1.5  2006/09/05 15:20:30  davidk 
     17 *     added logging changes to log problematic nucleator results. 
     18 *     (may include a bug that causes excessive logging). 
     19 * 
     20 *     Revision 1.4  2006/08/26 06:16:18  davidk 
     21 *     modified code to track the number of picks associted during the initial post-nucleation 
     22 *     association phase.  If the number is below the minimum expected, the a log 
     23 *     message is issued. 
     24 *     This was done because Glass *APPEARS* to be producing and then 
     25 *     squashing a bunch of bogus events, that should never have been produced 
     26 *     in the first place. 
     27 * 
     28 *     Revision 1.3  2006/05/04 23:26:01  davidk 
     29 *     Changed abest from some really big number, to something smaller but larger 
     30 *     than the cutoff.  Ideally it would be set to the cutoff or just over the cutoff 
     31 *     because there's no point (other than seeing if things are working) to setting 
     32 *     the value bigger than the cutoff, because values bigger than the cutoff will 
     33 *     never be used. 
    1134 * 
    1235 *     Revision 1.2  2005/10/17 06:29:46  davidk 
     
    326349  PICK * pPick; 
    327350 
    328   CDebug::Log(DEBUG_MAJOR_INFO, "Attempting to Delete origin %s\n", idOrigin); 
    329351  if(!(pOrigin = pGlint->getOrigin(idOrigin))) 
    330352  { 
     
    10291051//  returns: 
    10301052//              0: No changes 
    1031 //              1: Waifs associated, need to relocate 
     1053//              N > 0: Waifs associated, need to relocate 
    10321054int CGlass::Waif(char *idorg) { 
    10331055        ORIGIN *org; 
     
    10481070  // CARL 120303  
    10491071  PICK CurrentPick; 
    1050   int res=0; 
    10511072  //double aff; 
    10521073 
     
    10881109                iRetCode = OPCalc_CalcPickAffinity(org, &CurrentPick); 
    10891110    // STEP 3.2:   Ensure we were successfully able to calc an affinity 
     1111 
    10901112    if(iRetCode != 0) 
    10911113    { 
     
    11071129      { 
    11081130        n++; 
    1109         res = 1; 
    11101131      } 
    11111132    } 
    11121133  }  // end while(each waif in time range) 
    1113         return res; 
     1134        return n; 
    11141135}  // end Waif() 
    11151136 
     
    13831404        double lat; 
    13841405        double lon; 
    1385         double abest = 10000.0; 
     1406        double abest = dCut * 2; 
    13861407        double t0; 
    13871408        double lat0; 
     
    13891410        double z0; 
    13901411        int i; 
    1391  
     1412  int nAssociatedPicks; 
    13921413 
    13931414  // STEP 5: Only use Primary phases (P,Pup,Pdiff) for association 
     
    14311452      //     smallest so far, save the parameters of the current 
    14321453      //     origin: time, lat, lon, and depth(z) 
    1433                         if(a < abest) { 
     1454                        if(a < abest)  
     1455      { 
     1456        CDebug::Log(DEBUG_MINOR_INFO, "Nucleation:  a=%.2f, t=%.1f, lat=%.0f, lon = %.0f, z=%.1f\n", a, t, lat, lon, z); 
     1457 
    14341458                                abest = a; 
    14351459                                t0 = t; 
     
    14891513    if(!AssociatePickWOrigin(org.idOrigin, pck)) 
    14901514      return(false); 
     1515    nAssociatedPicks=1; 
    14911516 
    14921517 
     
    14941519    //       Attempt to associate any/all of the unassociated picks with 
    14951520    //       the new origin. 
    1496                 Waif(org.idOrigin); 
     1521                nAssociatedPicks+=Waif(org.idOrigin); 
     1522 
     1523    if(nAssociatedPicks < (nCut-1)) 
     1524    { 
     1525      time_t tOrigin; 
     1526      double  dLat, dLon; 
     1527      tOrigin = (time_t)org.dT; 
     1528      /********************************************************** 
     1529       * NOTE:  This condition is not NECCESSARILY an error.  It most commonly 
     1530                occurs because: 
     1531                   The hypocenter is close to a group of channels,  
     1532                   each (or several) channel generates 2 intersections 
     1533                   instead of 1, and the nucleation logic currently counts 
     1534                   intersections instead of channels 
     1535        *******************************************************************/ 
     1536      CDebug::Log(DEBUG_MAJOR_INFO, "Nucleated %s: %d lat:%.4f lon:%.4f z:%.4f, t:%.4f - %s" 
     1537                                     " but only able to associate %d phases with hypocenter! Something's wrong!\n", 
     1538                org.idOrigin, org.iOrigin, org.dLat, org.dLon, org.dZ, org.dT, ctime(&tOrigin), 
     1539                nAssociatedPicks); 
     1540      CDebug::Log(DEBUG_MAJOR_INFO, "Nucleated for pick %s.%s.%s.%s - %.0f\n",   
     1541                  pck->sSite, pck->sComp, pck->sNet, pck->sLoc, pck->dT); 
     1542      AssociatePicks(t0, z0, &dLat, &dLon, Pck, nPck, pTT,nCut, false, true); 
     1543      CDebug::Log(DEBUG_MAJOR_INFO, "Resulting in origin lat:%.4f lon:%.4f z:%.4f, t:%.4f\n", 
     1544                dLat, dLon, t0, z0); 
     1545 
     1546    } 
    14971547 
    14981548    // STEP 9.4: 
     
    18311881 
    18321882 
     1883void Debug( char *flag, char *szFormat, ... ) 
     1884{ 
     1885        va_list ap; 
     1886  int     rc; 
     1887 
     1888        va_start(ap,szFormat); 
     1889  rc = CDebug::LogVA(DEBUG_MAJOR_INFO, szFormat, ap); 
     1890  va_end(ap); 
     1891} 
  • trunk/src/seismic_processing/glass/src/modules/Glass/makefile.ind

    r2176 r3212  
    1515        glass.$(OBJ) \ 
    1616        Monitor.$(OBJ) \ 
     17        AssociatePicks.$(OBJ) \ 
    1718#       Rank.$(OBJ) \ 
    1819#       Sphere.$(OBJ) \ 
  • trunk/src/seismic_processing/glass/src/modules/Glass/valid_alg.cpp

    r2176 r3212  
    1212  int iPCtr = 0; 
    1313  int iPCICtr = 0; 
     14  int iPAllCtr = 0; 
    1415 
    1516  static int MIN_QLTY_CLOSEIN_ARR = 4; 
    1617  static int MIN_QLTY_ARR = nCut; 
     18  static int MIN_P_ARR = nCut * 2; 
    1719 
    1820  /*************************************************** 
     
    8890            } 
    8991          } 
     92          iPAllCtr++; 
    9093        }  // if a P phase 
    9194      }  // end while not at end of picklist 
    92       if((iPCtr < MIN_QLTY_ARR) && (iPCICtr < MIN_QLTY_CLOSEIN_ARR))  
     95      if((iPCtr < MIN_QLTY_ARR) && (iPCICtr < MIN_QLTY_CLOSEIN_ARR) && (iPAllCtr < MIN_P_ARR))  
    9396      { 
    9497        pGlint->endPickList(&iPickRef); 
     
    124127            } 
    125128          } 
     129          iPAllCtr++; 
    126130        }  // if a P phase 
    127131      }  // end while not at end of picklist 
    128       if((iPCtr < MIN_QLTY_ARR) && (iPCICtr < MIN_QLTY_CLOSEIN_ARR))  
     132      if((iPCtr < MIN_QLTY_ARR) && (iPCICtr < MIN_QLTY_CLOSEIN_ARR) && (iPAllCtr < MIN_P_ARR))  
    129133      { 
    130134        pGlint->endPickList(&iPickRef); 
     
    158162            } 
    159163          } 
     164          iPAllCtr++; 
    160165        }  // if a P phase 
    161166      }  // end while not at end of picklist 
    162       if((iPCtr < MIN_QLTY_ARR) && (iPCICtr < MIN_QLTY_CLOSEIN_ARR))  
     167      if((iPCtr < MIN_QLTY_ARR) && (iPCICtr < MIN_QLTY_CLOSEIN_ARR) && (iPAllCtr < MIN_P_ARR))  
    163168      { 
    164169        pGlint->endPickList(&iPickRef); 
     
    192197      } 
    193198    } 
    194     if(iPCtr <= (nCut/2))  
     199    if((iPCtr <= (nCut/2)) && (iPAllCtr < MIN_P_ARR))  
    195200    { 
    196201      CDebug::Log(DEBUG_MINOR_WARNING,"Origin %s/%d outside Western Hemisphere, but too few Good P picks(%d)/ need (%d).  Invalidating!\n", 
  • trunk/src/seismic_processing/glass/src/modules/Glock/Glock.cpp

    r2176 r3212  
    77 *    Revision history: 
    88 *     $Log$ 
    9  *     Revision 1.2  2006/05/22 16:01:25  paulf 
    10  *     added from hydra_proj, new version 
     9 *     Revision 1.3  2007/12/27 18:05:23  paulf 
     10 *     sync from hydra_proj circa Oct 2007 
     11 * 
     12 *     Revision 1.6  2006/09/30 05:34:51  davidk 
     13 *     All origin-pick relation calculations were moved to OPCalc(Gap, etc).  Now Glock 
     14 *     calls OPCalc to do the calculation of Origin-Pick derived parameters, and 
     15 *     calls Solve to invert the pick data into a better origin solution. 
     16 *     So now it acts as more of a delegatory shell, instead of containing a bunch 
     17 *     of calculations. 
     18 * 
     19 *     Revision 1.5  2006/05/04 23:16:25  davidk 
     20 *     Moved pMod and parameter initialization from static tasks to constructor tasks, 
     21 *     the way they should be. 
     22 * 
     23 *     Revision 1.4  2006/01/30 23:16:22  davidk 
     24 *     Added int type-cast to get rid of compiler warning. 
    1125 * 
    1226 *     Revision 1.3  2005/10/17 06:34:31  davidk 
     
    100114} 
    101115 
    102 #define RAD2DEG  57.29577951308 
    103 #define DEG2RAD 0.01745329251994 
    104 #define MAX_BELIEVABLE_DISTANCE_FOR_P_PHASE 110.0 
    105116 
    106117extern "C" { 
     
    108119} 
    109120 
    110 extern CMod *pMod; 
    111121 
    112122#define ITER_SUCCESS    0 
    113123#define ITER_NODATA             1 
    114124#define ITER_DEPTH              2 
     125 
     126#define RAD2DEG  57.29577951308 
     127#define DEG2RAD 0.01745329251994 
    115128 
    116129// Carl 120303 
     
    148161 
    149162//---------------------------------------------------------------------------------------CWave 
    150 CGlock::CGlock() { 
    151 //      DebugOn(); 
     163CGlock::CGlock(CMod * IN_pMod)  
     164{ 
    152165        for(int i=0; i<4; i++) 
    153166                bFree[i] = true; 
    154   CDebug::SetModuleName("CGlock"); 
     167 
     168        this->pMod = IN_pMod; 
     169        CDebug::SetModuleName("CGlock"); 
     170        pGlnt = pMod->pGlint; 
     171        pTT = pMod->pTT; 
     172        OPCalc_SetTravelTimePointer(pTT); 
     173        pSlv = pMod->pSolve; 
     174 
    155175} 
    156176 
     
    209229        bool fix; 
    210230        bool btemp; 
    211   static bool bParamsInitialized = false; 
    212  
    213  
    214  
    215   if(!bParamsInitialized) 
    216   { 
    217     pGlnt = pMod->pGlint; 
    218     pTT = pMod->pTT; 
    219     OPCalc_SetTravelTimePointer(pTT); 
    220     pSlv = pMod->pSolve; 
    221     bParamsInitialized = true; 
    222   } 
    223  
    224231 
    225232        pOrg = pGlnt->getOrigin(ent); 
     
    320327  } 
    321328 
    322         CDebug::Log(DEBUG_MAJOR_INFO,"Locate(): Chose location : %.4f %.4f %.4f - %.2f (%.1f-%3d)\n",  
     329        CDebug::Log(DEBUG_MINOR_INFO,"Locate(): Chose location : %.4f %.4f %.4f - %.2f (%.1f-%3d)\n",  
    323330              oBest.dLat, oBest.dLon, oBest.dZ,  
    324331              oBest.dT, oBest.dRms, oBest.nEq); 
     
    457464    coef[j++] = -pPick->ttt.dtdz;  
    458465 
    459   i = (pPick->ttt.dLocWeight + (GLOCK_WEIGHT_GRANULARITY/2)) / GLOCK_WEIGHT_GRANULARITY; 
     466  i = (int)((pPick->ttt.dLocWeight + (GLOCK_WEIGHT_GRANULARITY/2)) / GLOCK_WEIGHT_GRANULARITY); 
    460467  if(pSlv) 
    461468  { 
     
    476483 
    477484  // Initialize origin vars 
    478         int nEq = 0; 
     485        int rc = 0; 
    479486  int i; 
    480487 
    481         double sum = 0.0; 
    482   double dWeight = 0.0; 
    483   PICK * pck; 
    484   int iRetCode; 
    485   double dGap; 
    486  
    487   PhaseType  ptPhase; 
    488   PhaseClass pcPhase; 
    489  
    490   // Set default RMS to absurd level.  Shouldn't this be an affinity setting. 
    491   pOrg->dRms = 10000.0; 
     488 
     489  rc = OPCalc_ProcessOrigin(pOrg, pPick, nPck); 
     490  if(rc) 
     491    return(rc); 
     492 
    492493 
    493494 
     
    497498        for(i=0; i<nPck; i++)  
    498499  { 
    499                 pck = pPick[i]; 
    500     iRetCode = OPCalc_CalculateOriginPickParams(pck,pOrg); 
    501     if(iRetCode == -1) 
    502     { 
    503       CDebug::Log(DEBUG_MINOR_ERROR,"ProcessLocation(): OPCalc_CalculateOriginPickParams  failed with " 
    504                                     "terminal error.  See logfile.  Returning!\n"); 
    505       return(-1); 
    506     } 
    507     else if(iRetCode == 1) 
    508     { 
    509       // could not find TravelTimeTable entry for pOrg,pck 
    510       CDebug::Log(DEBUG_MINOR_INFO,"ProcessLocation(): OPCalc_CalculateOriginPickParams() could not " 
    511                                     "find TTT entry for Org,Pick!\n"); 
    512       continue; 
    513     } 
    514  
    515500    // calculate solve coefficients if desired 
    516501    if(solve) 
    517       AddPickCoefficientsForSolve(pck, pOrg); 
     502      AddPickCoefficientsForSolve(pPick[i], pOrg); 
    518503     
    519     // accumulate statistics 
    520     sum += pck->tRes*pck->tRes*pck->ttt.dLocWeight; 
    521  
    522     dWeight += pck->ttt.dLocWeight; 
    523  
    524     // copy the delta/azimuth of the pick to proper arrays for 
    525     // further calculations 
    526     pPickDistArray[nEq] = pck->dDelta; 
    527  
    528     // DK 021105  Change gap calculation to only use P-Class phases 
    529     // that way if we pull in random S, PPP, and SKiKP phases, 
    530     // they won't affect the gap "quality" of the solution. 
    531     ptPhase = GetPhaseType(pck->ttt.szPhase); 
    532     pcPhase = GetPhaseClass(ptPhase); 
    533     if(( (pcPhase == PHASECLASS_P) && (pck->dDelta < MAX_BELIEVABLE_DISTANCE_FOR_P_PHASE )) ||  
    534        (ptPhase == PHASE_PKPdf) 
    535       ) 
    536       pPickAzmArray[nEq] = pck->dAzm; 
    537     else 
    538       pPickAzmArray[nEq] = -1.0; 
    539  
    540  
    541     // increment the number of picks used to locate the origin 
    542     nEq++; 
    543      
    544     // keep the arrays from being overrun 
    545     if(nEq > OPCALC_MAX_PICKS) 
    546       break; 
    547504  }  // end for each pick in the Pick Array 
    548505 
    549   // if we didn't use atleast one pick.  Give up and go home. 
    550   if(nEq < 1) 
    551           return(1); 
    552  
    553  
    554   // Record the number of equations used to calc the location 
    555   pOrg->nEq = nEq; 
    556  
    557   // Record the residual standard deviation 
    558   pOrg->dRms = sqrt(sum/dWeight); 
    559  
    560   /* Calculate Pick Azimuth statistics for the Origin (Gap) 
    561    ****************************************************/ 
    562   // Sort the pick-azimuth array 
    563   qsortd(pPickAzmArray, nEq); 
    564  
    565   // If the Pick wasn't a P-class Pick, then we gave it a negative azm, 
    566   // so igonre all of the negative azm picks (which are all at the beginning 
    567   // since the array has been sorted 
    568         for(i=0; i<nEq-2; i++)  
    569   { 
    570     if(pPickAzmArray[i] >= 0.0) 
    571       break; 
    572   } 
    573  
    574   CDebug::Log(DEBUG_MINOR_INFO, 
    575               "ProcessLocation(): Calculating Gap for Org %d(%5.1f, %6.1f, %3.0f) based on %d valid picks: ", 
    576               pOrg->iOrigin, pOrg->dLat, pOrg->dLon, pOrg->dZ, nEq - i); 
    577   // Calculate the gap for the last-to-first wrap 
    578         dGap = pPickAzmArray[i] + 360.0 - pPickAzmArray[nEq-1]; 
    579         for(; i<nEq-1; i++)  
    580   { 
    581     // for each gap between two picks, record only if largest so far 
    582     if(pPickAzmArray[i+1] - pPickAzmArray[i] > dGap) 
    583       dGap = pPickAzmArray[i+1] - pPickAzmArray[i]; 
    584         } 
    585         pOrg->dGap = dGap; 
    586  
    587   /* Calculate Pick Distance statistics for the Origin 
    588    ****************************************************/ 
    589   // Sort the pick-distance array 
    590   qsortd(pPickDistArray, nEq); 
    591  
    592   // Calculate the minimum station distance for the origin 
    593         pOrg->dDelMin = pPickDistArray[0]; 
    594  
    595   // Calculate the maximum station distance for the origin 
    596         pOrg->dDelMax = pPickDistArray[nEq-1]; 
    597  
    598   // Calculate the median station distance for the origin 
    599         pOrg->dDelMod = 0.5*(pPickDistArray[nEq/2] + pPickDistArray[(nEq-1)/2]); 
    600  
    601  
    602   /* Calculate the Affinity for the Origin (and Picks)  
    603    ****************************************************/ 
    604   iRetCode = OPCalc_CalcOriginAffinity(pOrg, pPick, nPck); 
    605   if(iRetCode) 
    606   { 
    607     CDebug::Log(DEBUG_MINOR_ERROR, 
    608                 "Error: ProcessLocation(): OPCalc_CalcOriginAffinity() return (%d)\n", 
    609                 iRetCode); 
    610     return(iRetCode); 
    611   } 
    612       
    613   CDebug::Log(DEBUG_MINOR_INFO,"END Locate(): dRms:%.2f nEq:%d\n", 
    614               pOrg->dRms, nEq); 
    615506  return(0); 
    616507}  // End Process Location() 
     
    634525int CGlock::CompareOrigins(ORIGIN * po1, ORIGIN * po2) 
    635526{ 
     527  CDebug::Log(DEBUG_MINOR_INFO, 
     528              "Comparing Origins:\n" 
     529              "1) %.2f/%.2f/%.2f - %.2f  Aff: %.2f  AfGp: %.2f AfNeq: %.2f  RMS: %.2f Gap: %.2f\n" 
     530              "2) %.2f/%.2f/%.2f - %.2f  Aff: %.2f  AfGp: %.2f AfNeq: %.2f  RMS: %.2f Gap: %.2f\n", 
     531              po1->dLat, po1->dLon, po1->dZ, po1->dT, po1->dAff, po1->dAffGap, po1->dAffNumArr, po1->dRms, po1->dGap, 
     532              po2->dLat, po2->dLon, po2->dZ, po2->dT, po2->dAff, po2->dAffGap, po2->dAffNumArr, po2->dRms, po2->dGap 
     533             ); 
     534 
    636535  if(po1->dAff > po2->dAff) 
    637536    return(-1); 
  • trunk/src/seismic_processing/glass/src/modules/Glock/Glock.h

    r2176 r3212  
    77 *    Revision history: 
    88 *     $Log$ 
    9  *     Revision 1.2  2006/05/22 16:01:25  paulf 
    10  *     added from hydra_proj, new version 
     9 *     Revision 1.3  2007/12/27 18:05:23  paulf 
     10 *     sync from hydra_proj circa Oct 2007 
     11 * 
     12 *     Revision 1.2  2006/05/04 23:06:33  davidk 
     13 *     Added constructor that takes a Module pointer, instead of just the default 
     14 *     constructor, so the class can have something other than a hokey 
     15 *     global extern link back to its module. 
    1116 * 
    1217 *     Revision 1.1.1.1  2005/06/22 19:30:48  michelle 
     
    3641#include <IGlint.h> 
    3742 
    38  
    3943#define MAX_PCK 2000 
    4044 
    4145struct ISolve; 
     46class  CMod; 
    4247class CGlock { 
    4348public: 
     
    4651//      int                     nEq; 
    4752//      double          dRms; 
    48         bool            bFree[4];       // True if parameter free 
     53        bool               bFree[4];    // True if parameter free 
    4954        ITravelTime     *pTT; 
    5055        IGlint          *pGlnt; 
    5156        ISolve          *pSlv; 
    52         int                     nPck; 
     57        int                        nPck; 
    5358        ORIGIN          *pOrg; 
    54         PICK            *pPick[MAX_PCK]; 
     59        PICK              *pPick[MAX_PCK]; 
     60  CMod      *pMod; 
    5561 
    5662// Methods 
    57         CGlock(); 
     63        CGlock(CMod * pMod); 
    5864        virtual ~CGlock(); 
    5965        int Locate(char *ent, char *mask); 
  • trunk/src/seismic_processing/glass/src/modules/Glock/GlockMod.cpp

    r2176 r3212  
    2626        pMod = this; 
    2727  iNumLocatorIterations = 1;   
     28  pGlock = NULL; 
    2829} 
    2930 
     
    3334        if(pSolve) 
    3435                pSolve->Release(); 
     36  if(pGlock) 
     37    delete(pGlock); 
    3538} 
    3639 
     
    7679                } 
    7780 
     81    pGlock = new CGlock(pMod); 
     82 
    7883                return true; 
    7984        } 
     
    9196                strcpy(ent, str); 
    9297                str = msg->getStr("Mask"); 
     98 
    9399                if(!str) { 
    94100                        res = Locate(ent, 0); 
     
    134140int CMod::Locate(char *ent, char *mask) { 
    135141        int res; 
    136         CGlock glock; 
     142 
     143  if(!pGlock) 
     144  { 
     145    CDebug::Log(DEBUG_MAJOR_ERROR, "Error locator class unavailable.\n"); 
     146    return(1); 
     147  } 
    137148 
    138149        if(mask) 
    139                 res = glock.Locate(ent, mask); 
     150                res = pGlock->Locate(ent, mask); 
    140151        else 
    141                 res = glock.Locate(ent); 
     152                res = pGlock->Locate(ent); 
    142153        return res; 
    143154} 
  • trunk/src/seismic_processing/glass/src/modules/Glock/GlockMod.h

    r2176 r3212  
    11#include "module.h" 
    22#include <ITravelTime.h> 
     3#include "glock.h" 
    34 
    45struct IGlint; 
    56struct ISolve; 
     7class CGlock; 
     8 
    69class CMod : public CModule { 
    710// attributes 
     
    1114        ISolve          *pSolve; 
    1215  int       iNumLocatorIterations; 
     16  CGlock * pGlock; 
    1317 
    1418// Methods 
  • trunk/src/seismic_processing/glass/src/modules/ManQuake/ManQuakeScroll.cpp

    r2176 r3212  
    575575    _putenv("TZ=UTC+0"); 
    576576    *pdTime = timegm_ew(&tmTime);  // convert to time_t 
     577    *pdTime += atof(szTemp) - tmTime.tm_sec;  /* add the partial sec back in. */ 
    577578 
    578579  } 
  • trunk/src/seismic_processing/glass/src/modules/Network/NetworkMod.cpp

    r2176 r3212  
    4242  SCNL Name; 
    4343  const STATION * pStation; 
    44   const char * szDesc; 
    4544 
    4645        // The "ShutDown" message is broadcast when the system is shutting down. Messages 
     
    9594                        msg->setDbl("Elev", pStation->dElev); 
    9695                        msg->setDbl("Qual", pStation->dQual); 
    97                         szDesc = pStation->sDesc; 
     96                        /* removed use of sDesc field as it wasn't being used by anything.  
     97      szDesc = pStation->sDesc; 
    9898                        if(szDesc) 
    9999                          msg->setStr("Desc", szDesc); 
    100100                        else 
    101101              msg->setStr("Desc", ""); 
     102      *********************************/ 
    102103                        msg->setInt("Res", 0); 
    103104                } 
     
    105106        } 
    106107 
     108        if(msg->Is("NetGet")) { 
     109      STATION * StationList; 
     110      int       nLen; 
     111      pStaList->GetList(&StationList, &nLen); 
     112                        msg->setInt("pStart", (int)StationList); 
     113                        msg->setInt("iLen", nLen); 
     114                        msg->setInt("Res", 0); 
     115                return true; 
     116        } 
     117 
    107118        return false; 
    108119} 
  • trunk/src/seismic_processing/glass/src/modules/Network/makefile.ind

    r2176 r3212  
    1414        station.$(OBJ)  
    1515 
    16 CPP_OTHER_FLAGS = $(MODULE_CPP_FLAGS) 
     16CPP_OTHER_FLAGS = -I$(EW_HOME)\$(EW_VERSION)\src\seismic_processing\glass\src\modules\cpp\ $(MODULE_CPP_FLAGS) -I..\cpp\ 
    1717 
    1818 
  • trunk/src/seismic_processing/glass/src/modules/Network/station.cpp

    r2176 r3212  
    191191    strncpy(Station.Name.szSta,&pBuffer[STA_POS-1],STA_LEN); 
    192192    Station.Name.szSta[STA_LEN]=0; 
     193 
     194    /* ignore lines that start with # */ 
     195    if(Station.Name.szSta[0] == '#') 
     196      continue; 
     197 
    193198    strncpy(Station.Name.szNet,&pBuffer[NET_POS-1],NET_LEN); 
    194199    Station.Name.szNet[NET_LEN]=0; 
     
    292297  int i; 
    293298  STATION Station; 
     299  STATION * pSta; 
    294300 
    295301  memset(&Station, 0, sizeof(Station)); 
    296302  memcpy(&Station.Name, name, sizeof(SCNL)); 
    297303 
     304  pSta = (STATION *)bsearch(&Station, Sta, nSta, sizeof(STATION), CompareStationSCNLs); 
     305  return(pSta); 
     306  /************** replaced by bsearch call ***************************** 
    298307        for(i=0; i<nSta; i++) { 
    299308                if(CompareStationSCNLs(&Station, &Sta[i]) > 0) 
     
    306315  } 
    307316  return(NULL); 
    308 } 
    309  
     317  **********************************************************/ 
     318} 
     319 
     320 
     321bool CStation::GetList(STATION ** pStaList, int* pnLen) 
     322{ 
     323  *pStaList = Sta; 
     324  *pnLen = nSta; 
     325  return(true); 
     326} 
    310327 
    311328void CStation::SortStationList() 
  • trunk/src/seismic_processing/glass/src/modules/Network/station.h

    r2176 r3212  
    33 
    44#include "str.h" 
     5#include "IGlint.h" 
    56 
    67#define MAXSTA 10000 
    78#define MIN_STATION_QUAL_THRESHOLD .001 
    89 
    9 typedef struct _SCNL 
    10 { 
    11         char szSta[10]; 
    12         char szComp[10]; 
    13         char szNet[10]; 
    14         char szLoc[10]; 
    15 } SCNL; 
    16  
    17  
    18 typedef struct  
    19 { 
    20         SCNL            Name; 
    21         double          dLat; 
    22         double          dLon; 
    23         double          dElev; 
    24         double          dQual; 
    25         CStr            sDesc; 
    26 } STATION; 
    2710 
    2811class CStation  { 
     
    4023        bool LoadHypoInverse(const char *name); 
    4124        const STATION * Get(const SCNL *name); 
     25        bool GetList(STATION ** pStaList, int* pnLen); 
    4226        bool Put(const STATION * pStation); 
    4327 
  • trunk/src/seismic_processing/glass/src/modules/OPCalc/opcalc.cpp

    r2176 r3212  
    88#include <opcalc.h> 
    99#include <opcalc_const.h> 
     10 
     11extern "C" { 
     12void __cdecl qsortd (double *base, unsigned num); 
     13} 
     14 
     15 
     16int OPCalc_ProcessOriginSimple(ORIGIN * pOrg, PICK ** pPick, int nPck); 
     17 
    1018 
    1119// Lib Global variables - File Scope 
     
    3644 
    3745 
     46int __cdecl ComparePickAffinityAsc(const void * pvoid1, const void * pvoid2) 
     47{ 
     48  PICK * p1, *p2; 
     49 
     50  p1 = *(PICK **) pvoid1; 
     51  p2 = *(PICK **) pvoid2; 
     52 
     53  if(p1->dAff < p2->dAff) 
     54    return(-1); 
     55  if(p1->dAff > p2->dAff) 
     56    return(1); 
     57  else 
     58    return(0); 
     59} 
     60 
     61int __cdecl ComparePickResidDesc(const void * pvoid1, const void * pvoid2) 
     62{ 
     63  PICK * p1, *p2; 
     64 
     65  p1 = *(PICK **) pvoid1; 
     66  p2 = *(PICK **) pvoid2; 
     67 
     68  if(fabs(p1->tRes) > fabs(p2->tRes)) 
     69    return(-1); 
     70  if(fabs(p1->tRes) < fabs(p2->tRes)) 
     71    return(1); 
     72  else 
     73    return(0); 
     74} 
     75   
     76int __cdecl ComparePickiPickAsc(const void * pvoid1, const void * pvoid2) 
     77{ 
     78  PICK * p1, *p2; 
     79 
     80  p1 = *(PICK **) pvoid1; 
     81  p2 = *(PICK **) pvoid2; 
     82 
     83  if(p1->iPick < p2->iPick) 
     84    return(-1); 
     85  if(p1->iPick > p2->iPick) 
     86    return(1); 
     87  else 
     88    return(0); 
     89} 
     90   
     91 
     92int OPCalc_ProcessOrigin(ORIGIN * pOrg, PICK ** pPick, int nPck)  
     93{ 
     94 
     95  double dFullAff; 
     96  int    rc; 
     97  int    i; 
     98  PICK * pck; 
     99 
     100  /* process the origin with the full complement of picks  
     101   *******************************************************/ 
     102  if(rc=OPCalc_ProcessOriginSimple(pOrg, pPick, nPck)) 
     103    return(rc); 
     104 
     105  dFullAff = pOrg->dAff; 
     106 
     107  // log the results 
     108  CDebug::Log(DEBUG_MINOR_INFO,"OPC_PO: Full Origin: %.2f/%.2f/%.2f - %.2f  Aff: %.2f  AfGp: %.2f AfNeq: %.2f  RMS: %.2f Gap: %.2f\n", 
     109              pOrg->dLat, pOrg->dLon, pOrg->dZ, pOrg->dT, pOrg->dAff, pOrg->dAffGap, pOrg->dAffNumArr, pOrg->dRms, pOrg->dGap, 
     110              pOrg->dRms, pOrg->nEq); 
     111 
     112  for(i=0; i<nPck; i++) 
     113  { 
     114                pck = pPick[i]; 
     115    CDebug::Log(DEBUG_MINOR_INFO, 
     116                "%3d) %-4s %-6s %5.1f %3.0f %3.0f %5.2f %6.1f %4.1f %3.1f/%3.1f/%3.1f  %s\n", 
     117                                  i, pck->sSite, pck->sPhase, 
     118                                  pck->dDelta, pck->dAzm, pck->dToa * RAD2DEG, pck->tRes, pck->dT - pOrg->dT,  
     119                pck->dAff, pck->dAffDis, pck->dAffRes, pck->dAffPPD, pck->sTag 
     120               );   
     121  } 
     122 
     123  // sort the picks by resid 
     124  qsort(pPick, nPck, sizeof(PICK *), ComparePickResidDesc); 
     125 
     126  /* when trimming picks, don't trim anything that is either: 
     127     1) outside of the worst 20% in terms of residual 
     128     2) inside 1 std. deviation (assuming normal distribution with stddev = 3.33 sec)  
     129     We Make three BIG assumptions here: 
     130     a) That the ORIGIN is an accurate approximation of the Event origin 
     131     b) That the pick residual distribution is NORMAL. 
     132     c) That the stddev for such a distribution is 3.33 seconds. 
     133   **************************************************************/ 
     134#define OPCALC_MAX_RESID_TRIM_RATIO .20 
     135#define OPCALC_PICK_RESID_DIST_STD_DEV_SEC 3.33 
     136 
     137  // trim out the worst picks (by res) 
     138  for(i=0; i<(nPck*OPCALC_MAX_RESID_TRIM_RATIO); i++) 
     139  { 
     140                pck = pPick[i]; 
     141    CDebug::Log(DEBUG_MINOR_INFO, "Pick filter: %d res: %.2f aff: %.2f  (%.2f ~ %.2f)\n", 
     142                i, pck->tRes, pck->dAff, 
     143                fabs(pck->tRes), OPCALC_PICK_RESID_DIST_STD_DEV_SEC); 
     144    if(fabs(pck->tRes) < OPCALC_PICK_RESID_DIST_STD_DEV_SEC) 
     145      break; 
     146  } 
     147 
     148  /* process the origin with the full complement of picks  
     149   *******************************************************/ 
     150  if(i<nPck) 
     151  { 
     152    OPCalc_ProcessOriginSimple(pOrg, &pPick[i], nPck-i); 
     153 
     154    // log the results 
     155    CDebug::Log(DEBUG_MINOR_INFO,"OPC_PO: Trimmed Origin: %.2f/%.2f/%.2f - %.2f  Aff: %.2f  AfGp: %.2f AfNeq: %.2f  RMS: %.2f Gap: %.2f\n", 
     156                pOrg->dLat, pOrg->dLon, pOrg->dZ, pOrg->dT, pOrg->dAff, pOrg->dAffGap, pOrg->dAffNumArr, pOrg->dRms, pOrg->dGap, 
     157                pOrg->dRms, pOrg->nEq); 
     158 
     159    for(; i<nPck; i++) 
     160    { 
     161                  pck = pPick[i]; 
     162      CDebug::Log(DEBUG_MINOR_INFO, 
     163                  "%3d) %-4s %-6s %5.1f %3.0f %3.0f %5.2f %6.1f %4.1f %3.1f/%3.1f/%3.1f  %s\n", 
     164                                    i, pck->sSite, pck->sPhase, 
     165                                    pck->dDelta, pck->dAzm, pck->dToa * RAD2DEG, pck->tRes, pck->dT - pOrg->dT,  
     166                  pck->dAff, pck->dAffDis, pck->dAffRes, pck->dAffPPD, pck->sTag 
     167                 );   
     168    } 
     169 
     170    // if the full was better, then reprocess the parameters using the FULL  
     171    if(dFullAff > pOrg->dAff) 
     172    { 
     173      OPCalc_ProcessOriginSimple(pOrg, pPick, nPck); 
     174    } 
     175  } 
     176 
     177  // sort the picks by resid 
     178  qsort(pPick, nPck, sizeof(PICK *), ComparePickiPickAsc); 
     179 
     180  return(0); 
     181 
     182} 
     183int OPCalc_ProcessOriginSimple(ORIGIN * pOrg, PICK ** pPick, int nPck)  
     184{ 
     185 
     186  double pPickDistArray[OPCALC_MAX_PICKS]; 
     187  double pPickAzmArray[OPCALC_MAX_PICKS]; 
     188 
     189  // Initialize origin vars 
     190        int nEq = 0; 
     191  int i; 
     192 
     193        double sum = 0.0; 
     194  double dWeight = 0.0; 
     195  PICK * pck; 
     196  int iRetCode; 
     197  double dGap; 
     198 
     199  PhaseType  ptPhase; 
     200  PhaseClass pcPhase; 
     201 
     202  // Set default RMS to absurd level.  Shouldn't this be an affinity setting. 
     203  pOrg->dRms = 10000.0; 
     204 
     205 
     206//  CDebug::Log(DEBUG_MAJOR_INFO,"Locate(I): Org(%6.3f,%8.3f,%5.1f - %.2f)\n", 
     207//              pOrg->dLat, pOrg->dLon, pOrg->dZ, pOrg->dT); 
     208 
     209        for(i=0; i<nPck; i++)  
     210  { 
     211                pck = pPick[i]; 
     212    iRetCode = OPCalc_CalculateOriginPickParams(pck,pOrg); 
     213    if(iRetCode == -1) 
     214    { 
     215      CDebug::Log(DEBUG_MINOR_ERROR,"ProcessOrigin(): OPCalc_CalculateOriginPickParams  failed with " 
     216                                    "terminal error.  See logfile.  Returning!\n"); 
     217      return(-1); 
     218    } 
     219    else if(iRetCode == 1) 
     220    { 
     221      // could not find TravelTimeTable entry for pOrg,pck 
     222      CDebug::Log(DEBUG_MINOR_INFO,"ProcessOrigin(): OPCalc_CalculateOriginPickParams() could not " 
     223                                    "find TTT entry for Org,Pick!\n"); 
     224      continue; 
     225    } 
     226 
     227    // accumulate statistics 
     228    sum += pck->tRes*pck->tRes*pck->ttt.dLocWeight; 
     229 
     230    dWeight += pck->ttt.dLocWeight; 
     231 
     232    // copy the delta/azimuth of the pick to proper arrays for 
     233    // further calculations 
     234    pPickDistArray[nEq] = pck->dDelta; 
     235 
     236    // DK 021105  Change gap calculation to only use P-Class phases 
     237    // that way if we pull in random S, PPP, and SKiKP phases, 
     238    // they won't affect the gap "quality" of the solution. 
     239    ptPhase = GetPhaseType(pck->ttt.szPhase); 
     240    pcPhase = GetPhaseClass(ptPhase); 
     241    if(( (pcPhase == PHASECLASS_P) && (pck->dDelta < OPCALC_MAX_BELIEVABLE_DISTANCE_FOR_P_PHASE )) ||  
     242       (ptPhase == PHASE_PKPdf) 
     243      ) 
     244      pPickAzmArray[nEq] = pck->dAzm; 
     245    else 
     246      pPickAzmArray[nEq] = -1.0; 
     247 
     248 
     249    // increment the number of picks used to locate the origin 
     250    nEq++; 
     251     
     252    // keep the arrays from being overrun 
     253    if(nEq > OPCALC_MAX_PICKS) 
     254      break; 
     255  }  // end for each pick in the Pick Array 
     256 
     257  // if we didn't use atleast one pick.  Give up and go home. 
     258  if(nEq < 1) 
     259          return(1); 
     260 
     261 
     262  // Record the number of equations used to calc the location 
     263  pOrg->nEq = nEq; 
     264 
     265  // Record the residual standard deviation 
     266  pOrg->dRms = sqrt(sum/dWeight); 
     267 
     268  /* Calculate Pick Azimuth statistics for the Origin (Gap) 
     269   ****************************************************/ 
     270  // Sort the pick-azimuth array 
     271  qsortd(pPickAzmArray, nEq); 
     272 
     273  // If the Pick wasn't a P-class Pick, then we gave it a negative azm, 
     274  // so igonre all of the negative azm picks (which are all at the beginning 
     275  // since the array has been sorted 
     276        for(i=0; i<nEq-2; i++)  
     277  { 
     278    if(pPickAzmArray[i] >= 0.0) 
     279      break; 
     280  } 
     281 
     282  CDebug::Log(DEBUG_MAJOR_INFO, 
     283              "ProcessOrigin(): Calculating Gap for Org %d(%5.1f, %6.1f, %3.0f) based on %d valid picks.\n ", 
     284              pOrg->iOrigin, pOrg->dLat, pOrg->dLon, pOrg->dZ, nEq - i); 
     285  // Calculate the gap for the last-to-first wrap 
     286        dGap = pPickAzmArray[i] + 360.0 - pPickAzmArray[nEq-1]; 
     287        for(; i<nEq-1; i++)  
     288  { 
     289    // for each gap between two picks, record only if largest so far 
     290    if(pPickAzmArray[i+1] - pPickAzmArray[i] > dGap) 
     291      dGap = pPickAzmArray[i+1] - pPickAzmArray[i]; 
     292        } 
     293        pOrg->dGap = dGap; 
     294 
     295  /* Calculate Pick Distance statistics for the Origin 
     296   ****************************************************/ 
     297  // Sort the pick-distance array 
     298  qsortd(pPickDistArray, nEq); 
     299 
     300  // Calculate the minimum station distance for the origin 
     301        pOrg->dDelMin = pPickDistArray[0]; 
     302 
     303  // Calculate the maximum station distance for the origin 
     304        pOrg->dDelMax = pPickDistArray[nEq-1]; 
     305 
     306  // Calculate the median station distance for the origin 
     307        pOrg->dDelMod = 0.5*(pPickDistArray[nEq/2] + pPickDistArray[(nEq-1)/2]); 
     308 
     309 
     310  /* Calculate the Affinity for the Origin (and Picks)  
     311   ****************************************************/ 
     312  iRetCode = OPCalc_CalcOriginAffinity(pOrg, pPick, nPck); 
     313  if(iRetCode) 
     314  { 
     315    CDebug::Log(DEBUG_MINOR_ERROR, 
     316                "Error: ProcessOrigin(): OPCalc_CalcOriginAffinity() return (%d)\n", 
     317                iRetCode); 
     318    return(iRetCode); 
     319  } 
     320      
     321  return(0); 
     322}  // End Process Location() 
     323 
     324 
    38325int OPCalc_CalcOriginAffinity(ORIGIN * pOrg, PICK ** ppPick, int nPck)  
    39326{ 
     
    48335 
    49336  // Log the calculated values 
    50         CDebug::Log(DEBUG_MINOR_INFO,"Affinity(): dDelMin:%.2f dDelMod:%.2f dDelMax:%.2f\n", 
     337        CDebug::Log(DEBUG_MAJOR_INFO,"Affinity(): dDelMin:%.2f dDelMod:%.2f dDelMax:%.2f\n", 
    51338                pOrg->dDelMin, pOrg->dDelMod, pOrg->dDelMax); 
    52339 
     
    56343    //         pOrg->dAffGap = 1.0+OPCalc_BellCurve(pOrg->dGap/360.0); 
    57344    // dAffGap range is 0.0 - 2.0 
    58         if(pOrg->nEq < OPCALC_nMinStatPickCount) 
     345  pOrg->dAffGap = 4 * OPCalc_BellCurve(pOrg->dGap/360.0);  
     346        if(pOrg->nEq < OPCALC_nMinStatPickCount && pOrg->dAffGap < 1.0) 
    59347                pOrg->dAffGap = 1.0; 
    60   else 
    61     pOrg->dAffGap = 4 * OPCalc_BellCurve(pOrg->dGap/360.0);  
     348 
    62349//    pOrg->dAffGap = 3 * OPCalc_BellCurve(pOrg->dGap/360.0);  
    63350 
     
    74361                pOrg->dAffNumArr = 1.0; 
    75362        else 
    76                 pOrg->dAffNumArr = log10((float)(pOrg->nEq)); 
     363                pOrg->dAffNumArr = log10((double)(pOrg->nEq)); 
    77364 
    78365        for(i=0; i<nPck; i++)  
     
    99386  { 
    100387    pOrg->dAff = dAffinitySum / iAffinityNum; 
     388 
     389    /* now lets do something more advanced.   
     390       We are trying to calculate the "quality" of this origin.   
     391       We're not trying to recalculate where the origin should be, 
     392       only trying to caculate a "quality" number. 
     393       Under the current basic calculations, we can run into problems 
     394       where a couple of random picks can have residuals close enough in  
     395       to associate, but far enough out to lower the quality of the origin. 
     396       A problem is, that as soon as you remove a pick from the origin  
     397       calculation, you have to do a lot of quality recalculation.  Removing  
     398       one pick potentially affects both AffGap affinity component as well 
     399       as the AffNumArr. 
     400       What we'd like is to find some sort of peak quality value for the Origin, 
     401       (a reverse saddle).  We'll try to get there by taking the full result 
     402       (all-picks), and remove the picks with the lowest affinity until we hit  
     403       a point where the origin affinity starts to decrease.   
     404       Unfortunately this can't all be done in the OPCalc routines, because the 
     405       Gap is currently calculated in the Glock module ONLY. 
     406       DK 0920'06 
     407      ************************************************************************/ 
     408 
     409    for(i=0; i<nPck; i++)  
     410    { 
     411    } 
     412 
     413 
     414 
    101415  } 
    102416  else 
  • trunk/src/seismic_processing/glass/src/modules/Publisher/PublisherScroll.cpp

    r2189 r3212  
    9999//              dt->Date20().GetBuffer(), org->dLat, org->dLon, org->dZ, 
    100100//              org->nEq, org->dRms); 
    101         strncpy(txt, " Seq   DeclareTime    LastPub NextPub Nph Npub  Xs  Lat    Lon     Time", sizeof(txt)-1); 
     101        strncpy(txt, " Seq   DeclareTime    LastPub NextPub Nph Npub  Xs  Lat    Lon  Dep    Time", sizeof(txt)-1); 
    102102        txt[sizeof(txt)-1] = 0x00; 
    103103        TextOut(hdc, 10, h, txt, strlen(txt)); 
     
    194194    { 
    195195      sprintf(PubStatusList[nPub], 
    196               "%c%4d  %13s   %5s   %5s %4d %3d  %3d %5.1f %6.1f %13s", 
     196              "%c%4d  %13s   %5s   %5s %4d %3d  %3d %5.1f %6.1f %3.0f %13s", 
    197197              (QList[i].bDead) ? '-' : ' ', 
    198198              pOrigin->iOrigin, Date13(QList[i].tDeclare,sztDeclare), 
    199199              sztLastPub, sztNextPub,  
    200200              pOrigin->nPh, QList[i].iNumPub, QList[i].iNumChanges, 
    201               QList[i].dLat, QList[i].dLon, Date13(QList[i].tOrigin,sztOrigin)); 
     201              QList[i].dLat, QList[i].dLon, QList[i].dZ, Date13((time_t)QList[i].tOrigin,sztOrigin)); 
    202202    } 
    203203    else 
     
    205205      /* this is a dead quake */ 
    206206      sprintf(PubStatusList[nPub], 
    207               "%c%4d  %13s   %5s   %5s %4d %3d  %3d %5.1f %6.1f %13s", 
     207              "%c%4d  %13s   %5s   %5s %4d %3d  %3d %5.1f %6.1f %3.0f %13s", 
    208208              (QList[i].bDead) ? '-' : ' ', 
    209209              QList[i].iOrigin, Date13(QList[i].tDeclare,sztDeclare), 
    210210              sztLastPub, sztNextPub,  
    211211              0, QList[i].iNumPub, QList[i].iNumChanges, 
    212               QList[i].dLat, QList[i].dLon, Date13(QList[i].tOrigin,sztOrigin)); 
     212              QList[i].dLat, QList[i].dLon, QList[i].dZ, Date13((time_t)QList[i].tOrigin,sztOrigin)); 
    213213    } 
    214214    nPub++; 
  • trunk/src/seismic_processing/glass/src/modules/Publisher/publish.cpp

    r2189 r3212  
    77 *    Revision history: 
    88 *     $Log$ 
    9  *     Revision 1.1  2006/05/24 15:04:30  paulf 
    10  *     first inclusion 
     9 *     Revision 1.2  2007/12/27 18:05:23  paulf 
     10 *     sync from hydra_proj circa Oct 2007 
     11 * 
     12 *     Revision 1.3  2006/09/30 05:41:52  davidk 
     13 *     Added dZ(event depth) to the quake info tracked by publisher. 
     14 * 
     15 *     Revision 1.2  2006/04/22 01:14:54  davidk 
     16 *     Downgraded the severity on "unknown idOrigin" error in the publisher, 
     17 *     as it is not a serious error as once thought, and sitescope is sending it out 
     18 *     as fatal in v1.43. 
    1119 * 
    1220 *     Revision 1.1.1.1  2005/06/22 19:30:48  michelle 
     
    200208      QList[iQuake].dLon = (float)pOrg->dLon; 
    201209      QList[iQuake].tOrigin = (float)pOrg->dT; 
     210      QList[iQuake].dZ = (float)pOrg->dZ; 
    202211 
    203212      AlgOriginChanged(&QList[iQuake], ectChangeType); 
     
    208217    else 
    209218    { 
    210       CDebug::Log(DEBUG_MAJOR_WARNING, "OriginChanged(): Unknown idOrigin (%d)(%d).\n", 
     219      CDebug::Log(DEBUG_MINOR_WARNING, "OriginChanged(): Unknown idOrigin (%d)(%d).\n", 
    211220                  idOrigin, (int)ectChangeType); 
    212221      return(1); 
  • trunk/src/seismic_processing/glass/src/modules/Publisher/publish.h

    r2189 r3212  
    77 *    Revision history: 
    88 *     $Log$ 
    9  *     Revision 1.1  2006/05/24 15:04:30  paulf 
    10  *     first inclusion 
     9 *     Revision 1.2  2007/12/27 18:05:23  paulf 
     10 *     sync from hydra_proj circa Oct 2007 
     11 * 
     12 *     Revision 1.2  2006/09/30 05:41:34  davidk 
     13 *     Added dZ(event depth) to the quake info tracked by publisher. 
    1114 * 
    1215 *     Revision 1.1.1.1  2005/06/22 19:30:48  michelle 
     
    6871   float      dLat; 
    6972   float      dLon; 
     73   float      dZ; 
    7074   double     tOrigin; 
    7175} PubQuake; 
  • trunk/src/seismic_processing/glass/src/modules/Refocus/Refocus.cpp

    r2176 r3212  
    77 *    Revision history: 
    88 *     $Log$ 
    9  *     Revision 1.1  2006/05/22 16:01:25  paulf 
    10  *     added from hydra_proj, new version 
     9 *     Revision 1.2  2007/12/27 18:05:23  paulf 
     10 *     sync from hydra_proj circa Oct 2007 
     11 * 
     12 *     Revision 1.7  2006/04/27 20:16:01  davidk 
     13 *     downgraded "can't find origin" message to MINOR_WARNING from MINOR_ERROR. 
    1114 * 
    1215 *     Revision 1.6  2005/10/17 06:36:01  davidk 
     
    569572    // We could not find the Origin in glint!  This is bad, because we should only be called 
    570573    // for active quakes.  Issue Error Message! 
    571     CDebug::Log(DEBUG_MINOR_ERROR,"Quake():  Could not find Origin(%s) in Glint\n", ent); 
     574    CDebug::Log(DEBUG_MINOR_WARNING,"Quake():  Could not find Origin(%s) in Glint\n", ent); 
    572575    return; 
    573576  } 
Note: See TracChangeset for help on using the changeset viewer.