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,101 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Atmospheris
|
|
4
|
+
module Export
|
|
5
|
+
module Iso25331975
|
|
6
|
+
class GroupThreeAttrs < Lutaml::Model::Serializable
|
|
7
|
+
include AltitudeConvertableModel
|
|
8
|
+
|
|
9
|
+
attribute :pressure_scale_heights, UnitValueFloat, collection: true
|
|
10
|
+
attribute :specific_weights, UnitValueFloat, collection: true
|
|
11
|
+
attribute :air_number_densities, UnitValueFloat, collection: true
|
|
12
|
+
attribute :mean_speeds, UnitValueFloat, collection: true
|
|
13
|
+
attribute :frequencies, UnitValueFloat, collection: true
|
|
14
|
+
attribute :mean_free_paths, UnitValueFloat, collection: true
|
|
15
|
+
|
|
16
|
+
key_value do
|
|
17
|
+
map "geometric-altitude", to: :geometric_altitudes
|
|
18
|
+
map "geopotential-altitude", to: :geopotential_altitudes
|
|
19
|
+
map "pressure-scale-height", to: :pressure_scale_heights
|
|
20
|
+
map "specific-weight", to: :specific_weights
|
|
21
|
+
map "air-number-density", to: :air_number_densities
|
|
22
|
+
map "mean-speed", to: :mean_speeds
|
|
23
|
+
map "frequency", to: :frequencies
|
|
24
|
+
map "mean-free-path", to: :mean_free_paths
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# In meters only
|
|
28
|
+
def realize_values_from_geopotential(gp_h_m, precision: :reduced)
|
|
29
|
+
self.pressure_scale_heights = [
|
|
30
|
+
calculate(gp_h_m, :pressure_scale_height, precision: precision)
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
self.specific_weights = [
|
|
34
|
+
calculate(gp_h_m, :specific_weight, precision: precision)
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
self.air_number_densities = [
|
|
38
|
+
calculate(gp_h_m, :air_number_density, precision: precision)
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
self.mean_speeds = [
|
|
42
|
+
calculate(gp_h_m, :mean_speed, precision: precision)
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
self.frequencies = [
|
|
46
|
+
calculate(gp_h_m, :frequency, precision: precision)
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
self.mean_free_paths = [
|
|
50
|
+
calculate(gp_h_m, :mean_free_path, 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 :pressure_scale_height
|
|
59
|
+
v = isa.pressure_scale_height_from_geopotential(gp_h_m)
|
|
60
|
+
UnitValueFloat.new(
|
|
61
|
+
value: precision == :reduced ? v.round(1) : v,
|
|
62
|
+
unitsml: "m"
|
|
63
|
+
)
|
|
64
|
+
when :specific_weight
|
|
65
|
+
v = isa.specific_weight_from_geopotential(gp_h_m)
|
|
66
|
+
UnitValueFloat.new(
|
|
67
|
+
value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
|
|
68
|
+
unitsml: "N*m^-3"
|
|
69
|
+
)
|
|
70
|
+
when :air_number_density
|
|
71
|
+
v = isa.air_number_density_from_geopotential(gp_h_m)
|
|
72
|
+
UnitValueFloat.new(
|
|
73
|
+
value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
|
|
74
|
+
unitsml: "m^-3"
|
|
75
|
+
)
|
|
76
|
+
when :mean_speed
|
|
77
|
+
v = isa.mean_air_particle_speed_from_geopotential(gp_h_m)
|
|
78
|
+
UnitValueFloat.new(
|
|
79
|
+
value: precision == :reduced ? v.round(2) : v,
|
|
80
|
+
unitsml: "m*s^-1"
|
|
81
|
+
)
|
|
82
|
+
when :frequency
|
|
83
|
+
v = isa.air_particle_collision_frequency_from_geopotential(gp_h_m)
|
|
84
|
+
UnitValueFloat.new(
|
|
85
|
+
value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
|
|
86
|
+
unitsml: "s^-1"
|
|
87
|
+
)
|
|
88
|
+
when :mean_free_path
|
|
89
|
+
v = isa.mean_free_path_of_air_particles_from_geopotential(gp_h_m)
|
|
90
|
+
UnitValueFloat.new(
|
|
91
|
+
value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
|
|
92
|
+
unitsml: "m"
|
|
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 GroupTwo < AltitudeTable
|
|
7
|
+
attribute :by_geometric_altitude, GroupTwoAttrs, collection: true
|
|
8
|
+
attribute :by_geopotential_altitude, GroupTwoAttrs, 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: GroupTwoAttrs, unit: steps_unit, precision: :reduced)
|
|
16
|
+
super
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Atmospheris
|
|
4
|
+
module Export
|
|
5
|
+
module Iso25331975
|
|
6
|
+
class GroupTwoAttrs < Lutaml::Model::Serializable
|
|
7
|
+
include AltitudeConvertableModel
|
|
8
|
+
|
|
9
|
+
attribute :ppns, UnitValueFloat, collection: true
|
|
10
|
+
attribute :rhorhons, UnitValueFloat, collection: true
|
|
11
|
+
attribute :sqrt_rhorhons, UnitValueFloat, collection: true
|
|
12
|
+
attribute :speeds_of_sound, UnitValueInteger, collection: true
|
|
13
|
+
attribute :dynamic_viscosities, UnitValueFloat, collection: true
|
|
14
|
+
attribute :kinematic_viscosities, UnitValueFloat, collection: true
|
|
15
|
+
attribute :thermal_conductivities, UnitValueFloat, collection: true
|
|
16
|
+
|
|
17
|
+
key_value do
|
|
18
|
+
map "geometric-altitude", to: :geometric_altitudes
|
|
19
|
+
map "geopotential-altitude", to: :geopotential_altitudes
|
|
20
|
+
map "ppn", to: :ppns
|
|
21
|
+
map "rhorhon", to: :rhorhons
|
|
22
|
+
map "sqrt-rhorhon", to: :sqrt_rhorhons
|
|
23
|
+
map "speed-of-sound", to: :speeds_of_sound
|
|
24
|
+
map "dynamic-viscosity", to: :dynamic_viscosities
|
|
25
|
+
map "kinematic-viscosity", to: :kinematic_viscosities
|
|
26
|
+
map "thermal-conductivity", to: :thermal_conductivities
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# In meters only
|
|
30
|
+
def realize_values_from_geopotential(gp_h_m, precision: :reduced)
|
|
31
|
+
self.ppns = [
|
|
32
|
+
calculate(gp_h_m, :ppn, precision: precision)
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
self.rhorhons = [
|
|
36
|
+
calculate(gp_h_m, :rhorhon, precision: precision)
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
self.sqrt_rhorhons = [
|
|
40
|
+
calculate(gp_h_m, :sqrt_rhorhon, precision: precision)
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
self.speeds_of_sound = [
|
|
44
|
+
calculate(gp_h_m, :speed_of_sound, precision: precision)
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
self.dynamic_viscosities = [
|
|
48
|
+
calculate(gp_h_m, :dynamic_viscosity, precision: precision)
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
self.kinematic_viscosities = [
|
|
52
|
+
calculate(gp_h_m, :kinematic_viscosity, precision: precision)
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
self.thermal_conductivities = [
|
|
56
|
+
calculate(gp_h_m, :thermal_conductivity, precision: precision)
|
|
57
|
+
]
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def calculate(gp_h_m, name, precision: :reduced)
|
|
61
|
+
isa = precision == :high ? Isa::HighPrecision.instance : Isa::NormalPrecision.instance
|
|
62
|
+
|
|
63
|
+
case name
|
|
64
|
+
when :ppn
|
|
65
|
+
v = isa.p_p_n_from_geopotential(gp_h_m)
|
|
66
|
+
UnitValueFloat.new(
|
|
67
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
|
68
|
+
unitsml: nil
|
|
69
|
+
)
|
|
70
|
+
when :rhorhon
|
|
71
|
+
v = isa.rho_rho_n_from_geopotential(gp_h_m)
|
|
72
|
+
UnitValueFloat.new(
|
|
73
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
|
74
|
+
unitsml: nil
|
|
75
|
+
)
|
|
76
|
+
when :sqrt_rhorhon
|
|
77
|
+
v = isa.root_rho_rho_n_from_geopotential(gp_h_m)
|
|
78
|
+
UnitValueFloat.new(
|
|
79
|
+
value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
|
|
80
|
+
unitsml: nil
|
|
81
|
+
)
|
|
82
|
+
when :speed_of_sound
|
|
83
|
+
v = isa.speed_of_sound_from_geopotential(gp_h_m)
|
|
84
|
+
UnitValueInteger.new(
|
|
85
|
+
value: precision == :reduced ? (v * 1000.0).round : v,
|
|
86
|
+
unitsml: "m*s^-1"
|
|
87
|
+
)
|
|
88
|
+
when :dynamic_viscosity
|
|
89
|
+
v = isa.dynamic_viscosity_from_geopotential(gp_h_m)
|
|
90
|
+
UnitValueFloat.new(
|
|
91
|
+
value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
|
|
92
|
+
unitsml: "Pa*s"
|
|
93
|
+
)
|
|
94
|
+
when :kinematic_viscosity
|
|
95
|
+
v = isa.kinematic_viscosity_from_geopotential(gp_h_m)
|
|
96
|
+
UnitValueFloat.new(
|
|
97
|
+
value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
|
|
98
|
+
unitsml: "m^2*s^-1"
|
|
99
|
+
)
|
|
100
|
+
when :thermal_conductivity
|
|
101
|
+
v = isa.thermal_conductivity_from_geopotential(gp_h_m)
|
|
102
|
+
UnitValueFloat.new(
|
|
103
|
+
value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
|
|
104
|
+
unitsml: "W*m^-1*K^-1"
|
|
105
|
+
)
|
|
106
|
+
else
|
|
107
|
+
raise ArgumentError, "Unknown attribute: #{name}"
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Atmospheris
|
|
4
|
+
module Export
|
|
5
|
+
module Iso25331975
|
|
6
|
+
autoload :GroupOne, "atmospheris/export/iso_25331975/group_one"
|
|
7
|
+
autoload :GroupTwo, "atmospheris/export/iso_25331975/group_two"
|
|
8
|
+
autoload :GroupThree, "atmospheris/export/iso_25331975/group_three"
|
|
9
|
+
autoload :GroupOneAttrs, "atmospheris/export/iso_25331975/group_one_attrs"
|
|
10
|
+
autoload :GroupTwoAttrs, "atmospheris/export/iso_25331975/group_two_attrs"
|
|
11
|
+
autoload :GroupThreeAttrs, "atmospheris/export/iso_25331975/group_three_attrs"
|
|
12
|
+
|
|
13
|
+
class << self
|
|
14
|
+
def table_5
|
|
15
|
+
GroupOne.new.set_attrs
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def table_6
|
|
19
|
+
GroupTwo.new.set_attrs
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def table_7
|
|
23
|
+
GroupThree.new.set_attrs
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# The purpose of this class is to trim the attributes used in the ISO 2533:1985
|
|
4
|
+
# standard.
|
|
5
|
+
module Atmospheris
|
|
6
|
+
module Export
|
|
7
|
+
module Iso25331985
|
|
8
|
+
class PressureAttrs < ::Atmospheris::Export::PressureAttrs
|
|
9
|
+
key_value do
|
|
10
|
+
map "pressure", to: :pressures
|
|
11
|
+
map "geopotential-altitude", to: :geopotential_altitudes
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Atmospheris
|
|
4
|
+
module Export
|
|
5
|
+
module Iso25331985
|
|
6
|
+
class TableFiveSixAttrs < ::Atmospheris::Export::Iso25331975::GroupOneAttrs
|
|
7
|
+
# TODO: Completely override other attributes / key value mappings so
|
|
8
|
+
# they don't show in YAML
|
|
9
|
+
key_value do
|
|
10
|
+
map "geopotential-altitude", to: :geopotential_altitudes
|
|
11
|
+
map "pressure", to: :pressures
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Atmospheris
|
|
4
|
+
module Export
|
|
5
|
+
module Iso25331985
|
|
6
|
+
autoload :PressureAttrs, "atmospheris/export/iso_25331985/pressure_attrs"
|
|
7
|
+
autoload :TableFiveSixAttrs, "atmospheris/export/iso_25331985/table_five_six_attrs"
|
|
8
|
+
|
|
9
|
+
class TableOne < HypsometricalTable
|
|
10
|
+
# TODO: when Ruby's step does not create inaccurate floating point numbers
|
|
11
|
+
# This is a hack to solve a Ruby bug with floating point calcuations
|
|
12
|
+
# > (20.0..1770.9).step(0.1).to_a
|
|
13
|
+
# ...
|
|
14
|
+
# 1769.4,
|
|
15
|
+
# 1769.5,
|
|
16
|
+
# 1769.6000000000001, # <== we need to clean these
|
|
17
|
+
# 1769.7,
|
|
18
|
+
# 1769.8000000000002, # <== we need to clean these
|
|
19
|
+
# The last `map` should be removed if this bug is fixed
|
|
20
|
+
|
|
21
|
+
attribute :rows, PressureAttrs, collection: true
|
|
22
|
+
|
|
23
|
+
def steps
|
|
24
|
+
(5.0..19.99).step(0.01).to_a.map { |v| v.round(2) }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def steps_unit
|
|
28
|
+
:mbar
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def set_attrs(klass: PressureAttrs, unit: steps_unit, precision: :reduced)
|
|
32
|
+
super
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class TableTwo < HypsometricalTable
|
|
37
|
+
attribute :rows, PressureAttrs, collection: true
|
|
38
|
+
|
|
39
|
+
def steps
|
|
40
|
+
(20.0..1199.9).step(0.1).to_a.map { |v| v.round(1) }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def set_attrs(klass: PressureAttrs, unit: steps_unit, precision: :reduced)
|
|
44
|
+
super
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
class TableThree < TableOne
|
|
49
|
+
attribute :rows, PressureAttrs, collection: true
|
|
50
|
+
|
|
51
|
+
def steps
|
|
52
|
+
(4.0..9.99).step(0.01).to_a.map { |v| v.round(2) }
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def steps_unit
|
|
56
|
+
:mmhg
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def set_attrs(klass: PressureAttrs, unit: steps_unit, precision: :reduced)
|
|
60
|
+
super
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
class TableFour < TableTwo
|
|
65
|
+
attribute :rows, PressureAttrs, collection: true
|
|
66
|
+
|
|
67
|
+
def steps
|
|
68
|
+
(10.0..899.9).step(0.1).to_a.map { |v| v.round(1) }
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def steps_unit
|
|
72
|
+
:mmhg
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def set_attrs(klass: PressureAttrs, unit: steps_unit, precision: :reduced)
|
|
76
|
+
super
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
class TableFiveSix < Iso25331975::GroupOne
|
|
81
|
+
def steps
|
|
82
|
+
(-1000..4599).step(1)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def set_attrs(klass: TableFiveSixAttrs, unit: steps_unit, precision: :reduced)
|
|
86
|
+
super
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
class << self
|
|
91
|
+
def table_1
|
|
92
|
+
TableOne.new.set_attrs
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def table_2
|
|
96
|
+
TableTwo.new.set_attrs
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def table_3
|
|
100
|
+
TableThree.new.set_attrs
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def table_4
|
|
104
|
+
TableFour.new.set_attrs
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def table_56
|
|
108
|
+
TableFiveSix.new.set_attrs
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Atmospheris
|
|
4
|
+
module Export
|
|
5
|
+
module Iso25331997
|
|
6
|
+
module GroupBaseMeters
|
|
7
|
+
def steps
|
|
8
|
+
(-5000..2000).step(50)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class GroupOne < Iso25331975::GroupOne
|
|
13
|
+
include Iso25331997::GroupBaseMeters
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class GroupTwo < Iso25331975::GroupTwo
|
|
17
|
+
include Iso25331997::GroupBaseMeters
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
class GroupThree < Iso25331975::GroupThree
|
|
21
|
+
include Iso25331997::GroupBaseMeters
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
module GroupBaseFeet
|
|
25
|
+
def steps
|
|
26
|
+
(
|
|
27
|
+
(-16_500..-13_750).step(250) +
|
|
28
|
+
(-14_000..104_800).step(200) +
|
|
29
|
+
(105_000..262_500).step(500)
|
|
30
|
+
)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def steps_unit
|
|
34
|
+
:feet
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
class GroupFour < Iso25331975::GroupOne
|
|
39
|
+
include Iso25331997::GroupBaseFeet
|
|
40
|
+
def set_attrs(klass: Iso25331975::GroupOneAttrs, unit: steps_unit, precision: :reduced)
|
|
41
|
+
super
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
class GroupFive < Iso25331975::GroupTwo
|
|
46
|
+
include Iso25331997::GroupBaseFeet
|
|
47
|
+
def set_attrs(klass: Iso25331975::GroupTwoAttrs, unit: steps_unit, precision: :reduced)
|
|
48
|
+
super
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
class GroupSix < Iso25331975::GroupThree
|
|
53
|
+
include Iso25331997::GroupBaseFeet
|
|
54
|
+
def set_attrs(klass: Iso25331975::GroupThreeAttrs, unit: steps_unit, precision: :reduced)
|
|
55
|
+
super
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
class << self
|
|
60
|
+
def table_1
|
|
61
|
+
GroupOne.new.set_attrs
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def table_2
|
|
65
|
+
GroupTwo.new.set_attrs
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def table_3
|
|
69
|
+
GroupThree.new.set_attrs
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def table_4
|
|
73
|
+
GroupFour.new.set_attrs
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def table_5
|
|
77
|
+
GroupFive.new.set_attrs
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def table_6
|
|
81
|
+
GroupSix.new.set_attrs
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# The purpose of this class is really for XML grouping.
|
|
4
|
+
# It is not a table in the same sense as the other tables.
|
|
5
|
+
# It is a collection of attributes grouped by altitude type.
|
|
6
|
+
# This class is used to group the attributes by altitude type
|
|
7
|
+
# and to serialize them to XML.
|
|
8
|
+
|
|
9
|
+
# The class is used in the CombinedAltitudeAttrsGroup class
|
|
10
|
+
# and is not intended to be used directly.
|
|
11
|
+
module Atmospheris
|
|
12
|
+
module Export
|
|
13
|
+
module Iso25332025
|
|
14
|
+
class AltitudeAttrsGroup < Lutaml::Model::Serializable
|
|
15
|
+
attribute :rows, AltitudeAttrs, collection: true
|
|
16
|
+
|
|
17
|
+
xml do
|
|
18
|
+
element "attributes-group"
|
|
19
|
+
namespace Atmospheris::Iso2533Namespace
|
|
20
|
+
map_element "atmospheris-attributes", to: :rows
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Atmospheris
|
|
4
|
+
module Export
|
|
5
|
+
module Iso25332025
|
|
6
|
+
class CombinedAltitudeAttrsGroup < AltitudeTable
|
|
7
|
+
attribute :by_geometric_altitude, AltitudeAttrsGroup
|
|
8
|
+
attribute :by_geopotential_altitude, AltitudeAttrsGroup
|
|
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
|
+
xml do
|
|
16
|
+
element "atmospheris"
|
|
17
|
+
namespace Atmospheris::Iso2533Namespace
|
|
18
|
+
map_element "by-geometric-altitude", to: :by_geometric_altitude
|
|
19
|
+
map_element "by-geopotential-altitude", to: :by_geopotential_altitude
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def add_to_geometric(item)
|
|
23
|
+
by_geometric_altitude.rows << item
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def add_to_geopotential(item)
|
|
27
|
+
by_geopotential_altitude.rows << item
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def initialize_attrs
|
|
31
|
+
self.by_geometric_altitude = AltitudeAttrsGroup.new(rows: [])
|
|
32
|
+
self.by_geopotential_altitude = AltitudeAttrsGroup.new(rows: [])
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def set_attrs(klass: AltitudeAttrs, unit: steps_unit, precision: :normal)
|
|
36
|
+
super
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Atmospheris
|
|
4
|
+
module Export
|
|
5
|
+
module Iso25332025
|
|
6
|
+
autoload :AltitudeAttrsGroup, "atmospheris/export/iso_25332025/altitude_attrs_group"
|
|
7
|
+
autoload :CombinedAltitudeAttrsGroup, "atmospheris/export/iso_25332025/combined_altitude_attrs_group"
|
|
8
|
+
|
|
9
|
+
class AltitudesInMeters < CombinedAltitudeAttrsGroup
|
|
10
|
+
def steps
|
|
11
|
+
(
|
|
12
|
+
(-5000..31_950).step(50) +
|
|
13
|
+
(32_000..50_900).step(100) +
|
|
14
|
+
(51_000..80_000).step(200)
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class AltitudesInFeet < CombinedAltitudeAttrsGroup
|
|
20
|
+
def steps
|
|
21
|
+
(
|
|
22
|
+
(-16_500..-13_750).step(250) +
|
|
23
|
+
(-14_000..104_800).step(200) +
|
|
24
|
+
(105_000..262_500).step(500)
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def steps_unit
|
|
29
|
+
:feet
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
class AltitudesForPressure < CombinedAltitudeAttrsGroup
|
|
34
|
+
def steps
|
|
35
|
+
(-1000..4599).step(1)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
class HypsometricalMbar < HypsometricalTable
|
|
40
|
+
# TODO: when Ruby's step does not create inaccurate floating point numbers
|
|
41
|
+
# This is a hack to solve a Ruby bug with floating point calcuations
|
|
42
|
+
# > (20.0..1770.9).step(0.1).to_a
|
|
43
|
+
# ...
|
|
44
|
+
# 1769.4,
|
|
45
|
+
# 1769.5,
|
|
46
|
+
# 1769.6000000000001, # <== we need to clean these
|
|
47
|
+
# 1769.7,
|
|
48
|
+
# 1769.8000000000002, # <== we need to clean these
|
|
49
|
+
# The last `map` should be removed if this bug is fixed
|
|
50
|
+
def steps
|
|
51
|
+
(
|
|
52
|
+
(5.0..19.99).step(0.01).to_a.map { |v| v.round(2) } +
|
|
53
|
+
(20.0..1770.9).step(0.1).to_a.map { |v| v.round(1) }
|
|
54
|
+
)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def steps_unit
|
|
58
|
+
:mbar
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
class << self
|
|
63
|
+
def table_atmosphere_meters(precision: :reduced)
|
|
64
|
+
AltitudesInMeters.new.set_attrs(precision: precision)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def table_atmosphere_feet(precision: :reduced)
|
|
68
|
+
AltitudesInFeet.new.set_attrs(precision: precision)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def table_hypsometrical_altitude(precision: :reduced)
|
|
72
|
+
AltitudesForPressure.new.set_attrs(precision: precision)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def table_hypsometrical_mbar(precision: :reduced)
|
|
76
|
+
HypsometricalMbar.new.set_attrs(precision: precision)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|