Search in sources :

Example 81 with AbsoluteDate

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

the class PoissonSeriesParserTest method testCompile.

@Test
public void testCompile() throws OrekitException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
    String directory = "/assets/org/orekit/IERS-conventions/";
    PoissonSeriesParser parser = new PoissonSeriesParser(17).withPolynomialPart('t', PolynomialParser.Unit.NO_UNITS).withFirstDelaunay(4).withFirstPlanetary(9).withSinCos(0, 2, 1.0, 3, 1.0);
    InputStream xStream = getClass().getResourceAsStream(directory + "2010/tab5.2a.txt");
    PoissonSeries xSeries = parser.parse(xStream, "2010/tab5.2a.txt");
    InputStream yStream = getClass().getResourceAsStream(directory + "2010/tab5.2b.txt");
    PoissonSeries ySeries = parser.parse(yStream, "2010/tab5.2b.txt");
    InputStream zStream = getClass().getResourceAsStream(directory + "2010/tab5.2d.txt");
    PoissonSeries sSeries = parser.parse(zStream, "2010/tab5.2d.txt");
    PoissonSeries.CompiledSeries xysSeries = PoissonSeries.compile(xSeries, ySeries, sSeries);
    Method m = IERSConventions.class.getDeclaredMethod("getNutationArguments", TimeScale.class);
    m.setAccessible(true);
    FundamentalNutationArguments arguments = (FundamentalNutationArguments) m.invoke(IERSConventions.IERS_2010, (TimeScale) null);
    for (double dt = 0; dt < Constants.JULIAN_YEAR; dt += Constants.JULIAN_DAY) {
        AbsoluteDate date = AbsoluteDate.J2000_EPOCH.shiftedBy(dt);
        BodiesElements elements = arguments.evaluateAll(date);
        double x = xSeries.value(elements);
        double y = ySeries.value(elements);
        double s = sSeries.value(elements);
        double[] xys = xysSeries.value(elements);
        Assert.assertEquals(x, xys[0], 1.0e-15 * FastMath.abs(x));
        Assert.assertEquals(y, xys[1], 1.0e-15 * FastMath.abs(y));
        Assert.assertEquals(s, xys[2], 1.0e-15 * FastMath.abs(s));
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Method(java.lang.reflect.Method) TimeScale(org.orekit.time.TimeScale) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 82 with AbsoluteDate

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

the class JB2008 method getDensity.

/**
 * {@inheritDoc}
 */
@Override
public <T extends RealFieldElement<T>> T getDensity(final FieldAbsoluteDate<T> date, final FieldVector3D<T> position, final Frame frame) throws OrekitException {
    // check if data are available :
    final AbsoluteDate dateD = date.toAbsoluteDate();
    if ((dateD.compareTo(inputParams.getMaxDate()) > 0) || (dateD.compareTo(inputParams.getMinDate()) < 0)) {
        throw new OrekitException(OrekitMessages.NO_SOLAR_ACTIVITY_AT_DATE, dateD, inputParams.getMinDate(), inputParams.getMaxDate());
    }
    // compute MJD date
    final T dateMJD = date.durationFrom(AbsoluteDate.MODIFIED_JULIAN_EPOCH).divide(Constants.JULIAN_DAY);
    // compute geodetic position (km and °)
    final FieldGeodeticPoint<T> inBody = earth.transform(position, frame, date);
    // compute sun position
    final Frame ecef = earth.getBodyFrame();
    final FieldVector3D<T> sunPos = new FieldVector3D<>(date.getField(), sun.getPVCoordinates(dateD, ecef).getPosition());
    final FieldGeodeticPoint<T> sunInBody = earth.transform(sunPos, ecef, date);
    return getDensity(dateMJD, sunInBody.getLongitude(), sunInBody.getLatitude(), inBody.getLongitude(), inBody.getLatitude(), inBody.getAltitude(), inputParams.getF10(dateD), inputParams.getF10B(dateD), inputParams.getS10(dateD), inputParams.getS10B(dateD), inputParams.getXM10(dateD), inputParams.getXM10B(dateD), inputParams.getY10(dateD), inputParams.getY10B(dateD), inputParams.getDSTDTC(dateD));
}
Also used : Frame(org.orekit.frames.Frame) OrekitException(org.orekit.errors.OrekitException) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate)

Example 83 with AbsoluteDate

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

the class DragForce method acceleration.

/**
 * {@inheritDoc}
 */
@Override
public Vector3D acceleration(final SpacecraftState s, final double[] parameters) throws OrekitException {
    final AbsoluteDate date = s.getDate();
    final Frame frame = s.getFrame();
    final Vector3D position = s.getPVCoordinates().getPosition();
    final double rho = atmosphere.getDensity(date, position, frame);
    final Vector3D vAtm = atmosphere.getVelocity(date, position, frame);
    final Vector3D relativeVelocity = vAtm.subtract(s.getPVCoordinates().getVelocity());
    return spacecraft.dragAcceleration(date, frame, position, s.getAttitude().getRotation(), s.getMass(), rho, relativeVelocity, parameters);
}
Also used : Frame(org.orekit.frames.Frame) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate)

Example 84 with AbsoluteDate

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

the class DTM2000 method getDensity.

/**
 * {@inheritDoc}
 */
