Search in sources :

Example 76 with OneAxisEllipsoid

use of org.orekit.bodies.OneAxisEllipsoid in project Orekit by CS-SI.

the class JB2008Test method testDensityField.

@Test
public void testDensityField() throws OrekitException {
    final Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    final OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, itrf);
    final JB2008 atm = new JB2008(new InputParams(), CelestialBodyFactory.getSun(), earth);
    final AbsoluteDate date = InputParams.TC[4];
    for (double alt = 100; alt < 1000; alt += 50) {
        for (double lat = -1.2; lat < 1.2; lat += 0.4) {
            for (double lon = 0; lon < 6.28; lon += 0.8) {
                final GeodeticPoint point = new GeodeticPoint(lat, lon, alt * 1000.);
                final Vector3D pos = earth.transform(point);
                Field<Decimal64> field = Decimal64Field.getInstance();
                // Run
                final double rho = atm.getDensity(date, pos, itrf);
                final Decimal64 rho64 = atm.getDensity(new FieldAbsoluteDate<>(field, date), new FieldVector3D<>(field.getOne(), pos), itrf);
                Assert.assertEquals(rho, rho64.getReal(), rho * 4.0e-13);
            }
        }
    }
}
Also used : Frame(org.orekit.frames.Frame) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Decimal64(org.hipparchus.util.Decimal64) GeodeticPoint(org.orekit.bodies.GeodeticPoint) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 77 with OneAxisEllipsoid

use of org.orekit.bodies.OneAxisEllipsoid in project Orekit by CS-SI.

the class SimpleExponentialAtmosphereTest method testExpAtmosphere.

@Test
public void testExpAtmosphere() throws OrekitException {
    Vector3D posInEME2000 = new Vector3D(10000, Vector3D.PLUS_I);
    AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
    Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    SimpleExponentialAtmosphere atm = new SimpleExponentialAtmosphere(new OneAxisEllipsoid(Utils.ae, 1.0 / 298.257222101, itrf), 0.0004, 42000.0, 7500.0);
    Vector3D vel = atm.getVelocity(date, posInEME2000, FramesFactory.getEME2000());
    Transform toBody = FramesFactory.getEME2000().getTransformTo(itrf, date);
    Vector3D test = Vector3D.crossProduct(toBody.getRotationRate(), posInEME2000);
    test = test.subtract(vel);
    Assert.assertEquals(0, test.getNorm(), 2.9e-5);
}
Also used : Frame(org.orekit.frames.Frame) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) Transform(org.orekit.frames.Transform) AbsoluteDate(org.orekit.time.AbsoluteDate) SimpleExponentialAtmosphere(org.orekit.forces.drag.atmosphere.SimpleExponentialAtmosphere) Test(org.junit.Test)

Example 78 with OneAxisEllipsoid

use of org.orekit.bodies.OneAxisEllipsoid in project Orekit by CS-SI.

the class HarrisPriesterTest method setUp.

@Before
public void setUp() throws OrekitException {
    Utils.setDataRoot("regular-data");
    sun = CelestialBodyFactory.getSun();
    earthFrame = CelestialBodyFactory.getEarth().getBodyOrientedFrame();
    earth = new OneAxisEllipsoid(6378136.460, 1.0 / 298.257222101, earthFrame);
    // Equinoxe 21 mars 2003 à 1h00m
    utc = TimeScalesFactory.getUTC();
    date = new AbsoluteDate(new DateComponents(2003, 03, 21), new TimeComponents(1, 0, 0.), utc);
}
Also used : OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) DateComponents(org.orekit.time.DateComponents) TimeComponents(org.orekit.time.TimeComponents) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Before(org.junit.Before)

Example 79 with OneAxisEllipsoid

use of org.orekit.bodies.OneAxisEllipsoid in project Orekit by CS-SI.

the class OrekitEphemerisFileTest method testWritingToOEM.

