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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.adoc +652 -183
  4. data/lib/atmospheric/export/altitude_attrs.rb +238 -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 +88 -0
  10. data/lib/atmospheric/export/iso_25331975/group_three.rb +14 -27
  11. data/lib/atmospheric/export/iso_25331975/group_three_attrs.rb +87 -0
  12. data/lib/atmospheric/export/iso_25331975/group_two.rb +14 -28
  13. data/lib/atmospheric/export/iso_25331975/group_two_attrs.rb +96 -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,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model"
4
+
5
+ module Atmospheric
6
+ module Export
7
+ module Iso25331975
8
+ class GroupThreeAttrs < Lutaml::Model::Serializable
9
+ include AltitudeConvertableModel
10
+
11
+ attribute :pressure_scale_height, UnitValueFloat
12
+ attribute :specific_weight, UnitValueFloat
13
+ attribute :air_number_density, UnitValueFloat
14
+ attribute :mean_speed, UnitValueFloat
15
+ attribute :frequency, UnitValueFloat
16
+ attribute :mean_free_path, UnitValueFloat
17
+
18
+ key_value do
19
+ map "geometric-altitude-m", to: :geometric_altitude_m
20
+ map "geometric-altitude-ft", to: :geometric_altitude_ft
21
+ map "geopotential-altitude-m", to: :geopotential_altitude_m
22
+ map "geopotential-altitude-ft", to: :geopotential_altitude_ft
23
+ map "pressure-scale-height", to: :pressure_scale_height
24
+ map "specific-weight", to: :specific_weight
25
+ map "air-number-density", to: :air_number_density
26
+ map "mean-speed", to: :mean_speed
27
+ map "frequency", to: :frequency
28
+ map "mean-free-path", to: :mean_free_path
29
+ end
30
+
31
+ # In meters only
32
+ def realize_values_from_geopotential(gp_h_m, precision: :reduced)
33
+ %i[
34
+ pressure_scale_height specific_weight air_number_density mean_speed
35
+ frequency mean_free_path
36
+ ].each do |attr|
37
+ v = calculate(gp_h_m, attr, precision: precision)
38
+ send("#{attr}=", v) if respond_to?("#{attr}=")
39
+ end
40
+ end
41
+
42
+ def calculate(gp_h_m, name, precision: :reduced)
43
+ case name
44
+ when :pressure_scale_height
45
+ v = Isa::NormalPrecision.instance.pressure_scale_height_from_geopotential(gp_h_m)
46
+ UnitValueFloat.new(
47
+ value: precision == :reduced ? v.round(1) : v,
48
+ unitsml: "m"
49
+ )
50
+ when :specific_weight
51
+ v = Isa::NormalPrecision.instance.specific_weight_from_geopotential(gp_h_m)
52
+ UnitValueFloat.new(
53
+ value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
54
+ unitsml: "N*m^-3"
55
+ )
56
+ when :air_number_density
57
+ v = Isa::NormalPrecision.instance.air_number_density_from_geopotential(gp_h_m)
58
+ UnitValueFloat.new(
59
+ value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
60
+ unitsml: "m^-3"
61
+ )
62
+ when :mean_speed
63
+ v = Isa::NormalPrecision.instance.mean_air_particle_speed_from_geopotential(gp_h_m)
64
+ UnitValueFloat.new(
65
+ value: precision == :reduced ? v.round(2) : v,
66
+ unitsml: "m*s^-1"
67
+ )
68
+ when :frequency
69
+ v = Isa::NormalPrecision.instance.air_particle_collision_frequency_from_geopotential(gp_h_m)
70
+ UnitValueFloat.new(
71
+ value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
72
+ unitsml: "s^-1"
73
+ )
74
+ when :mean_free_path
75
+ v = Isa::NormalPrecision.instance.mean_free_path_of_air_particles_from_geopotential(gp_h_m)
76
+ UnitValueFloat.new(
77
+ value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
78
+ unitsml: "m"
79
+ )
80
+ else
81
+ raise ArgumentError, "Unknown attribute: #{name}"
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
@@ -1,38 +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_two_attrs"
5
+
9
6
  module Atmospheric
