Class: IngvQuake::MomentTensor

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ MomentTensor

Initializes a new MomentTensor instance with the provided data.

Parameters:

  • data (Hash)

    A hash containing detailed information about the data used for a moment-tensor inversion.



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

#clvdFloat (readonly)

CLVD (compensated linear vector dipole) parameter obtained from moment tensor inversion (decimal fraction between 0 and 1).

Returns:

  • (Float)

    the current value of clvd



22
23
24
# File 'lib/ingv_quake/models/moment_tensor.rb', line 22

def clvd
  @clvd
end

#creation_infoCreationInfo (readonly)

The creation information for the moment tensor.

Returns:



22
23
24
# File 'lib/ingv_quake/models/moment_tensor.rb', line 22

def creation_info
  @creation_info
end

#data_usedDataUsed (readonly)

Describes waveform data used for moment-tensor inversion.

Returns:

  • (DataUsed)

    the current value of data_used



22
23
24
# File 'lib/ingv_quake/models/moment_tensor.rb', line 22

def data_used
  @data_used
end

#derived_origin_idString (readonly)

Refers to the publicID of the Origin derived in the moment tensor inversion.

Returns:

  • (String)

    the current value of derived_origin_id



22
23
24
# File 'lib/ingv_quake/models/moment_tensor.rb', line 22

def derived_origin_id
  @derived_origin_id
end

#double_coupleFloat (readonly)

Double couple parameter obtained from moment tensor inversion (decimal fraction between 0 and 1).

Returns:

  • (Float)

    the current value of double_couple



22
23
24
# File 'lib/ingv_quake/models/moment_tensor.rb', line 22

def double_couple
  @double_couple
end

#isoFloat (readonly)

Isotropic part obtained from moment tensor inversion (decimal fraction between 0 and 1).

Returns:

  • (Float)

    the current value of iso



22
23
24
# File 'lib/ingv_quake/models/moment_tensor.rb', line 22

def iso
  @iso
end

#moment_magnitude_idString (readonly)

Refers to the publicID of the Magnitude object which represents the derived moment magnitude.

Returns:

  • (String)

    the current value of moment_magnitude_id



22
23
24
# File 'lib/ingv_quake/models/moment_tensor.rb', line 22

def moment_magnitude_id
  @moment_magnitude_id
end

#public_idString (readonly)

Resource identifier of MomentTensor.

Returns:

  • (String)

    the current value of public_id



22
23
24
# File 'lib/ingv_quake/models/moment_tensor.rb', line 22

def public_id
  @public_id
end

#scalar_momentFloat (readonly)

Scalar moment as derived in moment tensor inversion. Unit: N m.

Returns:

  • (Float)

    the current value of scalar_moment



22
23
24
# File 'lib/ingv_quake/models/moment_tensor.rb', line 22

def scalar_moment
  @scalar_moment
end

#tensorHash (readonly)

Tensor object holding the moment tensor elements.

Returns:

  • (Hash)

    the current value of tensor



22
23
24
# File 'lib/ingv_quake/models/moment_tensor.rb', line 22

def tensor
  @tensor
end

#variance_reductionFloat (readonly)

Variance reduction of moment tensor inversion, given in percent (Dreger 2003). This is a goodness-of-fit measure.

Returns:

  • (Float)

    the current value of variance_reduction



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