@Test
public void testWritingToOEM() throws OrekitException, IOException {
    final double muTolerance = 1e-12;
    final double positionTolerance = 1e-8;
    final double velocityTolerance = 1e-8;
    final String satId = "SATELLITE1";
    final double sma = 10000000;
    final double inc = Math.toRadians(45.0);
    final double ecc = 0.001;
    final double raan = 0.0;
    final double pa = 0.0;
    final double ta = 0.0;
    final AbsoluteDate date = new AbsoluteDate();
    final Frame frame = FramesFactory.getGCRF();
    final CelestialBody body = CelestialBodyFactory.getEarth();
    final double mu = body.getGM();
    KeplerianOrbit initialOrbit = new KeplerianOrbit(sma, ecc, inc, pa, raan, ta, PositionAngle.TRUE, frame, date, mu);
    KeplerianPropagator propagator = new KeplerianPropagator(initialOrbit);
    final double propagationDurationSeconds = 86400.0;
    final double stepSizeSeconds = 60.0;
    List<SpacecraftState> states = new ArrayList<SpacecraftState>();
    for (double dt = 0.0; dt < propagationDurationSeconds; dt += stepSizeSeconds) {
        states.add(propagator.propagate(date.shiftedBy(dt)));
    }
    OrekitEphemerisFile ephemerisFile = new OrekitEphemerisFile();
    OrekitSatelliteEphemeris satellite = ephemerisFile.addSatellite(satId);
    satellite.addNewSegment(states);
    String tempOemFile = Files.createTempFile("OrekitEphemerisFileTest", ".oem").toString();
    new OEMWriter().write(tempOemFile, ephemerisFile);
    EphemerisFile ephemerisFromFile = new OEMParser().parse(tempOemFile);
    Files.delete(Paths.get(tempOemFile));
    EphemerisSegment segment = ephemerisFromFile.getSatellites().get(satId).getSegments().get(0);
    assertEquals(states.get(0).getDate(), segment.getStart());
    assertEquals(states.get(states.size() - 1).getDate(), segment.getStop());
    assertEquals(states.size(), segment.getCoordinates().size());
    assertEquals(frame, segment.getFrame());
    assertEquals(body.getName().toUpperCase(), segment.getFrameCenterString());
    assertEquals(body.getGM(), segment.getMu(), muTolerance);
    for (int i = 0; i < states.size(); i++) {
        TimeStampedPVCoordinates expected = states.get(i).getPVCoordinates();
        TimeStampedPVCoordinates actual = segment.getCoordinates().get(i);
        assertEquals(expected.getDate(), actual.getDate());
        assertEquals(0.0, Vector3D.distance(expected.getPosition(), actual.getPosition()), positionTolerance);
        assertEquals(0.0, Vector3D.distance(expected.getVelocity(), actual.getVelocity()), velocityTolerance);
    }
    // test ingested ephemeris generates access intervals
    final OneAxisEllipsoid parentShape = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
    final double latitude = 0.0;
    final double longitude = 0.0;
    final double altitude = 0.0;
    final GeodeticPoint point = new GeodeticPoint(latitude, longitude, altitude);
    final TopocentricFrame topo = new TopocentricFrame(parentShape, point, "testPoint1");
    final ElevationDetector elevationDetector = new ElevationDetector(topo);
    final EphemerisSegmentPropagator ephemerisSegmentPropagator = new EphemerisSegmentPropagator(segment);
    final EventsLogger lookupLogger = new EventsLogger();
    ephemerisSegmentPropagator.addEventDetector(lookupLogger.monitorDetector(elevationDetector));
    final EventsLogger referenceLogger = new EventsLogger();
    propagator.clearEventsDetectors();
    propagator.addEventDetector(referenceLogger.monitorDetector(elevationDetector));
    propagator.propagate(segment.getStart(), segment.getStop());
    ephemerisSegmentPropagator.propagate(segment.getStart(), segment.getStop());
    final double dateEpsilon = 1.0e-9;
    assertTrue(referenceLogger.getLoggedEvents().size() > 0);
    assertEquals(referenceLogger.getLoggedEvents().size(), lookupLogger.getLoggedEvents().size());
    for (int i = 0; i < referenceLogger.getLoggedEvents().size(); i++) {
        LoggedEvent reference = referenceLogger.getLoggedEvents().get(i);
        LoggedEvent actual = lookupLogger.getLoggedEvents().get(i);
        assertEquals(0.0, FastMath.abs(reference.getState().getDate().durationFrom(actual.getState().getDate())), dateEpsilon);
    }
    final Propagator embeddedPropagator = segment.getPropagator();
    final EventsLogger embeddedPropLogger = new EventsLogger();
    embeddedPropagator.addEventDetector(embeddedPropLogger.monitorDetector(elevationDetector));
    embeddedPropagator.propagate(segment.getStart(), segment.getStop());
    assertEquals(referenceLogger.getLoggedEvents().size(), embeddedPropLogger.getLoggedEvents().size());
    for (int i = 0; i < referenceLogger.getLoggedEvents().size(); i++) {
        LoggedEvent reference = referenceLogger.getLoggedEvents().get(i);
        LoggedEvent actual = embeddedPropLogger.getLoggedEvents().get(i);
        assertEquals(0.0, FastMath.abs(reference.getState().getDate().durationFrom(actual.getState().getDate())), dateEpsilon);
    }
    final List<SpacecraftState> readInStates = new ArrayList<SpacecraftState>();
    segment.getCoordinates().forEach(c -> {
        try {
            readInStates.add(new SpacecraftState(new CartesianOrbit(c, frame, mu)));
        } catch (IllegalArgumentException | OrekitException e) {
            fail(e.getLocalizedMessage());
        }
    });
    final int interpolationPoints = 5;
    Ephemeris directEphemProp = new Ephemeris(readInStates, interpolationPoints);
    final EventsLogger directEphemPropLogger = new EventsLogger();
    directEphemProp.addEventDetector(directEphemPropLogger.monitorDetector(elevationDetector));
    directEphemProp.propagate(segment.getStart(), segment.getStop());
    assertEquals(referenceLogger.getLoggedEvents().size(), directEphemPropLogger.getLoggedEvents().size());
    for (int i = 0; i < referenceLogger.getLoggedEvents().size(); i++) {
        LoggedEvent reference = referenceLogger.getLoggedEvents().get(i);
        LoggedEvent actual = directEphemPropLogger.getLoggedEvents().get(i);
        assertEquals(0.0, FastMath.abs(reference.getState().getDate().durationFrom(actual.getState().getDate())), dateEpsilon);
    }
}
Also used : Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) CartesianOrbit(org.orekit.orbits.CartesianOrbit) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) LoggedEvent(org.orekit.propagation.events.EventsLogger.LoggedEvent) ElevationDetector(org.orekit.propagation.events.ElevationDetector) ArrayList(java.util.ArrayList) TopocentricFrame(org.orekit.frames.TopocentricFrame) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) OrekitSatelliteEphemeris(org.orekit.files.general.OrekitEphemerisFile.OrekitSatelliteEphemeris) EphemerisSegment(org.orekit.files.general.EphemerisFile.EphemerisSegment) Propagator(org.orekit.propagation.Propagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) CelestialBody(org.orekit.bodies.CelestialBody) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrekitException(org.orekit.errors.OrekitException) GeodeticPoint(org.orekit.bodies.GeodeticPoint) OEMParser(org.orekit.files.ccsds.OEMParser) GeodeticPoint(org.orekit.bodies.GeodeticPoint) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) OEMWriter(org.orekit.files.ccsds.OEMWriter) EventsLogger(org.orekit.propagation.events.EventsLogger) OrekitSatelliteEphemeris(org.orekit.files.general.OrekitEphemerisFile.OrekitSatelliteEphemeris) Ephemeris(org.orekit.propagation.analytical.Ephemeris) Test(org.junit.Test)