10
7
  module Export
11
8
  module Iso25331975
9
+ class GroupTwo < AltitudeTable
10
+ attribute :by_geometric_altitude, GroupTwoAttrs, collection: true
11
+ attribute :by_geopotential_altitude, GroupTwoAttrs, collection: true
12
12
 
13
- class GroupTwo < GroupBase
14
- # In meters only
15
- def row_from_geopotential(gp_h_f)
16
- {
17
- "ppn" => round_to_sig_figs(Isa.p_p_n_from_geopotential(gp_h_f), 6),
18
- "rhorhon" => round_to_sig_figs(Isa.rho_rho_n_from_geopotential(gp_h_f), 6),
19
- "sqrt-rhorhon" => round_to_sig_figs(Isa.root_rho_rho_n_from_geopotential(gp_h_f), 6),
20
- "speed-of-sound" => (Isa.speed_of_sound_from_geopotential(gp_h_f) * 1000.0).round,
21
- "dynamic-viscosity" => round_to_sig_figs(Isa.dynamic_viscosity_from_geopotential(gp_h_f), 5),
22
- "kinematic-viscosity" => round_to_sig_figs(Isa.kinematic_viscosity_from_geopotential(gp_h_f), 5),
23
- "thermal-conductivity" => round_to_sig_figs(Isa.thermal_conductivity_from_geopotential(gp_h_f), 5),
24
- }
13
+ key_value do
14
+ map "by-geometric-altitude", to: :by_geometric_altitude
15
+ map "by-geopotential-altitude", to: :by_geopotential_altitude
25
16
  end
26
17
 
18
+ def set_attrs(klass: GroupTwoAttrs, unit: steps_unit, precision: :reduced)
19
+ super
20
+ end
27
21
  end
28
22
  end
29
-
30
23
  end
31
24
  end
