Class: Atmospheric::Export::Iso25331975::GroupTwoAttrs

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Includes:
AltitudeConvertableModel
Defined in:
lib/atmospheric/export/iso_25331975/group_two_attrs.rb

Instance Method Summary collapse

Methods included from AltitudeConvertableModel

included, #realize_altitudes, #set_altitude, #set_geometric_altitude, #set_geopotential_altitude

Methods included from Utils

#ft_to_m, #m_to_ft, #round_to_sig_figs, #values_in_m_ft

Instance Method Details

#calculate(gp_h_m, name, precision: :reduced) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/atmospheric/export/iso_25331975/group_two_attrs.rb', line 60

def calculate(gp_h_m, name, precision: :reduced)
  isa = precision == :high ? Isa::HighPrecision.instance : Isa::NormalPrecision.instance

  case name
  when :ppn
    v = isa.p_p_n_from_geopotential(gp_h_m)
    UnitValueFloat.new(
      value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
      unitsml: nil
    )
  when :rhorhon
    v = isa.rho_rho_n_from_geopotential(gp_h_m)
    UnitValueFloat.new(
      value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
      unitsml: nil
    )
  when :sqrt_rhorhon
    v = isa.root_rho_rho_n_from_geopotential(gp_h_m)
    UnitValueFloat.new(
      value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
      unitsml: nil
    )
  when :speed_of_sound
    v = isa.speed_of_sound_from_geopotential(gp_h_m)
    UnitValueInteger.new(
      value: precision == :reduced ? (v * 1000.0).round : v,
      unitsml: "m*s^-1"
    )
  when :dynamic_viscosity
    v = isa.dynamic_viscosity_from_geopotential(gp_h_m)
    UnitValueFloat.new(
      value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
      unitsml: "Pa*s"
    )
  when :kinematic_viscosity
    v = isa.kinematic_viscosity_from_geopotential(gp_h_m)
    UnitValueFloat.new(
      value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
      unitsml: "m^2*s^-1"
    )
  when :thermal_conductivity
    v = isa.thermal_conductivity_from_geopotential(gp_h_m)
    UnitValueFloat.new(
      value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
      unitsml: "W*m^-1*K^-1"
    )
  else
    raise ArgumentError, "Unknown attribute: #{name}"
  end
end

#realize_values_from_geopotential(gp_h_m, precision: :reduced) ⇒ Object

In meters only



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/atmospheric/export/iso_25331975/group_two_attrs.rb', line 30

def realize_values_from_geopotential(gp_h_m, precision: :reduced)
  self.ppns = [
    calculate(gp_h_m, :ppn, precision: precision)
  ]

  self.rhorhons = [
    calculate(gp_h_m, :rhorhon, precision: precision)
  ]

  self.sqrt_rhorhons = [
    calculate(gp_h_m, :sqrt_rhorhon, precision: precision)
  ]

  self.speeds_of_sound = [
    calculate(gp_h_m, :speed_of_sound, precision: precision)
  ]

  self.dynamic_viscosities = [
    calculate(gp_h_m, :dynamic_viscosity, precision: precision)
  ]

  self.kinematic_viscosities = [
    calculate(gp_h_m, :kinematic_viscosity, precision: precision)
  ]

  self.thermal_conductivities = [
    calculate(gp_h_m, :thermal_conductivity, precision: precision)
  ]
end