@Override
public <T extends RealFieldElement<T>> T getDensity(final FieldAbsoluteDate<T> date, final FieldVector3D<T> position, final Frame frame) throws OrekitException {
    // check if data are available :
    final AbsoluteDate dateD = date.toAbsoluteDate();
    if ((dateD.compareTo(inputParams.getMaxDate()) > 0) || (dateD.compareTo(inputParams.getMinDate()) < 0)) {
        throw new OrekitException(OrekitMessages.NO_SOLAR_ACTIVITY_AT_DATE, dateD, inputParams.getMinDate(), inputParams.getMaxDate());
    }
    // compute day number in current year
    final Calendar cal = new GregorianCalendar();
    cal.setTime(date.toDate(TimeScalesFactory.getUTC()));
    final int day = cal.get(Calendar.DAY_OF_YEAR);
    // position in ECEF so we only have to do the transform once
    final Frame ecef = earth.getBodyFrame();
    final FieldVector3D<T> pEcef = frame.getTransformTo(ecef, date).transformPosition(position);
    // compute geodetic position
    final FieldGeodeticPoint<T> inBody = earth.transform(pEcef, ecef, date);
    final T alti = inBody.getAltitude();
    final T lon = inBody.getLongitude();
    final T lat = inBody.getLatitude();
    // compute local solar time
    final Vector3D sunPos = sun.getPVCoordinates(dateD, ecef).getPosition();
    final T y = pEcef.getY().multiply(sunPos.getX()).subtract(pEcef.getX().multiply(sunPos.getY()));
    final T x = pEcef.getX().multiply(sunPos.getX()).add(pEcef.getY().multiply(sunPos.getY()));
    final T hl = y.atan2(x).add(FastMath.PI);
    // get current solar activity data and compute
    return getDensity(day, alti, lon, lat, hl, inputParams.getInstantFlux(dateD), inputParams.getMeanFlux(dateD), inputParams.getThreeHourlyKP(dateD), inputParams.get24HoursKp(dateD));
}
Also used : Frame(org.orekit.frames.Frame) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) OrekitException(org.orekit.errors.OrekitException) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) GeodeticPoint(org.orekit.bodies.GeodeticPoint) FieldGeodeticPoint(org.orekit.bodies.FieldGeodeticPoint)

Example 85 with AbsoluteDate

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

the class MarshallSolarActivityFutureEstimation method get24HoursKp.

/**
 * The Kp index is derived from the Ap index.
 * <p>The method used is explained on <a
 * href="http://www.ngdc.noaa.gov/stp/GEOMAG/kp_ap.html">
 * NOAA website.</a> as follows:</p>
 * <p>The scale is 0 to 9 expressed in thirds of a unit, e.g. 5- is 4 2/3,
 * 5 is 5 and 5+ is 5 1/3. The ap (equivalent range) index is derived from
 * the Kp index as follows:</p>
 * <table border="1">
 * <caption>Kp / Ap Conversion Table</caption>
 * <tbody>
 * <tr>
 * <td>Kp</td><td>0o</td><td>0+</td><td>1-</td><td>1o</td><td>1+</td><td>2-</td><td>2o</td><td>2+</td><td>3-</td><td>3o</td><td>3+</td><td>4-</td><td>4o</td><td>4+</td>
 * </tr>
 * <tr>
 * <td>ap</td><td>0</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>9</td><td>12</td><td>15</td><td>18</td><td>22</td><td>27</td><td>32</td>
 * </tr>
 * <tr>
 * <td>Kp</td><td>5-</td><td>5o</td><td>5+</td><td>6-</td><td>6o</td><td>6+</td><td>7-</td><td>7o</td><td>7+</td><td>8-</td><td>8o</td><td>8+</td><td>9-</td><td>9o</td>
 * </tr>
 * <tr>
 * <td>ap</td><td>39</td><td>48</td><td>56</td><td>67</td><td>80</td><td>94</td><td>111</td><td>132</td><td>154</td><td>179</td><td>207</td><td>236</td><td>300</td><td>400</td>
 * </tr>
 * </tbody>
 * </table>
 * @param date date of the Kp data
 * @return the 24H geomagnetic index
 * @exception OrekitException if the date is out of range of available data
 */
public double get24HoursKp(final AbsoluteDate date) throws OrekitException {
    // get the neighboring dates
    bracketDate(date);
    // perform a linear interpolation
    final AbsoluteDate previousDate = previousParam.getDate();
    final AbsoluteDate currentDate = currentParam.getDate();
    final double dt = currentDate.durationFrom(previousDate);
    final double previousAp = previousParam.getAp();
    final double currentAp = currentParam.getAp();
    final double previousWeight = currentDate.durationFrom(date) / dt;
    final double currentWeight = date.durationFrom(previousDate) / dt;
    final double ap = previousAp * previousWeight + currentAp * currentWeight;
    // equation 4 in [1] for Ap to Kp conversion
    return 1.89 * FastMath.asinh(0.154 * ap);
}
Also used : AbsoluteDate(org.orekit.time.AbsoluteDate)

Aggregations

AbsoluteDate (org.orekit.time.AbsoluteDate)840 Test (org.junit.Test)632 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)321 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)283 SpacecraftState (org.orekit.propagation.SpacecraftState)279 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)204 PVCoordinates (org.orekit.utils.PVCoordinates)193 Orbit (org.orekit.orbits.Orbit)157 Frame (org.orekit.frames.Frame)152 OrekitException (org.orekit.errors.OrekitException)141 DateComponents (org.orekit.time.DateComponents)134 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)106 CartesianOrbit (org.orekit.orbits.CartesianOrbit)104 EquinoctialOrbit (org.orekit.orbits.EquinoctialOrbit)97 ArrayList (java.util.ArrayList)96 Propagator (org.orekit.propagation.Propagator)90 TimeScale (org.orekit.time.TimeScale)90 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)88 TimeComponents (org.orekit.time.TimeComponents)88 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)87