32
- # rubocop:enable Metrics/AbcSize
33
- # rubocop:enable Metrics/BlockLength
34
- # rubocop:enable Metrics/CyclomaticComplexity
35
- # rubocop:enable Metrics/MethodLength
36
- # rubocop:enable Metrics/PerceivedComplexity
37
- # rubocop:enable Layout/LineLength
38
- # rubocop:enable Layout/HashAlignment
@@ -0,0 +1,96 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model"
4
+
5
+ module Atmospheric
6
+ module Export
7
+ module Iso25331975
8
+ class GroupTwoAttrs < Lutaml::Model::Serializable
9
+ include AltitudeConvertableModel
10
+
11
+ attribute :ppn, UnitValueFloat
12
+ attribute :rhorhon, UnitValueFloat
13
+ attribute :sqrt_rhorhon, UnitValueFloat
14
+ attribute :speed_of_sound, UnitValueInteger
15
+ attribute :dynamic_viscosity, UnitValueFloat
16
+ attribute :kinematic_viscosity, UnitValueFloat
17
+ attribute :thermal_conductivity, 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 "ppn", to: :ppn
25
+ map "rhorhon", to: :rhorhon
26
+ map "sqrt-rhorhon", to: :sqrt_rhorhon
27
+ map "speed-of-sound", to: :speed_of_sound
28
+ map "dynamic-viscosity", to: :dynamic_viscosity
29
+ map "kinematic-viscosity", to: :kinematic_viscosity
30
+ map "thermal-conductivity", to: :thermal_conductivity
31
+ end
32
+
33
+ # In meters only
34
+ def realize_values_from_geopotential(gp_h_m, precision: :reduced)
35
+ %i[
36
+ ppn rhorhon sqrt_rhorhon speed_of_sound
37
+ dynamic_viscosity kinematic_viscosity thermal_conductivity
38
+ ].each do |attr|
39
+ v = calculate(gp_h_m, attr, precision: precision)
40
+ send("#{attr}=", v) if respond_to?("#{attr}=")
41
+ end
42
+ end
43
+
44
+ def calculate(gp_h_m, name, precision: :reduced)
45
+ case name
46
+
47
+ when :ppn
48
+ v = Isa::NormalPrecision.instance.p_p_n_from_geopotential(gp_h_m)
49
+ UnitValueFloat.new(
50
+ value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
51
+ unitsml: nil
52
+ )
53
+ when :rhorhon
54
+ v = Isa::NormalPrecision.instance.rho_rho_n_from_geopotential(gp_h_m)
55
+ UnitValueFloat.new(
56
+ value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
57
+ unitsml: nil
58
+ )
59
+ when :sqrt_rhorhon
60
+ v = Isa::NormalPrecision.instance.root_rho_rho_n_from_geopotential(gp_h_m)
61
+ UnitValueFloat.new(
62
+ value: precision == :reduced ? round_to_sig_figs(v, 6) : v,
63
+ unitsml: nil
64
+ )
65
+ when :speed_of_sound
66
+ v = Isa::NormalPrecision.instance.speed_of_sound_from_geopotential(gp_h_m)
67
+ UnitValueInteger.new(
68
+ value: precision == :reduced ? (v * 1000.0).round : v,
69
+ unitsml: "m*s^-1"
70
+ )
71
+ when :dynamic_viscosity
72
+ v = Isa::NormalPrecision.instance.dynamic_viscosity_from_geopotential(gp_h_m)
73
+ UnitValueFloat.new(
74
+ value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
75
+ unitsml: "Pa*s"
76
+ )
77
+ when :kinematic_viscosity
78
+ v = Isa::NormalPrecision.instance.kinematic_viscosity_from_geopotential(gp_h_m)
79
+ UnitValueFloat.new(
80
+ value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
81
+ unitsml: "m^2*s^-1"
82
+ )
83
+ when :thermal_conductivity
84
+ v = Isa::NormalPrecision.instance.thermal_conductivity_from_geopotential(gp_h_m)
85
+ UnitValueFloat.new(
86
+ value: precision == :reduced ? round_to_sig_figs(v, 5) : v,
87
+ unitsml: "W*m^-1*K^-1"
88
+ )
89
+ else
90
+ raise ArgumentError, "Unknown attribute: #{name}"
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
@@ -1,37 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Atmospheric
2
4
  module Export
3
5
  module Iso25331975
4
6
  class << self
5
7
  def table_5
6
- GroupOne.new.to_h
8
+ GroupOne.new.set_attrs
7
9
  end
8
10
 
9
11
  def table_6
10
- GroupTwo.new.to_h
12
+ GroupTwo.new.set_attrs
11
13
  end
12
14
 
13
15
  def table_7
14
- GroupThree.new.to_h
15
- end
16
-
17
- def table_5_yaml
18
- GroupOne.new.to_yaml
19
- end
20
-
21
- def table_6_yaml
22
- GroupTwo.new.to_yaml
23
- end
24
-
25
- def table_7_yaml
26
- GroupThree.new.to_yaml
16
+ GroupThree.new.set_attrs
27
17
  end
28
18
  end
29
-
30
19
  end
31
20
  end
32
21
  end
33
22
 
34
- require_relative "iso_25331975/group_base"
35
23
  require_relative "iso_25331975/group_one"
36
24
  require_relative "iso_25331975/group_two"
37
25
  require_relative "iso_25331975/group_three"
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../pressure_attrs"
4
+
5
+ # The purpose of this class is to trim the attributes used in the ISO 2533:1985
6
+ # standard.
7
+ module Atmospheric
8
+ module Export
9
+ module Iso25331985
10
+ class PressureAttrs < ::Atmospheric::Export::PressureAttrs
11
+ key_value do
12
+ map "pressure-mbar", to: :pressure_mbar
13
+ map "pressure-mmhg", to: :pressure_mmhg
14
+ map "geopotential-altitude-m", to: :geopotential_altitude_m
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../iso_25331975/group_one_attrs"
4
+
5
+ module Atmospheric
6
+ module Export
7
+ module Iso25331985
8
+ class TableFiveSixAttrs < ::Atmospheric::Export::Iso25331975::GroupOneAttrs
9
+ # TODO: Completely override other attributes / key value mappings so
10
+ # they don't show in YAML
11
+ key_value do
12
+ map "geopotential-altitude-m", to: :geopotential_altitude_m
13
+ map "pressure-mbar", to: :pressure_mbar
14
+ map "pressure-mmhg", to: :pressure_mmhg
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,12 +1,14 @@
1
- require_relative "./target"
2
- require_relative "./hypsometrical_tables"
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "hypsometrical_table"
4
+ require_relative "iso_25331985/pressure_attrs"
5
+ require_relative "iso_25331985/table_five_six_attrs"
6
+ require_relative "iso_25331975/group_one"
3
7
 
