Search in sources :

Example 11 with DateComponents

use of org.orekit.time.DateComponents in project Orekit by CS-SI.

the class BoxAndSolarArraySpacecraftTest method setUp.

@Before
public void setUp() {
    try {
        Utils.setDataRoot("regular-data");
        mu = 3.9860047e14;
        double ae = 6.378137e6;
        double c20 = -1.08263e-3;
        double c30 = 2.54e-6;
        double c40 = 1.62e-6;
        double c50 = 2.3e-7;
        double c60 = -5.5e-7;
        AbsoluteDate date = new AbsoluteDate(new DateComponents(1970, 7, 1), new TimeComponents(13, 59, 27.816), TimeScalesFactory.getUTC());
        // Satellite position as circular parameters, raan chosen to have sun elevation with
        // respect to orbit plane roughly evolving roughly from 15 to 15.2 degrees in the test range
        Orbit circ = new CircularOrbit(7178000.0, 0.5e-4, -0.5e-4, FastMath.toRadians(50.), FastMath.toRadians(280), FastMath.toRadians(10.0), PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu);
        propagator = new EcksteinHechlerPropagator(circ, new LofOffset(circ.getFrame(), LOFType.VVLH), ae, mu, c20, c30, c40, c50, c60);
    } catch (OrekitException oe) {
        Assert.fail(oe.getLocalizedMessage());
    }
}
Also used : EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) Orbit(org.orekit.orbits.Orbit) CircularOrbit(org.orekit.orbits.CircularOrbit) CircularOrbit(org.orekit.orbits.CircularOrbit) DateComponents(org.orekit.time.DateComponents) OrekitException(org.orekit.errors.OrekitException) TimeComponents(org.orekit.time.TimeComponents) LofOffset(org.orekit.attitudes.LofOffset) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Before(org.junit.Before)

Example 12 with DateComponents

use of org.orekit.time.DateComponents in project Orekit by CS-SI.

the class ICGEMFormatReader method loadData.

/**
 * {@inheritDoc}
 */
