Package gov.usgs.earthquake.eids
Class QuakemlUtils
java.lang.Object
gov.usgs.earthquake.eids.QuakemlUtils
Utility methods for ANSS Quakeml objects.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.static org.quakeml_1_2.Event
getFirstEvent
(org.quakeml_1_2.EventParameters eventParameters) Find the first event in a message.static org.quakeml_1_2.FocalMechanism
getFocalMechanism
(org.quakeml_1_2.Event event, String id) Find a specific FocalMechanism in an event.static org.quakeml_1_2.Quakeml
getLightweightFocalMechanism
(org.quakeml_1_2.Quakeml q, 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.Quakeml
getLightweightOrigin
(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.Magnitude
getMagnitude
(org.quakeml_1_2.Event event, String id) Find a specific Magnitude in an event.static String
getMagnitudeType
(String magnitudeType) static org.quakeml_1_2.Origin
Find a specific Origin in an Event.static org.quakeml_1_2.Magnitude
getPreferredMagnitude
(org.quakeml_1_2.Event event) Find the preferred Magnitude in an Event.static org.quakeml_1_2.Origin
getPreferredOrigin
(org.quakeml_1_2.Event event) Find the preferred Origin in an Event.static BigInteger
getValue
(org.quakeml_1_2.IntegerQuantity value) static BigDecimal
getValue
(org.quakeml_1_2.RealQuantity value) static Date
getValue
(org.quakeml_1_2.TimeQuantity value) static boolean
hasPhaseData
(org.quakeml_1_2.Event event) Check if an event has phase data.static void
removePhaseData
(org.quakeml_1_2.Event event) Similar tohasPhaseData(Event)
, but empties any lists that have phase data.static org.quakeml_1_2.Event
shallowClone
(org.quakeml_1_2.Event oldEvent) Create a copy of an event object.static org.quakeml_1_2.EventParameters
shallowClone
(org.quakeml_1_2.EventParameters oldEventParameters) Create a copy of an event parameters object.static org.quakeml_1_2.FocalMechanism
shallowClone
(org.quakeml_1_2.FocalMechanism oldMech) Create a copy of a focal mechanism object.static org.quakeml_1_2.Magnitude
shallowClone
(org.quakeml_1_2.Magnitude oldMagnitude) Create a copy of a magnitude object.static org.quakeml_1_2.Origin
shallowClone
(org.quakeml_1_2.Origin oldOrigin) Create a copy of an origin object.
-
Constructor Details
-
QuakemlUtils
public QuakemlUtils()
-
-
Method Details
-
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
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
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, 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
- Parameters:
value
- RealQuantity- Returns:
- value.getValue(), or null if value == null.
-
getValue
- Parameters:
value
- IntegerQuantity- Returns:
- value.getValue(), or null if value == null.
-
getValue
- Parameters:
value
- TimeQuantity- Returns:
- value.getValue(), or null if value == null.
-
getMagnitudeType
- 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, 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.
-