4
8
  module Atmospheric
5
9
  module Export
6
-
7
10
  module Iso25331985
8
-
9
- class TableOne < HypsometricalTables::TableBase
11
+ class TableOne < HypsometricalTable
10
12
  # TODO: when Ruby's step does not create inaccurate floating point numbers
11
13
  # This is a hack to solve a Ruby bug with floating point calcuations
12
14
  # > (20.0..1770.9).step(0.1).to_a
@@ -17,120 +19,97 @@ module Atmospheric
17
19
  # 1769.7,
18
20
  # 1769.8000000000002, # <== we need to clean these
19
21
  # The last `map` should be removed if this bug is fixed
22
+
23
+ attribute :rows, PressureAttrs, collection: true
24
+
20
25
  def steps
21
- (5.0..19.99).step(0.01).to_a.map {|v| v.round(2)}
26
+ (5.0..19.99).step(0.01).to_a.map { |v| v.round(2) }
22
27
  end
23
28
 
24
29
  def steps_unit
25
30
  :mbar
26
31
  end
27
32
 
28
- def row(p, unit: steps_unit)
29
- method_name = "geopotential_altitude_from_pressure_#{unit}"
30
- value = Isa.send(method_name, p).round
31
- {
32
- "pressure-#{unit}" => p,
33
- "geopotential-altitude" => value,
34
- }
33
+ def set_attrs(klass: PressureAttrs, unit: steps_unit, precision: :reduced)
34
+ super
35
35
  end
36
36
  end
37
37
 
38
- class TableTwo < HypsometricalTables::TableBase
38
+ class TableTwo < HypsometricalTable
39
+ attribute :rows, PressureAttrs, collection: true
40
+
39
41
  def steps
40
- (20.0..1199.9).step(0.1).to_a.map {|v| v.round(1)}
42
+ (20.0..1199.9).step(0.1).to_a.map { |v| v.round(1) }
41
43
  end
42
44
 
43
- def row(p, unit:)
44
- method_name = "geopotential_altitude_from_pressure_#{unit}"
45
- value = Isa.send(method_name, p).round
46
- {
47
- "pressure-#{unit}" => p,
48
- "geopotential-altitude" => value,
49
- }
45
+ def set_attrs(klass: PressureAttrs, unit: steps_unit, precision: :reduced)
46
+ super
50
47
  end
51
48
  end
52
49
 
53
- # Same as Table 1 with mmHg
54
50
  class TableThree < TableOne
51
+ attribute :rows, PressureAttrs, collection: true
52
+
55
53
  def steps
56
- (4.0..9.99).step(0.01).to_a.map {|v| v.round(2)}
54
+ (4.0..9.99).step(0.01).to_a.map { |v| v.round(2) }
57
55
  end
58
56
 
59
57
  def steps_unit
60
58
  :mmhg
61
59
  end
60
+
61
+ def set_attrs(klass: PressureAttrs, unit: steps_unit, precision: :reduced)
62
+ super
63
+ end
62
64
  end
63
65
 
64
- # Same as Table 3 with mmHg
65
66
  class TableFour < TableTwo
67
+ attribute :rows, PressureAttrs, collection: true
68
+
66
69
  def steps
67
- (10.0..899.9).step(0.1).to_a.map {|v| v.round(1)}
70
+ (10.0..899.9).step(0.1).to_a.map { |v| v.round(1) }
68
71
  end
