atmospheris 0.5.1
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 +7 -0
- data/LICENSE.txt +25 -0
- data/README.adoc +1254 -0
- data/lib/atmospheris/export/altitude_attrs.rb +296 -0
- data/lib/atmospheris/export/altitude_convertable_model.rb +80 -0
- data/lib/atmospheris/export/altitude_table.rb +49 -0
- data/lib/atmospheris/export/hypsometrical_table.rb +36 -0
- data/lib/atmospheris/export/iso_25331975/group_one.rb +21 -0
- data/lib/atmospheris/export/iso_25331975/group_one_attrs.rb +101 -0
- data/lib/atmospheris/export/iso_25331975/group_three.rb +21 -0
- data/lib/atmospheris/export/iso_25331975/group_three_attrs.rb +101 -0
- data/lib/atmospheris/export/iso_25331975/group_two.rb +21 -0
- data/lib/atmospheris/export/iso_25331975/group_two_attrs.rb +113 -0
- data/lib/atmospheris/export/iso_25331975.rb +28 -0
- data/lib/atmospheris/export/iso_25331985/pressure_attrs.rb +16 -0
- data/lib/atmospheris/export/iso_25331985/table_five_six_attrs.rb +16 -0
- data/lib/atmospheris/export/iso_25331985.rb +113 -0
- data/lib/atmospheris/export/iso_25331997.rb +86 -0
- data/lib/atmospheris/export/iso_25332025/altitude_attrs_group.rb +25 -0
- data/lib/atmospheris/export/iso_25332025/combined_altitude_attrs_group.rb +41 -0
- data/lib/atmospheris/export/iso_25332025.rb +81 -0
- data/lib/atmospheris/export/precision_value.rb +9 -0
- data/lib/atmospheris/export/pressure_attrs.rb +87 -0
- data/lib/atmospheris/export/utils.rb +30 -0
- data/lib/atmospheris/export.rb +17 -0
- data/lib/atmospheris/isa.rb +493 -0
- data/lib/atmospheris/namespace.rb +8 -0
- data/lib/atmospheris/unit_value_float.rb +23 -0
- data/lib/atmospheris/unit_value_integer.rb +23 -0
- data/lib/atmospheris/version.rb +5 -0
- data/lib/atmospheris.rb +14 -0
- metadata +117 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Atmospheris
|
|
4
|
+
module Export
|
|
5
|
+
class AltitudeAttrs < Lutaml::Model::Serializable
|
|
6
|
+
include AltitudeConvertableModel
|
|
7
|
+
|
|
8
|
+
# From Group One
|
|
9
|
+
attribute :temperatures, UnitValueFloat, collection: true
|
|
10
|
+
attribute :pressures, UnitValueFloat, collection: true
|
|
11
|
+
attribute :densities, UnitValueFloat, collection: true
|
|
12
|
+
attribute :accelerations, UnitValueFloat, collection: true
|
|
13
|
+
|
|
14
|
+
# From Group Two
|
|
15
|
+
attribute :ppns, UnitValueFloat, collection: true
|
|
16
|
+
attribute :rhorhons, UnitValueFloat, collection: true
|
|
17
|
+
attribute :sqrt_rhorhons, UnitValueFloat, collection: true
|
|
18
|
+
attribute :speeds_of_sound, UnitValueFloat, collection: true
|
|
19
|
+
attribute :dynamic_viscosities, UnitValueFloat, collection: true
|
|
20
|
+
attribute :kinematic_viscosities, UnitValueFloat, collection: true
|
|
21
|
+
attribute :thermal_conductivities, UnitValueFloat, collection: true
|
|
22
|
+
|
|
23
|
+
# From Group Three
|
|
24
|
+
attribute :pressure_scale_heights, UnitValueFloat, collection: true
|
|
25
|
+
attribute :specific_weights, UnitValueFloat, collection: true
|
|
26
|
+
attribute :air_number_densities, UnitValueFloat, collection: true
|
|
27
|
+
attribute :mean_speeds, UnitValueFloat, collection: true
|
|
28
|
+
attribute :frequencies, UnitValueFloat, collection: true
|
|
29
|
+
attribute :mean_free_paths, UnitValueFloat, collection: true
|
|
30
|
+
attribute :precision, PrecisionValue
|
|
31
|
+
|
|
32
|
+
key_value do
|
|
33
|
+
map "geometric-altitude", to: :geometric_altitudes
|
|
34
|
+
map "geopotential-altitude", to: :geopotential_altitudes
|
|
35
|
+
|
|
36
|
+
# From Group One
|
|
37
|
+
map "temperature", to: :temperatures
|
|
38
|
+
map "pressure", to: :pressures
|
|
39
|
+
map "density", to: :densities
|
|
40
|
+
map "acceleration", to: :accelerations
|
|
41
|
+
|
|
42
|
+
# From Group Two
|
|
43
|
+
map "ppn", to: :ppns
|
|
44
|
+
map "rhorhon", to: :rhorhons
|
|
45
|
+
map "sqrt-rhorhon", to: :sqrt_rhorhons
|
|
46
|
+
map "speed-of-sound", to: :speeds_of_sound
|
|
47
|
+
map "dynamic-viscosity", to: :dynamic_viscosities
|
|
48
|
+
map "kinematic-viscosity", to: :kinematic_viscosities
|
|
49
|
+
map "thermal-conductivity", to: :thermal_conductivities
|
|
50
|
+
|
|
51
|
+
# From Group Three
|
|
52
|
+
map "pressure-scale-height", to: :pressure_scale_heights
|
|
53
|
+
map "specific-weight", to: :specific_weights
|
|
54
|
+
map "air-number-density", to: :air_number_densities
|
|
55
|
+
map "mean-speed", to: :mean_speeds
|
|
56
|
+
map "frequency", to: :frequencies
|
|
57
|
+
map "mean-free-path", to: :mean_free_paths
|
|
58
|
+
|
|
59
|
+
map "precision", to: :precision
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
xml do
|
|
63
|
+
element "atmosphere-attributes"
|
|
64
|
+
namespace Atmospheris::Iso2533Namespace
|
|
65
|
+
map_element "geometric-altitude", to: :geometric_altitudes
|
|
66
|
+
map_element "geopotential-altitude", to: :geopotential_altitudes
|
|
67
|
+
|
|
68
|
+
# From Group One
|
|
69
|
+
map_element "temperature", to: :temperatures
|
|
70
|
+
map_element "pressure", to: :pressures
|
|
71
|
+
map_element "density", to: :densities
|
|
72
|
+
map_element "acceleration", to: :accelerations
|
|
73
|
+
|
|
74
|
+
# From Group Two
|
|
75
|
+
map_element "ppn", to: :ppns
|
|
76
|
+
map_element "rhorhon", to: :rhorhons
|
|
77
|
+
map_element "sqrt-rhorhon", to: :sqrt_rhorhons
|
|
78
|
+
map_element "speed-of-sound", to: :speeds_of_sound
|
|
79
|
+
map_element "dynamic-viscosity", to: :dynamic_viscosities
|
|
80
|
+
map_element "kinematic-viscosity", to: :kinematic_viscosities
|
|
81
|
+
map_element "thermal-conductivity", to: :thermal_conductivities
|
|
82
|
+
|
|
83
|
+
# From Group Three
|
|
84
|
+
map_element "pressure-scale-height", to: :pressure_scale_heights
|
|
85
|
+
map_element "specific-weight", to: :specific_weights
|
|
86
|
+
map_element "air-number-density", to: :air_number_densities
|
|
87
|
+
map_element "mean-speed", to: :mean_speeds
|
|
88
|
+
map_element "frequency", to: :frequencies
|
|
89
|
+
map_element "mean-free-path", to: :mean_free_paths
|
|
90
|
+
|
|
91
|
+
map_element "precision", to: :precision
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# In meters only
|
|
95
|
+
def realize_values_from_geopotential(gp_h_m, precision: :reduced)
|
|
96
|
+
self.precision = precision.to_s
|
|
97
|
+
|
|
98
|
+
# Group One
|
|
99
|
+
self.temperatures = [
|
|
100
|
+
calculate(gp_h_m, :temperature_k, precision: precision),
|
|
101
|
+
calculate(gp_h_m, :temperature_c, precision: precision)
|
|
102
|
+
]
|
|
103
|
+
|
|
104
|
+
self.pressures = [
|
|
105
|
+
calculate(gp_h_m, :pressure_mbar, precision: precision),
|
|
106
|
+
calculate(gp_h_m, :pressure_mmhg, precision: precision)
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
self.densities = [
|
|
110
|
+
calculate(gp_h_m, :density, precision: precision)
|
|
111
|
+
]
|
|
112
|
+
|
|
113
|
+
self.accelerations = [
|
|
114
|
+
calculate(gp_h_m, :acceleration, precision: precision)
|
|
115
|
+
]
|
|
116
|
+
|
|
117
|
+
# Group Two
|
|
118
|
+
self.ppns = [
|
|
119
|
+
calculate(gp_h_m, :ppn, precision: precision)
|
|
120
|
+
]
|
|
121
|
+
|
|
122
|
+
self.rhorhons = [
|
|
123
|
+
calculate(gp_h_m, :rhorhon, precision: precision)
|
|
124
|
+
]
|
|
125
|
+
|
|
126
|
+
self.sqrt_rhorhons = [
|
|
127
|
+
calculate(gp_h_m, :sqrt_rhorhon, precision: precision)
|
|
128
|
+
]
|
|
129
|
+
|
|
130
|
+
self.speeds_of_sound = [
|
|
131
|
+
calculate(gp_h_m, :speed_of_sound, precision: precision)
|
|
132
|
+
]
|
|
133
|
+
|
|
134
|
+
self.dynamic_viscosities = [
|
|
135
|
+
calculate(gp_h_m, :dynamic_viscosity, precision: precision)
|
|
136
|
+
]
|
|
137
|
+
|
|
138
|
+
self.kinematic_viscosities = [
|
|
139
|
+
calculate(gp_h_m, :kinematic_viscosity, precision: precision)
|
|
140
|
+
]
|
|
141
|
+
|
|
142
|
+
self.thermal_conductivities = [
|
|
143
|
+
calculate(gp_h_m, :thermal_conductivity, precision: precision)
|
|
144
|
+
]
|
|
145
|
+
|
|
146
|
+
# Group Three
|
|
147
|
+
self.pressure_scale_heights = [
|
|
148
|
+
calculate(gp_h_m, :pressure_scale_height, precision: precision)
|
|
149
|
+
]
|
|
150
|
+
|
|
151
|
+
self.specific_weights = [
|
|
152
|
+
calculate(gp_h_m, :specific_weight, precision: precision)
|
|
153
|
+
]
|
|
154
|
+
|
|
155
|
+
self.air_number_densities = [
|
|
156
|
+
calculate(gp_h_m, :air_number_density, precision: precision)
|
|
157
|
+
]
|
|
158
|
+
|
|
159
|
+
self.mean_speeds = [
|
|
160
|
+
calculate(gp_h_m, :mean_speed, precision: precision)
|
|
161
|
+
]
|
|
162
|
+
|
|
163
|
+
self.frequencies = [
|
|
164
|
+
calculate(gp_h_m, :frequency, precision: precision)
|
|
165
|
+
]
|
|
166
|
+
|
|
167
|
+
self.mean_free_paths = [
|
|
168
|
+
calculate(gp_h_m, :mean_free_path, precision: precision)
|
|
169
|
+
]
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def calculate(gp_h_m, name, precision: :reduced)
|
|
173
|
+
isa = precision == :high ? Isa::HighPrecision.instance : Isa::NormalPrecision.instance
|
|
174
|
+
|
|
175
|
+
case name
|
|
176
|
+
when :temperature_k
|
|
177
|
+
v = isa.temperature_at_layer_from_geopotential(gp_h_m)
|
|
178
|
+
UnitValueFloat.new(
|
|
179
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
|
180
|
+
unitsml: "K"
|
|
181
|
+
)
|
|
182
|
+
when :temperature_c
|
|
183
|
+
v = isa.temperature_at_layer_celcius(gp_h_m)
|
|
184
|
+
UnitValueFloat.new(
|
|
185
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
|
186
|
+
unitsml: "degC"
|
|
187
|
+
)
|
|
188
|
+
when :pressure_mbar
|
|
189
|
+
v = isa.pressure_from_geopotential_mbar(gp_h_m)
|
|
190
|
+
UnitValueFloat.new(
|
|
191
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
|
192
|
+
unitsml: "mbar"
|
|
193
|
+
)
|
|
194
|
+
when :pressure_mmhg
|
|
195
|
+
v = isa.pressure_from_geopotential_mmhg(gp_h_m)
|
|
196
|
+
UnitValueFloat.new(
|
|
197
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
|
198
|
+
unitsml: "mm_Hg"
|
|
199
|
+
)
|
|
200
|
+
when :density
|
|
201
|
+
v = isa.density_from_geopotential(gp_h_m)
|
|
202
|
+
UnitValueFloat.new(
|
|
203
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
|
204
|
+
unitsml: "kg*m^-3"
|
|
205
|
+
)
|
|
206
|
+
when :acceleration
|
|
207
|
+
v = isa.gravity_at_geopotential(gp_h_m)
|
|
208
|
+
UnitValueFloat.new(
|
|
209
|
+
value: precision == :reduced ? v.round(4) : v,
|
|
210
|
+
unitsml: "m*s^-2"
|
|
211
|
+
)
|
|
212
|
+
when :ppn
|
|
213
|
+
v = isa.p_p_n_from_geopotential(gp_h_m)
|
|
214
|
+
UnitValueFloat.new(
|
|
215
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
|
216
|
+
unitsml: nil
|
|
217
|
+
)
|
|
218
|
+
when :rhorhon
|
|
219
|
+
v = isa.rho_rho_n_from_geopotential(gp_h_m)
|
|
220
|
+
UnitValueFloat.new(
|
|
221
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
|
222
|
+
unitsml: nil
|
|
223
|
+
)
|
|
224
|
+
when :sqrt_rhorhon
|
|
225
|
+
v = isa.root_rho_rho_n_from_geopotential(gp_h_m)
|
|
226
|
+
UnitValueFloat.new(
|
|
227
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
|
228
|
+
unitsml: nil
|
|
229
|
+
)
|
|
230
|
+
when :speed_of_sound
|
|
231
|
+
v = isa.speed_of_sound_from_geopotential(gp_h_m)
|
|
232
|
+
UnitValueFloat.new(
|
|
233
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
|
234
|
+
unitsml: "m*s^-1"
|
|
235
|
+
)
|
|
236
|
+
when :dynamic_viscosity
|
|
237
|
+
v = isa.dynamic_viscosity_from_geopotential(gp_h_m)
|
|
238
|
+
UnitValueFloat.new(
|
|
239
|
+
value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
|
|
240
|
+
unitsml: "Pa*s"
|
|
241
|
+
)
|
|
242
|
+
when :kinematic_viscosity
|
|
243
|
+
v = isa.kinematic_viscosity_from_geopotential(gp_h_m)
|
|
244
|
+
UnitValueFloat.new(
|
|
245
|
+
value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
|
|
246
|
+
unitsml: "m^2*s^-1"
|
|
247
|
+
)
|
|
248
|
+
when :thermal_conductivity
|
|
249
|
+
v = isa.thermal_conductivity_from_geopotential(gp_h_m)
|
|
250
|
+
UnitValueFloat.new(
|
|
251
|
+
value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
|
|
252
|
+
unitsml: "W*m^-1*K^-1"
|
|
253
|
+
)
|
|
254
|
+
when :pressure_scale_height
|
|
255
|
+
v = isa.pressure_scale_height_from_geopotential(gp_h_m)
|
|
256
|
+
UnitValueFloat.new(
|
|
257
|
+
value: precision == :reduced ? v.round(1) : v,
|
|
258
|
+
unitsml: "m"
|
|
259
|
+
)
|
|
260
|
+
when :specific_weight
|
|
261
|
+
v = isa.specific_weight_from_geopotential(gp_h_m)
|
|
262
|
+
UnitValueFloat.new(
|
|
263
|
+
value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
|
|
264
|
+
unitsml: "N*m^-3"
|
|
265
|
+
)
|
|
266
|
+
when :air_number_density
|
|
267
|
+
v = isa.air_number_density_from_geopotential(gp_h_m)
|
|
268
|
+
UnitValueFloat.new(
|
|
269
|
+
value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
|
|
270
|
+
unitsml: "m^-3"
|
|
271
|
+
)
|
|
272
|
+
when :mean_speed
|
|
273
|
+
v = isa.mean_air_particle_speed_from_geopotential(gp_h_m)
|
|
274
|
+
UnitValueFloat.new(
|
|
275
|
+
value: precision == :reduced ? v.round(2) : v,
|
|
276
|
+
unitsml: "m*s^-1"
|
|
277
|
+
)
|
|
278
|
+
when :frequency
|
|
279
|
+
v = isa.air_particle_collision_frequency_from_geopotential(gp_h_m)
|
|
280
|
+
UnitValueFloat.new(
|
|
281
|
+
value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
|
|
282
|
+
unitsml: "s^-1"
|
|
283
|
+
)
|
|
284
|
+
when :mean_free_path
|
|
285
|
+
v = isa.mean_free_path_of_air_particles_from_geopotential(gp_h_m)
|
|
286
|
+
UnitValueFloat.new(
|
|
287
|
+
value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
|
|
288
|
+
unitsml: "m"
|
|
289
|
+
)
|
|
290
|
+
else
|
|
291
|
+
raise ArgumentError, "Unknown attribute: #{name}"
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Atmospheris
|
|
4
|
+
module Export
|
|
5
|
+
module AltitudeConvertableModel
|
|
6
|
+
include Utils
|
|
7
|
+
|
|
8
|
+
def self.included(base)
|
|
9
|
+
base.class_eval do
|
|
10
|
+
attribute :geometric_altitudes, UnitValueInteger, collection: true
|
|
11
|
+
attribute :geopotential_altitudes, UnitValueInteger, collection: true
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def set_altitude(value:, type: :geometric, unit: :meters,
|
|
16
|
+
precision: :reduced)
|
|
17
|
+
case type
|
|
18
|
+
when :geometric
|
|
19
|
+
set_geometric_altitude(value, unit: unit, precision: precision)
|
|
20
|
+
when :geopotential
|
|
21
|
+
set_geopotential_altitude(value, unit: unit, precision: precision)
|
|
22
|
+
else
|
|
23
|
+
raise ArgumentError,
|
|
24
|
+
"Invalid type: #{type}. Use :geometric or :geopotential."
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
self
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def set_geopotential_altitude(h, unit: :meters, precision: :reduced)
|
|
31
|
+
hgpm, hgpf = values_in_m_ft(h, unit: unit)
|
|
32
|
+
hgmm = Isa::NormalPrecision.instance.geometric_altitude_from_geopotential(hgpm)
|
|
33
|
+
hgmf = m_to_ft(hgmm).round
|
|
34
|
+
# TODO: We have to used reduced here because we must round values for
|
|
35
|
+
# the Integer data type as defined.
|
|
36
|
+
realize_altitudes(hgmm, hgmf, hgpm, hgpf, precision: :reduced)
|
|
37
|
+
realize_values_from_geopotential(hgpm, precision: precision)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def set_geometric_altitude(h, unit: :meters, precision: :reduced)
|
|
41
|
+
hgmm, hgmf = values_in_m_ft(h, unit: unit)
|
|
42
|
+
hgpm = Isa::NormalPrecision.instance.geopotential_altitude_from_geometric(hgmm)
|
|
43
|
+
hgpf = m_to_ft(hgpm).round
|
|
44
|
+
# TODO: We have to used reduced here because we must round values for
|
|
45
|
+
# the Integer data type as defined.
|
|
46
|
+
realize_altitudes(hgmm, hgmf, hgpm, hgpf, precision: :reduced)
|
|
47
|
+
realize_values_from_geopotential(hgpm, precision: precision)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def realize_altitudes(hgmm, hgmf, hgpm, hgpf, precision: :reduced)
|
|
51
|
+
self.geometric_altitudes = [
|
|
52
|
+
UnitValueInteger.new(
|
|
53
|
+
value: precision == :reduced ? hgmm.round : hgmm,
|
|
54
|
+
unitsml: "m"
|
|
55
|
+
),
|
|
56
|
+
UnitValueInteger.new(
|
|
57
|
+
value: precision == :reduced ? hgmf.round : hgmf,
|
|
58
|
+
unitsml: "ft"
|
|
59
|
+
)
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
self.geopotential_altitudes = [
|
|
63
|
+
UnitValueInteger.new(
|
|
64
|
+
value: precision == :reduced ? hgpm.round : hgpm,
|
|
65
|
+
unitsml: "m"
|
|
66
|
+
),
|
|
67
|
+
UnitValueInteger.new(
|
|
68
|
+
value: precision == :reduced ? hgpf.round : hgpf,
|
|
69
|
+
unitsml: "ft"
|
|
70
|
+
)
|
|
71
|
+
]
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def realize_values_from_geopotential(gp_h_m, precision:)
|
|
75
|
+
raise NotImplementedError,
|
|
76
|
+
"realize_values_from_geopotential method must be implemented in the including class"
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Atmospheris
|
|
4
|
+
module Export
|
|
5
|
+
class AltitudeTable < Lutaml::Model::Serializable
|
|
6
|
+
# Step 50 from -2k to 40k, step 100 above 32k, 200 above 51k to 80k
|
|
7
|
+
def steps
|
|
8
|
+
((-2000..31_950).step(50) +
|
|
9
|
+
(32_000..50_900).step(100) +
|
|
10
|
+
(51_000..80_000).step(200))
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def steps_unit
|
|
14
|
+
:meters
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def add_to_geometric(item)
|
|
18
|
+
by_geometric_altitude << item
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def add_to_geopotential(item)
|
|
22
|
+
by_geopotential_altitude << item
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def initialize_attrs
|
|
26
|
+
self.by_geometric_altitude = []
|
|
27
|
+
self.by_geopotential_altitude = []
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def set_attrs(klass:, unit: steps_unit, precision: :normal)
|
|
31
|
+
initialize_attrs
|
|
32
|
+
|
|
33
|
+
steps.each do |h|
|
|
34
|
+
add_to_geometric(
|
|
35
|
+
klass.new.set_altitude(
|
|
36
|
+
type: :geometric, unit: unit, value: h, precision: precision
|
|
37
|
+
)
|
|
38
|
+
)
|
|
39
|
+
add_to_geopotential(
|
|
40
|
+
klass.new.set_altitude(
|
|
41
|
+
type: :geopotential, unit: unit, value: h, precision: precision
|
|
42
|
+
)
|
|
43
|
+
)
|
|
44
|
+
end
|
|
45
|
+
self
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Atmospheris
|
|
4
|
+
module Export
|
|
5
|
+
class HypsometricalTable < Lutaml::Model::Serializable
|
|
6
|
+
attribute :rows, PressureAttrs, collection: true
|
|
7
|
+
|
|
8
|
+
xml do
|
|
9
|
+
element "atmospheris"
|
|
10
|
+
namespace Atmospheris::Iso2533Namespace
|
|
11
|
+
map_element "hypsometrical-attributes", to: :rows
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def steps
|
|
15
|
+
(0..0)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def steps_unit
|
|
19
|
+
:mbar
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def initialize_attrs
|
|
23
|
+
self.rows = []
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def set_attrs(klass: PressureAttrs, unit: steps_unit, precision: :reduced)
|
|
27
|
+
initialize_attrs
|
|
28
|
+
|
|
29
|
+
steps.each do |p|
|
|
30
|
+
rows << klass.new.set_pressure(value: p, unit: unit, precision: precision)
|
|
31
|
+
end
|
|
32
|
+
self
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Atmospheris
|
|
4
|
+
module Export
|
|
5
|
+
module Iso25331975
|
|
6
|
+
class GroupOne < AltitudeTable
|
|
7
|
+
attribute :by_geometric_altitude, GroupOneAttrs, collection: true
|
|
8
|
+
attribute :by_geopotential_altitude, GroupOneAttrs, collection: true
|
|
9
|
+
|
|
10
|
+
key_value do
|
|
11
|
+
map "by-geometric-altitude", to: :by_geometric_altitude
|
|
12
|
+
map "by-geopotential-altitude", to: :by_geopotential_altitude
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def set_attrs(klass: GroupOneAttrs, unit: steps_unit, precision: :reduced)
|
|
16
|
+
super
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Atmospheris
|
|
4
|
+
module Export
|
|
5
|
+
module Iso25331975
|
|
6
|
+
class GroupOneAttrs < Lutaml::Model::Serializable
|
|
7
|
+
include AltitudeConvertableModel
|
|
8
|
+
|
|
9
|
+
attribute :temperatures, UnitValueInteger, collection: true
|
|
10
|
+
attribute :pressures, UnitValueFloat, collection: true
|
|
11
|
+
attribute :densities, UnitValueFloat, collection: true
|
|
12
|
+
attribute :accelerations, UnitValueFloat, collection: true
|
|
13
|
+
|
|
14
|
+
key_value do
|
|
15
|
+
map "geometric-altitude", to: :geometric_altitudes
|
|
16
|
+
map "geopotential-altitude", to: :geopotential_altitudes
|
|
17
|
+
map "temperature", to: :temperatures
|
|
18
|
+
map "pressure", to: :pressures
|
|
19
|
+
map "density", to: :densities
|
|
20
|
+
map "acceleration", to: :accelerations
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
xml do
|
|
24
|
+
element "group-one-attrs"
|
|
25
|
+
map_element "geometric-altitude", to: :geometric_altitudes
|
|
26
|
+
map_element "geopotential-altitude", to: :geopotential_altitudes
|
|
27
|
+
map_element "temperature", to: :temperatures
|
|
28
|
+
map_element "pressure", to: :pressures
|
|
29
|
+
map_element "density", to: :densities
|
|
30
|
+
map_element "acceleration", to: :accelerations
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# In meters only
|
|
34
|
+
def realize_values_from_geopotential(gp_h_m, precision: :reduced)
|
|
35
|
+
self.temperatures = [
|
|
36
|
+
calculate(gp_h_m, :temperature_k, precision: precision),
|
|
37
|
+
calculate(gp_h_m, :temperature_c, precision: precision)
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
self.pressures = [
|
|
41
|
+
calculate(gp_h_m, :pressure_mbar, precision: precision),
|
|
42
|
+
calculate(gp_h_m, :pressure_mmhg, precision: precision)
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
self.densities = [
|
|
46
|
+
calculate(gp_h_m, :density, precision: precision)
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
self.accelerations = [
|
|
50
|
+
calculate(gp_h_m, :acceleration, precision: precision)
|
|
51
|
+
]
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def calculate(gp_h_m, name, precision: :reduced)
|
|
55
|
+
isa = precision == :high ? Isa::HighPrecision.instance : Isa::NormalPrecision.instance
|
|
56
|
+
|
|
57
|
+
case name
|
|
58
|
+
when :temperature_k
|
|
59
|
+
v = isa.temperature_at_layer_from_geopotential(gp_h_m)
|
|
60
|
+
UnitValueInteger.new(
|
|
61
|
+
value: precision == :reduced ? (v * 1000.0).round : v,
|
|
62
|
+
unitsml: "K"
|
|
63
|
+
)
|
|
64
|
+
when :temperature_c
|
|
65
|
+
v = isa.temperature_at_layer_celcius(gp_h_m)
|
|
66
|
+
UnitValueInteger.new(
|
|
67
|
+
value: precision == :reduced ? (v * 1000.0).round : v,
|
|
68
|
+
unitsml: "degC"
|
|
69
|
+
)
|
|
70
|
+
when :pressure_mbar
|
|
71
|
+
v = isa.pressure_from_geopotential_mbar(gp_h_m)
|
|
72
|
+
UnitValueFloat.new(
|
|
73
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
|
74
|
+
unitsml: "mbar"
|
|
75
|
+
)
|
|
76
|
+
when :pressure_mmhg
|
|
77
|
+
v = isa.pressure_from_geopotential_mmhg(gp_h_m)
|
|
78
|
+
UnitValueFloat.new(
|
|
79
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
|
80
|
+
unitsml: "mm_Hg"
|
|
81
|
+
)
|
|
82
|
+
when :density
|
|
83
|
+
v = isa.density_from_geopotential(gp_h_m)
|
|
84
|
+
UnitValueFloat.new(
|
|
85
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
|
86
|
+
unitsml: "kg*m^-3"
|
|
87
|
+
)
|
|
88
|
+
when :acceleration
|
|
89
|
+
v = isa.gravity_at_geopotential(gp_h_m)
|
|
90
|
+
UnitValueFloat.new(
|
|
91
|
+
value: precision == :reduced ? v.round(4) : v,
|
|
92
|
+
unitsml: "m*s^-2"
|
|
93
|
+
)
|
|
94
|
+
else
|
|
95
|
+
raise ArgumentError, "Unknown attribute: #{name}"
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Atmospheris
|
|
4
|
+
module Export
|
|
5
|
+
module Iso25331975
|
|
6
|
+
class GroupThree < AltitudeTable
|
|
7
|
+
attribute :by_geometric_altitude, GroupThreeAttrs, collection: true
|
|
8
|
+
attribute :by_geopotential_altitude, GroupThreeAttrs, collection: true
|
|
9
|
+
|
|
10
|
+
key_value do
|
|
11
|
+
map "by-geometric-altitude", to: :by_geometric_altitude
|
|
12
|
+
map "by-geopotential-altitude", to: :by_geopotential_altitude
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def set_attrs(klass: GroupThreeAttrs, unit: steps_unit, precision: :reduced)
|
|
16
|
+
super
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|