atmospheric 0.4.3 → 0.4.5

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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.adoc +681 -183
  4. data/lib/atmospheric/export/altitude_attrs.rb +247 -0
  5. data/lib/atmospheric/export/altitude_convertable_model.rb +84 -0
  6. data/lib/atmospheric/export/altitude_table.rb +51 -0
  7. data/lib/atmospheric/export/hypsometrical_table.rb +38 -0
  8. data/lib/atmospheric/export/iso_25331975/group_one.rb +15 -27
  9. data/lib/atmospheric/export/iso_25331975/group_one_attrs.rb +90 -0
  10. data/lib/atmospheric/export/iso_25331975/group_three.rb +14 -27
  11. data/lib/atmospheric/export/iso_25331975/group_three_attrs.rb +89 -0
  12. data/lib/atmospheric/export/iso_25331975/group_two.rb +14 -28
  13. data/lib/atmospheric/export/iso_25331975/group_two_attrs.rb +97 -0
  14. data/lib/atmospheric/export/iso_25331975.rb +5 -17
  15. data/lib/atmospheric/export/iso_25331985/pressure_attrs.rb +19 -0
  16. data/lib/atmospheric/export/iso_25331985/table_five_six_attrs.rb +19 -0
  17. data/lib/atmospheric/export/iso_25331985.rb +42 -63
  18. data/lib/atmospheric/export/iso_25331997.rb +21 -39
  19. data/lib/atmospheric/export/iso_25332025/altitude_attrs_group.rb +27 -0
  20. data/lib/atmospheric/export/iso_25332025/combined_altitude_attrs_group.rb +44 -0
  21. data/lib/atmospheric/export/iso_25332025.rb +81 -0
  22. data/lib/atmospheric/export/pressure_attrs.rb +93 -0
  23. data/lib/atmospheric/export/{target.rb → utils.rb} +10 -13
  24. data/lib/atmospheric/export.rb +3 -1
  25. data/lib/atmospheric/isa.rb +119 -114
  26. data/lib/atmospheric/unit_value_float.rb +24 -0
  27. data/lib/atmospheric/unit_value_integer.rb +24 -0
  28. data/lib/atmospheric/version.rb +1 -1
  29. data/lib/atmospheric.rb +1 -0
  30. metadata +38 -28
  31. data/lib/atmospheric/export/hypsometrical_tables.rb +0 -34
  32. data/lib/atmospheric/export/iso_25331975/group_base.rb +0 -72
  33. data/lib/atmospheric/export/iso_25332024.rb +0 -205
  34. data/spec/fixtures/iso-2533-1975-table5.yaml +0 -18297
  35. data/spec/fixtures/iso-2533-1975-table6.yaml +0 -18298
  36. data/spec/fixtures/iso-2533-1975-table7.yaml +0 -16265
