SigmaEigenvectorsCovariance.java

  1. /* Copyright 2002-2022 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. import org.orekit.errors.OrekitException;
  19. import org.orekit.errors.OrekitMessages;
  20. import org.orekit.files.ccsds.section.CommentsContainer;

  21. /**
  22.  * Container for Sigma/Eigenvectors Covariance data. The positional covariance one-sigma
  23. dispersions corresponding to the major, intermediate and minor eigenvalues, followed by the associated eigenvectors.
  24. The data is presented on a single line (12 values separated by spaces). (Condition: Mandatory if ALT_COV_TYPE = CSIG3EIGVEC3)
  25.  */
  26. public class SigmaEigenvectorsCovariance extends CommentsContainer {

  27.     /** Sigma/Eigenvectors Covariance covariance matrix. */
  28.     private double[] csig3eigvec3;

  29.     /** Flag indicating whether the alternate covariance type set in the CDM Object metadata section is Sigma/Eigenvectors Covariance. */
  30.     private boolean altCovFlag;

  31.     /** Simple constructor.
  32.      * <p> The Sigma/Eigenvectors Covariance data is only provided if {@link CdmMetadataKey#ALT_COV_TYPE} is {@link AltCovarianceType#CSIG3EIGVEC3}, otherwise
  33.      * its terms will return NaN. </p>
  34.      * @param altCovFlag Flag indicating whether the alternate covariance type set in the CDM Object metadata section is Sigma/Eigenvectors Covariance.
  35.      */
  36.     public SigmaEigenvectorsCovariance(final boolean altCovFlag) {
  37.         this.altCovFlag = altCovFlag;
  38.         csig3eigvec3 = new double[12];

  39.         for (int i = 0; i < csig3eigvec3.length; ++i) {
  40.             csig3eigvec3[i] = Double.NaN;
  41.         }
  42.     }

  43.     /** {@inheritDoc} */
  44.     @Override
  45.     public void validate(final double version) {
  46.         super.validate(version);

  47.         // Conditional on ALT_COV_TYPE = Sigma/Eigenvectors Covariance
  48.         if (!isAltCovFlagSet()) {
  49.             throw new OrekitException(OrekitMessages.CCSDS_DATE_INVALID_PREAMBLE_FIELD, CdmMetadataKey.ALT_COV_TYPE);
  50.         }

  51.         // We only check values that are mandatory in a cdm file
  52.         for (int i = 0; i < getCsig3eigvec3().length; i++) {
  53.             checkNotNaN(getCsig3eigvec3()[i],              SigmaEigenvectorsCovarianceKey.CSIG3EIGVEC3);
  54.         }
  55.     }


  56.     /**
  57.      * Get the Sigma/Eigenvectors Covariance data.
  58.      * <p> The Sigma/Eigenvectors Covariance data is only provided if {@link CdmMetadataKey#ALT_COV_TYPE} is {@link AltCovarianceType#CSIG3EIGVEC3}, otherwise
  59.      * its terms will return NaN. </p>
  60.      * @return covarianceData the covariance data in the Sigma/Eigenvectors format.
  61.      */
  62.     public double[] getCsig3eigvec3() {
  63.         return csig3eigvec3 == null ? null : csig3eigvec3.clone();
  64.     }

  65.     /**
  66.      * Set the Sigma/Eigenvectors Covariance data.
  67.      * @param csig3eigvec3 the covariance data in the Sigma/Eigenvectors format.
  68.      */
  69.     public void setCsig3eigvec3(final double[] csig3eigvec3) {
  70.         refuseFurtherComments();

  71.         // Conditional on ALT_COV_TYPE = Sigma/Eigenvectors Covariance
  72.         if (!isAltCovFlagSet()) {
  73.             throw new OrekitException(OrekitMessages.CCSDS_DATE_INVALID_PREAMBLE_FIELD, CdmMetadataKey.ALT_COV_TYPE);
  74.         }

  75.         this.csig3eigvec3 = csig3eigvec3 == null ? null : csig3eigvec3.clone();
  76.     }

  77.     /** Get the flag indicating whether the alternate covariance type set in the CDM Object metadata section is Sigma/Eigenvectors Covariance.
  78.      * @return the altCovFlag
  79.      */
  80.     public boolean isAltCovFlagSet() {
  81.         return altCovFlag;
  82.     }

  83. }