Package gov.usgs.earthquake.eids
Class QuakemlUtils
- java.lang.Object
-
- gov.usgs.earthquake.eids.QuakemlUtils
-
public class QuakemlUtils extends java.lang.ObjectUtility methods for ANSS Quakeml objects.
-
-
Constructor Summary
Constructors Constructor Description QuakemlUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.quakeml_1_2.CreationInfogetCreationInfo(org.quakeml_1_2.CreationInfo... infos)Flatten multiple creation info objects, but using the most specific (at end of list) value that is not null.static org.quakeml_1_2.EventgetFirstEvent(org.quakeml_1_2.EventParameters eventParameters)Find the first event in a message.static org.quakeml_1_2.FocalMechanismgetFocalMechanism(org.quakeml_1_2.Event event, java.lang.String id)Find a specific FocalMechanism in an event.static org.quakeml_1_2.QuakemlgetLightweightFocalMechanism(org.quakeml_1_2.Quakeml q, java.lang.String focalMechanismId)Extract a focalMechanism, triggering origin, derived origin, and derived magnitude from the first event in a quakeml message.static org.quakeml_1_2.QuakemlgetLightweightOrigin(org.quakeml_1_2.Quakeml q)Extract the preferred origin and magnitude from the first event in a quakeml message.static org.quakeml_1_2.MagnitudegetMagnitude(org.quakeml_1_2.Event event, java.lang.String id)Find a specific Magnitude in an event.static java.lang.StringgetMagnitudeType(java.lang.String magnitudeType)static org.quakeml_1_2.OrigingetOrigin(org.quakeml_1_2.Event event, java.lang.String id)Find a specific Origin in an Event.static org.quakeml_1_2.MagnitudegetPreferredMagnitude(org.quakeml_1_2.Event event)Find the preferred Magnitude in an Event.static org.quakeml_1_2.OrigingetPreferredOrigin(org.quakeml_1_2.Event event)Find the preferred Origin in an Event.static java.math.BigIntegergetValue(org.quakeml_1_2.IntegerQuantity value)static java.math.BigDecimalgetValue(org.quakeml_1_2.RealQuantity value)static java.util.DategetValue(org.quakeml_1_2.TimeQuantity value)static booleanhasPhaseData(org.quakeml_1_2.Event event)Check if an event has phase data.static voidremovePhaseData(org.quakeml_1_2.Event event)Similar tohasPhaseData(Event), but empties any lists that have phase data.static org.quakeml_1_2.EventshallowClone(org.quakeml_1_2.Event oldEvent)Create a copy of an event object.static org.quakeml_1_2.EventParametersshallowClone(org.quakeml_1_2.EventParameters oldEventParameters)Create a copy of an event parameters object.static org.quakeml_1_2.FocalMechanismshallowClone(org.quakeml_1_2.FocalMechanism oldMech)Create a copy of a focal mechanism object.static org.quakeml_1_2.MagnitudeshallowClone(org.quakeml_1_2.Magnitude oldMagnitude)Create a copy of a magnitude object.static org.quakeml_1_2.OriginshallowClone(org.quakeml_1_2.Origin oldOrigin)Create a copy of an origin object.
-
-
-
Method Detail
-
getFirstEvent
public static org.quakeml_1_2.Event getFirstEvent(org.quakeml_1_2.EventParameters eventParameters)
Find the first event in a message. If a quakeml event object does not exist, check for the first internal or scenario event.- Parameters:
eventParameters- to find event from- Returns:
- first event
-
getPreferredOrigin
public static org.quakeml_1_2.Origin getPreferredOrigin(org.quakeml_1_2.Event event)
Find the preferred Origin in an Event.- Parameters:
event- event- Returns:
- Origin with publicID equal to event.getPreferredOriginID(), or null if not found.
-
getOrigin
public static org.quakeml_1_2.Origin getOrigin(org.quakeml_1_2.Event event, java.lang.String id)Find a specific Origin in an Event.- Parameters:
event- event to searchid- publicID to find- Returns:
- Origin with publicID equal to id, or null if not found.
-
getPreferredMagnitude
public static org.quakeml_1_2.Magnitude getPreferredMagnitude(org.quakeml_1_2.Event event)
Find the preferred Magnitude in an Event.- Parameters:
event- event to search- Returns:
- Magnitude with publicID equal to event.getPreferredMagnitudeID(), or null if not found.
-
getMagnitude
public static org.quakeml_1_2.Magnitude getMagnitude(org.quakeml_1_2.Event event, java.lang.String id)Find a specific Magnitude in an event.- Parameters:
event- event to searchid- publicID to find.- Returns:
- Magnitude with publicID equal to id, or null if not found.
-
getFocalMechanism
public static org.quakeml_1_2.FocalMechanism getFocalMechanism(org.quakeml_1_2.Event event, java.lang.String id)Find a specific FocalMechanism in an event.- Parameters:
event- event to searchid- publicID to find.- Returns:
- FocalMechanism with publicID equal to id, or null if not found.
-
getCreationInfo
public static org.quakeml_1_2.CreationInfo getCreationInfo(org.quakeml_1_2.CreationInfo... infos)
Flatten multiple creation info objects, but using the most specific (at end of list) value that is not null.- Parameters:
infos- to flatten- Returns:
- a CreationInfo object with the most specific properties (later in arguments list), which may be null.
-
getValue
public static java.math.BigDecimal getValue(org.quakeml_1_2.RealQuantity value)
- Parameters:
value- RealQuantity- Returns:
- value.getValue(), or null if value == null.
-
getValue
public static java.math.BigInteger getValue(org.quakeml_1_2.IntegerQuantity value)
- Parameters:
value- IntegerQuantity- Returns:
- value.getValue(), or null if value == null.
-
getValue
public static java.util.Date getValue(org.quakeml_1_2.TimeQuantity value)
- Parameters:
value- TimeQuantity- Returns:
- value.getValue(), or null if value == null.
-
getMagnitudeType
public static java.lang.String getMagnitudeType(java.lang.String magnitudeType)
- Parameters:
magnitudeType- to return- Returns:
- MagntitudeType string
-
hasPhaseData
public static boolean hasPhaseData(org.quakeml_1_2.Event event)
Check if an event has phase data.- event.getPicks()
- event.getAmplitudes()
- event.getStationMagnitudes()
- event.getOrigins()
- origin.getArrivals()
- event.getMagnitudes()
- magnitude.getStationMagnitudeContributions()
- Parameters:
event- event to search.- Returns:
- true if phase data found, false otherwise.
-
removePhaseData
public static void removePhaseData(org.quakeml_1_2.Event event)
Similar tohasPhaseData(Event), but empties any lists that have phase data. Also removes <waveformID> elements from focalMechanism.- Parameters:
event- event to clear.
-
getLightweightOrigin
public static org.quakeml_1_2.Quakeml getLightweightOrigin(org.quakeml_1_2.Quakeml q)
Extract the preferred origin and magnitude from the first event in a quakeml message.- Parameters:
q- the quakeml message with a preferred origin.- Returns:
- a new Quakeml object.
-
getLightweightFocalMechanism
public static org.quakeml_1_2.Quakeml getLightweightFocalMechanism(org.quakeml_1_2.Quakeml q, java.lang.String focalMechanismId)Extract a focalMechanism, triggering origin, derived origin, and derived magnitude from the first event in a quakeml message.- Parameters:
q- the quakeml message with a focalMechanismfocalMechanismId- the focalMechanism to extract.- Returns:
- a new Quakeml object.
-
shallowClone
public static org.quakeml_1_2.EventParameters shallowClone(org.quakeml_1_2.EventParameters oldEventParameters)
Create a copy of an event parameters object. omits anies, events, and other attributes.- Parameters:
oldEventParameters- to copy- Returns:
- a new EventParameters object.
-
shallowClone
public static org.quakeml_1_2.Event shallowClone(org.quakeml_1_2.Event oldEvent)
Create a copy of an event object. omits amplitudes, anies, event descriptions, mechanisms, magnitudes, origins, other attributes, picks, preferred*ID, and station magnitudes.- Parameters:
oldEvent- to copy- Returns:
- a new Event object.
-
shallowClone
public static org.quakeml_1_2.Origin shallowClone(org.quakeml_1_2.Origin oldOrigin)
Create a copy of an origin object. omits anies, arrivals, and other attributes.- Parameters:
oldOrigin- to copy- Returns:
- a new Origin object.
-
shallowClone
public static org.quakeml_1_2.Magnitude shallowClone(org.quakeml_1_2.Magnitude oldMagnitude)
Create a copy of a magnitude object. omits anies, other attributes, and station magnitude contributions.- Parameters:
oldMagnitude- to copy- Returns:
- a new Magnitude object.
-
shallowClone
public static org.quakeml_1_2.FocalMechanism shallowClone(org.quakeml_1_2.FocalMechanism oldMech)
Create a copy of a focal mechanism object. omits anies, other attributes.- Parameters:
oldMech- to copy- Returns:
- a new FocalMechanism object.
-
-