@@ -0,0 +1,247 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model"
4
+ require_relative "../unit_value_float"
5
+ require_relative "../unit_value_integer"
6
+
7
+ module Atmospheric
8
+ module Export
9
+ class AltitudeAttrs < Lutaml::Model::Serializable
10
+ include AltitudeConvertableModel
11
+
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
19
+
20
+ # 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
28
+
29
+ # 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
36
+ attribute :precision, :string, values: %w[reduced normal high]
37
+
38
+ key_value do
39
+ map "geometric-altitude-m", to: :geometric_altitude_m
40
+ map "geometric-altitude-ft", to: :geometric_altitude_ft
41
+ map "geopotential-altitude-m", to: :geopotential_altitude_m
42
+ map "geopotential-altitude-ft", to: :geopotential_altitude_ft
43
+
44
+ # From Group One
45
+ map "temperature-k", to: :temperature_k
46
+ map "temperature-c", to: :temperature_c
47
+ map "pressure-mbar", to: :pressure_mbar
48
+ map "pressure-mmhg", to: :pressure_mmhg
49
+ map "density", to: :density
50
+ map "acceleration", to: :acceleration
51
+
52
+ # From Group Two
53
+ map "ppn", to: :ppn
54
+ map "rhorhon", to: :rhorhon
55
+ map "sqrt-rhorhon", to: :sqrt_rhorhon
56
+ map "speed-of-sound", to: :speed_of_sound
57
+ map "dynamic-viscosity", to: :dynamic_viscosity
58
+ map "kinematic-viscosity", to: :kinematic_viscosity
59
+ map "thermal-conductivity", to: :thermal_conductivity
60
+
61
+ # From Group Three
62
+ map "pressure-scale-height", to: :pressure_scale_height
63
+ map "specific-weight", to: :specific_weight
64
+ map "air-number-density", to: :air_number_density
65
+ map "mean-speed", to: :mean_speed
66
+ map "frequency", to: :frequency
67
+ map "mean-free-path", to: :mean_free_path
68
+
69
+ map "precision", to: :precision
70
+ end
71
+
72
+ xml do
73
+ root "atmosphere-attributes"
74
+ map_element "geometric-altitude-m", to: :geometric_altitude_m
75
+ map_element "geometric-altitude-ft", to: :geometric_altitude_ft
76
+ map_element "geopotential-altitude-m", to: :geopotential_altitude_m
77
+ map_element "geopotential-altitude-ft", to: :geopotential_altitude_ft
78
+
79
+ # From Group One
80
+ map_element "temperature-k", to: :temperature_k
81
+ map_element "temperature-c", to: :temperature_c
82
+ map_element "pressure-mbar", to: :pressure_mbar
83
+ map_element "pressure-mmhg", to: :pressure_mmhg
84
+ map_element "density", to: :density
85
+ map_element "acceleration", to: :acceleration
86
+
87
+ # From Group Two
88
+ map_element "ppn", to: :ppn
89
+ map_element "rhorhon", to: :rhorhon
90
+ map_element "sqrt-rhorhon", to: :sqrt_rhorhon
91
+ map_element "speed-of-sound", to: :speed_of_sound
92
+ map_element "dynamic-viscosity", to: :dynamic_viscosity
93
+ map_element "kinematic-viscosity", to: :kinematic_viscosity
94
+ map_element "thermal-conductivity", to: :thermal_conductivity
95
+
96
+ # From Group Three
97
+ map_element "pressure-scale-height", to: :pressure_scale_height
98
+ map_element "specific-weight", to: :specific_weight
99
+ map_element "air-number-density", to: :air_number_density
100
+ map_element "mean-speed", to: :mean_speed
101
+ map_element "frequency", to: :frequency
102
+ map_element "mean-free-path", to: :mean_free_path
103
+
104
+ map_element "precision", to: :precision
105
+ end
106
+
107
+ # In meters only
108
+ def realize_values_from_geopotential(gp_h_m, precision: :reduced)
109
+ self.precision = precision.to_s
110
+
111
+ %i[
112
+ temperature_k temperature_c pressure_mbar pressure_mmhg density
113
+ acceleration ppn rhorhon sqrt_rhorhon speed_of_sound
114
+ dynamic_viscosity kinematic_viscosity thermal_conductivity
115
+ pressure_scale_height specific_weight air_number_density mean_speed
116
+ frequency mean_free_path
117
+ ].each do |attr|
118
+ v = calculate(gp_h_m, attr, precision: precision)
119
+ send("#{attr}=", v) if respond_to?("#{attr}=")
120
+ end
121
+ end
122
+
123
+ def calculate(gp_h_m, name, precision: :reduced)
124
+ isa = precision == :high ? Isa::HighPrecision.instance : Isa::NormalPrecision.instance
125
+
126
+ case name
127
+ when :temperature_k
128
+ v = isa.temperature_at_layer_from_geopotential(gp_h_m)
129
+ UnitValueFloat.new(
130
+ value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
131
+ unitsml: "K"
132
+ )
133
+ when :temperature_c
134
+ v = isa.temperature_at_layer_celcius(gp_h_m)
135
+ UnitValueFloat.new(
136
+ value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
137
+ unitsml: "degC"
138
+ )
139
+ when :pressure_mbar
140
+ v = isa.pressure_from_geopotential_mbar(gp_h_m)
141
+ UnitValueFloat.new(
142
+ value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
143
+ unitsml: "mbar"
144
+ )
145
+ when :pressure_mmhg
146
+ v = isa.pressure_from_geopotential_mmhg(gp_h_m)
147
+ UnitValueFloat.new(
148
+ value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
149
+ unitsml: "u:mm_Hg"
150
+ )
151
+ when :density
152
+ v = isa.density_from_geopotential(gp_h_m)
153
+ UnitValueFloat.new(
154
+ value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
155
+ unitsml: "kg*m^-3"
156
+ )
157
+ when :acceleration
158
+ v = isa.gravity_at_geopotential(gp_h_m)
159
+ UnitValueFloat.new(
160
+ value: precision == :reduced ? v.round(4) : v,
161
+ unitsml: "m*s^-2"
162
+ )
163
+ when :ppn
164
+ v = isa.p_p_n_from_geopotential(gp_h_m)
165
+ UnitValueFloat.new(
166
+ value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
167
+ unitsml: nil
168
+ )
169
+ when :rhorhon
170
+ v = isa.rho_rho_n_from_geopotential(gp_h_m)
171
+ UnitValueFloat.new(
172
+ value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
173
+ unitsml: nil
174
+ )
175
+ when :sqrt_rhorhon
176
+ v = isa.root_rho_rho_n_from_geopotential(gp_h_m)
177
+ UnitValueFloat.new(
178
+ value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
179
+ unitsml: nil
180
+ )
181
+ when :speed_of_sound
182
+ v = isa.speed_of_sound_from_geopotential(gp_h_m)
183
+ UnitValueFloat.new(
184
+ value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
185
+ unitsml: "m*s^-1"
186
+ )
187
+ when :dynamic_viscosity
188
+ v = isa.dynamic_viscosity_from_geopotential(gp_h_m)
189
+ UnitValueFloat.new(
190
+ value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
191
+ unitsml: "Pa*s"
192
+ )
193
+ when :kinematic_viscosity
194
+ v = isa.kinematic_viscosity_from_geopotential(gp_h_m)
195
+ UnitValueFloat.new(
196
+ value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
197
+ unitsml: "m^2*s^-1"
198
+ )
199
+ when :thermal_conductivity
200
+ v = isa.thermal_conductivity_from_geopotential(gp_h_m)
201
+ UnitValueFloat.new(
202
+ value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
203
+ unitsml: "W*m^-1*K^-1"
204
+ )
205
+ when :pressure_scale_height
206
+ v = isa.pressure_scale_height_from_geopotential(gp_h_m)
207
+ UnitValueFloat.new(
208
+ value: precision == :reduced ? v.round(1) : v,
209
+ unitsml: "m"
210
+ )
211
+ when :specific_weight
212
+ v = isa.specific_weight_from_geopotential(gp_h_m)
213
+ UnitValueFloat.new(
214
+ value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
215
+ unitsml: "N*m^-3"
216
+ )
217
+ when :air_number_density
218
+ v = isa.air_number_density_from_geopotential(gp_h_m)
219
+ UnitValueFloat.new(
220
+ value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
221
+ unitsml: "m^-3"
222
+ )
223
+ when :mean_speed
224
+ v = isa.mean_air_particle_speed_from_geopotential(gp_h_m)
225
+ UnitValueFloat.new(
226
+ value: precision == :reduced ? v.round(2) : v,
227
+ unitsml: "m*s^-1"
228
+ )
229
+ when :frequency
230
+ v = isa.air_particle_collision_frequency_from_geopotential(gp_h_m)
231
+ UnitValueFloat.new(
232
+ value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
233
+ unitsml: "s^-1"
234
+ )
235
+ when :mean_free_path
236
+ v = isa.mean_free_path_of_air_particles_from_geopotential(gp_h_m)
237
+ UnitValueFloat.new(
238
+ value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
239
+ unitsml: "m"
240
+ )
241
+ else
242
+ raise ArgumentError, "Unknown attribute: #{name}"
243
+ end
244
+ end
245
+ end
246
+ end
247
+ end
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "utils"
4
+ require_relative "../unit_value_float"
5
+ require_relative "../unit_value_integer"
6
+
7
+ module Atmospheric
8
+ module Export
9
+ module AltitudeConvertableModel
10
+ include Utils
11
+
12
+ def self.included(base)
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
18
+ end
19
+ end
20
+
21
+ def set_altitude(value:, type: :geometric, unit: :meters,
22
+ precision: :reduced)
23
+ case type
24
+ when :geometric
25
+ set_geometric_altitude(value, unit: unit, precision: precision)
26
+ when :geopotential
27
+ set_geopotential_altitude(value, unit: unit, precision: precision)
28
+ else
29
+ raise ArgumentError,
30
+ "Invalid type: #{type}. Use :geometric or :geopotential."
31
+ end
32
+
33
+ self
34
+ end
35
+
36
+ def set_geopotential_altitude(h, unit: :meters, precision: :reduced)
37
+ hgpm, hgpf = values_in_m_ft(h, unit: unit)
38
+ hgmm = Isa::NormalPrecision.instance.geometric_altitude_from_geopotential(hgpm)
39
+ hgmf = m_to_ft(hgmm).round
40
+ # TODO: We have to used reduced here because we must round values for
41
+ # the Integer data type as defined.
42
+ realize_altitudes(hgmm, hgmf, hgpm, hgpf, precision: :reduced)
43
+ realize_values_from_geopotential(hgpm, precision: precision)
44
+ end
45
+
46
+ def set_geometric_altitude(h, unit: :meters, precision: :reduced)
47
+ hgmm, hgmf = values_in_m_ft(h, unit: unit)
48
+ hgpm = Isa::NormalPrecision.instance.geopotential_altitude_from_geometric(hgmm)
49
+ hgpf = m_to_ft(hgpm).round
50
+ # TODO: We have to used reduced here because we must round values for
51
+ # the Integer data type as defined.
52
+ realize_altitudes(hgmm, hgmf, hgpm, hgpf, precision: :reduced)
53
+ realize_values_from_geopotential(hgpm, precision: precision)
54
+ end
55
+
56
+ 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
+ )
61
+
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
+ )
76
+ end
77
+
78
+ def realize_values_from_geopotential(gp_h_m, precision:)
79
+ raise NotImplementedError,
80
+ "realize_values_from_geopotential method must be implemented in the including class"
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model"
4
+
5
+ module Atmospheric
6
+ module Export
7
+ class AltitudeTable < Lutaml::Model::Serializable
8
+ # Step 50 from -2k to 40k, step 100 above 32k, 200 above 51k to 80k
9
+ def steps
10
+ ((-2000..31_950).step(50) +
11
+ (32_000..50_900).step(100) +
12
+ (51_000..80_000).step(200))
13
+ end
14
+
15
+ def steps_unit
16
+ :meters
17
+ end
18
+
19
+ def add_to_geometric(item)
20
+ by_geometric_altitude << item
21
+ end
22
+
23
+ def add_to_geopotential(item)
24
+ by_geopotential_altitude << item
25
+ end
26
+
27
+ def initialize_attrs
28
+ self.by_geometric_altitude = []
29
+ self.by_geopotential_altitude = []
30
+ end
31
+
32
+ def set_attrs(klass:, unit: steps_unit, precision: :normal)
33
+ initialize_attrs
34
+
35
+ steps.each do |h|
36
+ add_to_geometric(
37
+ klass.new.set_altitude(
38
+ type: :geometric, unit: unit, value: h, precision: precision
39
+ )
40
+ )
41
+ add_to_geopotential(
42
+ klass.new.set_altitude(
43
+ type: :geopotential, unit: unit, value: h, precision: precision
44
+ )
45
+ )
46
+ end
47
+ self
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model"
4
+ require_relative "pressure_attrs"
5
+
6
+ module Atmospheric
7
+ module Export
8
+ class HypsometricalTable < Lutaml::Model::Serializable
9
+ attribute :rows, PressureAttrs, collection: true
10
+
11
+ xml do
12
+ root "atmospheric"
13
+ map_element "hypsometrical-attributes", to: :rows
14
+ end
15
+
16
+ def steps
17
+ (0..0)
18
+ end
19
+
20
+ def steps_unit
21
+ :mbar
22
+ end
23
+
24
+ def initialize_attrs
25
+ self.rows = []
26
+ end
27
+
28
+ def set_attrs(klass: PressureAttrs, unit: steps_unit, precision: :reduced)
29
+ initialize_attrs
30
+
31
+ steps.each do |p|
32
+ rows << klass.new.set_pressure(value: p, unit: unit, precision: precision)
33
+ end
34
+ self
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,36 +1,24 @@
1
- require_relative "./group_base"
2
- # rubocop:disable Metrics/AbcSize
3
- # rubocop:disable Metrics/BlockLength
4
- # rubocop:disable Metrics/CyclomaticComplexity
5
- # rubocop:disable Metrics/MethodLength
6
- # rubocop:disable Metrics/PerceivedComplexity
7
- # rubocop:disable Layout/LineLength
8
- # rubocop:disable Layout/HashAlignment
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../altitude_table"
4
+ require_relative "group_one_attrs"
5
+
9
6
  module Atmospheric
