atmospheric 0.4.4 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,221 +10,282 @@ module Atmospheric
10
10
  include AltitudeConvertableModel
11
11
 
12
12
  # From Group One
13
- attribute :temperature_k, UnitValueFloat
14
- attribute :temperature_c, UnitValueFloat
15
- attribute :pressure_mbar, UnitValueFloat
16
- attribute :pressure_mmhg, UnitValueFloat
17
- attribute :density, UnitValueFloat
18
- attribute :acceleration, UnitValueFloat
13
+ attribute :temperatures, UnitValueFloat, collection: true
14
+ attribute :pressures, UnitValueFloat, collection: true
15
+ attribute :densities, UnitValueFloat, collection: true
16
+ attribute :accelerations, UnitValueFloat, collection: true
19
17
 
20
18
  # From Group Two
21
- attribute :ppn, UnitValueFloat
22
- attribute :rhorhon, UnitValueFloat
23
- attribute :sqrt_rhorhon, UnitValueFloat
24
- attribute :speed_of_sound, UnitValueFloat
25
- attribute :dynamic_viscosity, UnitValueFloat
26
- attribute :kinematic_viscosity, UnitValueFloat
27
- attribute :thermal_conductivity, UnitValueFloat
19
+ attribute :ppns, UnitValueFloat, collection: true
20
+ attribute :rhorhons, UnitValueFloat, collection: true
21
+ attribute :sqrt_rhorhons, UnitValueFloat, collection: true
22
+ attribute :speeds_of_sound, UnitValueFloat, collection: true
23
+ attribute :dynamic_viscosities, UnitValueFloat, collection: true
24
+ attribute :kinematic_viscosities, UnitValueFloat, collection: true
25
+ attribute :thermal_conductivities, UnitValueFloat, collection: true
28
26
 
29
27
  # From Group Three
30
- attribute :pressure_scale_height, UnitValueFloat
31
- attribute :specific_weight, UnitValueFloat
32
- attribute :air_number_density, UnitValueFloat
33
- attribute :mean_speed, UnitValueFloat
34
- attribute :frequency, UnitValueFloat
35
- attribute :mean_free_path, UnitValueFloat
28
+ attribute :pressure_scale_heights, UnitValueFloat, collection: true
29
+ attribute :specific_weights, UnitValueFloat, collection: true
30
+ attribute :air_number_densities, UnitValueFloat, collection: true
31
+ attribute :mean_speeds, UnitValueFloat, collection: true
32
+ attribute :frequencies, UnitValueFloat, collection: true
33
+ attribute :mean_free_paths, UnitValueFloat, collection: true
34
+ attribute :precision, :string, values: %w[reduced normal high]
36
35
 
37
36
  key_value do
38
- map "geometric-altitude-m", to: :geometric_altitude_m
39
- map "geometric-altitude-ft", to: :geometric_altitude_ft
40
- map "geopotential-altitude-m", to: :geopotential_altitude_m
41
- map "geopotential-altitude-ft", to: :geopotential_altitude_ft
37
+ map "geometric-altitude", to: :geometric_altitudes
38
+ map "geopotential-altitude", to: :geopotential_altitudes
42
39
 
43
40
  # From Group One
44
- map "temperature-k", to: :temperature_k
45
- map "temperature-c", to: :temperature_c
46
- map "pressure-mbar", to: :pressure_mbar
47
- map "pressure-mmhg", to: :pressure_mmhg
48
- map "density", to: :density
49
- map "acceleration", to: :acceleration
41
+ map "temperature", to: :temperatures
42
+ map "pressure", to: :pressures
43
+ map "density", to: :densities
44
+ map "acceleration", to: :accelerations
50
45
 
51
46
  # From Group Two
