Class: IngvQuake::MomentTensor
- Inherits:
-
Object
- Object
- IngvQuake::MomentTensor
- Defined in:
- lib/ingv_quake/models/moment_tensor.rb
Overview
The MomentTensor class represents a moment tensor solution for an event. It is an optional part of a FocalMechanism description.
Instance Attribute Summary collapse
-
#clvd ⇒ Float
readonly
CLVD (compensated linear vector dipole) parameter obtained from moment tensor inversion (decimal fraction between 0 and 1).
-
#creation_info ⇒ CreationInfo
readonly
The creation information for the moment tensor.
-
#data_used ⇒ DataUsed
readonly
Describes waveform data used for moment-tensor inversion.
-
#derived_origin_id ⇒ String
readonly
Refers to the publicID of the Origin derived in the moment tensor inversion.
-
#double_couple ⇒ Float
readonly
Double couple parameter obtained from moment tensor inversion (decimal fraction between 0 and 1).
-
#iso ⇒ Float
readonly
Isotropic part obtained from moment tensor inversion (decimal fraction between 0 and 1).
-
#moment_magnitude_id ⇒ String
readonly
Refers to the publicID of the Magnitude object which represents the derived moment magnitude.
-
#public_id ⇒ String
readonly
Resource identifier of MomentTensor.
-
#scalar_moment ⇒ Float
readonly
Scalar moment as derived in moment tensor inversion.
-
#tensor ⇒ Hash
readonly
Tensor object holding the moment tensor elements.
-
#variance_reduction ⇒ Float
readonly
Variance reduction of moment tensor inversion, given in percent (Dreger 2003).
Instance Method Summary collapse
-
#initialize(data) ⇒ MomentTensor
constructor
Initializes a new MomentTensor instance with the provided data.
- #parse_tensor(tensor_data) ⇒ Object
Constructor Details
#initialize(data) ⇒ MomentTensor
Initializes a new MomentTensor instance with the provided data.
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ingv_quake/models/moment_tensor.rb', line 30 def initialize(data) @public_id = data.fetch('publicID', nil) @variance_reduction = data.fetch('varianceReduction', nil)&.to_f @double_couple = data.fetch('doubleCouple', nil)&.to_f @clvd = data.fetch('clvd', nil)&.to_f @iso = data.fetch('iso', nil)&.to_f @derived_origin_id = data.fetch('derivedOriginID', nil) @moment_magnitude_id = data.fetch('momentMagnitudeID', nil) @tensor = parse_tensor(data.fetch('tensor', {})) @scalar_moment = data.dig('scalarMoment', 'value')&.to_f @data_used = data.fetch('dataUsed', nil)&.then { |data_used_data| DataUsed.new(data_used_data) } @creation_info = data.fetch('creationInfo', nil)&.then { |creation_info_data| CreationInfo.new(creation_info_data) } end |
Instance Attribute Details
#clvd ⇒ Float (readonly)
CLVD (compensated linear vector dipole) parameter obtained from moment tensor inversion (decimal fraction between 0 and 1).
22 23 24 |
# File 'lib/ingv_quake/models/moment_tensor.rb', line 22 def clvd @clvd end |
#creation_info ⇒ CreationInfo (readonly)
The creation information for the moment tensor.
22 23 24 |
# File 'lib/ingv_quake/models/moment_tensor.rb', line 22 def creation_info @creation_info end |
#data_used ⇒ DataUsed (readonly)
Describes waveform data used for moment-tensor inversion.
22 23 24 |
# File 'lib/ingv_quake/models/moment_tensor.rb', line 22 def data_used @data_used end |
#derived_origin_id ⇒ String (readonly)
Refers to the publicID of the Origin derived in the moment tensor inversion.
22 23 24 |
# File 'lib/ingv_quake/models/moment_tensor.rb', line 22 def derived_origin_id @derived_origin_id end |
#double_couple ⇒ Float (readonly)
Double couple parameter obtained from moment tensor inversion (decimal fraction between 0 and 1).
22 23 24 |
# File 'lib/ingv_quake/models/moment_tensor.rb', line 22 def double_couple @double_couple end |
#iso ⇒ Float (readonly)
Isotropic part obtained from moment tensor inversion (decimal fraction between 0 and 1).
22 23 24 |
# File 'lib/ingv_quake/models/moment_tensor.rb', line 22 def iso @iso end |
#moment_magnitude_id ⇒ String (readonly)
Refers to the publicID of the Magnitude object which represents the derived moment magnitude.
22 23 24 |
# File 'lib/ingv_quake/models/moment_tensor.rb', line 22 def moment_magnitude_id @moment_magnitude_id end |
#public_id ⇒ String (readonly)
Resource identifier of MomentTensor.
22 23 24 |
# File 'lib/ingv_quake/models/moment_tensor.rb', line 22 def public_id @public_id end |
#scalar_moment ⇒ Float (readonly)
Scalar moment as derived in moment tensor inversion. Unit: N m.
22 23 24 |
# File 'lib/ingv_quake/models/moment_tensor.rb', line 22 def scalar_moment @scalar_moment end |
#tensor ⇒ Hash (readonly)
Tensor object holding the moment tensor elements.
22 23 24 |
# File 'lib/ingv_quake/models/moment_tensor.rb', line 22 def tensor @tensor end |
#variance_reduction ⇒ Float (readonly)
Variance reduction of moment tensor inversion, given in percent (Dreger 2003). This is a goodness-of-fit measure.
22 23 24 |
# File 'lib/ingv_quake/models/moment_tensor.rb', line 22 def variance_reduction @variance_reduction end |
Instance Method Details
#parse_tensor(tensor_data) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/ingv_quake/models/moment_tensor.rb', line 44 def parse_tensor(tensor_data) tensor = {} tensor_data.each do |key, value_data| tensor[key] = value_data.dig('value')&.to_f end tensor end |