10
7
  module Export
11
8
  module Iso25331975
9
+ class GroupOne < AltitudeTable
10
+ attribute :by_geometric_altitude, GroupOneAttrs, collection: true
11
+ attribute :by_geopotential_altitude, GroupOneAttrs, collection: true
12
12
 
13
- class GroupOne < GroupBase
14
- # In meters only
15
- def row_from_geopotential(gp_h_f)
16
- {
17
- "temperature-K" => (Isa.temperature_at_layer_from_geopotential(gp_h_f) * 1000.0).round,
18
- "temperature-C" => (Isa.temperature_at_layer_celcius(gp_h_f) * 1000.0).round,
19
- "pressure-mbar" => round_to_sig_figs(Isa.pressure_from_geopotential_mbar(gp_h_f), 6),
20
- "pressure-mmhg" => round_to_sig_figs(Isa.pressure_from_geopotential_mmhg(gp_h_f), 6),
21
- "density" => round_to_sig_figs(Isa.density_from_geopotential(gp_h_f), 6),
22
- "acceleration" => Isa.gravity_at_geopotential(gp_h_f).round(4),
23
- }
13
+ key_value do
14
+ map "by-geometric-altitude", to: :by_geometric_altitude
15
+ map "by-geopotential-altitude", to: :by_geopotential_altitude
16
+ end
17
+
18
+ def set_attrs(klass: GroupOneAttrs, unit: steps_unit, precision: :reduced)
19
+ super
24
20
  end