69
72
 
70
73
  def steps_unit
71
74
  :mmhg
72
75
  end
76
+
77
+ def set_attrs(klass: PressureAttrs, unit: steps_unit, precision: :reduced)
78
+ super
79
+ end
73
80
  end
74
81
 
75
- class TableFiveSix < HypsometricalTables::TableBase
82
+ class TableFiveSix < Iso25331975::GroupOne
76
83
  def steps
77
84
  (-1000..4599).step(1)
78
85
  end
79
86
 
80
- def row(h, unit:)
81
- {
82
- "geopotential-altitude" => h,
83
- "pressure-mbar" => round_to_sig_figs(Isa.pressure_from_geopotential_mbar(h.to_f), 6),
84
- "pressure-mmhg" => round_to_sig_figs(Isa.pressure_from_geopotential_mmhg(h.to_f), 6),
85
- }
87
+ def set_attrs(klass: TableFiveSixAttrs, unit: steps_unit, precision: :reduced)
88
+ super
86
89
  end
87
90
  end
88
91
 
89
92
  class << self
90
-
91
93
  def table_1
92
- TableOne.new.to_h
93
- end
94
-
95
- def table_1_yaml
96
- TableOne.new.to_yaml
94
+ TableOne.new.set_attrs
97
95
  end
98
96
 
99
97
  def table_2
100
- TableTwo.new.to_h
101
- end
102
-
103
- def table_2_yaml
104
- TableTwo.new.to_yaml
98
+ TableTwo.new.set_attrs
105
99
  end
106
100
 
107
101
  def table_3
108
- TableThree.new.to_h
109
- end
110
-
111
- def table_3_yaml
112
- TableThree.new.to_yaml
102
+ TableThree.new.set_attrs
113
103
  end
114
104
 
115
105
  def table_4
116
- TableFour.new.to_h
117
- end
118
-
119
- def table_4_yaml
120
- TableFour.new.to_yaml
106
+ TableFour.new.set_attrs
121
107
  end
122
108
 
123
109
  def table_56
124
- TableFiveSix.new.to_h
125
- end
126
-
127
- def table_56_yaml
128
- TableFiveSix.new.to_yaml
110
+ TableFiveSix.new.set_attrs
129
111
  end
130
-
131
112
  end
132
-
133
113
  end
134
-
135
114
  end
136
- end
115
+ end
@@ -1,11 +1,10 @@
1
- require_relative "./target"
1
+ # frozen_string_literal: true
2
+
2
3
  require_relative "./iso_25331975"
3
4
 
4
5
  module Atmospheric
5
6
  module Export
6
-
7
7
  module Iso25331997
8
-
9
8
  module GroupBaseMeters
10
9
  def steps
11
10
  (-5000..2000).step(50)
@@ -27,9 +26,9 @@ module Atmospheric
27
26
  module GroupBaseFeet
28
27
  def steps
29
28
  (
30
- (-16500..-13750).step(250) +
31
- (-14000..104800).step(200) +
32
- (105000..262500).step(500)
29
+ (-16_500..-13_750).step(250) +
30
+ (-14_000..104_800).step(200) +
31
+ (105_000..262_500).step(500)
33
32
  )
34
33
  end
35
34
 
@@ -40,67 +39,50 @@ module Atmospheric
40
39
 
41
40
  class GroupFour < Iso25331975::GroupOne
42
41
  include Iso25331997::GroupBaseFeet
42
+ def set_attrs(klass: Iso25331975::GroupOneAttrs, unit: steps_unit, precision: :reduced)
43
+ super
44
+ end
43
45
  end
44
46
 
45
47
  class GroupFive < Iso25331975::GroupTwo
46
48
  include Iso25331997::GroupBaseFeet
49
+ def set_attrs(klass: Iso25331975::GroupTwoAttrs, unit: steps_unit, precision: :reduced)
50
+ super
51
+ end
47
52
  end
48
53
 
49
54
  class GroupSix < Iso25331975::GroupThree
50
55
  include Iso25331997::GroupBaseFeet
