atmospheric 0.4.3 → 0.4.4
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.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.adoc +652 -183
- data/lib/atmospheric/export/altitude_attrs.rb +238 -0
- data/lib/atmospheric/export/altitude_convertable_model.rb +84 -0
- data/lib/atmospheric/export/altitude_table.rb +51 -0
- data/lib/atmospheric/export/hypsometrical_table.rb +38 -0
- data/lib/atmospheric/export/iso_25331975/group_one.rb +15 -27
- data/lib/atmospheric/export/iso_25331975/group_one_attrs.rb +88 -0
- data/lib/atmospheric/export/iso_25331975/group_three.rb +14 -27
- data/lib/atmospheric/export/iso_25331975/group_three_attrs.rb +87 -0
- data/lib/atmospheric/export/iso_25331975/group_two.rb +14 -28
- data/lib/atmospheric/export/iso_25331975/group_two_attrs.rb +96 -0
- data/lib/atmospheric/export/iso_25331975.rb +5 -17
- data/lib/atmospheric/export/iso_25331985/pressure_attrs.rb +19 -0
- data/lib/atmospheric/export/iso_25331985/table_five_six_attrs.rb +19 -0
- data/lib/atmospheric/export/iso_25331985.rb +42 -63
- data/lib/atmospheric/export/iso_25331997.rb +21 -39
- data/lib/atmospheric/export/iso_25332025/altitude_attrs_group.rb +27 -0
- data/lib/atmospheric/export/iso_25332025/combined_altitude_attrs_group.rb +44 -0
- data/lib/atmospheric/export/iso_25332025.rb +81 -0
- data/lib/atmospheric/export/pressure_attrs.rb +93 -0
- data/lib/atmospheric/export/{target.rb → utils.rb} +10 -13
- data/lib/atmospheric/export.rb +3 -1
- data/lib/atmospheric/isa.rb +119 -114
- data/lib/atmospheric/unit_value_float.rb +24 -0
- data/lib/atmospheric/unit_value_integer.rb +24 -0
- data/lib/atmospheric/version.rb +1 -1
- data/lib/atmospheric.rb +1 -0
- metadata +38 -28
- data/lib/atmospheric/export/hypsometrical_tables.rb +0 -34
- data/lib/atmospheric/export/iso_25331975/group_base.rb +0 -72
- data/lib/atmospheric/export/iso_25332024.rb +0 -205
- data/spec/fixtures/iso-2533-1975-table5.yaml +0 -18297
- data/spec/fixtures/iso-2533-1975-table6.yaml +0 -18298
- data/spec/fixtures/iso-2533-1975-table7.yaml +0 -16265
@@ -0,0 +1,238 @@
|
|
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
|
+
|
37
|
+
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
|
42
|
+
|
43
|
+
# 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
|
50
|
+
|
51
|
+
# 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
|
59
|
+
|
60
|
+
# 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
|
67
|
+
end
|
68
|
+
|
69
|
+
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
|
75
|
+
|
76
|
+
# 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
|
83
|
+
|
84
|
+
# 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
|
92
|
+
|
93
|
+
# 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
|
100
|
+
end
|
101
|
+
|
102
|
+
# In meters only
|
103
|
+
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
|
114
|
+
end
|
115
|
+
|
116
|
+
def calculate(gp_h_m, name, precision: :reduced)
|
117
|
+
case name
|
118
|
+
when :temperature_k
|
119
|
+
v = Isa::NormalPrecision.instance.temperature_at_layer_from_geopotential(gp_h_m)
|
120
|
+
UnitValueFloat.new(
|
121
|
+
value: precision == :reduced ? (v * 1000.0).round : v,
|
122
|
+
unitsml: "K"
|
123
|
+
)
|
124
|
+
when :temperature_c
|
125
|
+
v = Isa::NormalPrecision.instance.temperature_at_layer_celcius(gp_h_m)
|
126
|
+
UnitValueFloat.new(
|
127
|
+
value: precision == :reduced ? (v * 1000.0).round : v,
|
128
|
+
unitsml: "degC"
|
129
|
+
)
|
130
|
+
when :pressure_mbar
|
131
|
+
v = Isa::NormalPrecision.instance.pressure_from_geopotential_mbar(gp_h_m)
|
132
|
+
UnitValueFloat.new(
|
133
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
134
|
+
unitsml: "mbar"
|
135
|
+
)
|
136
|
+
when :pressure_mmhg
|
137
|
+
v = Isa::NormalPrecision.instance.pressure_from_geopotential_mmhg(gp_h_m)
|
138
|
+
UnitValueFloat.new(
|
139
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
140
|
+
unitsml: "u:mm_Hg"
|
141
|
+
)
|
142
|
+
when :density
|
143
|
+
v = Isa::NormalPrecision.instance.density_from_geopotential(gp_h_m)
|
144
|
+
UnitValueFloat.new(
|
145
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
146
|
+
unitsml: "kg*m^-3"
|
147
|
+
)
|
148
|
+
when :acceleration
|
149
|
+
v = Isa::NormalPrecision.instance.gravity_at_geopotential(gp_h_m)
|
150
|
+
UnitValueFloat.new(
|
151
|
+
value: precision == :reduced ? v.round(4) : v,
|
152
|
+
unitsml: "m*s^-2"
|
153
|
+
)
|
154
|
+
when :ppn
|
155
|
+
v = Isa::NormalPrecision.instance.p_p_n_from_geopotential(gp_h_m)
|
156
|
+
UnitValueFloat.new(
|
157
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
158
|
+
unitsml: nil
|
159
|
+
)
|
160
|
+
when :rhorhon
|
161
|
+
v = Isa::NormalPrecision.instance.rho_rho_n_from_geopotential(gp_h_m)
|
162
|
+
UnitValueFloat.new(
|
163
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
164
|
+
unitsml: nil
|
165
|
+
)
|
166
|
+
when :sqrt_rhorhon
|
167
|
+
v = Isa::NormalPrecision.instance.root_rho_rho_n_from_geopotential(gp_h_m)
|
168
|
+
UnitValueFloat.new(
|
169
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
170
|
+
unitsml: nil
|
171
|
+
)
|
172
|
+
when :speed_of_sound
|
173
|
+
v = Isa::NormalPrecision.instance.speed_of_sound_from_geopotential(gp_h_m)
|
174
|
+
UnitValueFloat.new(
|
175
|
+
value: precision == :reduced ? (v * 1000.0).round : v,
|
176
|
+
unitsml: "m*s^-1"
|
177
|
+
)
|
178
|
+
when :dynamic_viscosity
|
179
|
+
v = Isa::NormalPrecision.instance.dynamic_viscosity_from_geopotential(gp_h_m)
|
180
|
+
UnitValueFloat.new(
|
181
|
+
value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
|
182
|
+
unitsml: "Pa*s"
|
183
|
+
)
|
184
|
+
when :kinematic_viscosity
|
185
|
+
v = Isa::NormalPrecision.instance.kinematic_viscosity_from_geopotential(gp_h_m)
|
186
|
+
UnitValueFloat.new(
|
187
|
+
value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
|
188
|
+
unitsml: "m^2*s^-1"
|
189
|
+
)
|
190
|
+
when :thermal_conductivity
|
191
|
+
v = Isa::NormalPrecision.instance.thermal_conductivity_from_geopotential(gp_h_m)
|
192
|
+
UnitValueFloat.new(
|
193
|
+
value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
|
194
|
+
unitsml: "W*m^-1*K^-1"
|
195
|
+
)
|
196
|
+
when :pressure_scale_height
|
197
|
+
v = Isa::NormalPrecision.instance.pressure_scale_height_from_geopotential(gp_h_m)
|
198
|
+
UnitValueFloat.new(
|
199
|
+
value: precision == :reduced ? v.round(1) : v,
|
200
|
+
unitsml: "m"
|
201
|
+
)
|
202
|
+
when :specific_weight
|
203
|
+
v = Isa::NormalPrecision.instance.specific_weight_from_geopotential(gp_h_m)
|
204
|
+
UnitValueFloat.new(
|
205
|
+
value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
|
206
|
+
unitsml: "N*m^-3"
|
207
|
+
)
|
208
|
+
when :air_number_density
|
209
|
+
v = Isa::NormalPrecision.instance.air_number_density_from_geopotential(gp_h_m)
|
210
|
+
UnitValueFloat.new(
|
211
|
+
value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
|
212
|
+
unitsml: "m^-3"
|
213
|
+
)
|
214
|
+
when :mean_speed
|
215
|
+
v = Isa::NormalPrecision.instance.mean_air_particle_speed_from_geopotential(gp_h_m)
|
216
|
+
UnitValueFloat.new(
|
217
|
+
value: precision == :reduced ? v.round(2) : v,
|
218
|
+
unitsml: "m*s^-1"
|
219
|
+
)
|
220
|
+
when :frequency
|
221
|
+
v = Isa::NormalPrecision.instance.air_particle_collision_frequency_from_geopotential(gp_h_m)
|
222
|
+
UnitValueFloat.new(
|
223
|
+
value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
|
224
|
+
unitsml: "s^-1"
|
225
|
+
)
|
226
|
+
when :mean_free_path
|
227
|
+
v = Isa::NormalPrecision.instance.mean_free_path_of_air_particles_from_geopotential(gp_h_m)
|
228
|
+
UnitValueFloat.new(
|
229
|
+
value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
|
230
|
+
unitsml: "m"
|
231
|
+
)
|
232
|
+
else
|
233
|
+
raise ArgumentError, "Unknown attribute: #{name}"
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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,88 @@
|
|
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
|
+
case name
|
45
|
+
when :temperature_k
|
46
|
+
v = Isa::NormalPrecision.instance.temperature_at_layer_from_geopotential(gp_h_m)
|
47
|
+
UnitValueInteger.new(
|
48
|
+
value: precision == :reduced ? (v * 1000.0).round : v,
|
49
|
+
unitsml: "K"
|
50
|
+
)
|
51
|
+
when :temperature_c
|
52
|
+
v = Isa::NormalPrecision.instance.temperature_at_layer_celcius(gp_h_m)
|
53
|
+
UnitValueInteger.new(
|
54
|
+
value: precision == :reduced ? (v * 1000.0).round : v,
|
55
|
+
unitsml: "degC"
|
56
|
+
)
|
57
|
+
when :pressure_mbar
|
58
|
+
v = Isa::NormalPrecision.instance.pressure_from_geopotential_mbar(gp_h_m)
|
59
|
+
UnitValueFloat.new(
|
60
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
61
|
+
unitsml: "mbar"
|
62
|
+
)
|
63
|
+
when :pressure_mmhg
|
64
|
+
v = Isa::NormalPrecision.instance.pressure_from_geopotential_mmhg(gp_h_m)
|
65
|
+
UnitValueFloat.new(
|
66
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
67
|
+
unitsml: "u:mm_Hg"
|
68
|
+
)
|
69
|
+
when :density
|
70
|
+
v = Isa::NormalPrecision.instance.density_from_geopotential(gp_h_m)
|
71
|
+
UnitValueFloat.new(
|
72
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
73
|
+
unitsml: "kg*m^-3"
|
74
|
+
)
|
75
|
+
when :acceleration
|
76
|
+
v = Isa::NormalPrecision.instance.gravity_at_geopotential(gp_h_m)
|
77
|
+
UnitValueFloat.new(
|
78
|
+
value: precision == :reduced ? v.round(4) : v,
|
79
|
+
unitsml: "m*s^-2"
|
80
|
+
)
|
81
|
+
else
|
82
|
+
raise ArgumentError, "Unknown attribute: #{name}"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -1,37 +1,24 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
14
|
-
|
15
|
-
|
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
|