public void loadData(final InputStream input, final String name) throws IOException, ParseException, OrekitException {
    // reset the indicator before loading any data
    setReadComplete(false);
    referenceDate = null;
    cTrend.clear();
    sTrend.clear();
    cCos.clear();
    cSin.clear();
    sCos.clear();
    sSin.clear();
    // by default, the field is normalized with unknown tide system
    // (will be overridden later if non-default)
    normalized = true;
    tideSystem = TideSystem.UNKNOWN;
    final BufferedReader r = new BufferedReader(new InputStreamReader(input, "UTF-8"));
    boolean inHeader = true;
    double[][] c = null;
    double[][] s = null;
    boolean okCoeffs = false;
    int lineNumber = 0;
    for (String line = r.readLine(); line != null; line = r.readLine()) {
        try {
            ++lineNumber;
            if (line.trim().length() == 0) {
                continue;
            }
            final String[] tab = line.split("\\s+");
            if (inHeader) {
                if ((tab.length == 2) && PRODUCT_TYPE.equals(tab[0])) {
                    if (!GRAVITY_FIELD.equals(tab[1])) {
                        throw new OrekitParseException(OrekitMessages.UNABLE_TO_PARSE_LINE_IN_FILE, lineNumber, name, line);
                    }
                } else if ((tab.length == 2) && tab[0].endsWith(GRAVITY_CONSTANT)) {
                    setMu(parseDouble(tab[1]));
                } else if ((tab.length == 2) && REFERENCE_RADIUS.equals(tab[0])) {
                    setAe(parseDouble(tab[1]));
                } else if ((tab.length == 2) && MAX_DEGREE.equals(tab[0])) {
                    final int degree = FastMath.min(getMaxParseDegree(), Integer.parseInt(tab[1]));
                    final int order = FastMath.min(getMaxParseOrder(), degree);
                    c = buildTriangularArray(degree, order, missingCoefficientsAllowed() ? 0.0 : Double.NaN);
                    s = buildTriangularArray(degree, order, missingCoefficientsAllowed() ? 0.0 : Double.NaN);
                } else if ((tab.length == 2) && TIDE_SYSTEM_INDICATOR.equals(tab[0])) {
                    if (ZERO_TIDE.equals(tab[1])) {
                        tideSystem = TideSystem.ZERO_TIDE;
                    } else if (TIDE_FREE.equals(tab[1])) {
                        tideSystem = TideSystem.TIDE_FREE;
                    } else if (TIDE_UNKNOWN.equals(tab[1])) {
                        tideSystem = TideSystem.UNKNOWN;
                    } else {
                        throw new OrekitParseException(OrekitMessages.UNABLE_TO_PARSE_LINE_IN_FILE, lineNumber, name, line);
                    }
                } else if ((tab.length == 2) && NORMALIZATION_INDICATOR.equals(tab[0])) {
                    if (NORMALIZED.equals(tab[1])) {
                        normalized = true;
                    } else if (UNNORMALIZED.equals(tab[1])) {
                        normalized = false;
                    } else {
                        throw new OrekitParseException(OrekitMessages.UNABLE_TO_PARSE_LINE_IN_FILE, lineNumber, name, line);
                    }
                } else if ((tab.length == 2) && END_OF_HEADER.equals(tab[0])) {
                    inHeader = false;
                }
            } else {
                if ((tab.length == 7 && GFC.equals(tab[0])) || (tab.length == 8 && GFCT.equals(tab[0]))) {
                    final int i = Integer.parseInt(tab[1]);
                    final int j = Integer.parseInt(tab[2]);
                    if (i < c.length && j < c[i].length) {
                        parseCoefficient(tab[3], c, i, j, "C", name);
                        parseCoefficient(tab[4], s, i, j, "S", name);
                        okCoeffs = true;
                        if (tab.length == 8) {
                            // check the reference date (format yyyymmdd)
                            final DateComponents localRef = new DateComponents(Integer.parseInt(tab[7].substring(0, 4)), Integer.parseInt(tab[7].substring(4, 6)), Integer.parseInt(tab[7].substring(6, 8)));
                            if (referenceDate == null) {
                                // first reference found, store it
                                referenceDate = localRef;
                            } else if (!referenceDate.equals(localRef)) {
                                throw new OrekitException(OrekitMessages.SEVERAL_REFERENCE_DATES_IN_GRAVITY_FIELD, referenceDate, localRef, name);
                            }
                        }
                    }
                } else if (tab.length == 7 && (DOT.equals(tab[0]) || TRND.equals(tab[0]))) {
                    final int i = Integer.parseInt(tab[1]);
                    final int j = Integer.parseInt(tab[2]);
                    if (i < c.length && j < c[i].length) {
                        // store the secular trend coefficients
                        extendListOfLists(cTrend, i, j, 0.0);
                        extendListOfLists(sTrend, i, j, 0.0);
                        parseCoefficient(tab[3], cTrend, i, j, "Ctrend", name);
                        parseCoefficient(tab[4], sTrend, i, j, "Strend", name);
                    }
                } else if (tab.length == 8 && (ASIN.equals(tab[0]) || ACOS.equals(tab[0]))) {
                    final int i = Integer.parseInt(tab[1]);
                    final int j = Integer.parseInt(tab[2]);
                    if (i < c.length && j < c[i].length) {
                        // extract arrays corresponding to period
                        final Double period = Double.valueOf(tab[7]);
                        if (!cCos.containsKey(period)) {
                            cCos.put(period, new ArrayList<List<Double>>());
                            cSin.put(period, new ArrayList<List<Double>>());
                            sCos.put(period, new ArrayList<List<Double>>());
                            sSin.put(period, new ArrayList<List<Double>>());
                        }
                        final List<List<Double>> cCosPeriod = cCos.get(period);
                        final List<List<Double>> cSinPeriod = cSin.get(period);
                        final List<List<Double>> sCosPeriod = sCos.get(period);
                        final List<List<Double>> sSinPeriod = sSin.get(period);
                        // store the pulsation coefficients
                        extendListOfLists(cCosPeriod, i, j, 0.0);
                        extendListOfLists(cSinPeriod, i, j, 0.0);
                        extendListOfLists(sCosPeriod, i, j, 0.0);
                        extendListOfLists(sSinPeriod, i, j, 0.0);
                        if (ACOS.equals(tab[0])) {
                            parseCoefficient(tab[3], cCosPeriod, i, j, "Ccos", name);
                            parseCoefficient(tab[4], sCosPeriod, i, j, "SCos", name);
                        } else {
                            parseCoefficient(tab[3], cSinPeriod, i, j, "Csin", name);
                            parseCoefficient(tab[4], sSinPeriod, i, j, "Ssin", name);
                        }
                    }
                } else {
                    throw new OrekitParseException(OrekitMessages.UNABLE_TO_PARSE_LINE_IN_FILE, lineNumber, name, line);
                }
            }
        } catch (NumberFormatException nfe) {
            final OrekitParseException pe = new OrekitParseException(OrekitMessages.UNABLE_TO_PARSE_LINE_IN_FILE, lineNumber, name, line);
            pe.initCause(nfe);
            throw pe;
        }
    }
    if (missingCoefficientsAllowed() && c.length > 0 && c[0].length > 0) {
        // ensure at least the (0, 0) element is properly set
        if (Precision.equals(c[0][0], 0.0, 0)) {
            c[0][0] = 1.0;
        }
    }
    if (Double.isNaN(getAe()) || Double.isNaN(getMu()) || !okCoeffs) {
        String loaderName = getClass().getName();
        loaderName = loaderName.substring(loaderName.lastIndexOf('.') + 1);
        throw new OrekitException(OrekitMessages.UNEXPECTED_FILE_FORMAT_ERROR_FOR_LOADER, name, loaderName);
    }
    setRawCoefficients(normalized, c, s, name);
    setTideSystem(tideSystem);
    setReadComplete(true);
}
Also used : InputStreamReader(java.io.InputStreamReader) DateComponents(org.orekit.time.DateComponents) OrekitParseException(org.orekit.errors.OrekitParseException) BufferedReader(java.io.BufferedReader) OrekitException(org.orekit.errors.OrekitException) ArrayList(java.util.ArrayList) List(java.util.List)

