OneWayGNSSRangeBuilder - What should the remoteClockModel look like?

Hello,
I am attempting to use the OneWayGNSSRangeBuilder and OneWayGNSSPhaseBuilder constructors, and I am having trouble figuring out how to create an appropriate ToDoubleFunction remoteClockModel for input to these constructors. Can anyone help me understand what the remoteClockModel should look like?
Thank you!

In most cases when building simulated measurements, you would use a smooth clock model like a perfect clock that has a constant zero offset or a quadratic clock model.

In the first case, you could just use a constant lambda function in the builders constructors, like date -> 0.0.

In the second case, quadratic model, you could also use a lambda function and put the quadratic coefficients right into the function definition, but that would be cumbersome and more difficult to read. So in this case, I would suggest to go the extra mile and first set up an instance of ClockModel and then call its offset model in the lambda function. In fact, this would work for any clock model, not only quadratic. Here is an example, with quadratic model:

final ClockModel remoteClockModel = new QuadraticClockModel(referenceDate, a0, a1, a2);
final MeasurementBuilder<OneWayGNSSRange> b =
      new OneWayGNSSRangeBuilder(noiseSource, local, remote,
                                 date -> remoteClockModel.getOffset(date).getOffset(),
                                 sigma, baseWeight);

Beware that for the code above to work, the remoteClockModel variable must really be declared final, otherwise it would not be possible to use it from within the lambda function.

Note that this work with any clock models, so if for example you were attempting to simulate measurements that match a reference SP3, you could use the extractClockModel method that has been added a few weeks ago to SP3Ephemeris to get an AggregatedClockModel that you could then reference in the builders.

Thank you for this response, Luc! I am starting to understand how to create a clock model.
But is there any way to provide the clock model to the builder without a lambda function? I am still learning lambda functions, and since I am calling Orekit from Matlab, I have not yet figured out how to properly use lambda functions in Matlab either.
Thanks again.
Erin

Yes, you can create a class by yourself instead of having the compiler do it from the lambda function.
Try something along these lines:

public class MyRemoteClock implements ToDoubleFunction<AbsoluteDate> {

    private final ClockModel underlyingClock;

    public MyRemoteClock(final ClockModel underlyingClock) {
        this.underlyingClock = underlyingClock;
    }

    public double applyAsDouble(final AbsoluteDate date) {
        return underlyingClock.getOffset(date).getOffset();
    }
}

However, I realized I forgot something important. The constructor that takes a ToDoubleFunction as an argument will be deprecated when version 12.1 is published, it is already deprecated in the develop branch. This constructor will be replaced by another one that must have a QuadraticClockModel as its argument. The reason is that this model is the only one for which we can retrieve gradient with respect to parameters (here the three quadratic coefficients). So if you want to simulate a perfect clock, you must use a quadratic model with all coefficients set to zero, and if you want to use an SP3, you’re out of luck and have to complain to me.

I am not really happy with this limitation, but found no other way yet to be able to estimate clock parameters. It may be acceptable, though, as when estimating clocks, polynomial models up to degree 2 is really widespread.

Thanks for this reply, Luc. I ended up putting the project that requires the clock on hold for now, but when I return to it I will refer to your answer above.
Erin