25
21
  end
26
22
  end
27
-
28
23
  end
29
24
  end
30
- # rubocop:enable Metrics/AbcSize
31
- # rubocop:enable Metrics/BlockLength
32
- # rubocop:enable Metrics/CyclomaticComplexity
33
- # rubocop:enable Metrics/MethodLength
34
- # rubocop:enable Metrics/PerceivedComplexity
35
- # rubocop:enable Layout/LineLength
36
- # rubocop:enable Layout/HashAlignment
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model"
4
+ require_relative "../altitude_convertable_model"
5
+
6
+ module Atmospheric
7
+ module Export
8
+ module Iso25331975
9
+ class GroupOneAttrs < Lutaml::Model::Serializable
10
+ include AltitudeConvertableModel
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
18
+
19
+ 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
30
+ end
31
+
32
+ # In meters only
33
+ 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
41
+ end
42
+
43
+ def calculate(gp_h_m, name, precision: :reduced)
44
+ isa = precision == :high ? Isa::HighPrecision.instance : Isa::NormalPrecision.instance
45
+
46
+ case name
47
+ when :temperature_k
48
+ v = isa.temperature_at_layer_from_geopotential(gp_h_m)
49
+ UnitValueInteger.new(
50
+ value: precision == :reduced ? (v * 1000.0).round : v,
51
+ unitsml: "K"
52
+ )
53
+ when :temperature_c
54
+ v = isa.temperature_at_layer_celcius(gp_h_m)
55
+ UnitValueInteger.new(
56
+ value: precision == :reduced ? (v * 1000.0).round : v,
57
+ unitsml: "degC"
58
+ )
59
+ when :pressure_mbar
60
+ v = isa.pressure_from_geopotential_mbar(gp_h_m)
61
+ UnitValueFloat.new(
62
+ value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
63
+ unitsml: "mbar"
64
+ )
65
+ when :pressure_mmhg
66
+ v = isa.pressure_from_geopotential_mmhg(gp_h_m)
67
+ UnitValueFloat.new(
68
+ value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
69
+ unitsml: "u:mm_Hg"
70
+ )
71
+ when :density
72
+ v = isa.density_from_geopotential(gp_h_m)
73
+ UnitValueFloat.new(
74
+ value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
75
+ unitsml: "kg*m^-3"
76
+ )
77
+ when :acceleration
78
+ v = isa.gravity_at_geopotential(gp_h_m)
79
+ UnitValueFloat.new(
80
+ value: precision == :reduced ? v.round(4) : v,
81
+ unitsml: "m*s^-2"
82
+ )
83
+ else
84
+ raise ArgumentError, "Unknown attribute: #{name}"
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
@@ -1,37 +1,24 @@
1
- require_relative "./group_base"
2
- # rubocop:disable Metrics/AbcSize
3
- # rubocop:disable Metrics/BlockLength
4
- # rubocop:disable Metrics/CyclomaticComplexity
5
- # rubocop:disable Metrics/MethodLength
6
- # rubocop:disable Metrics/PerceivedComplexity
7
- # rubocop:disable Layout/LineLength
8
- # rubocop:disable Layout/HashAlignment
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../altitude_table"
4
+ require_relative "group_three_attrs"
5
+
9
6
  module Atmospheric