Example 13 with DateComponents

use of org.orekit.time.DateComponents in project Orekit by CS-SI.

the class DSSTPropagatorTest method getLEOState.

private SpacecraftState getLEOState() throws IllegalArgumentException, OrekitException {
    final Vector3D position = new Vector3D(-6142438.668, 3492467.560, -25767.25680);
    final Vector3D velocity = new Vector3D(505.8479685, 942.7809215, 7435.922231);
    // Spring equinoxe 21st mars 2003 1h00m
    final AbsoluteDate initDate = new AbsoluteDate(new DateComponents(2003, 03, 21), new TimeComponents(1, 0, 0.), TimeScalesFactory.getUTC());
    return new SpacecraftState(new EquinoctialOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), initDate, 3.986004415E14));
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) PVCoordinates(org.orekit.utils.PVCoordinates) DateComponents(org.orekit.time.DateComponents) TimeComponents(org.orekit.time.TimeComponents) AbsoluteDate(org.orekit.time.AbsoluteDate)

Example 14 with DateComponents

use of org.orekit.time.DateComponents in project Orekit by CS-SI.

the class IERSConventionsTest method testTidalCorrection1996.

@Test
public void testTidalCorrection1996() throws OrekitException {
    // the reference value has been computed using interp_old.f from
    // ftp://hpiers.obspm.fr/iers/models/ with the following driver program:
    // 
    // PROGRAM OR_TEST
    // IMPLICIT NONE
    // INTEGER J, N
    // PARAMETER (N = 4)
    // INTEGER MJD(N)
    // DOUBLE PRECISION TTTAI, TAIUTC
    // PARAMETER (TAIUTC = 32.000D0)
    // PARAMETER (TTTAI  = 32.184D0)
    // DOUBLE PRECISION RJD(N), X(N), Y(N), T(N), H(5)
    // DOUBLE PRECISION RJDINT, XINT, YINT, TINT, CORX, CORY, CORT
    // DATA(MJD(J),    T(J),        X(J),      Y(J),
    // &     J=1,4)/
    // &    52653, -0.2979055D0, -0.120344D0, 0.217095D0,
    // &    52654, -0.2984238D0, -0.121680D0, 0.219400D0,
    // &    52655, -0.2987682D0, -0.122915D0, 0.221760D0,
    // &    52656, -0.2989957D0, -0.124248D0, 0.224294D0/
    // C
    // DATA(H(J),J=1,5)/0.0D0, 3600.0D0, 7200.0D0, 43200.0D0, 86400.0D0/
    // C
    // DO 10 J = 1, N
    // RJD(J) = MJD(J) + (TTTAI + TAIUTC) / 86400.0D0
    // 10   CONTINUE
    // C
    // DO 20 J = 1, 5
    // RJDINT = RJD(2) + H(J) / 86400.0D0
    // CALL INTERP(RJD,X,Y,T,N,RJDINT,XINT,YINT,TINT)
    // WRITE(6, 30) H(J), TINT, XINT, YINT
    // 20   CONTINUE
    // 30   FORMAT(F7.1,3(1X, F20.17))
    // C
    // END PROGRAM
    // 
    // the output of this test reads:
    // 0.0 -0.29839889612705234 -0.12191552977388567  0.21921143351558756
    // 3600.0 -0.29841696994736727 -0.12208276003864491  0.21925416583607277
    // 7200.0 -0.29843402412052122 -0.12218102086455683  0.21930263880545320
    // 43200.0 -0.29866785146390035 -0.12250027826538630  0.22103779809979979
    // 86400.0 -0.29874248853173840 -0.12308592577174847  0.22161565557764881
    Utils.setLoaders(IERSConventions.IERS_1996, Utils.buildEOPList(IERSConventions.IERS_1996, ITRFVersion.ITRF_2008, new double[][] { { 52653, -0.2979055, 0.0005744, -0.120344, 0.217095, 0.0, 0.0, 0.0, 0.0 }, { 52654, -0.2984238, 0.0004224, -0.121680, 0.219400, 0.0, 0.0, 0.0, 0.0 }, { 52655, -0.2987682, 0.0002878, -0.122915, 0.221760, 0.0, 0.0, 0.0, 0.0 }, { 52656, -0.2989957, 0.0001778, -0.124248, 0.224294, 0.0, 0.0, 0.0, 0.0 } }));
    EOPHistory eopHistory = FramesFactory.getEOPHistory(IERSConventions.IERS_1996, false);
    final AbsoluteDate t0 = new AbsoluteDate(new DateComponents(DateComponents.MODIFIED_JULIAN_EPOCH, 52654), TimeScalesFactory.getUTC());
    for (double[] row : new double[][] { { 0.0, -0.29839889612705234, -0.12191552977388567, 0.21921143351558756 }, { 3600.0, -0.29841696994736727, -0.12208276003864491, 0.21925416583607277 }, { 7200.0, -0.29843402412052122, -0.12218102086455683, 0.21930263880545320 }, { 43200.0, -0.29866785146390035, -0.12250027826538630, 0.22103779809979979 }, { 86400.0, -0.29874248853173840, -0.12308592577174847, 0.22161565557764881 } }) {
        AbsoluteDate date = t0.shiftedBy(row[0]);
        Assert.assertEquals(row[1], eopHistory.getUT1MinusUTC(date), 8.8e-11);
        Assert.assertEquals(row[2] * Constants.ARC_SECONDS_TO_RADIANS, eopHistory.getPoleCorrection(date).getXp(), 3.2e-14);
        Assert.assertEquals(row[3] * Constants.ARC_SECONDS_TO_RADIANS, eopHistory.getPoleCorrection(date).getYp(), 8.2e-15);
    }
}
Also used : DateComponents(org.orekit.time.DateComponents) EOPHistory(org.orekit.frames.EOPHistory) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 15 with DateComponents

