AttitudeCovariance.java

  1. /* Copyright 2022-2025 Luc Maisonobe
  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.adm.acm;

  18. import java.util.List;

  19. import org.hipparchus.linear.DiagonalMatrix;
  20. import org.orekit.time.AbsoluteDate;
  21. import org.orekit.time.TimeStamped;
  22. import org.orekit.utils.units.Unit;

  23. /** Covariance entry.
  24.  * @author Luc Maisonobe
  25.  * @since 12.0
  26.  */
  27. public class AttitudeCovariance implements TimeStamped {

  28.     /** Type of the elements. */
  29.     private final AttitudeCovarianceType type;

  30.     /** Entry date. */
  31.     private final AbsoluteDate date;

  32.     /** Covariance matrix. */
  33.     private final DiagonalMatrix matrix;

  34.     /** Simple constructor.
  35.      * @param type type of the elements
  36.      * @param date entry date
  37.      * @param fields matrix diagonal elements
  38.      * @param first index of first field to consider
  39.      */
  40.     public AttitudeCovariance(final AttitudeCovarianceType type, final AbsoluteDate date,
  41.                               final String[] fields, final int first) {
  42.         final List<Unit> units = type.getUnits();
  43.         this.type   = type;
  44.         this.date   = date;
  45.         this.matrix = new DiagonalMatrix(units.size());
  46.         for (int k = 0; k < matrix.getRowDimension(); ++k) {
  47.             matrix.setEntry(k, k, units.get(k).toSI(Double.parseDouble(fields[first + k])));
  48.         }
  49.     }

  50.     /** {@inheritDoc} */
  51.     @Override
  52.     public AbsoluteDate getDate() {
  53.         return date;
  54.     }

  55.     /** Get the covariance matrix.
  56.      * @return covariance matrix
  57.      */
  58.     public DiagonalMatrix getMatrix() {
  59.         return matrix;
  60.     }

  61.     /** Get the type of the elements.
  62.      * @return type of the elements
  63.      */
  64.     public AttitudeCovarianceType getType() {
  65.         return type;
  66.     }

  67. }