52
- map "ppn", to: :ppn
53
- map "rhorhon", to: :rhorhon
54
- map "sqrt-rhorhon", to: :sqrt_rhorhon
55
- map "speed-of-sound", to: :speed_of_sound
56
- map "dynamic-viscosity", to: :dynamic_viscosity
57
- map "kinematic-viscosity", to: :kinematic_viscosity
58
- map "thermal-conductivity", to: :thermal_conductivity
47
+ map "ppn", to: :ppns
48
+ map "rhorhon", to: :rhorhons
49
+ map "sqrt-rhorhon", to: :sqrt_rhorhons
50
+ map "speed-of-sound", to: :speeds_of_sound
51
+ map "dynamic-viscosity", to: :dynamic_viscosities
52
+ map "kinematic-viscosity", to: :kinematic_viscosities
53
+ map "thermal-conductivity", to: :thermal_conductivities
59
54
 
60
55
  # From Group Three
61
- map "pressure-scale-height", to: :pressure_scale_height
62
- map "specific-weight", to: :specific_weight
63
- map "air-number-density", to: :air_number_density
64
- map "mean-speed", to: :mean_speed
65
- map "frequency", to: :frequency
66
- map "mean-free-path", to: :mean_free_path
56
+ map "pressure-scale-height", to: :pressure_scale_heights
57
+ map "specific-weight", to: :specific_weights
58
+ map "air-number-density", to: :air_number_densities
59
+ map "mean-speed", to: :mean_speeds
60
+ map "frequency", to: :frequencies
61
+ map "mean-free-path", to: :mean_free_paths
62
+
63
+ map "precision", to: :precision
67
64
  end
68
65
 
69
66
  xml do
70
- root "atmosphere-attributes"
71
- map_element "geometric-altitude-m", to: :geometric_altitude_m
72
- map_element "geometric-altitude-ft", to: :geometric_altitude_ft
73
- map_element "geopotential-altitude-m", to: :geopotential_altitude_m
74
- map_element "geopotential-altitude-ft", to: :geopotential_altitude_ft
67
+ element "atmosphere-attributes"
68
+ map_element "geometric-altitude", to: :geometric_altitudes
69
+ map_element "geopotential-altitude", to: :geopotential_altitudes
75
70
 
76
71
  # From Group One
77
- map_element "temperature-k", to: :temperature_k
78
- map_element "temperature-c", to: :temperature_c
79
- map_element "pressure-mbar", to: :pressure_mbar
80
- map_element "pressure-mmhg", to: :pressure_mmhg
81
- map_element "density", to: :density
82
- map_element "acceleration", to: :acceleration
72
+ map_element "temperature", to: :temperatures
73
+ map_element "pressure", to: :pressures
74
+ map_element "density", to: :densities
75
+ map_element "acceleration", to: :accelerations
83
76
 
84
77
  # From Group Two
85
- map_element "ppn", to: :ppn
86
- map_element "rhorhon", to: :rhorhon
87
- map_element "sqrt-rhorhon", to: :sqrt_rhorhon
88
- map_element "speed-of-sound", to: :speed_of_sound
89
- map_element "dynamic-viscosity", to: :dynamic_viscosity
90
- map_element "kinematic-viscosity", to: :kinematic_viscosity
91
- map_element "thermal-conductivity", to: :thermal_conductivity
78
+ map_element "ppn", to: :ppns
79
+ map_element "rhorhon", to: :rhorhons
80
+ map_element "sqrt-rhorhon", to: :sqrt_rhorhons
81
+ map_element "speed-of-sound", to: :speeds_of_sound
82
+ map_element "dynamic-viscosity", to: :dynamic_viscosities
83
+ map_element "kinematic-viscosity", to: :kinematic_viscosities
84
+ map_element "thermal-conductivity", to: :thermal_conductivities
92
85
 
93
86
  # From Group Three
