Multi Event Visibility check

Hi everyone,
I’m working to implement a program to study visibility Check from four several ground stations (network ground stations), but I don’t understand how to manage multi events detector. If I simply add four elevation detector at the same propagator it doesn’t work. How can I resolve this problem?

Did you change the default setting for the event hendler?
By default, the ElevationDetector uses a StopOnDecreasing handler, which means the propagation will stop at the first visibility loss. You should probaly use something like:

  EventDetector ed = new ElevationDetector(...).
                     withHandler(new ContinueOnEvent<>());

Beware that as the various withXxx() methods use a combination of fluent and builder APIs, the
detector you need to register to your propagator is the one returned by the chained calls, not the initial one from the new, which is immutable.

Thank you for the answer @luc ,
I used the VisibilityHandler descripted in the tutorial “Visibility Check”, replacing STOP Action with RESET_STATE to avoid to continue the propagation. The code is:

private static class VisibilityHandler implements EventHandler {
public Action eventOccurred(final SpacecraftState s, final ElevationDetector detector,
                            final boolean increasing) {
	

    if (increasing) {
        System.out.println(" Visibility on " + detector.getTopocentricFrame().getName()
                                             + " begins at " + s.getDate());
       
        return Action.CONTINUE;
    } else {
        
    	System.out.println(" Visibility on " + detector.getTopocentricFrame().getName()
                + " ends at " + s.getDate());

return Action.RESET_STATE ;

                 }
            }

}This text will be hidden


This Handler is called in the detectors

final EventDetector sta1Visi =
new ElevationDetector(maxcheck, threshold, sta1Frame).
withConstantElevation(elevation).
withHandler(new VisibilityHandler());
    final EventDetector sta2Visi =
            new ElevationDetector(maxcheck, threshold, sta2Frame).
            withConstantElevation(elevation).
            withHandler(new VisibilityHandler());
   
    final EventDetector sta3Visi =
            new ElevationDetector(maxcheck, threshold, sta3Frame).
            withConstantElevation(elevation).
            withHandler(new VisibilityHandler());
  
    final EventDetector sta4Visi =
            new ElevationDetector(maxcheck, threshold, sta4Frame).
            withConstantElevation(elevation).
            withHandler(new VisibilityHandler());
    
 EventsLogger logger = new EventsLogger();

// Add event to be detected
prop.addEventDetector(logger.monitorDetector(sta1Visi));
prop.addEventDetector(logger.monitorDetector(sta2Visi));
prop.addEventDetector(logger.monitorDetector(sta3Visi));
prop.addEventDetector(logger.monitorDetector(sta4Visi));

	//propagate
	prop.propagate(initialDate.shiftedBy(5400.));   

It is correct? I would like also to extrapolate time duration (Date of stop visibility- date of start visibility) for each station, but I don’t know how to get the Date of beginning of visibility. It is possible?
Thank you for your support

replacing STOP Action with RESET_STATE to avoid to continue the propagation.

No, you should use Action.CONTINUE for both increasing and decreasing events here. Action.RESET is used when your want to change spacecraft state at event. A typical example would be to simulate an impulse maneuver. This is not whant you want here, you just want the propagator to continue running.

EventsLogger logger = new EventsLogger();

Here you are using both a custom VisibilityHandler and an EventLogger to monitor your events. Their is some redundancy here. If you want to just print something on the fly, a custom handler like VisibilityHandler is the way to go, and you can forget about the logger. If on the other hand you want to gather all the events as they appear and to process them all at the end of the propagation, then EventLogger is the way to go. With both methods, you could get the duration of visibility, but it is much simpler with a custom handler as follows:

If you use a custom handler, then the handler should store the date of the increasing event in a field of the hander, and compute the duration when the next decreasing event happens. Something akin to:

public class DurationHandler implements EventHandler<ElevationDetector> {
  private AbsoluteDate raisingDate = null;
  public Action eventOccurred(SpacecraftState s, ElevationDetector detector, boolean increasing) {
      if (increasing) {
         raisingDate = s.getDate();
      } else if (raisingDate != null) {
        System.out.println("visibility at " +detector.getTopocentricFrame().getName() +
                           " from " + raisingDate + " to " + s.getDate() +
                           ", duration = " + s.getDate().durationFrom(raisingDate) + " s");
      }
      return Action.CONTINUE;
}

Doing the same with the logger implies you find by yourself matching raising/setting pairs for each station, as the events will be logged only sorted by date and you may have raising on station A, then raising on station B, then setting on station A, then setting on station B. It is possible, though, just slightly more complex.

Thank you very much for the help, now I have understand the problem.

Hey, @luc

As always, providing useful content! Thanks a lot.

In addition to what was asked before, I’d like to know how can I combine the elevation detector with elevation extremum detector?

I want to take the pass and the max elevation of it. In this case of multi-event visibility check, how could I achieve that?

Hello @rodreras,

I believe you mean that you want to save the pass and max elevation for each ground station right ?

To do so, you can still use a simple ElevationDetector with your own EventHandler to store passes and then loop over your passes to check for the maximum elevation value (for each event handler).

Now if you want to filter passes over a specific elevation you can modifiy your ElevationDetector with withConstantElevation​(double newMinElevation) or withElevationMask​(ElevationMask newElevationMask).

ElevationDetector documentation 12.2.1

EventHandlerdocumentation 12.2.1

Cheers,
Vincent

1 Like

Hi all,

I think @rodreras was talking about the maximum over the whole pass, not just at enter and exit of field of view. For that you have an ElevationExtremumDetector. You can do that as post process on the passes specifically with the IntegratedEphemeris obtained via the generator. Otherwise in the loop you’ll need to wrap it with EventSlopeFilter and/or EventEnablingPreeicateFilter to filter out the minima or values outside the passes.

Cheers,
Romain.

1 Like

That was my thought but it seems that i expressed myself badly. My idea was to store values of the elevation during passes and then go over them to find out the maximum in order to have both the whole passes and their associated extrema.

Cheers
Vincent

1 Like

Note that the extremum detector really finds the exact extremum, even if it lies between points, but the extra accuracy may be moot depending on application.