10
7
  module Export
11
8
  module Iso25331975
9
+ class GroupThree < AltitudeTable
10
+ attribute :by_geometric_altitude, GroupThreeAttrs, collection: true
11
+ attribute :by_geopotential_altitude, GroupThreeAttrs, collection: true
12
12
 
13
- class GroupThree < GroupBase
14
- # In meters only
15
- def row_from_geopotential(gp_h_f)
16
- {
17
- "pressure-scale-height" => Isa.pressure_scale_height_from_geopotential(gp_h_f).round(1),
18
- "specific-weight" => round_to_sig_figs(Isa.specific_weight_from_geopotential(gp_h_f), 5),
19
- "air-number-density" => round_to_sig_figs(Isa.air_number_density_from_geopotential(gp_h_f), 5),
20
- "mean-speed" => Isa.mean_air_particle_speed_from_geopotential(gp_h_f).round(2),
21
- "frequency" => round_to_sig_figs(Isa.air_particle_collision_frequency_from_geopotential(gp_h_f), 5),
22
- "mean-free-path" => round_to_sig_figs(Isa.mean_free_path_of_air_particles_from_geopotential(gp_h_f), 5),
23
- }
13
+ key_value do
14
+ map "by-geometric-altitude", to: :by_geometric_altitude
15
+ map "by-geopotential-altitude", to: :by_geopotential_altitude
24
16
  end
25
17
 
18
+ def set_attrs(klass: GroupThreeAttrs, unit: steps_unit, precision: :reduced)
19
+ super
20
+ end
26
21
  end
27
22
  end
28
-
29
23
  end
30
24
  end
31
- # rubocop:enable Metrics/AbcSize
32
- # rubocop:enable Metrics/BlockLength
33
- # rubocop:enable Metrics/CyclomaticComplexity
34
- # rubocop:enable Metrics/MethodLength
35
- # rubocop:enable Metrics/PerceivedComplexity
36
- # rubocop:enable Layout/LineLength
37
- # rubocop:enable Layout/HashAlignment