Question on position of Earth relative to the Moon

HI,

I am trying to use Orekit to compute the following:

Given a location on the surface of the Moon (latitude + longitude + altitude) and a given Date and Time:

  1. Find the locat azimuth and elevation of the Earth;
  2. Find the local azimuth and elevation of the Sun;

I have created the following code to do so:


CelestialBody moon = CelestialBodyFactory.getMoon();

	// Define a GeodeticPoint at the location of the observer on the surface of the moon.
	GeodeticPoint geodeticPoint = new GeodeticPoint(observerLatitude,observerLongitude, observerAltitude);			
		Frame moonFrame = moon.getBodyOrientedFrame();
								
		BodyShape moonBodyShape = new OneAxisEllipsoid(Constants.MOON_EQUATORIAL_RADIUS, MOON_FLATTENING, moonFrame);
		TopocentricFrame moonCentricLocation = new TopocentricFrame(moonBodyShape, geodeticPoint, "location");
					
		AbsoluteDate absoluteDate =  new AbsoluteDate(date, getUTCScale());
		TimeStampedPVCoordinates earthCoordinatesInMoonFrame = earth.getPVCoordinates(absoluteDate, moonCentricLocation);
		
		// Convert Sun position in Horizontal Coordinates.
		earthCoordinates = convertToHorizontalCoordinates(earthCoordinatesInMoonFrame.getPosition());

private HorizontalCoordinates convertToHorizontalCoordinates(Vector3D positionInTopocentricFrame)
{
	double r = positionInTopocentricFrame.getNorm();
	double rXY = Math.sqrt(positionInTopocentricFrame.getX() * positionInTopocentricFrame.getX() +
						   positionInTopocentricFrame.getY() * positionInTopocentricFrame.getY());
	
	double elevation = Math.atan((positionInTopocentricFrame.getZ() / rXY));
	double azimuth = Math.toRadians(90) - Math.atan2(positionInTopocentricFrame.getY(), positionInTopocentricFrame.getX());
	
	
	HorizontalCoordinates coordinates = ApogyCoreEnvironmentFactory.eINSTANCE.createHorizontalCoordinates();				
	coordinates.setAltitude(elevation);
	coordinates.setAzimuth(azimuth);
	coordinates.setRadius(r);
	
	return coordinates;
}

I am getting values that are close to what I expect (based on calculation done in STK), but not quite (the elevation of the Earth can deviate by more than 10 degrees in certain cases, I can provide a csv file containing the expected and actual data if usefull).

So what I am doing wrong ?

Thanks !

Hi Pallard,

What effects are you considering in STK? The computation you’ve presented above is the geometrical quantities. I.e. ignoring light time delay and other aberration effects. STK has many options and it can be hard to determine what it is actually computing. Are the large differences all near zenith?

Also see TopocentricFrame.getElevation(...) and .getAzimuth(...) though your method may be faster if you compute elevation as arcsin(z/r).

Regards,
Evan

Hi Evan,

Thanks for your quick answer.

I just have found what the problem was: the date I used for the calculation are read from a CSV file produced by STK. The date format that I used for parsing the time and date from the file was wrong. This caused my test code to feed an incorrect time to the Orekit earth.getPVCoordinates(…) function. I have corrected the error and I am now getting good results (the Earth azimuth is within 0.003 deg and elevation within 0.006 over a year). For the Sun azimuth and elevation, I am now getting slightly less good agreements (the Sun azimuth is within 0.539 deg and elevation within 0.01 over a year).

As for effects, I am not considering anything outside of what the code I posted. What else should I consider to improve the result (especially for the Sun) ?

Thanks again,

Pierre

Your welcome. Glad you fixed the big error.

The question is what effects is STK considering? Since there is more error for the Sun than for the Earth light time delay seems like a plausible answer. Try turning off light time delay in STK (might be called apparent position) and see if it improves your results. Or conversely try accounting for the light time delay in Orekit.

Regards,
Evan