atmospheric 0.2.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,205 @@
1
+ require_relative "./target"
2
+ require_relative "./hypsometrical_tables"
3
+ require_relative "./iso_25331975"
4
+
5
+ module Atmospheric
6
+ module Export
7
+
8
+ module Iso25332024
9
+
10
+ module GroupBaseMeters
11
+ def steps
12
+ (
13
+ (-5000..31950).step(50) +
14
+ (32000..50900).step(100) +
15
+ (51000..80000).step(200)
16
+ )
17
+ end
18
+ end
19
+
20
+ class GroupOneMeters < Iso25331975::GroupOne
21
+ include Iso25332024::GroupBaseMeters
22
+ end
23
+
24
+ class GroupTwoMeters < Iso25331975::GroupTwo
25
+ include Iso25332024::GroupBaseMeters
26
+ end
27
+
28
+ class GroupThreeMeters < Iso25331975::GroupThree
29
+ include Iso25332024::GroupBaseMeters
30
+ end
31
+
32
+ module GroupBaseFeet
33
+ def steps
34
+ (
35
+ (-16500..-13750).step(250) +
36
+ (-14000..104800).step(200) +
37
+ (105000..262500).step(500)
38
+ )
39
+ end
40
+
41
+ def steps_unit
42
+ :feet
43
+ end
44
+ end
45
+
46
+ class GroupOneFeet < Iso25331975::GroupOne
47
+ include Iso25332024::GroupBaseFeet
48
+ end
49
+
50
+ class GroupTwoFeet < Iso25331975::GroupTwo
51
+ include Iso25332024::GroupBaseFeet
52
+ end
53
+
54
+ class GroupThreeFeet < Iso25331975::GroupThree
55
+ include Iso25332024::GroupBaseFeet
56
+ end
57
+
58
+ class HypsometricalMbar < HypsometricalTables::TableBase
59
+ # TODO: when Ruby's step does not create inaccurate floating point numbers
60
+ # This is a hack to solve a Ruby bug with floating point calcuations
61
+ # > (20.0..1770.9).step(0.1).to_a
62
+ # ...
63
+ # 1769.4,
64
+ # 1769.5,
65
+ # 1769.6000000000001, # <== we need to clean these
66
+ # 1769.7,
67
+ # 1769.8000000000002, # <== we need to clean these
68
+ # The last `map` should be removed if this bug is fixed
69
+ def steps
70
+ (
71
+ (5.0..19.99).step(0.01).to_a.map {|v| v.round(2)} +
72
+ (20.0..1770.9).step(0.1).to_a.map {|v| v.round(1)}
73
+ )
74
+ end
75
+
76
+ def steps_unit
77
+ :mbar
78
+ end
79
+
80
+ def row(p, unit:)
81
+ method_name = "geopotential_altitude_from_pressure_#{unit}"
82
+ gp_h_m = Isa.send(method_name, p)
83
+ gp_h_ft = m_to_ft(gp_h_m)
84
+ gm_h_m = Isa.geometric_altitude_from_geopotential(p)
85
+ gm_h_ft = m_to_ft(gm_h_m)
86
+ {
87
+ "pressure-#{unit}" => p,
88
+ "geopotential-altitude-m" => gp_h_m.round(1),
89
+ "geopotential-altitude-ft" => gp_h_ft.round,
90
+ "geometric-altitude-m" => gm_h_m.round(1),
91
+ "geometric-altitude-ft" => gm_h_ft.round,
92
+ }
93
+ end
94
+ end
95
+
96
+ class HypsometricalGeometric < HypsometricalTables::TableBase
97
+ def steps
98
+ (-1000..4599).step(1)
99
+ end
100
+
101
+ def row(hgmm, unit:)
102
+ hgpm = Isa.geopotential_altitude_from_geometric(hgmm)
103
+ {
104
+ "geometric-altitude-m" => hgpm,
105
+ "pressure-mbar" => round_to_sig_figs(Isa.pressure_from_geopotential_mbar(hgpm.to_f), 6),
106
+ # "pressure-mmhg" => round_to_sig_figs(Isa.pressure_from_geopotential_mmhg(hgpm.to_f), 6),
107
+ }
108
+ end
109
+ end
110
+
111
+ class HypsometricalGeopotential < HypsometricalTables::TableBase
112
+ def steps
113
+ (-1000..4599).step(1)
114
+ end
115
+
116
+ def row(hgpm, unit:)
117
+ {
118
+ "geopotential-altitude-m" => hgpm,
119
+ "pressure-mbar" => round_to_sig_figs(Isa.pressure_from_geopotential_mbar(hgpm.to_f), 6),
120
+ # "pressure-mmhg" => round_to_sig_figs(Isa.pressure_from_geopotential_mmhg(hgpm.to_f), 6),
121
+ }
122
+ end
123
+ end
124
+
125
+
126
+
127
+ class << self
128
+ def table_5
129
+ GroupOneMeters.new.to_h
130
+ end
131
+
132
+ def table_6
133
+ GroupTwoMeters.new.to_h
134
+ end
135
+
136
+ def table_7
137
+ GroupThreeMeters.new.to_h
138
+ end
139
+
140
+ def table_8
141
+ GroupOneFeet.new.to_h
142
+ end
143
+
144
+ def table_9
145
+ GroupTwoFeet.new.to_h
146
+ end
147
+
148
+ def table_10
149
+ GroupThreeFeet.new.to_h
150
+ end
151
+
152
+ def table_11
153
+ HypsometricalMbar.new.to_h
154
+ end
155
+
156
+ def table_12
157
+ HypsometricalGeometric.new.to_h
158
+ end
159
+
160
+ def table_13
161
+ HypsometricalGeopotential.new.to_h
162
+ end
163
+
164
+ def table_5_yaml
165
+ GroupOneMeters.new.to_yaml
166
+ end
167
+
168
+ def table_6_yaml
169
+ GroupTwoMeters.new.to_yaml
170
+ end
171
+
172
+ def table_7_yaml
173
+ GroupThreeMeters.new.to_yaml
174
+ end
175
+
176
+ def table_8_yaml
177
+ GroupOneFeet.new.to_yaml
178
+ end
179
+
180
+ def table_9_yaml
181
+ GroupTwoFeet.new.to_yaml
182
+ end
183
+
184
+ def table_10_yaml
185
+ GroupThreeFeet.new.to_yaml
186
+ end
187
+
188
+ def table_11_yaml
189
+ HypsometricalMbar.new.to_yaml
190
+ end
191
+
192
+ def table_12_yaml
193
+ HypsometricalGeometric.new.to_yaml
194
+ end
195
+
196
+ def table_13_yaml
197
+ HypsometricalGeopotential.new.to_yaml
198
+ end
199
+
200
+ end
201
+
202
+ end
203
+
204
+ end
205
+ end
@@ -5,4 +5,5 @@ end
5
5
 
6
6
  require_relative "export/iso_25331975"
7
7
  require_relative "export/iso_25331997"
8
- require_relative "export/hypsometrical_tables"
8
+ require_relative "export/iso_25331985"
9
+ require_relative "export/iso_25332024"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Atmospheric
4
- VERSION = "0.2.2"
4
+ VERSION = "0.4.0"
5
5
  end