From f2e2036696be8f08693b0d3ee89160b077596f7f Mon Sep 17 00:00:00 2001 From: Jean-Marie Saurel Date: Thu, 4 Mar 2021 16:11:15 +0000 Subject: [PATCH 1/3] Better handling of incoming messages without magnitude --- src/ipgp/apps/ew2sc3/ew2sc3.cpp | 47 ++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/src/ipgp/apps/ew2sc3/ew2sc3.cpp b/src/ipgp/apps/ew2sc3/ew2sc3.cpp index e7894a8cd..526846fe2 100644 --- a/src/ipgp/apps/ew2sc3/ew2sc3.cpp +++ b/src/ipgp/apps/ew2sc3/ew2sc3.cpp @@ -839,7 +839,10 @@ int EW2SC3::extractOrigin(char* msg) { eventMin = line.substr(10, 2); eventSec = line.substr(12, 2) + "." + line.substr(14, 2); eventSec = blank_replace(eventSec, zero); - eventAmplitudeMagnitude = line.substr(36, 1) + "." + line.substr(37, 2); + if ( line.substr(36, 3) == " " ) + eventAmplitudeMagnitude = "NaN"; + else + eventAmplitudeMagnitude = line.substr(36, 1) + "." + line.substr(37, 2); eventAmplitudeMagnitude = blank_replace(eventAmplitudeMagnitude, zero); neventMonth = blank_replace(eventMonth, zero); neventDay = blank_replace(eventDay, zero); @@ -865,8 +868,10 @@ int EW2SC3::extractOrigin(char* msg) { eventLonMin = line.substr(27, 4); eventErh = line.substr(85, 2) + "." + line.substr(87, 2); eventErz = line.substr(89, 2) + "." + line.substr(91, 2); - - eventCodaDurationMagnitude = line.substr(70, 1) + "." + line.substr(71, 2); + if ( line.substr(70, 3) == " " ) + eventCodaDurationMagnitude = "NaN"; + else + eventCodaDurationMagnitude = line.substr(70, 1) + "." + line.substr(71, 2); eventCodaDurationMagnitude = blank_replace(eventCodaDurationMagnitude, zero); eventPreferredMagnitude = line.substr(147, 1) + "." + line.substr(148, 2); eventPreferredMagnitude = blank_replace(eventPreferredMagnitude, zero); @@ -1178,24 +1183,28 @@ int EW2SC3::extractOrigin(char* msg) { mci.setModificationTime(Time::GMT()); // Amplitude magnitude - MagnitudePtr amag = Magnitude::Create(); - amag->setType("ML"); - amag->setOriginID(origin->publicID()); - amag->setMagnitude(RealQuantity(to_double(eventAmplitudeMagnitude))); - amag->setMethodID("mean"); - amag->setStationCount(idx); - amag->setCreationInfo(mci); - origin->add(amag.get()); + if ( eventAmplitudeMagnitude != "NaN" ) { + MagnitudePtr amag = Magnitude::Create(); + amag->setType("ML"); + amag->setOriginID(origin->publicID()); + amag->setMagnitude(RealQuantity(to_double(eventAmplitudeMagnitude))); + amag->setMethodID("mean"); + amag->setStationCount(idx); + amag->setCreationInfo(mci); + origin->add(amag.get()); + } // Coda duration magnitude - MagnitudePtr dmag = Magnitude::Create(); - dmag->setType("Md"); - dmag->setOriginID(origin->publicID()); - dmag->setMagnitude(RealQuantity(to_double(eventCodaDurationMagnitude))); - dmag->setMethodID("mean"); - dmag->setStationCount(idx); - dmag->setCreationInfo(mci); - origin->add(dmag.get()); + if ( eventCodaDurationMagnitude != "NaN" ) { + MagnitudePtr dmag = Magnitude::Create(); + dmag->setType("Md"); + dmag->setOriginID(origin->publicID()); + dmag->setMagnitude(RealQuantity(to_double(eventCodaDurationMagnitude))); + dmag->setMethodID("mean"); + dmag->setStationCount(idx); + dmag->setCreationInfo(mci); + origin->add(dmag.get()); + } OriginQuality oq; if ( to_double(eventRms) != .0 ) From 44930ec31d08229da2e062403bd04ca08517553e Mon Sep 17 00:00:00 2001 From: Jean-Marie Saurel Date: Tue, 13 Jul 2021 16:46:36 +0000 Subject: [PATCH 2/3] Remove unused variables and bug correction Event date space were not converted to 0 when parsing the message --- src/ipgp/apps/ew2sc3/ew2sc3.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/ipgp/apps/ew2sc3/ew2sc3.cpp b/src/ipgp/apps/ew2sc3/ew2sc3.cpp index 526846fe2..23e5b2a48 100644 --- a/src/ipgp/apps/ew2sc3/ew2sc3.cpp +++ b/src/ipgp/apps/ew2sc3/ew2sc3.cpp @@ -780,11 +780,6 @@ int EW2SC3::extractOrigin(char* msg) { string eventErz; string eventMinDistance; string zero = "0"; - string neventMonth; - string neventDay; - string neventHour; - string neventMin; - string neventSec; string tmpFile = _configPath + "arc.tmp"; // Write temporary archive file @@ -838,22 +833,23 @@ int EW2SC3::extractOrigin(char* msg) { eventHour = line.substr(8, 2); eventMin = line.substr(10, 2); eventSec = line.substr(12, 2) + "." + line.substr(14, 2); - eventSec = blank_replace(eventSec, zero); if ( line.substr(36, 3) == " " ) eventAmplitudeMagnitude = "NaN"; else eventAmplitudeMagnitude = line.substr(36, 1) + "." + line.substr(37, 2); eventAmplitudeMagnitude = blank_replace(eventAmplitudeMagnitude, zero); - neventMonth = blank_replace(eventMonth, zero); - neventDay = blank_replace(eventDay, zero); - neventHour = blank_replace(eventHour, zero); - neventMin = blank_replace(eventMin, zero); - neventSec = blank_replace(eventSec, zero); + eventYear = blank_replace(eventYear, zero); + eventMonth = blank_replace(eventMonth, zero); + eventDay = blank_replace(eventDay, zero); + eventHour = blank_replace(eventHour, zero); + eventMin = blank_replace(eventMin, zero); + eventSec = blank_replace(eventSec, zero); eventDepth = line.substr(31, 3) + "." + line.substr(34, 2); eventPhases = line.substr(39, 3); eventAzimuth = line.substr(42, 3); eventMinDistance = line.substr(45, 3); eventRms = line.substr(48, 2) + "." + line.substr(50, 2); + eventRms = blank_replace(eventRms, zero); eventLatDeg = line.substr(16, 2); if ( line.substr(18, 1) == "S" ) eventLatSit = "S"; @@ -867,7 +863,9 @@ int EW2SC3::extractOrigin(char* msg) { eventLonSit = "W"; eventLonMin = line.substr(27, 4); eventErh = line.substr(85, 2) + "." + line.substr(87, 2); + eventErh = blank_replace(eventErh, zero); eventErz = line.substr(89, 2) + "." + line.substr(91, 2); + eventErz = blank_replace(eventErz, zero); if ( line.substr(70, 3) == " " ) eventCodaDurationMagnitude = "NaN"; else From 068f983581d418bc0100139948f9fbaf8a4f6a94 Mon Sep 17 00:00:00 2001 From: Jean-Marie Saurel Date: Thu, 28 Apr 2022 13:48:46 +0000 Subject: [PATCH 3/3] Skip phases if they are not labelled P or S --- src/ipgp/plugins/locator/hypo71/hypo71.cpp | 150 +++++++++++---------- 1 file changed, 79 insertions(+), 71 deletions(-) diff --git a/src/ipgp/plugins/locator/hypo71/hypo71.cpp b/src/ipgp/plugins/locator/hypo71/hypo71.cpp index fdcd95642..a197ac051 100644 --- a/src/ipgp/plugins/locator/hypo71/hypo71.cpp +++ b/src/ipgp/plugins/locator/hypo71/hypo71.cpp @@ -1437,7 +1437,7 @@ Origin* Hypo71::locate(PickList& pickList) { pick->waveformID().stationCode()); char buffer[10]; - double pmin, psec, ssec; + double pmin, psec, ssec, ptime; if ( pick->phaseHint().code().find("P") != string::npos ) { @@ -1454,49 +1454,55 @@ Origin* Hypo71::locate(PickList& pickList) { double newmin = (pmin / 60) - (int) (sharedTime / 3600) * 60; pMinute = toString((int) newmin); - psec = getTimeValue(pickList, pick->waveformID().networkCode(), staName, "P", 0) - pmin; - if ( psec > 99.99 ) - sprintf(buffer, "%#03.1f", ssec); - else - sprintf(buffer, "%#02.2f", psec); - pSec = toString(buffer); - - pPolarity = getPickPolarity(pickList, pick->waveformID().networkCode(), - pick->waveformID().stationCode(), "P"); - - try { - if ( pConfig.readInto(uncertaintyList, "WEIGHT_UNCERTAINTY_BOUNDARIES") ) { - h71PWeight = toString(getH71Weight(pickList, pick->waveformID().networkCode(), staName, "P", uncertaintyList)); - } - else - h71PWeight = toString(getH71Weight(pickList, pick->waveformID().networkCode(), staName, "P", maxUncertainty)); - } - catch ( ... ) { - h71PWeight = maxWeight; - } - - ssec = getTimeValue(pickList, pick->waveformID().networkCode(), staName, "S", 0) - pmin; - if ( ssec > 0. ) { - //! if ssec > 99.99 then it won't fit into a F5.2 so we convert it into a F5.1 - if ( ssec > 99.99 ) + ptime = getTimeValue(pickList, pick->waveformID().networkCode(), staName, "P", 0); + if ( ptime != -1 ) { + psec = ptime - pmin; + if ( psec > 99.99 ) sprintf(buffer, "%#03.1f", ssec); else - sprintf(buffer, "%#02.2f", ssec); - sSec = toString(buffer); + sprintf(buffer, "%#02.2f", psec); + pSec = toString(buffer); - sPolarity = getPickPolarity(pickList, pick->waveformID().networkCode(), - pick->waveformID().stationCode(), "S"); + pPolarity = getPickPolarity(pickList, pick->waveformID().networkCode(), + pick->waveformID().stationCode(), "P"); - isSPhase = true; try { if ( pConfig.readInto(uncertaintyList, "WEIGHT_UNCERTAINTY_BOUNDARIES") ) { - h71SWeight = toString(getH71Weight(pickList, pick->waveformID().networkCode(), staName, "S", uncertaintyList)); + h71PWeight = toString(getH71Weight(pickList, pick->waveformID().networkCode(), staName, "P", uncertaintyList)); } else - h71SWeight = toString(getH71Weight(pickList, pick->waveformID().networkCode(), staName, "S", maxUncertainty)); + h71PWeight = toString(getH71Weight(pickList, pick->waveformID().networkCode(), staName, "P", maxUncertainty)); } catch ( ... ) { - h71SWeight = maxWeight; + h71PWeight = maxWeight; + } + } + + ptime = getTimeValue(pickList, pick->waveformID().networkCode(), staName, "S", 0); + if ( ptime != -1 ) { + ssec = ptime - pmin; + if ( ssec > 0. ) { + //! if ssec > 99.99 then it won't fit into a F5.2 so we convert it into a F5.1 + if ( ssec > 99.99 ) + sprintf(buffer, "%#03.1f", ssec); + else + sprintf(buffer, "%#02.2f", ssec); + sSec = toString(buffer); + + sPolarity = getPickPolarity(pickList, pick->waveformID().networkCode(), + pick->waveformID().stationCode(), "S"); + + isSPhase = true; + try { + if ( pConfig.readInto(uncertaintyList, "WEIGHT_UNCERTAINTY_BOUNDARIES") ) { + h71SWeight = toString(getH71Weight(pickList, pick->waveformID().networkCode(), staName, "S", uncertaintyList)); + } + else + h71SWeight = toString(getH71Weight(pickList, pick->waveformID().networkCode(), staName, "S", maxUncertainty)); + } + catch ( ... ) { + h71SWeight = maxWeight; + } } } } @@ -2732,7 +2738,7 @@ Hypo71::getZTR(const PickList& pickList) { string stationMappedName = getStationMappedCode(pick->waveformID().networkCode(), pick->waveformID().stationCode()); char buffer[10]; - double pmin, psec, ssec; + double pmin, psec, ssec, ptime; string tmpDate = pick->time().value().toString("%Y").substr(2, 2) + pick->time().value().toString("%m") + pick->time().value().toString("%d"); @@ -2753,46 +2759,51 @@ Hypo71::getZTR(const PickList& pickList) { double newmin = pmin / 60 - (int) (sharedTime / 3600) * 60; pMinute = toString((int) newmin); - psec = getTimeValue(pickList, pick->waveformID().networkCode(), staName, "P", 0) - pmin; - pPolarity = getPickPolarity(pickList, pick->waveformID().networkCode(), staName, "P"); - if ( psec > 99.99 ) - sprintf(buffer, "%#03.1f", ssec); - else - sprintf(buffer, "%#02.2f", psec); - pSec = toString(buffer); - - try { - if ( pConfig.readInto(uncertaintyList, "WEIGHT_UNCERTAINTY_BOUNDARIES") ) { - h71PWeight = toString(getH71Weight(pickList, pick->waveformID().networkCode(), staName, "P", uncertaintyList)); - } - else - h71PWeight = toString(getH71Weight(pickList, pick->waveformID().networkCode(), staName, "P", maxUncertainty)); - } - catch ( ... ) { - h71PWeight = maxWeight; - } - - ssec = getTimeValue(pickList, pick->waveformID().networkCode(), staName, "S", 0) - pmin; - - if ( ssec > 0. ) { - // If ssec > 99.99 then it won't fit into a F5.2 - // so we convert it into a F5.1 - if ( ssec > 99.99 ) + ptime = getTimeValue(pickList, pick->waveformID().networkCode(), staName, "P", 0); + if ( ptime != -1 ) { + psec = ptime - pmin; + pPolarity = getPickPolarity(pickList, pick->waveformID().networkCode(), staName, "P"); + if ( psec > 99.99 ) sprintf(buffer, "%#03.1f", ssec); else - sprintf(buffer, "%#02.2f", ssec); - sSec = toString(buffer); - sPolarity = getPickPolarity(pickList, pick->waveformID().networkCode(), staName, "S"); - isSPhase = true; + sprintf(buffer, "%#02.2f", psec); + pSec = toString(buffer); + try { if ( pConfig.readInto(uncertaintyList, "WEIGHT_UNCERTAINTY_BOUNDARIES") ) { - h71SWeight = toString(getH71Weight(pickList, pick->waveformID().networkCode(), staName, "S", uncertaintyList)); + h71PWeight = toString(getH71Weight(pickList, pick->waveformID().networkCode(), staName, "P", uncertaintyList)); } else - h71SWeight = toString(getH71Weight(pickList, pick->waveformID().networkCode(), staName, "S", maxUncertainty)); + h71PWeight = toString(getH71Weight(pickList, pick->waveformID().networkCode(), staName, "P", maxUncertainty)); } catch ( ... ) { - h71SWeight = maxWeight; + h71PWeight = maxWeight; + } + } + + ptime = getTimeValue(pickList, pick->waveformID().networkCode(), staName, "S", 0); + if ( ptime != -1 ) { + ssec = ptime - pmin; + if ( ssec > 0. ) { + // If ssec > 99.99 then it won't fit into a F5.2 + // so we convert it into a F5.1 + if ( ssec > 99.99 ) + sprintf(buffer, "%#03.1f", ssec); + else + sprintf(buffer, "%#02.2f", ssec); + sSec = toString(buffer); + sPolarity = getPickPolarity(pickList, pick->waveformID().networkCode(), staName, "S"); + isSPhase = true; + try { + if ( pConfig.readInto(uncertaintyList, "WEIGHT_UNCERTAINTY_BOUNDARIES") ) { + h71SWeight = toString(getH71Weight(pickList, pick->waveformID().networkCode(), staName, "S", uncertaintyList)); + } + else + h71SWeight = toString(getH71Weight(pickList, pick->waveformID().networkCode(), staName, "S", maxUncertainty)); + } + catch ( ... ) { + h71SWeight = maxWeight; + } } } } @@ -3040,7 +3051,7 @@ Hypo71::getZTR(const PickList& pickList) { minDepth = depth; minRMS = toDouble(rms); minER = ER; - + _trialLatDeg = latDeg; _trialLatMin = latMin; _trialLonDeg = lonDeg; @@ -3369,6 +3380,3 @@ void Hypo71::updateProfile(const string& name) { } } // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - -