CdmData.java

  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. import java.util.List;

  19. import org.orekit.files.ccsds.ndm.odm.UserDefined;
  20. import org.orekit.files.ccsds.section.CommentsContainer;
  21. import org.orekit.files.ccsds.section.Data;

  22. /**
  23.  * Container for Conjunction Data Message data.
  24.  * @author Melina Vanel
  25.  * @since 11.2
  26.  */
  27. public class CdmData implements Data {

  28.     /** General comments block. */
  29.     private final CommentsContainer commentsBlock;

  30.     /** Quaternion block. */
  31.     private ODParameters ODParametersBlock;

  32.     /** Euler angles block. */
  33.     private AdditionalParameters additionalParametersBlock;

  34.     /** Spin-stabilized block. */
  35.     private final StateVector stateVectorBlock;

  36.     /** Spacecraft parameters block. */
  37.     private RTNCovariance covarianceMatrixBlock;

  38.     /** XYZ covariance block. */
  39.     private final XYZCovariance xyzCovarianceMatrixBlock;

  40.     /** Sigma/Eigenvectors covariance block. */
  41.     private final SigmaEigenvectorsCovariance sig3EigVec3CovarianceBlock;

  42.     /** Type of alternate covariance, if present. */
  43.     private AltCovarianceType altCovarianceType;

  44.     /** Additional Covariance Metadata block. */
  45.     private AdditionalCovarianceMetadata additionalCovMetadata;

  46.     /** The block containing the user defined parameters. */
  47.     private UserDefined userDefinedBlock;





  48.      /** Default constructor.
  49.      * @param commentsBlock general comments block
  50.      * @param ODParametersBlock OD parameters block (may be null)
  51.      * @param additionalParametersBlock additionnal parameters block (may be null)
  52.      * @param stateVectorBlock state vector block
  53.      * @param covarianceMatrixBlock covariance matrix in RTN coordinates frame block
  54.      * @param xyzCovarianceBlock XYZ covariance matrix block
  55.      * @param sig3EigVec3CovarianceBlock sigma/eigenvector covariance block
  56.      * @param altCovarianceType type of alternate covariance
  57.      * @param additionalCovMetadata additional covariance metadata
  58.      */
  59.     private CdmData(final CommentsContainer commentsBlock,
  60.                    final ODParameters ODParametersBlock,
  61.                    final AdditionalParameters additionalParametersBlock,
  62.                    final StateVector stateVectorBlock,
  63.                    final RTNCovariance covarianceMatrixBlock,
  64.                    final XYZCovariance xyzCovarianceBlock,
  65.                    final SigmaEigenvectorsCovariance sig3EigVec3CovarianceBlock,
  66.                    final AltCovarianceType altCovarianceType,
  67.                    final AdditionalCovarianceMetadata additionalCovMetadata) {
  68.         this.commentsBlock             = commentsBlock;
  69.         this.ODParametersBlock         = ODParametersBlock;
  70.         this.additionalParametersBlock = additionalParametersBlock;
  71.         this.stateVectorBlock               = stateVectorBlock;
  72.         this.covarianceMatrixBlock          = covarianceMatrixBlock;
  73.         this.xyzCovarianceMatrixBlock       = xyzCovarianceBlock;
  74.         this.sig3EigVec3CovarianceBlock     = sig3EigVec3CovarianceBlock;
  75.         this.altCovarianceType              = altCovarianceType;
  76.         this.additionalCovMetadata          = additionalCovMetadata;
  77.         this.userDefinedBlock               = null;
  78.     }

  79.      /**  Constructor with RTN covariance.
  80.      * @param commentsBlock general comments block
  81.      * @param ODParametersBlock OD parameters block (may be null)
  82.      * @param additionalParametersBlock additionnal parameters block (may be null)
  83.      * @param stateVectorBlock state vector block
  84.      * @param covarianceMatrixBlock covariance matrix in RTN coordinates frame block

  85.      */
  86.     public CdmData(final CommentsContainer commentsBlock,
  87.                    final ODParameters ODParametersBlock,
  88.                    final AdditionalParameters additionalParametersBlock,
  89.                    final StateVector stateVectorBlock,
  90.                    final RTNCovariance covarianceMatrixBlock) {
  91.         this(commentsBlock, ODParametersBlock, additionalParametersBlock, stateVectorBlock,
  92.              covarianceMatrixBlock, null, null, null, null);
  93.     }

  94.      /**  Constructor with RTN covariance.
  95.      * @param commentsBlock general comments block
  96.      * @param ODParametersBlock OD parameters block (may be null)
  97.      * @param additionalParametersBlock additionnal parameters block (may be null)
  98.      * @param stateVectorBlock state vector block
  99.      * @param covarianceMatrixBlock covariance matrix in RTN coordinates frame block
  100.      * @param additionalCovMetadata additional covariance metadata
  101.      */
  102.     public CdmData(final CommentsContainer commentsBlock,
  103.                    final ODParameters ODParametersBlock,
  104.                    final AdditionalParameters additionalParametersBlock,
  105.                    final StateVector stateVectorBlock,
  106.                    final RTNCovariance covarianceMatrixBlock,
  107.                    final AdditionalCovarianceMetadata additionalCovMetadata) {
  108.         this(commentsBlock, ODParametersBlock, additionalParametersBlock, stateVectorBlock,
  109.              covarianceMatrixBlock, null, null, null, additionalCovMetadata);
  110.     }

  111.      /**  Constructor with RTN and XYZ covariance.
  112.      * @param commentsBlock general comments block
  113.      * @param ODParametersBlock OD parameters block (may be null)
  114.      * @param additionalParametersBlock additionnal parameters block (may be null)
  115.      * @param stateVectorBlock state vector block
  116.      * @param covarianceMatrixBlock covariance matrix in RTN coordinates frame block
  117.      * @param xyzCovarianceBlock XYZ covariance matrix block
  118.      * @param additionalCovMetadata additional covariance metadata
  119.      */
  120.     public CdmData(final CommentsContainer commentsBlock,
  121.                    final ODParameters ODParametersBlock,
  122.                    final AdditionalParameters additionalParametersBlock,
  123.                    final StateVector stateVectorBlock,
  124.                    final RTNCovariance covarianceMatrixBlock,
  125.                    final XYZCovariance xyzCovarianceBlock,
  126.                    final AdditionalCovarianceMetadata additionalCovMetadata) {
  127.         this(commentsBlock, ODParametersBlock, additionalParametersBlock, stateVectorBlock,
  128.              covarianceMatrixBlock, xyzCovarianceBlock, null, AltCovarianceType.XYZ, additionalCovMetadata);
  129.     }

  130.      /**  Constructor with RTN and sigma/eigenvector covariance.
  131.      * @param commentsBlock general comments block
  132.      * @param ODParametersBlock OD parameters block (may be null)
  133.      * @param additionalParametersBlock additionnal parameters block (may be null)
  134.      * @param stateVectorBlock state vector block
  135.      * @param covarianceMatrixBlock covariance matrix in RTN coordinates frame block
  136.      * @param sig3EigVec3CovarianceBlock sigma/eigenvector covariance block
  137.      * @param additionalCovMetadata additional covariance metadata
  138.      */
  139.     public CdmData(final CommentsContainer commentsBlock,
  140.                    final ODParameters ODParametersBlock,
  141.                    final AdditionalParameters additionalParametersBlock,
  142.                    final StateVector stateVectorBlock,
  143.                    final RTNCovariance covarianceMatrixBlock,
  144.                    final SigmaEigenvectorsCovariance sig3EigVec3CovarianceBlock,
  145.                    final AdditionalCovarianceMetadata additionalCovMetadata) {
  146.         this(commentsBlock, ODParametersBlock, additionalParametersBlock, stateVectorBlock,
  147.              covarianceMatrixBlock, null, sig3EigVec3CovarianceBlock, AltCovarianceType.CSIG3EIGVEC3, additionalCovMetadata);
  148.     }

  149.     /** {@inheritDoc} */
  150.     @Override
  151.     public void validate(final double version) {
  152.         if (ODParametersBlock != null) {
  153.             ODParametersBlock.validate(version);
  154.         }
  155.         if (additionalParametersBlock != null) {
  156.             additionalParametersBlock.validate(version);
  157.         }
  158.         stateVectorBlock.validate(version);

  159.         // covariance options
  160.         if (altCovarianceType == null) {
  161.             covarianceMatrixBlock.validate(version);
  162.         } else if (altCovarianceType == AltCovarianceType.XYZ) {
  163.             xyzCovarianceMatrixBlock.validate(version);
  164.         } else if (altCovarianceType == AltCovarianceType.CSIG3EIGVEC3) {
  165.             sig3EigVec3CovarianceBlock.validate(version);
  166.         }

  167.     }

  168.     /** Get the comments.
  169.      * @return comments
  170.      */
  171.     public List<String> getComments() {
  172.         return commentsBlock.getComments();
  173.     }

  174.     /** Get the OD parameters logical block.
  175.      * @return OD parameters block (may be null)
  176.      */
  177.     public ODParameters getODParametersBlock() {
  178.         return ODParametersBlock;
  179.     }

  180.     /** Set the OD parameters logical block.
  181.      * @param ODParametersBlock the OD Parameters logical block
  182.      */
  183.     public void setODParametersBlock(final ODParameters ODParametersBlock) {
  184.         this.ODParametersBlock = ODParametersBlock;
  185.     }

  186.     /** Get the additional parameters logical block.
  187.      * @return additional parameters block (may be null)
  188.      */
  189.     public AdditionalParameters getAdditionalParametersBlock() {
  190.         return additionalParametersBlock;
  191.     }

  192.     /** Set the additional parameters logical block.
  193.      * @param additionalParametersBlock the additional parameters logical block
  194.      */
  195.     public void setAdditionalParametersBlock(final AdditionalParameters additionalParametersBlock) {
  196.         this.additionalParametersBlock = additionalParametersBlock;
  197.     }

  198.     /** Get the state vector logical block.
  199.      * @return state vector block
  200.      */
  201.     public StateVector getStateVectorBlock() {
  202.         return stateVectorBlock;
  203.     }

  204.     /** Get the covariance matrix logical block.
  205.      * <p> The RTN Covariance Matrix is provided in the 9×9 Lower Triangular Form. All parameters of the 6×6 position/velocity submatrix
  206.      * are mandatory. The remaining elements will return NaN if not provided. </p>
  207.      * @return covariance matrix block
  208.      */
  209.     public RTNCovariance getRTNCovarianceBlock() {
  210.         return covarianceMatrixBlock;
  211.     }

  212.     /** Get the Covariance Matrix in the XYZ Coordinate Frame (defined by value of {@link CdmMetadataKey#ALT_COV_REF_FRAME}).
  213.      * <p> This block is not mandatory and on condition that {@link CdmMetadataKey#ALT_COV_TYPE} = {@link AltCovarianceType#XYZ}.
  214.      * <p> This method will return null if the block is not defined in the CDM. </p>
  215.      * @return XYZ covariance matrix block
  216.      */
  217.     public XYZCovariance getXYZCovarianceBlock() {
  218.         return xyzCovarianceMatrixBlock;
  219.     }

  220.     /** Get the Sigma / Eigenvector covariance logical block.
  221.      * <p> This block is not mandatory and on condition that {@link CdmMetadataKey#ALT_COV_TYPE} = {@link AltCovarianceType#CSIG3EIGVEC3}.
  222.      * <p> This method will return null if the block is not defined in the CDM. </p>
  223.      * @return the Sigma / Eigenvector covariance block
  224.      */
  225.     public SigmaEigenvectorsCovariance getSig3EigVec3CovarianceBlock() {
  226.         return sig3EigVec3CovarianceBlock;
  227.     }

  228.     /** Get the additional covariance metadata logical block.
  229.      * <p> This method will return null if the block is not defined in the CDM. </p>
  230.      * @return the additional covariance metadata logical block
  231.      */
  232.     public AdditionalCovarianceMetadata getAdditionalCovMetadataBlock() {
  233.         return additionalCovMetadata;
  234.     }

  235.     /** Set the additional covariance metadata logical block.
  236.      * @param covarianceMatrixBlock the additional covariance metadata logical block
  237.      */
  238.     public void setCovarianceMatrixBlock(final RTNCovariance covarianceMatrixBlock) {
  239.         this.covarianceMatrixBlock = covarianceMatrixBlock;
  240.     }

  241.     /** Get the user defined logical block.
  242.      * <p> This method will return null if the block is not defined in the CDM. </p>
  243.      * @return the additional covariance metadata logical block
  244.      */
  245.     public UserDefined getUserDefinedBlock() {
  246.         return userDefinedBlock;
  247.     }

  248.      /** Set the user defined logical block.
  249.      * <p> This block is added at the end of the CDM parsing as common to both Object 1 and 2. </p>
  250.      * @param userDefinedBlock the user defined block to set
  251.      */
  252.     public void setUserDefinedBlock(final UserDefined userDefinedBlock) {
  253.         this.userDefinedBlock = userDefinedBlock;
  254.     }
  255. }