56
+ def set_attrs(klass: Iso25331975::GroupThreeAttrs, unit: steps_unit, precision: :reduced)
57
+ super
58
+ end
51
59
  end
52
60
 
53
61
  class << self
54
62
  def table_1
55
- GroupOne.new.to_h
63
+ GroupOne.new.set_attrs
56
64
  end
57
65
 
58
66
  def table_2
59
- GroupTwo.new.to_h
67
+ GroupTwo.new.set_attrs
60
68
  end
61
69
 
62
70
  def table_3
63
- GroupThree.new.to_h
71
+ GroupThree.new.set_attrs
64
72
  end
65
73
 
66
74
  def table_4
67
- GroupFour.new.to_h
75
+ GroupFour.new.set_attrs
68
76
  end
69
77
 
70
78
  def table_5
71
- GroupFive.new.to_h
79
+ GroupFive.new.set_attrs
72
80
  end
73
81
 
74
82
  def table_6
75
- GroupSix.new.to_h
76
- end
77
-
78
- def table_1_yaml
79
- GroupOne.new.to_yaml
80
- end
81
-
82
- def table_2_yaml
83
- GroupTwo.new.to_yaml
84
- end
85
-
86
- def table_3_yaml
87
- GroupThree.new.to_yaml
88
- end
89
-
90
- def table_4_yaml
91
- GroupFour.new.to_yaml
92
- end
93
-
94
- def table_5_yaml
95
- GroupFive.new.to_yaml
96
- end
97
-
98
- def table_6_yaml
99
- GroupSix.new.to_yaml
83
+ GroupSix.new.set_attrs
100
84
  end
101
85
  end
102
-
103
86
  end
104
-
105
87
  end
106
- end
88
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model"
4
+ require_relative "../altitude_attrs"
5
+
6
+ # The purpose of this class is really for XML grouping.
7
+ # It is not a table in the same sense as the other tables.
8
+ # It is a collection of attributes grouped by altitude type.
9
+ # This class is used to group the attributes by altitude type
10
+ # and to serialize them to XML.
11
+
12
+ # The class is used in the CombinedAltitudeAttrsGroup class
13
+ # and is not intended to be used directly.
14
+ module Atmospheric
15
+ module Export
16
+ module Iso25332025
17
+ class AltitudeAttrsGroup < Lutaml::Model::Serializable
18
+ attribute :rows, AltitudeAttrs, collection: true
19
+
20
+ xml do
21
+ root "attributes-group"
22
+ map_element "atmospheric-attributes", to: :rows
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../altitude_table"
4
+ require_relative "../altitude_attrs"
5
+ require_relative "altitude_attrs_group"
6
+
7
+ module Atmospheric
8
+ module Export
9
+ module Iso25332025
10
+ class CombinedAltitudeAttrsGroup < AltitudeTable
11
+ attribute :by_geometric_altitude, AltitudeAttrsGroup
12
+ attribute :by_geopotential_altitude, AltitudeAttrsGroup
13
+
14
+ key_value do
15
+ map "by-geometric-altitude", to: :by_geometric_altitude
16
+ map "by-geopotential-altitude", to: :by_geopotential_altitude
17
+ end
18
+
19
+ xml do
20
+ root "atmospheric"
21
+ map_element "by-geometric-altitude", to: :by_geometric_altitude
22
+ map_element "by-geopotential-altitude", to: :by_geopotential_altitude
23
+ end
24
+
25
+ def add_to_geometric(item)
26
+ by_geometric_altitude.rows << item
27
+ end
28
+
29
+ def add_to_geopotential(item)
30
+ by_geopotential_altitude.rows << item
31
+ end
32
+
33
+ def initialize_attrs
34
+ self.by_geometric_altitude = AltitudeAttrsGroup.new(rows: [])
35
+ self.by_geopotential_altitude = AltitudeAttrsGroup.new(rows: [])
36
+ end
37
+
38
+ def set_attrs(klass: AltitudeAttrs, unit: steps_unit, precision: :normal)
39
+ super
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end