use of org.orekit.time.DateComponents in project Orekit by CS-SI.

the class IERSConventionsTest method testTidalCorrection2003.

@Test
public void testTidalCorrection2003() throws OrekitException {
    // the reference value has been computed using the September 2007 version
    // of interp.f from ftp://hpiers.obspm.fr/iers/models/ adding input/output
    // parameters for LOD (which was already computed in the underlying routines),
    // with the following driver program:
    // 
    // PROGRAM OR_TEST
    // IMPLICIT NONE
    // INTEGER J, N
    // PARAMETER (N = 4)
    // INTEGER MJD(N)
    // DOUBLE PRECISION TTTAI, TAIUTC
    // PARAMETER (TAIUTC = 32.000D0)
    // PARAMETER (TTTAI  = 32.184D0)
    // DOUBLE PRECISION RJD(N), UT1(N), LOD(N), X(N), Y(N), H(5)
    // DOUBLE PRECISION RJD_INT, UT1_INT, LOD_INT, X_INT, Y_INT
    // DATA(MJD(J),   UT1(J),     LOD(J),      X(J),      Y(J),
    // &     J=1,4)/
    // &    52653, -0.2979055D0, 0.0005744D0, -0.120344D0, 0.217095D0,
    // &    52654, -0.2984238D0, 0.0004224D0, -0.121680D0, 0.219400D0,
    // &    52655, -0.2987682D0, 0.0002878D0, -0.122915D0, 0.221760D0,
    // &    52656, -0.2989957D0, 0.0001778D0, -0.124248D0, 0.224294D0/
    // C
    // DATA(H(J),J=1,5)/0.0D0, 3600.0D0, 7200.0D0, 43200.0D0, 86400.0D0/
    // C
    // DO 10 J = 1, N
    // RJD(J) = MJD(J) + (TTTAI + TAIUTC) / 86400.0D0
    // 10   CONTINUE
    // C
    // DO 20 J = 1, 5
    // RJD_INT = RJD(2) + H(J) / 86400.0D0
    // CALL INTERP(RJD,X,Y,UT1,LOD,N,
    // &                RJD_INT,X_INT,Y_INT,UT1_INT,LOD_INT)
    // WRITE(6, 30) H(J),UT1_INT,LOD_INT,X_INT,Y_INT
    // 20   CONTINUE
    // 30   FORMAT(F7.1,4(1X, F20.17))
    // C
    // END PROGRAM
    // 
    // the output of this test reads:
    // 0.0 -0.29840026968370659  0.00045312852893139 -0.12196223480123573  0.21922730818562719
    // 3600.0 -0.29841834564816189  0.00041710864863793 -0.12213345007640604  0.21927433626001305
    // 7200.0 -0.29843503870494986  0.00039207574457087 -0.12222881007999241  0.21932415788122142
    // 43200.0 -0.29866930257052676  0.00042895046506082 -0.12247697694276605  0.22105450666130921
    // 86400.0 -0.29874235341010519  0.00035460263868306 -0.12312252389660779  0.22161364352515728
    Utils.setLoaders(IERSConventions.IERS_2003, Utils.buildEOPList(IERSConventions.IERS_2003, ITRFVersion.ITRF_2008, new double[][] { { 52653, -0.2979055, 0.0005744, -0.120344, 0.217095, 0.0, 0.0, 0.0, 0.0 }, { 52654, -0.2984238, 0.0004224, -0.121680, 0.219400, 0.0, 0.0, 0.0, 0.0 }, { 52655, -0.2987682, 0.0002878, -0.122915, 0.221760, 0.0, 0.0, 0.0, 0.0 }, { 52656, -0.2989957, 0.0001778, -0.124248, 0.224294, 0.0, 0.0, 0.0, 0.0 } }));
    EOPHistory eopHistory = FramesFactory.getEOPHistory(IERSConventions.IERS_2003, false);
    final AbsoluteDate t0 = new AbsoluteDate(new DateComponents(DateComponents.MODIFIED_JULIAN_EPOCH, 52654), TimeScalesFactory.getUTC());
    for (double[] row : new double[][] { { 0.0, -0.29840026968370659, 0.00045312852893139, -0.12196223480123573, 0.21922730818562719 }, { 3600.0, -0.29841834564816189, 0.00041710864863793, -0.12213345007640604, 0.21927433626001305 }, { 7200.0, -0.29843503870494986, 0.00039207574457087, -0.12222881007999241, 0.21932415788122142 }, { 43200.0, -0.29866930257052676, 0.00042895046506082, -0.12247697694276605, 0.22105450666130921 }, { 86400.0, -0.29874235341010519, 0.00035460263868306, -0.12312252389660779, 0.22161364352515728 } }) {
        AbsoluteDate date = t0.shiftedBy(row[0]);
        Assert.assertEquals(row[1], eopHistory.getUT1MinusUTC(date), 4.3e-8);
        Assert.assertEquals(row[2], eopHistory.getLOD(date), 1.4e-7);
        Assert.assertEquals(row[3] * Constants.ARC_SECONDS_TO_RADIANS, eopHistory.getPoleCorrection(date).getXp(), 1.6e-10);
        Assert.assertEquals(row[4] * Constants.ARC_SECONDS_TO_RADIANS, eopHistory.getPoleCorrection(date).getYp(), 0.7e-10);
    }
}
Also used : DateComponents(org.orekit.time.DateComponents) EOPHistory(org.orekit.frames.EOPHistory) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Aggregations

DateComponents (org.orekit.time.DateComponents)148 AbsoluteDate (org.orekit.time.AbsoluteDate)129 Test (org.junit.Test)98 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)87 TimeComponents (org.orekit.time.TimeComponents)87 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)64 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)62 Orbit (org.orekit.orbits.Orbit)47 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)46 SpacecraftState (org.orekit.propagation.SpacecraftState)45 PVCoordinates (org.orekit.utils.PVCoordinates)40 CartesianOrbit (org.orekit.orbits.CartesianOrbit)37 OrekitException (org.orekit.errors.OrekitException)34 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)33 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)28 AbstractLegacyForceModelTest (org.orekit.forces.AbstractLegacyForceModelTest)28 CircularOrbit (org.orekit.orbits.CircularOrbit)25 EquinoctialOrbit (org.orekit.orbits.EquinoctialOrbit)25 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)23 Rotation (org.hipparchus.geometry.euclidean.threed.Rotation)22