Example 80 with OneAxisEllipsoid

use of org.orekit.bodies.OneAxisEllipsoid in project Orekit by CS-SI.

the class NRLMSISE00Test method testLegacy.

@Test
public void testLegacy() throws OrekitException, NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    // Build the model
    Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, itrf);
    NRLMSISE00 atm = new NRLMSISE00(null, null, earth);
    // Common data for all cases
    final int doy = 172;
    final double sec = 29000.;
    final double alt = 400.;
    final double lat = 60.;
    final double lon = -70.;
    final double hl = 16.;
    final double f107a = 150.;
    final double f107 = 150.;
    double[] ap = { 4., 100., 100., 100., 100., 100., 100. };
    final boolean print = false;
    Method gtd7 = getOutputClass().getDeclaredMethod("gtd7", Double.TYPE);
    gtd7.setAccessible(true);
    // Case #1
    final Object out1 = createOutput(atm, doy, sec, lat, lon, hl, f107a, f107, ap);
    gtd7.invoke(out1, alt);
    checkLegacy(1, out1, print);
    // Case #2
    final int doy2 = 81;
    final Object out2 = createOutput(atm, doy2, sec, lat, lon, hl, f107a, f107, ap);
    gtd7.invoke(out2, alt);
    checkLegacy(2, out2, print);
    // Case #3
    final double sec3 = 75000.;
    final double alt3 = 1000.;
    final Object out3 = createOutput(atm, doy, sec3, lat, lon, hl, f107a, f107, ap);
    gtd7.invoke(out3, alt3);
    checkLegacy(3, out3, print);
    // Case #4
    final double alt4 = 100.;
    final Object out4 = createOutput(atm, doy, sec, lat, lon, hl, f107a, f107, ap);
    gtd7.invoke(out4, alt4);
    checkLegacy(4, out4, print);
    // Case #5
    final double lat5 = 0.;
    final Object out5 = createOutput(atm, doy, sec, lat5, lon, hl, f107a, f107, ap);
    gtd7.invoke(out5, alt);
    checkLegacy(5, out5, print);
    // Case #6
    final double lon6 = 0.;
    final Object out6 = createOutput(atm, doy, sec, lat, lon6, hl, f107a, f107, ap);
    gtd7.invoke(out6, alt);
    checkLegacy(6, out6, print);
    // Case #7
    final double hl7 = 4.;
    final Object out7 = createOutput(atm, doy, sec, lat, lon, hl7, f107a, f107, ap);
    gtd7.invoke(out7, alt);
    checkLegacy(7, out7, print);
    // Case #8
    final double f107a8 = 70.;
    final Object out8 = createOutput(atm, doy, sec, lat, lon, hl, f107a8, f107, ap);
    gtd7.invoke(out8, alt);
    checkLegacy(8, out8, print);
    // Case #9
    final double f1079 = 180.;
    final Object out9 = createOutput(atm, doy, sec, lat, lon, hl, f107a, f1079, ap);
    gtd7.invoke(out9, alt);
    checkLegacy(9, out9, print);
    // Case #10
    ap[0] = 40.;
    final Object out10 = createOutput(atm, doy, sec, lat, lon, hl, f107a, f107, ap);
    gtd7.invoke(out10, alt);
    checkLegacy(10, out10, print);
    ap[0] = 4.;
    // Case #11
    final double alt11 = 0.;
    final Object out11 = createOutput(atm, doy, sec, lat, lon, hl, f107a, f107, ap);
    gtd7.invoke(out11, alt11);
    checkLegacy(11, out11, print);
    // Case #12
    final double alt12 = 10.;
    final Object out12 = createOutput(atm, doy, sec, lat, lon, hl, f107a, f107, ap);
    gtd7.invoke(out12, alt12);
    checkLegacy(12, out12, print);
    // Case #13
    final double alt13 = 30.;
    final Object out13 = createOutput(atm, doy, sec, lat, lon, hl, f107a, f107, ap);
    gtd7.invoke(out13, alt13);
    checkLegacy(13, out13, print);
    // Case #14
    final double alt14 = 50.;
    final Object out14 = createOutput(atm, doy, sec, lat, lon, hl, f107a, f107, ap);
    gtd7.invoke(out14, alt14);
    checkLegacy(14, out14, print);
    // Case #15
    final double alt15 = 70.;
    final Object out15 = createOutput(atm, doy, sec, lat, lon, hl, f107a, f107, ap);
    gtd7.invoke(out15, alt15);
    checkLegacy(15, out15, print);
    // Case #16
    NRLMSISE00 otherAtm = atm.withSwitch(9, -1);
    final Object out16 = createOutput(otherAtm, doy, sec, lat, lon, hl, f107a, f107, ap);
    gtd7.invoke(out16, alt);
    checkLegacy(16, out16, print);
    // Case #17
    final double alt17 = 100.;
    final Object out17 = createOutput(otherAtm, doy, sec, lat, lon, hl, f107a, f107, ap);
    gtd7.invoke(out17, alt17);
    checkLegacy(17, out17, print);
}
Also used : Frame(org.orekit.frames.Frame) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) Method(java.lang.reflect.Method) GeodeticPoint(org.orekit.bodies.GeodeticPoint) Test(org.junit.Test)

Aggregations

OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)146 Test (org.junit.Test)89 AbsoluteDate (org.orekit.time.AbsoluteDate)83 GeodeticPoint (org.orekit.bodies.GeodeticPoint)65 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)59 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)57 SpacecraftState (org.orekit.propagation.SpacecraftState)48 Frame (org.orekit.frames.Frame)47 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)45 Orbit (org.orekit.orbits.Orbit)42 PVCoordinates (org.orekit.utils.PVCoordinates)42 TopocentricFrame (org.orekit.frames.TopocentricFrame)34 EquinoctialOrbit (org.orekit.orbits.EquinoctialOrbit)31 OrekitException (org.orekit.errors.OrekitException)29 CircularOrbit (org.orekit.orbits.CircularOrbit)29 KeplerianPropagator (org.orekit.propagation.analytical.KeplerianPropagator)29 DateComponents (org.orekit.time.DateComponents)29 Propagator (org.orekit.propagation.Propagator)28 Before (org.junit.Before)26 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)23