Problem with measurements generation

Hi,
I am new to orekit and I am trying to simulate RA Dec measurements using AngularRaDecBuilder in python wrapper. However, when I use the build method, I get the following error:

JavaError: <super: <class ‘JavaError’>, >
Java stacktrace:
java.lang.NullPointerException
at org.orekit.estimation.measurements.generation.AngularRaDecBuilder.build(AngularRaDecBuilder.java:82)

I still don’t know exactly how to debug the Java, but looking at the code it seems it is a problem that happens while trying to set a reference date for parameters drivers missing one.

Do you have any idea or suggestion regarding what could be causing this issue? Thank you.

Hi Marc,

To be able to help it is best if you post a code example, preferable that can be run as-is. First step is to see if there is something with the interface between python and java.

Hi,
this is an example of my code:

import orekit
vm = orekit.initVM()

from orekit.pyhelpers import setup_orekit_curdir
setup_orekit_curdir()

from org.orekit.frames import FramesFactory, TopocentricFrame
from org.orekit.bodies import OneAxisEllipsoid, GeodeticPoint
from org.orekit.time import TimeScalesFactory, AbsoluteDate
from org.orekit.utils import IERSConventions, Constants, AbsolutePVCoordinates
from org.orekit.estimation.measurements.generation import AngularRaDecBuilder

from org.orekit.propagation import SpacecraftState
from org.orekit.propagation.analytical.tle import TLE, TLEPropagator

from org.orekit.estimation.measurements import ObservableSatellite, GroundStation

from math import radians

LLAstat = [40,12,300.0]

‘’’
TLE_1 = ‘1 03669U 69009A 22058.06856683 .00000039 00000+0 18086-4 0 9995’
TLE_2 = ‘2 03669 88.4274 318.0001 1711743 177.6329 183.4294 11.29525671182675’
‘’’

TLEfile = ‘tle.txt’
TLEread = open(TLEfile,‘r’)
TLEstrings = TLEread.readlines()
mytle = TLE(TLEstrings[0],TLEstrings[1])

ITRF = FramesFactory.getITRF(IERSConventions.IERS_2010, True)
earth = OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
Constants.WGS84_EARTH_FLATTENING,
ITRF)

latitude = radians(LLAstat[0])
longitude = radians(LLAstat[1])
altitude = LLAstat[2]
station = GeodeticPoint(latitude, longitude, altitude)
station_frame = TopocentricFrame(earth, station, “ObservingStation”)

inertialFrame = FramesFactory.getEME2000()

propagator = TLEPropagator.selectExtrapolator(mytle)

epoch = [2022,2,28,1,1,1.0]
extrapDate = AbsoluteDate(epoch[0], epoch[1], epoch[2],
epoch[3], epoch[4], epoch[5],
TimeScalesFactory.getUTC())

pv = propagator.getPVCoordinates(extrapDate, inertialFrame)

‘’’
generating RA-Dec
‘’’

satellite = ObservableSatellite(0)
ground_station = GroundStation(station_frame)
ra_dec_builder = AngularRaDecBuilder(None, ground_station, inertialFrame,
[float(0.1),float(0.1)], [float(1),float(1)], satellite)

abs_pv_coord = AbsolutePVCoordinates(inertialFrame, pv)
sc_state = SpacecraftState(abs_pv_coord)

radec = ra_dec_builder.build([sc_state])

Note that I obtain the same error if I provide a CorrelatedRandomVectorGenerator to AngularRaDecBuilder. I also get a similar error if I use AngularAzElBuilder.
Thank you.

Hi @petrus.hyvonen and @marc ,

I convert the python code to java, the full error message is as followings:

Exception in thread "main" java.lang.NullPointerException: Cannot invoke "org.orekit.time.AbsoluteDate.durationFrom(org.orekit.time.AbsoluteDate)" because "start" is null
	at org.orekit.estimation.measurements.generation.AngularRaDecBuilder.build(AngularRaDecBuilder.java:82)
	at test.T1.t2(T1.java:71)

The line 82 of “AngularRaDecBuilder.java”:

       // set a reference date for parameters missing one
        for (final ParameterDriver driver : dummy.getParametersDrivers()) {
            if (driver.getReferenceDate() == null) {
                final AbsoluteDate start = getStart();
                final AbsoluteDate end   = getEnd();
L82-->                driver.setReferenceDate(start.durationFrom(end) <= 0 ? start : end);
            }
        }

So the exception is due to that “the start data is null”, actually the end date is also null.

See deeply in class AbstractMeasurementBuilder,which is the parent class of AngularRaDecBuilder,
there is a method init to initialize builder at the start of a measurements generation, “…typically setting up parameters reference dates”.

    public void init(final AbsoluteDate start, final AbsoluteDate end) {
        spanStart = start;
        spanEnd   = end;
    }

So you should call ra_dec_builder.init(startDate, endDate) once before building an measurement.

