OceanTides weird behavior

Hi guys, my question is - does OceanTides force model have to be reloaded or cleared somehow before it is used with different parameters? I’m trying to observe impact of different degrees and orders of the tide model on tidal acceleration. So I set say 10 harmonics to take into account and compute oceanTides.acceleration() for some predefined states. It works fine. Then I change to 20 harmonics (I use python wrapper and Jupyter notebook) but acceleration doesn’t change at all. If I clear everything by restarting the kernel and use 20 harmonics for the first try, I get new values (different from the case of 10 = 20 harmonics from earlier). Setup and calculation is within a function, I just call it with different parameters. I suspect that the model somehow gets stuck since it doesn’t react to parameter changing but reloads after complete clearing. I would greatly appreciate an explanation of this situation and how to fix it.

Also, could you please give some details about the meaning and impact of parameters step ( DEFAULT_STEP=600.0 sec) and nbPoints (DEFAULT_POINTS=12) in solid and ocean tide models?
More points and shorter time step give more precise results?

I don’t understand how you change degree and order without rebuilding the OceanTides force model. The only place these parameters are set is in the constructor. Maybe this is a difference between the Python wrapper and the Java underlying library.

The time step and number of points are used to avoid lengthy recomputation of the perturbing field, which depends on time. The field is only recomputed according to these time steps and field is interpolated between the steps, using the number of points specified. The time step should therefore be consistent with the evolution of tides, 600s is good to deal with tides created by the Sun and the Moon.

More points may generate Runge phenomenon (and in fact by now I even think 12 is high, I don’t remember why we chose that). Shorter time steps would give more accurate results, but increase computation time.

Thank you @luc. Let me show some of related code. It is the Python wrapper and .ipynb notebook. After preparation I execute cells 1 through 3 one by one:

#cell 1
def calc_oceanTides_acceleration(inertial_frame, time_moment, state_inertial, timestep, points, degree):

ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_2010, True)
earth_frame = FramesFactory.getITRF(IERSConventions.IERS_2010, False)
gravityProvider = GravityFieldFactory.getNormalizedProvider(100, 100)

oceanTides = OceanTides(earth_frame, gravityProvider.getAe(), gravityProvider.getMu(), 
                        True, timestep, points, degree, degree, IERSConventions.IERS_2010, ut1) 

state = SpacecraftState(AbsolutePVCoordinates(inertial_frame, time_moment, state_inertial))

return oceanTides.acceleration(state, ForceModel.cast_(oceanTides).getParameters()).toArray()

#cell 2
acc10 = calc_oceanTides_acceleration(FramesFactory.getGCRF(), time_moments[0], state_inertial_true[0], 600.0, 12, 10)
print(acc10)

output: [-1.579685889400383e-08, -3.247904310426961e-09, 3.1001379770842736e-08]

#cell 3 (executed right after cell 2):
acc20 = calc_oceanTides_acceleration(FramesFactory.getGCRF(), time_moments[0], state_inertial_true[0], 600.0, 12, 20)
print(acc20)

output: [-1.579685889400383e-08, -3.247904310426961e-09, 3.1001379770842736e-08]

Note that outputs are identical besides the degree and order changed from 10 to 20.
Then I restart the kernel, prepare, execute cell 1 and then cell 3, skipping cell 2:

#cell 3
acc20 = calc_oceanTides_acceleration(FramesFactory.getGCRF(), time_moments[0], state_inertial_true[0], 600.0, 12, 20)
print(acc20)

output: [-7.122729011616203e-09, 5.8980470410523975e-09, 4.178373788888947e-08]

A noticable effect in acceleration can be observed, as expected. So it looks like the forcemodel loads 10 harmonics from the tide model file and then reuses them despite for the second time the function asks to rebuild everything with 20 harmonics. Looks like I have to reload the forcemodel or tidemodel provider explicitly somehow?

This is weird.
I don’t understand what happens.
Could you provide the spacecraft state data (position and date) so we try to reproduce this?

Hey there,

Could you try running your code in a Python console or with an IDE?
I’m no expert but I think sometimes Jupyter NBs do weird stuff in terms of cache.

Cheers,
Romain.

Date:<AbsoluteDate: 2021-03-29T23:59:42.000Z>

State in GCRS: <PVCoordinates: {P(531.7545638326519, -718035.0404060499, 6835039.371647774), V(1165.678605794716, -7476.55626016528, -789.2919601239232), A(0.0, 0.0, 0.0)}>

@Serrof, a good suggestion, but after running as a single .py file in IDE (Geany) I’ve still got the same problem (acc10 and acc20 values are the same)

Hi,

I confirmed the same behavior in Java.
It doesn’t happen if two different DataContext are used.
There’s definitely something happening in the caching of the ocean tides model.

I think it’s located in GravityFields.getOceanTidesWaves(degree, order). After two successive calls with (10, 10) and (20, 20) the degree, order in the waves is still set to 10.

Ok, I think I got it :wink:

In OceanTidesReader, method stillAcceptData just checks if some ocean waves already exist.

/** {@inheritDoc} */
    @Override
    public boolean stillAcceptsData() {
        return waves.isEmpty();
    }

So I think it doesn’t care if the degree/order is higher than what’s already there.

I compared it to the same method in PotentialCoefficientsReader and here there’s a check on the degree/order of the harmonics already loaded.

/** {@inheritDoc} */
    public boolean stillAcceptsData() {
        return !(readComplete &&
                 getMaxAvailableDegree() >= getMaxParseDegree() &&
                 getMaxAvailableOrder()  >= getMaxParseOrder());
    }

I think the same behavior should be implemented in OceanTidesReader.
@Aspern could you open a bug on the issue tracker please ?

@MaximeJ, thank you, that looks plausible. I’ve opened an issue. Meanwhile, since I’m working with Python wrapper, I’ll have to organize my code differently to avoid this problem. By the way, I suspect that changing other parameters in the same fashion doesn’t work either: playing with different ‘steps’ and ‘points’ doesn’t show a difference. But it might just look that way because of the main problem, I’m not sure.

Hi all!

Maybe we could include this fix in a 11.3.3 patch version?

Bryan

Good idea, same goes for @clamadvi and @luc recent thread since Python users cannot use the develop branch as easily as Java users.

I’m not sure either. I haven’t seen much difference between two different configurations even when the tides are properly loaded in different data contexts.

Yes, sorry about that. One way I made it work in my test is by using different DataContext for the different tide models.
You can try this to avoid the problem.
And make sure to use the OceanTides constructor that doesn’t use the default data context (i.e. the one with the last argument being GravityFields)

Thanks @MaximeJ, that’s allright, it was just for figuring out how many tidal harmonics I should take into account in my situation.

No, I know @clamadvi and indeed he will need branch issue-1047, which cannot be added in a patch release.

Hi!

The issue is fixed in MR 452. The fix will be available in the next patch release :wink:

Best regards,
Bryan

2 Likes