1 /* Copyright 2002-2024 CS GROUP
2 * Licensed to CS GROUP (CS) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * CS licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.orekit.files.ccsds.ndm.cdm;
18
19 import org.orekit.errors.OrekitException;
20 import org.orekit.errors.OrekitMessages;
21 import org.orekit.files.ccsds.section.CommentsContainer;
22
23 /**
24 * Container for Sigma/Eigenvectors Covariance data. The positional covariance one-sigma
25 dispersions corresponding to the major, intermediate and minor eigenvalues, followed by the associated eigenvectors.
26 The data is presented on a single line (12 values separated by spaces). (Condition: Mandatory if ALT_COV_TYPE = CSIG3EIGVEC3)
27 */
28 public class SigmaEigenvectorsCovariance extends CommentsContainer {
29
30 /** Sigma/Eigenvectors Covariance covariance matrix. */
31 private double[] csig3eigvec3;
32
33 /** Flag indicating whether the alternate covariance type set in the CDM Object metadata section is Sigma/Eigenvectors Covariance. */
34 private boolean altCovFlag;
35
36 /** Simple constructor.
37 * <p> The Sigma/Eigenvectors Covariance data is only provided if {@link CdmMetadataKey#ALT_COV_TYPE} is {@link AltCovarianceType#CSIG3EIGVEC3}, otherwise
38 * its terms will return NaN. </p>
39 * @param altCovFlag Flag indicating whether the alternate covariance type set in the CDM Object metadata section is Sigma/Eigenvectors Covariance.
40 */
41 public SigmaEigenvectorsCovariance(final boolean altCovFlag) {
42 this.altCovFlag = altCovFlag;
43 csig3eigvec3 = new double[12];
44
45 for (int i = 0; i < csig3eigvec3.length; ++i) {
46 csig3eigvec3[i] = Double.NaN;
47 }
48 }
49
50 /** {@inheritDoc} */
51 @Override
52 public void validate(final double version) {
53 super.validate(version);
54
55 // Conditional on ALT_COV_TYPE = Sigma/Eigenvectors Covariance
56 if (!isAltCovFlagSet()) {
57 throw new OrekitException(OrekitMessages.CCSDS_DATE_INVALID_PREAMBLE_FIELD, CdmMetadataKey.ALT_COV_TYPE);
58 }
59
60 // We only check values that are mandatory in a cdm file
61 for (int i = 0; i < getCsig3eigvec3().length; i++) {
62 checkNotNaN(getCsig3eigvec3()[i], SigmaEigenvectorsCovarianceKey.CSIG3EIGVEC3.name());
63 }
64 }
65
66
67 /**
68 * Get the Sigma/Eigenvectors Covariance data.
69 * <p> The Sigma/Eigenvectors Covariance data is only provided if {@link CdmMetadataKey#ALT_COV_TYPE} is {@link AltCovarianceType#CSIG3EIGVEC3}, otherwise
70 * its terms will return NaN. </p>
71 * @return covarianceData the covariance data in the Sigma/Eigenvectors format.
72 */
73 public double[] getCsig3eigvec3() {
74 return csig3eigvec3 == null ? null : csig3eigvec3.clone();
75 }
76
77 /**
78 * Set the Sigma/Eigenvectors Covariance data.
79 * @param csig3eigvec3 the covariance data in the Sigma/Eigenvectors format.
80 */
81 public void setCsig3eigvec3(final double[] csig3eigvec3) {
82 refuseFurtherComments();
83
84 // Conditional on ALT_COV_TYPE = Sigma/Eigenvectors Covariance
85 if (!isAltCovFlagSet()) {
86 throw new OrekitException(OrekitMessages.CCSDS_DATE_INVALID_PREAMBLE_FIELD, CdmMetadataKey.ALT_COV_TYPE);
87 }
88
89 this.csig3eigvec3 = csig3eigvec3 == null ? null : csig3eigvec3.clone();
90 }
91
92 /** Get the flag indicating whether the alternate covariance type set in the CDM Object metadata section is Sigma/Eigenvectors Covariance.
93 * @return the altCovFlag
94 */
95 public boolean isAltCovFlagSet() {
96 return altCovFlag;
97 }
98
99 }