I have been having a lot of trouble figuring out how to get my altitudeEventDetector to work. Right now the way that I’m propogating a large spacecraft works with all the perturbations configured into “stpProp” propagator object.
Since there are non-conservative forces in the propagator, I know that the satellite will eventually crash into the earth. I tried to make sure that even if such a thing happened, I’d still be able to plot it. However this AltitudeDetector doesn’t seem to stop the propagation process. The satellite gets well within the 100 km I set as my target “altitude”.
the time steps are 60 seconds each, and the total time propagated is 0.1 days. It used to be one day but again, the event didn’t stop the propagation so it just failed and threw an error instead of plotting everything leading up to it.
I am new to Orekit, and semi-new to python so I’m hoping there are some easy explanations. any help is super appreciated. The code I’m referencing is below
altitudeEventDetector = AltitudeDetector(altidude,EarthBody).withHandler(StopOnEvent())
print(altitudeEventDetector.getAltitude())
stpProp.addEventDetector(altitudeEventDetector)
time = [initialEpoch.shiftedBy(float(dt)) for dt in np.arange(0.0, totalTimePropogated, propogationTimeSteps)]
starlinkStates = [stpProp.propagate(k) for k in time]
I think your loop is the culprit: you restart a propagation each time instead of doing one propagation that should end at event occurrence.
The recommended way to use propagation is to first set up a step handler (with fixed steps if you want) and possibly event detectors as you want, and then just use one single call to propagate from start time to end time. The step handler will be called several times (i.e. it is the library that performs the time loop, not your code), and the single propagation will either be stopped at the end if no StopOnEvent is encountered because the event condition is never met, or it will be stopped when the event occurs.
That would make sense. I have the capability to set up a start and end date as well. The only reason I have that for loop is because I had set the integrator myself while constructing the NumericalPropagator object. If I go down the step handler rout will it still take my integrator’s preference towards fixed-steps or adaptive-steps? By doing the for loop and I essentially nullifying the adaptive-steps as well?
It seems I would just use: init(SpacecraftState s0, AbsoluteDate t)
then do a .propogate() with the start and end date?
The integrator step size and the step handler size are independent of each other. Internally, there is a step normalization layer that leverages the integrator steps into step handler steps. If the integrator steps are larger, then the step handler will be called several time per integration step. If the integrator step are smaller, then at some integration steps the step handler will not be called at all. If the integration steps are variable, the step handler steps remain regular.
You don’t have to call the init method by yourself, when you call propagate it will be called automatically.
Okay. This makes sense. Below is what I think I was meant to change based on your input. “totalTimePropogated” is just about a day. the “addEventDetector” doesn’t throw an error, but now that I’m trying to put in a step handler it doesn’t seem to like it. it throws me the error " ‘NumericalPropagator’ object has no attribute ‘setStepHandler’ " which is confusing me since it autofills when I start typing in “.setSt” for example.
I think I’m misunderstanding some fundamentals in the code here. It hasn’t seemed (so far) to produce anything but one point when I’ve just done propagate with the end date. It seems like from what you’re saying I should be adding in this step handler but I’m not sure I’m doing that correctly. Ideally once I had constructed my NumericalPropogator, it would just be a couple lines of code to propagate it as intended so I could plot it. I’ve attached those code snippets below.
Insted of creating a new (empty) multiplexer for step handlers, you should just retrieve the default one (which is also empty), and add you own handler to it (something like stpProp.getMultiplexer()add(timeSteps, MyPlottingHandler()).). Your plotting method would occur in this step handler.
I suggest you look at the propagation tutorial.