94
- map_element "pressure-scale-height", to: :pressure_scale_height
95
- map_element "specific-weight", to: :specific_weight
96
- map_element "air-number-density", to: :air_number_density
97
- map_element "mean-speed", to: :mean_speed
98
- map_element "frequency", to: :frequency
99
- map_element "mean-free-path", to: :mean_free_path
87
+ map_element "pressure-scale-height", to: :pressure_scale_heights
88
+ map_element "specific-weight", to: :specific_weights
89
+ map_element "air-number-density", to: :air_number_densities
90
+ map_element "mean-speed", to: :mean_speeds
91
+ map_element "frequency", to: :frequencies
92
+ map_element "mean-free-path", to: :mean_free_paths
93
+
94
+ map_element "precision", to: :precision
100
95
  end
101
96
 
102
97
  # In meters only
103
98
  def realize_values_from_geopotential(gp_h_m, precision: :reduced)
104
- %i[
105
- temperature_k temperature_c pressure_mbar pressure_mmhg density
106
- acceleration ppn rhorhon sqrt_rhorhon speed_of_sound
107
- dynamic_viscosity kinematic_viscosity thermal_conductivity
108
- pressure_scale_height specific_weight air_number_density mean_speed
109
- frequency mean_free_path
110
- ].each do |attr|
111
- v = calculate(gp_h_m, attr, precision: precision)
112
- send("#{attr}=", v) if respond_to?("#{attr}=")
113
- end
99
+ self.precision = precision.to_s
100
+
101
+ # Group One
102
+ self.temperatures = [
103
+ calculate(gp_h_m, :temperature_k, precision: precision),
104
+ calculate(gp_h_m, :temperature_c, precision: precision)
105
+ ]
106
+
107
+ self.pressures = [
108
+ calculate(gp_h_m, :pressure_mbar, precision: precision),
109
+ calculate(gp_h_m, :pressure_mmhg, precision: precision)
110
+ ]
111
+
112
+ self.densities = [
113
+ calculate(gp_h_m, :density, precision: precision)
114
+ ]
115
+
116
+ self.accelerations = [
117
+ calculate(gp_h_m, :acceleration, precision: precision)
118
+ ]
119
+
120
+ # Group Two
121
+ self.ppns = [
122
+ calculate(gp_h_m, :ppn, precision: precision)
123
+ ]
124
+
125
+ self.rhorhons = [
126
+ calculate(gp_h_m, :rhorhon, precision: precision)
127
+ ]
128
+
129
+ self.sqrt_rhorhons = [
130
+ calculate(gp_h_m, :sqrt_rhorhon, precision: precision)
131
+ ]
132
+
133
+ self.speeds_of_sound = [
134
+ calculate(gp_h_m, :speed_of_sound, precision: precision)
135
+ ]
136
+
137
+ self.dynamic_viscosities = [
138
+ calculate(gp_h_m, :dynamic_viscosity, precision: precision)
139
+ ]
140
+
141
+ self.kinematic_viscosities = [
142
+ calculate(gp_h_m, :kinematic_viscosity, precision: precision)
143
+ ]
144
+
145
+ self.thermal_conductivities = [
146
+ calculate(gp_h_m, :thermal_conductivity, precision: precision)
147
+ ]
148
+
149
+ # Group Three
150
+ self.pressure_scale_heights = [
151
+ calculate(gp_h_m, :pressure_scale_height, precision: precision)
152
+ ]
153
+
154
+ self.specific_weights = [
155
+ calculate(gp_h_m, :specific_weight, precision: precision)
156
+ ]
157
+
158
+ self.air_number_densities = [
159
+ calculate(gp_h_m, :air_number_density, precision: precision)
160
+ ]
161
+
162
+ self.mean_speeds = [
163
+ calculate(gp_h_m, :mean_speed, precision: precision)
164
+ ]
165
+
166
+ self.frequencies = [
167
+ calculate(gp_h_m, :frequency, precision: precision)
168
+ ]
169
+
170
+ self.mean_free_paths = [
171
+ calculate(gp_h_m, :mean_free_path, precision: precision)
172
+ ]
114
173
  end
115
174
 
116
175
  def calculate(gp_h_m, name, precision: :reduced)
