1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.time.clocks;
18
19 import java.util.Collections;
20 import java.util.List;
21 import java.util.Map;
22 import java.util.function.DoubleFunction;
23
24 import org.hipparchus.CalculusFieldElement;
25 import org.hipparchus.analysis.differentiation.Gradient;
26 import org.hipparchus.util.FastMath;
27 import org.orekit.time.AbsoluteDate;
28 import org.orekit.time.TimeInterval;
29 import org.orekit.utils.drivers.ParameterDriver;
30
31
32
33
34
35
36
37 public class ConstantClockModel implements ClockModel {
38
39
40 private final ParameterDriver offset;
41
42
43
44
45
46
47 public ConstantClockModel(final double offset) {
48 this.offset = new ParameterDriver("a0", 0.0, FastMath.scalb(1.0, -10),
49 Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY,
50 TimeInterval.UNLIMITED);
51 this.offset.setValue(offset);
52 }
53
54
55 @Override
56 public AbsoluteDate getValidityStart() {
57 return offset.getValidity().getStartDate();
58 }
59
60
61 @Override
62 public AbsoluteDate getValidityEnd() {
63 return offset.getValidity().getEndDate();
64 }
65
66
67 @Override
68 public List<ParameterDriver> getParametersDrivers() {
69 return Collections.singletonList(offset);
70 }
71
72
73 @Override
74 public ClockOffset getOffset(final AbsoluteDate date) {
75 return new ClockOffset(date, offset.getValue(), 0, 0);
76 }
77
78
79 @Override
80 public <T extends CalculusFieldElement<T>> ConstantFieldClockModel<T> toField(final DoubleFunction<T> converter) {
81 return new ConstantFieldClockModel<>(converter.apply(offset.getValue()));
82 }
83
84
85 @Override
86 public ConstantFieldClockModel<Gradient> toGradient(final int freeParameters, final Map<String, Integer> indices) {
87 return toField(v -> Gradient.constant(freeParameters, v));
88 }
89
90 }