1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.orekit.files.ccsds.ndm.odm.ocm;
19
20 import java.io.IOException;
21 import java.util.ArrayList;
22 import java.util.List;
23
24 import org.orekit.files.ccsds.definitions.BodyFacade;
25 import org.orekit.files.ccsds.definitions.TimeConverter;
26 import org.orekit.files.ccsds.definitions.Units;
27 import org.orekit.files.ccsds.section.AbstractWriter;
28 import org.orekit.files.ccsds.utils.generation.Generator;
29 import org.orekit.utils.units.Unit;
30
31
32
33
34
35 class PerturbationsWriter extends AbstractWriter {
36
37
38 private final Perturbations perturbations;
39
40
41 private final TimeConverter timeConverter;
42
43
44
45
46
47 PerturbationsWriter(final Perturbations perturbations, final TimeConverter timeConverter) {
48 super(OcmDataSubStructureKey.pert.name(), OcmDataSubStructureKey.PERT.name());
49 this.perturbations = perturbations;
50 this.timeConverter = timeConverter;
51 }
52
53
54 @Override
55 protected void writeContent(final Generator generator) throws IOException {
56
57
58 generator.writeComments(perturbations.getComments());
59
60
61 generator.writeEntry(PerturbationsKey.ATMOSPHERIC_MODEL.name(), perturbations.getAtmosphericModel(), null, false);
62
63
64 if (perturbations.getGravityModel() != null) {
65 final String model =
66 new StringBuilder().
67 append(perturbations.getGravityModel()).
68 append(": ").
69 append(perturbations.getGravityDegree()).
70 append("D ").
71 append(perturbations.getGravityOrder()).
72 append('O').
73 toString();
74 generator.writeEntry(PerturbationsKey.GRAVITY_MODEL.name(), model, null, false);
75 }
76 generator.writeEntry(PerturbationsKey.EQUATORIAL_RADIUS.name(), perturbations.getEquatorialRadius(), Unit.KILOMETRE, false);
77 generator.writeEntry(PerturbationsKey.GM.name(), perturbations.getGm(), Units.KM3_PER_S2, false);
78 if (perturbations.getNBodyPerturbations() != null && !perturbations.getNBodyPerturbations().isEmpty()) {
79 final List<String> names = new ArrayList<>();
80 for (BodyFacade bf : perturbations.getNBodyPerturbations()) {
81 names.add(bf.getName());
82 }
83 generator.writeEntry(PerturbationsKey.N_BODY_PERTURBATIONS.name(), names, false);
84 }
85 generator.writeEntry(PerturbationsKey.CENTRAL_BODY_ROTATION.name(), perturbations.getCentralBodyRotation(), Units.DEG_PER_S, false);
86 generator.writeEntry(PerturbationsKey.OBLATE_FLATTENING.name(), perturbations.getOblateFlattening(), Unit.ONE, false);
87 generator.writeEntry(PerturbationsKey.OCEAN_TIDES_MODEL.name(), perturbations.getOceanTidesModel(), null, false);
88 generator.writeEntry(PerturbationsKey.SOLID_TIDES_MODEL.name(), perturbations.getSolidTidesModel(), null, false);
89 generator.writeEntry(PerturbationsKey.REDUCTION_THEORY.name(), perturbations.getReductionTheory(), null, false);
90
91
92 generator.writeEntry(PerturbationsKey.ALBEDO_MODEL.name(), perturbations.getAlbedoModel(), null, false);
93 generator.writeEntry(PerturbationsKey.ALBEDO_GRID_SIZE.name(), perturbations.getAlbedoGridSize(), false);
94 generator.writeEntry(PerturbationsKey.SHADOW_MODEL.name(), perturbations.getShadowModel(), false);
95 if (perturbations.getShadowBodies() != null && !perturbations.getShadowBodies().isEmpty()) {
96 final List<String> names = new ArrayList<>();
97 for (BodyFacade bf : perturbations.getShadowBodies()) {
98 names.add(bf.getName());
99 }
100 generator.writeEntry(PerturbationsKey.SHADOW_BODIES.name(), names, false);
101 }
102 generator.writeEntry(PerturbationsKey.SRP_MODEL.name(), perturbations.getSrpModel(), null, false);
103
104
105 generator.writeEntry(PerturbationsKey.SW_DATA_SOURCE.name(), perturbations.getSpaceWeatherSource(), null, false);
106 generator.writeEntry(PerturbationsKey.SW_DATA_EPOCH.name(), timeConverter, perturbations.getSpaceWeatherEpoch(), true, false);
107 generator.writeEntry(PerturbationsKey.SW_INTERP_METHOD.name(), perturbations.getInterpMethodSW(), null, false);
108 generator.writeEntry(PerturbationsKey.FIXED_GEOMAG_KP.name(), perturbations.getFixedGeomagneticKp(), Units.NANO_TESLA, false);
109 generator.writeEntry(PerturbationsKey.FIXED_GEOMAG_AP.name(), perturbations.getFixedGeomagneticAp(), Units.NANO_TESLA, false);
110 generator.writeEntry(PerturbationsKey.FIXED_GEOMAG_DST.name(), perturbations.getFixedGeomagneticDst(), Units.NANO_TESLA, false);
111 generator.writeEntry(PerturbationsKey.FIXED_F10P7.name(), perturbations.getFixedF10P7(), Unit.SOLAR_FLUX_UNIT, false);
112 generator.writeEntry(PerturbationsKey.FIXED_F10P7_MEAN.name(), perturbations.getFixedF10P7Mean(), Unit.SOLAR_FLUX_UNIT, false);
113 generator.writeEntry(PerturbationsKey.FIXED_M10P7.name(), perturbations.getFixedM10P7(), Unit.SOLAR_FLUX_UNIT, false);
114 generator.writeEntry(PerturbationsKey.FIXED_M10P7_MEAN.name(), perturbations.getFixedM10P7Mean(), Unit.SOLAR_FLUX_UNIT, false);
115 generator.writeEntry(PerturbationsKey.FIXED_S10P7.name(), perturbations.getFixedS10P7(), Unit.SOLAR_FLUX_UNIT, false);
116 generator.writeEntry(PerturbationsKey.FIXED_S10P7_MEAN.name(), perturbations.getFixedS10P7Mean(), Unit.SOLAR_FLUX_UNIT, false);
117 generator.writeEntry(PerturbationsKey.FIXED_Y10P7.name(), perturbations.getFixedY10P7(), Unit.SOLAR_FLUX_UNIT, false);
118 generator.writeEntry(PerturbationsKey.FIXED_Y10P7_MEAN.name(), perturbations.getFixedY10P7Mean(), Unit.SOLAR_FLUX_UNIT, false);
119
120 }
121
122 }