Coupling Events with Detector

First off, hi everyone. I am an orekit newbee so sorry if these questions have an obvious solution, but:

Using Conda install (recently) w/orekit 12.0.1 and python 3.11.8.final.0

Consider the following scenario: Propagating a satellite and finding the AOS+LOS times of several ground stations (TopocentricFrame) using ElevationDetector.

Questions:

  1. If only using the EventsLogger and iterating through events after propagation, how do I identify the ElevationDetector involved in the event? The event.getEventDetector() method returns an object with different id than the originally created ElevationDetector.
  2. Using EventHandler.eventOccurred() should return an Action, but I cannot find the python definition? I found the correct import in the examples, but I have problem making it work:
class TestHandler(EventHandler):
   # Without __init__() orekit throws NotImplementedError: ('instantiating java class', <class '<...>.TestHandler'>)
   def __init__(self):
       pass 

   def eventOccurred(self, s: SpacecraftState, detector: EventDetector, increasing: bool):
       print(f"Event: {increasing}")
       return Action.CONTINUE

# Adding the event handler using this:
ed = (ElevationDetector(site.frame).
     withConstantElevation(radians(site.min_elevation)).
     withHandler(TestHandler()))

I get the following error:

orekit.JavaError: <super: <class 'JavaError'>, <JavaError object>>
    Java stacktrace:
java.lang.NullPointerException
        at org.orekit.propagation.events.AbstractDetector.init(AbstractDetector.java:105)
        at org.orekit.propagation.events.EventsLogger$LoggingWrapper.init(EventsLogger.java:214)
        at org.orekit.propagation.events.EventState.init(EventState.java:148)
        at org.orekit.propagation.analytical.AbstractAnalyticalPropagator.propagate(AbstractAnalyticalPropagator.java:135)

Hi and welcome to orekit!

It is indeed not obvious. To subclass java classes in Python one needs to use some specially designed classes for this, that is prepared in the orekit python wrapper. These are named the same, but with a Python added in front, so you should subclass PythonEventHandler.

You will also need to implement all methods that are exposed to python in that class, you can see an example at python_files/test/EventDetectorTest.py · master · Orekit Labs / Orekit Python Wrapper · GitLab

Regards,

2 Likes