176
+ isa = precision == :high ? Isa::HighPrecision.instance : Isa::NormalPrecision.instance
177
+
117
178
  case name
118
179
  when :temperature_k
119
- v = Isa::NormalPrecision.instance.temperature_at_layer_from_geopotential(gp_h_m)
180
+ v = isa.temperature_at_layer_from_geopotential(gp_h_m)
120
181
  UnitValueFloat.new(
121
- value: precision == :reduced ? (v * 1000.0).round : v,
182
+ value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
122
183
  unitsml: "K"
123
184
  )
124
185
  when :temperature_c
125
- v = Isa::NormalPrecision.instance.temperature_at_layer_celcius(gp_h_m)
186
+ v = isa.temperature_at_layer_celcius(gp_h_m)
126
187
  UnitValueFloat.new(
127
- value: precision == :reduced ? (v * 1000.0).round : v,
188
+ value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
128
189
  unitsml: "degC"
129
190
  )
130
191
  when :pressure_mbar
131
- v = Isa::NormalPrecision.instance.pressure_from_geopotential_mbar(gp_h_m)
192
+ v = isa.pressure_from_geopotential_mbar(gp_h_m)
132
193
  UnitValueFloat.new(
133
194
  value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
134
195
  unitsml: "mbar"
135
196
  )
136
197
  when :pressure_mmhg
137
- v = Isa::NormalPrecision.instance.pressure_from_geopotential_mmhg(gp_h_m)
198
+ v = isa.pressure_from_geopotential_mmhg(gp_h_m)
138
199
  UnitValueFloat.new(
139
200
  value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
140
- unitsml: "u:mm_Hg"
201
+ unitsml: "mm_Hg"
141
202
  )
142
203
  when :density
143
- v = Isa::NormalPrecision.instance.density_from_geopotential(gp_h_m)
204
+ v = isa.density_from_geopotential(gp_h_m)
144
205
  UnitValueFloat.new(
145
206
  value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
146
207
  unitsml: "kg*m^-3"
147
208
  )
148
209
  when :acceleration
149
- v = Isa::NormalPrecision.instance.gravity_at_geopotential(gp_h_m)
210
+ v = isa.gravity_at_geopotential(gp_h_m)
150
211
  UnitValueFloat.new(
151
212
  value: precision == :reduced ? v.round(4) : v,
152
213
  unitsml: "m*s^-2"
153
214
  )
154
215
  when :ppn
155
- v = Isa::NormalPrecision.instance.p_p_n_from_geopotential(gp_h_m)
216
+ v = isa.p_p_n_from_geopotential(gp_h_m)
156
217
  UnitValueFloat.new(
157
218
  value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
158
219
  unitsml: nil
159
220
  )
160
221
  when :rhorhon
161
- v = Isa::NormalPrecision.instance.rho_rho_n_from_geopotential(gp_h_m)
222
+ v = isa.rho_rho_n_from_geopotential(gp_h_m)
162
223
  UnitValueFloat.new(
163
224
  value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
164
225
  unitsml: nil
165
226
  )
166
227
  when :sqrt_rhorhon
167
- v = Isa::NormalPrecision.instance.root_rho_rho_n_from_geopotential(gp_h_m)
228
+ v = isa.root_rho_rho_n_from_geopotential(gp_h_m)
168
229
  UnitValueFloat.new(
169
230
  value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
170
231
  unitsml: nil
171
232
  )
172
233
  when :speed_of_sound
173
- v = Isa::NormalPrecision.instance.speed_of_sound_from_geopotential(gp_h_m)
234
+ v = isa.speed_of_sound_from_geopotential(gp_h_m)
174
235
  UnitValueFloat.new(
175
- value: precision == :reduced ? (v * 1000.0).round : v,
236
+ value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
176
237
  unitsml: "m*s^-1"
177
238
  )
178
239
  when :dynamic_viscosity