Furthermore, it is better to use these builders with org.orekit.estimation.measurements.generation.Generator.

Regards,
Lirw

Thank you @lirw1984, I called the init method, with the same date for startDate and endDate in this single measurement example, and the building of measurement works now.

Now, I was actually trying to use the builder with the Generator class and an EventBasedScheduler. Anyway I cannot manage to make it work. I fear I am calling something in the wrong way but I do not fully understand every orekit input and how to check it, so I do not understand where I am wrong.

At the end of the previous code, I added the following:

elMask = 10.0
sun = CelestialBodyFactory.getSun()

elDetector = ElevationDetector(station_frame)
elDetector.withConstantElevation(elMask)
satEclDetector = EclipseDetector(abs_pv_coord, Constants.WGS84_EARTH_EQUATORIAL_RADIUS, earth)
satSunDetector = BooleanDetector.notCombine(satEclDetector)
nightGroundDetector = GroundAtNightDetector(station_frame, sun, GroundAtNightDetector.NAUTICAL_DAWN_DUSK_ELEVATION, None)
optObsPossibleDetector = BooleanDetector.andCombine([elDetector, satSunDetector, nightGroundDetector])

UTCScale = TimeScalesFactory.getUTC()
stepDetector = FixedStepSelector(60.0, UTCScale)

EBS = EventBasedScheduler(ra_dec_builder, stepDetector, propagator, optObsPossibleDetector, SignSemantic.FEASIBLE_MEASUREMENT_WHEN_POSITIVE)
EBS.init(extrapDate, extrapDate)

gen = Generator()
gen.addPropagator(propagator)
gen.addScheduler(EBS)
gen.generate(extrapDate, extrapDate)

I also changed the location and time of the measurement, so to make it feasible by a telescope:

LLAstat = [80,-120, 300.0]
epoch = [2022,2,28,6,0,0.0]

When I launch the code, I get this error:

JavaError: <super: <class 'JavaError'>, <JavaError object>>
    Java stacktrace:
org.orekit.errors.OrekitException: zero norm
	at org.orekit.errors.OrekitException.unwrap(OrekitException.java:154)
	at org.orekit.propagation.analytical.AbstractAnalyticalPropagator.propagate(AbstractAnalyticalPropagator.java:162)
	at org.orekit.propagation.PropagatorsParallelizer.propagate(PropagatorsParallelizer.java:140)
	at org.orekit.estimation.measurements.generation.Generator.generate(Generator.java:95)
Caused by: org.hipparchus.exception.MathRuntimeException: zero norm
	at org.hipparchus.geometry.euclidean.threed.Vector3D.orthogonal(Vector3D.java:342)
	at org.orekit.bodies.Ellipsoid.getPlaneSection(Ellipsoid.java:138)
	at org.orekit.bodies.Ellipsoid.pointOnLimb(Ellipsoid.java:255)
	at org.orekit.propagation.events.EclipseDetector.g(EclipseDetector.java:182)
	at org.orekit.propagation.events.NegateDetector.g(NegateDetector.java:89)
	at org.orekit.propagation.events.BooleanDetector.g(BooleanDetector.java:225)
	at org.orekit.propagation.events.AdapterDetector.g(AdapterDetector.java:61)
	at org.orekit.estimation.measurements.generation.EventBasedScheduler$FeasibilityAdapter.init(EventBasedScheduler.java:148)
	at org.orekit.propagation.events.EventState.init(EventState.java:141)
	at org.orekit.propagation.analytical.AbstractAnalyticalPropagator.propagate(AbstractAnalyticalPropagator.java:130)
2 more

Is there something clearly wrong in what I am doing?
Thank you, little by little I am gaining a better understanding on how to use orekit.

To explain better my intention: I want to generate feasible pseudo-observations with a telescope. For example, given a start date, a stop date and a time step between measurements, I would like the script to return all feasible optical measurements in the given time interval from the given observing station.

Hi @marc,

I’m sorry I don’t have much time to read all your code but I’ve noted that you use degrees to create the GeodeticPoint that represents your station.

This will not work, you have to use latitude/longitude in radians (Orekit works with SI units) when creating your geodetic point.

I hope this helps, although I’m not sure this will solve the last issue you submitted to us.

Maxime

Thanks @MaximeJ, sorry if I didn’t write it clearly, but actually later in the code I’m converting latitude and longitude degrees to radians before to use these coordinates.

I also tried to use the sun AbsolutePVCoordinates as argument of GroundAtNightDetector (while in the code I posted I used the CelestialBody directly), but this didn’t solve my issue.

More generally, I was also wondering whether the EventBasedScheduler added to the Generator should provide, in principle, all the measurements meeting the defined conditions between the start date and the stop date, even if “holes” are present (i.e. between the visible passes).

I hope I’m not making a big mess :slight_smile: , anyway if I find a solution and come to a conclusion for my doubt I will write it here.