PsdPredicate.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.sinex;

  18. import org.orekit.models.earth.displacement.PsdCorrection;
  19. import org.orekit.time.AbsoluteDate;
  20. import org.orekit.utils.Constants;

  21. import java.util.function.Predicate;

  22. /** Predicates for Post-Seismic Deformation lines.
  23.  * @author Luc Maisonobe
  24.  * @since 13.0
  25.  */
  26. enum PsdPredicate implements Predicate<SinexParseInfo> {

  27.     /** Predicate for AEXP_E line. */
  28.     AEXP_E {
  29.         protected void store(final SinexParseInfo parseInfo, final double value, final Station station,
  30.                              final AbsoluteDate epoch) {
  31.             parseInfo.setEvolution(PsdCorrection.TimeEvolution.EXP);
  32.             parseInfo.setAxis(PsdCorrection.Axis.EAST);
  33.             parseInfo.setAmplitude(value, station, epoch);
  34.         }
  35.     },

  36.     /** Predicate for TEXP_E line. */
  37.     TEXP_E {
  38.         protected void store(final SinexParseInfo parseInfo, final double value, final Station station,
  39.                              final AbsoluteDate epoch) {
  40.             parseInfo.setEvolution(PsdCorrection.TimeEvolution.EXP);
  41.             parseInfo.setAxis(PsdCorrection.Axis.EAST);
  42.             parseInfo.setRelaxationTime(value * Constants.JULIAN_YEAR, station, epoch);
  43.         }
  44.     },

  45.     /** Predicate for ALOG_E line. */
  46.     ALOG_E {
  47.         protected void store(final SinexParseInfo parseInfo, final double value, final Station station,
  48.                              final AbsoluteDate epoch) {
  49.             parseInfo.setEvolution(PsdCorrection.TimeEvolution.LOG);
  50.             parseInfo.setAxis(PsdCorrection.Axis.EAST);
  51.             parseInfo.setAmplitude(value, station, epoch);
  52.         }
  53.     },

  54.     /** Predicate for TLOG_E line. */
  55.     TLOG_E {
  56.         protected void store(final SinexParseInfo parseInfo, final double value, final Station station,
  57.                              final AbsoluteDate epoch) {
  58.             parseInfo.setEvolution(PsdCorrection.TimeEvolution.LOG);
  59.             parseInfo.setAxis(PsdCorrection.Axis.EAST);
  60.             parseInfo.setRelaxationTime(value * Constants.JULIAN_YEAR, station, epoch);
  61.         }
  62.     },

  63.     /** Predicate for AEXP_N line. */
  64.     AEXP_N {
  65.         protected void store(final SinexParseInfo parseInfo, final double value, final Station station,
  66.                              final AbsoluteDate epoch) {
  67.             parseInfo.setEvolution(PsdCorrection.TimeEvolution.EXP);
  68.             parseInfo.setAxis(PsdCorrection.Axis.NORTH);
  69.             parseInfo.setAmplitude(value, station, epoch);
  70.         }
  71.     },

  72.     /** Predicate for TEXP_N line. */
  73.     TEXP_N {
  74.         protected void store(final SinexParseInfo parseInfo, final double value, final Station station,
  75.                              final AbsoluteDate epoch) {
  76.             parseInfo.setEvolution(PsdCorrection.TimeEvolution.EXP);
  77.             parseInfo.setAxis(PsdCorrection.Axis.NORTH);
  78.             parseInfo.setRelaxationTime(value * Constants.JULIAN_YEAR, station, epoch);
  79.         }
  80.     },

  81.     /** Predicate for ALOG_N line. */
  82.     ALOG_N {
  83.         protected void store(final SinexParseInfo parseInfo, final double value, final Station station,
  84.                              final AbsoluteDate epoch) {
  85.             parseInfo.setEvolution(PsdCorrection.TimeEvolution.LOG);
  86.             parseInfo.setAxis(PsdCorrection.Axis.NORTH);
  87.             parseInfo.setAmplitude(value, station, epoch);
  88.         }
  89.     },

  90.     /** Predicate for TLOG_N line. */
  91.     TLOG_N {
  92.         protected void store(final SinexParseInfo parseInfo, final double value, final Station station,
  93.                              final AbsoluteDate epoch) {
  94.             parseInfo.setEvolution(PsdCorrection.TimeEvolution.LOG);
  95.             parseInfo.setAxis(PsdCorrection.Axis.NORTH);
  96.             parseInfo.setRelaxationTime(value * Constants.JULIAN_YEAR, station, epoch);
  97.         }
  98.     },

  99.     /** Predicate for AEXP_U line. */
  100.     AEXP_U {
  101.         protected void store(final SinexParseInfo parseInfo, final double value, final Station station,
  102.                              final AbsoluteDate epoch) {
  103.             parseInfo.setEvolution(PsdCorrection.TimeEvolution.EXP);
  104.             parseInfo.setAxis(PsdCorrection.Axis.UP);
  105.             parseInfo.setAmplitude(value, station, epoch);
  106.         }
  107.     },

  108.     /** Predicate for TEXP_U line. */
  109.     TEXP_U {
  110.         protected void store(final SinexParseInfo parseInfo, final double value, final Station station,
  111.                              final AbsoluteDate epoch) {
  112.             parseInfo.setEvolution(PsdCorrection.TimeEvolution.EXP);
  113.             parseInfo.setAxis(PsdCorrection.Axis.UP);
  114.             parseInfo.setRelaxationTime(value * Constants.JULIAN_YEAR, station, epoch);
  115.         }
  116.     },

  117.     /** Predicate for ALOG_U line. */
  118.     ALOG_U {
  119.         protected void store(final SinexParseInfo parseInfo, final double value, final Station station,
  120.                              final AbsoluteDate epoch) {
  121.             parseInfo.setEvolution(PsdCorrection.TimeEvolution.LOG);
  122.             parseInfo.setAxis(PsdCorrection.Axis.UP);
  123.             parseInfo.setAmplitude(value, station, epoch);
  124.         }
  125.     },

  126.     /** Predicate for TLOG_U line. */
  127.     TLOG_U {
  128.         protected void store(final SinexParseInfo parseInfo, final double value, final Station station,
  129.                              final AbsoluteDate epoch) {
  130.             parseInfo.setEvolution(PsdCorrection.TimeEvolution.LOG);
  131.             parseInfo.setAxis(PsdCorrection.Axis.UP);
  132.             parseInfo.setRelaxationTime(value * Constants.JULIAN_YEAR, station, epoch);
  133.         }
  134.     };

  135.     /** {@inheritDoc} */
  136.     @Override
  137.     public boolean test(final SinexParseInfo parseInfo) {
  138.         if (name().equals(parseInfo.parseString(7, 6))) {
  139.             // this is the data type we are concerned with
  140.             store(parseInfo, parseInfo.parseDouble(47, 22),
  141.                   parseInfo.getCurrentLineStation(14),
  142.                   parseInfo.stringEpochToAbsoluteDate(parseInfo.parseString(27, 12), false));
  143.             return true;
  144.         } else {
  145.             // it is a data type for another predicate
  146.             return false;
  147.         }
  148.     }

  149.     /**
  150.      * Store parsed fields.
  151.      *
  152.      * @param parseInfo container for parse info
  153.      * @param value     parsed value
  154.      * @param station   station
  155.      * @param epoch     current epoch
  156.      */
  157.     protected abstract void store(SinexParseInfo parseInfo, double value, Station station, AbsoluteDate epoch);

  158. }