179
- v = Isa::NormalPrecision.instance.dynamic_viscosity_from_geopotential(gp_h_m)
240
+ v = isa.dynamic_viscosity_from_geopotential(gp_h_m)
180
241
  UnitValueFloat.new(
181
242
  value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
182
243
  unitsml: "Pa*s"
183
244
  )
184
245
  when :kinematic_viscosity
185
- v = Isa::NormalPrecision.instance.kinematic_viscosity_from_geopotential(gp_h_m)
246
+ v = isa.kinematic_viscosity_from_geopotential(gp_h_m)
186
247
  UnitValueFloat.new(
187
248
  value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
188
249
  unitsml: "m^2*s^-1"
189
250
  )
190
251
  when :thermal_conductivity
191
- v = Isa::NormalPrecision.instance.thermal_conductivity_from_geopotential(gp_h_m)
252
+ v = isa.thermal_conductivity_from_geopotential(gp_h_m)
192
253
  UnitValueFloat.new(
193
254
  value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
194
255
  unitsml: "W*m^-1*K^-1"
195
256
  )
196
257
  when :pressure_scale_height
197
- v = Isa::NormalPrecision.instance.pressure_scale_height_from_geopotential(gp_h_m)
258
+ v = isa.pressure_scale_height_from_geopotential(gp_h_m)
198
259
  UnitValueFloat.new(
199
260
  value: precision == :reduced ? v.round(1) : v,
200
261
  unitsml: "m"
201
262
  )
202
263
  when :specific_weight
203
- v = Isa::NormalPrecision.instance.specific_weight_from_geopotential(gp_h_m)
264
+ v = isa.specific_weight_from_geopotential(gp_h_m)
204
265
  UnitValueFloat.new(
205
266
  value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
206
267
  unitsml: "N*m^-3"
207
268
  )
208
269
  when :air_number_density
209
- v = Isa::NormalPrecision.instance.air_number_density_from_geopotential(gp_h_m)
270
+ v = isa.air_number_density_from_geopotential(gp_h_m)
210
271
  UnitValueFloat.new(
211
272
  value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
212
273
  unitsml: "m^-3"
213
274
  )
214
275
  when :mean_speed
215
- v = Isa::NormalPrecision.instance.mean_air_particle_speed_from_geopotential(gp_h_m)
276
+ v = isa.mean_air_particle_speed_from_geopotential(gp_h_m)
216
277
  UnitValueFloat.new(
217
278
  value: precision == :reduced ? v.round(2) : v,
218
279
  unitsml: "m*s^-1"
219
280
  )
220
281
  when :frequency
221
- v = Isa::NormalPrecision.instance.air_particle_collision_frequency_from_geopotential(gp_h_m)
282
+ v = isa.air_particle_collision_frequency_from_geopotential(gp_h_m)
222
283
  UnitValueFloat.new(
223
284
  value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
224
285
  unitsml: "s^-1"
225
286
  )
226
287
  when :mean_free_path
227
- v = Isa::NormalPrecision.instance.mean_free_path_of_air_particles_from_geopotential(gp_h_m)
288
+ v = isa.mean_free_path_of_air_particles_from_geopotential(gp_h_m)
228
289
  UnitValueFloat.new(
229
290
  value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
230
291
  unitsml: "m"
@@ -11,10 +11,8 @@ module Atmospheric
11
11
 
12
12
  def self.included(base)
13
13
  base.class_eval do
14
- attribute :geometric_altitude_m, UnitValueInteger
15
- attribute :geometric_altitude_ft, UnitValueInteger
16
- attribute :geopotential_altitude_m, UnitValueInteger
17
- attribute :geopotential_altitude_ft, UnitValueInteger
14
+ attribute :geometric_altitudes, UnitValueInteger, collection: true
15
+ attribute :geopotential_altitudes, UnitValueInteger, collection: true
18
16
  end
19
17
  end
20
18
 
@@ -54,25 +52,27 @@ module Atmospheric
54
52
  end
55
53
 
56
54
  def realize_altitudes(hgmm, hgmf, hgpm, hgpf, precision: :reduced)
57
- self.geometric_altitude_m = UnitValueInteger.new(
58
- value: precision == :reduced ? hgmm.round : hgmm,
59
- unitsml: "m"
60
- )
55
+ self.geometric_altitudes = [
56
+ UnitValueInteger.new(
57
+ value: precision == :reduced ? hgmm.round : hgmm,
58
+ unitsml: "m"
59
+ ),
60
+ UnitValueInteger.new(
61
+ value: precision == :reduced ? hgmf.round : hgmf,
62
+ unitsml: "ft"
63
+ )
64
+ ]
61
65
 
62
- self.geometric_altitude_ft = UnitValueInteger.new(
63
- value: precision == :reduced ? hgmf.round : hgmf,
64
- unitsml: "ft"
65
- )
66
-
67
- self.geopotential_altitude_m = UnitValueInteger.new(
68
- value: precision == :reduced ? hgpm.round : hgpm,
69
- unitsml: "m"
70
- )
71
-
72
- self.geopotential_altitude_ft = UnitValueInteger.new(
73
- value: precision == :reduced ? hgpf.round : hgpf,
74
- unitsml: "ft"
75
- )
66
+ self.geopotential_altitudes = [
67
+ UnitValueInteger.new(
68
+ value: precision == :reduced ? hgpm.round : hgpm,
69
+ unitsml: "m"
70
+ ),
71
+ UnitValueInteger.new(
72
+ value: precision == :reduced ? hgpf.round : hgpf,
73
+ unitsml: "ft"
74
+ )
75
+ ]
76
76
  end
77
77
 
78
78
  def realize_values_from_geopotential(gp_h_m, precision:)
@@ -9,7 +9,7 @@ module Atmospheric
9
9
  attribute :rows, PressureAttrs, collection: true
10
10
 
11
11
  xml do
12
- root "atmospheric"
12
+ element "atmospheric"
13
13
  map_element "hypsometrical-attributes", to: :rows
14
14
  end
15
15
 
@@ -9,71 +9,87 @@ module Atmospheric
9
9
  class GroupOneAttrs < Lutaml::Model::Serializable
10
10
  include AltitudeConvertableModel
11
11
 
12
- attribute :temperature_k, UnitValueInteger
13
- attribute :temperature_c, UnitValueInteger
14
- attribute :pressure_mbar, UnitValueFloat
15
- attribute :pressure_mmhg, UnitValueFloat
16
- attribute :density, UnitValueFloat
17
- attribute :acceleration, UnitValueFloat
12
+ attribute :temperatures, UnitValueInteger, collection: true
13
+ attribute :pressures, UnitValueFloat, collection: true
14
+ attribute :densities, UnitValueFloat, collection: true
15
+ attribute :accelerations, UnitValueFloat, collection: true
18
16
 
19
17
  key_value do
20
- map "geometric-altitude-m", to: :geometric_altitude_m
21
- map "geometric-altitude-ft", to: :geometric_altitude_ft
22
- map "geopotential-altitude-m", to: :geopotential_altitude_m
23
- map "geopotential-altitude-ft", to: :geopotential_altitude_ft
24
- map "temperature-k", to: :temperature_k
25
- map "temperature-c", to: :temperature_c
26
- map "pressure-mbar", to: :pressure_mbar
27
- map "pressure-mmhg", to: :pressure_mmhg
28
- map "density", to: :density
29
- map "acceleration", to: :acceleration
18
+ map "geometric-altitude", to: :geometric_altitudes
19
+ map "geopotential-altitude", to: :geopotential_altitudes
20
+ map "temperature", to: :temperatures
21
+ map "pressure", to: :pressures
22
+ map "density", to: :densities
23
+ map "acceleration", to: :accelerations
24
+ end
25
+
26
+ xml do
27
+ element "group-one-attrs"
28
+ map_element "geometric-altitude", to: :geometric_altitudes
29
+ map_element "geopotential-altitude", to: :geopotential_altitudes
30
+ map_element "temperature", to: :temperatures
31
+ map_element "pressure", to: :pressures
32
+ map_element "density", to: :densities
33
+ map_element "acceleration", to: :accelerations
30
34
  end
31
35
 
32
36
  # In meters only
33
37
  def realize_values_from_geopotential(gp_h_m, precision: :reduced)
34
- %i[
35
- temperature_k temperature_c pressure_mbar pressure_mmhg density
36
- acceleration
37
- ].each do |attr|
38
- v = calculate(gp_h_m, attr, precision: precision)
39
- send("#{attr}=", v) if respond_to?("#{attr}=")
40
- end
38
+ self.temperatures = [
39
+ calculate(gp_h_m, :temperature_k, precision: precision),
40
+ calculate(gp_h_m, :temperature_c, precision: precision)
41
+ ]
42
+
43
+ self.pressures = [
44
+ calculate(gp_h_m, :pressure_mbar, precision: precision),
45
+ calculate(gp_h_m, :pressure_mmhg, precision: precision)
46
+ ]
47
+
48
+ self.densities = [
49
+ calculate(gp_h_m, :density, precision: precision)
50
+ ]
51
+
52
+ self.accelerations = [
53
+ calculate(gp_h_m, :acceleration, precision: precision)
54
+ ]
41
55
  end
42
56
 
43
57
  def calculate(gp_h_m, name, precision: :reduced)
58
+ isa = precision == :high ? Isa::HighPrecision.instance : Isa::NormalPrecision.instance
59
+
44
60
  case name
45
61
  when :temperature_k
46
- v = Isa::NormalPrecision.instance.temperature_at_layer_from_geopotential(gp_h_m)
62
+ v = isa.temperature_at_layer_from_geopotential(gp_h_m)
47
63
  UnitValueInteger.new(
48
64
  value: precision == :reduced ? (v * 1000.0).round : v,
49
65
  unitsml: "K"
50
66
  )
51
67
  when :temperature_c
52
- v = Isa::NormalPrecision.instance.temperature_at_layer_celcius(gp_h_m)
68
+ v = isa.temperature_at_layer_celcius(gp_h_m)
53
69
  UnitValueInteger.new(
54
70
  value: precision == :reduced ? (v * 1000.0).round : v,
55
71
  unitsml: "degC"
56
72
  )
57
73
  when :pressure_mbar
58
- v = Isa::NormalPrecision.instance.pressure_from_geopotential_mbar(gp_h_m)
74
+ v = isa.pressure_from_geopotential_mbar(gp_h_m)
59
75
  UnitValueFloat.new(
60
76
  value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
61
77
  unitsml: "mbar"
62
78
  )
63
79
  when :pressure_mmhg
64
- v = Isa::NormalPrecision.instance.pressure_from_geopotential_mmhg(gp_h_m)
80
+ v = isa.pressure_from_geopotential_mmhg(gp_h_m)
65
81
  UnitValueFloat.new(
66
82
  value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
67
- unitsml: "u:mm_Hg"
83
+ unitsml: "mm_Hg"
68
84
  )
69
85
  when :density
70
- v = Isa::NormalPrecision.instance.density_from_geopotential(gp_h_m)
86
+ v = isa.density_from_geopotential(gp_h_m)
71
87
  UnitValueFloat.new(
72
88
  value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
73
89
  unitsml: "kg*m^-3"
74
90
  )
75
91
  when :acceleration
76
- v = Isa::NormalPrecision.instance.gravity_at_geopotential(gp_h_m)
92
+ v = isa.gravity_at_geopotential(gp_h_m)
77
93
  UnitValueFloat.new(
78
94
  value: precision == :reduced ? v.round(4) : v,
79
95
  unitsml: "m*s^-2"