Search in sources :

Example 66 with OrekitException

use of org.orekit.errors.OrekitException in project Orekit by CS-SI.

the class Geoid method transform.

/**
 * {@inheritDoc}
 *
 * @param point The surface relative point to transform. Altitude is
 *              orthometric height, that is height above the {@link Geoid}.
 *              Latitude and longitude are both geodetic and defined with
 *              respect to the {@link #getEllipsoid() reference ellipsoid}.
 * @param <T> type of the field elements
 * @return point at the same location but as a Cartesian point in the {@link
 * #getBodyFrame() body frame}.
 * @see #transform(Vector3D, Frame, AbsoluteDate)
 * @since 9.0
 */
@Override
public <T extends RealFieldElement<T>> FieldVector3D<T> transform(final FieldGeodeticPoint<T> point) {
    try {
        // convert orthometric height to height above ellipsoid using undulation
        // TODO pass in date to allow user to specify
        final double undulation = this.getUndulation(point.getLatitude().getReal(), point.getLongitude().getReal(), this.defaultDate);
        final FieldGeodeticPoint<T> ellipsoidal = new FieldGeodeticPoint<>(point.getLatitude(), point.getLongitude(), point.getAltitude().add(undulation));
        // transform using reference ellipsoid
        return this.getEllipsoid().transform(ellipsoidal);
    } catch (OrekitException e) {
        // an OrekitException, so wrap in an exception we can throw.
        throw new RuntimeException(e);
    }
}
Also used : FieldGeodeticPoint(org.orekit.bodies.FieldGeodeticPoint) MathRuntimeException(org.hipparchus.exception.MathRuntimeException) OrekitException(org.orekit.errors.OrekitException)

Example 67 with OrekitException

use of org.orekit.errors.OrekitException in project Orekit by CS-SI.

the class KlobucharIonoCoefficientsLoader method loadData.

/**
 * Load Klobuchar-Style ionospheric coefficients read from some file.
 * @param input data input stream
 * @param name name of the file (or zip entry)
 * @exception IOException if data can't be read
 * @exception ParseException if data can't be parsed
 * @exception OrekitException if some data is missing
 * or if some loader specific error occurs
 */
public void loadData(final InputStream input, final String name) throws IOException, ParseException, OrekitException {
    // Open stream and parse data
    final BufferedReader br = new BufferedReader(new InputStreamReader(input, "UTF-8"));
    int lineNumber = 0;
    final String splitter = "\\s+";
    for (String line = br.readLine(); line != null; line = br.readLine()) {
        ++lineNumber;
        line = line.trim();
        try {
            // Read alphas
            if (line.length() > 0 && line.endsWith("ALPHA")) {
                final String[] alpha_line = line.split(splitter);
                alpha = new double[4];
                for (int j = 0; j < 4; j++) {
                    alpha[j] = Double.valueOf(alpha_line[j].replace("D", "E"));
                }
            }
            // Read betas
            if (line.length() > 0 && line.endsWith("BETA")) {
                final String[] beta_line = line.split(splitter);
                beta = new double[4];
                for (int j = 0; j < 4; j++) {
                    beta[j] = Double.valueOf(beta_line[j].replace("D", "E"));
                }
            }
        } catch (NumberFormatException nfe) {
            throw new OrekitException(OrekitMessages.UNABLE_TO_PARSE_LINE_IN_FILE, lineNumber, name, line);
        }
    }
    // Check that alphas and betas were found
    if (alpha == null || beta == null) {
        throw new OrekitException(OrekitMessages.NO_KLOBUCHAR_ALPHA_BETA_IN_FILE, name);
    }
    // Close the stream after reading
    input.close();
}
Also used : InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) OrekitException(org.orekit.errors.OrekitException)

Example 68 with OrekitException

use of org.orekit.errors.OrekitException in project Orekit by CS-SI.

the class IsotropicRadiationCNES95Convention method radiationPressureAcceleration.

/**
 * {@inheritDoc}
 */
@Override
public FieldVector3D<DerivativeStructure> radiationPressureAcceleration(final AbsoluteDate date, final Frame frame, final Vector3D position, final Rotation rotation, final double mass, final Vector3D flux, final double[] parameters, final String paramName) throws OrekitException {
    final DerivativeStructure absorptionCoeffDS;
    final DerivativeStructure specularReflectionCoeffDS;
    if (ABSORPTION_COEFFICIENT.equals(paramName)) {
        absorptionCoeffDS = factory.variable(0, parameters[0]);
        specularReflectionCoeffDS = factory.constant(parameters[1]);
    } else if (REFLECTION_COEFFICIENT.equals(paramName)) {
        absorptionCoeffDS = factory.constant(parameters[0]);
        specularReflectionCoeffDS = factory.variable(0, parameters[1]);
    } else {
        throw new OrekitException(OrekitMessages.UNSUPPORTED_PARAMETER_NAME, paramName, ABSORPTION_COEFFICIENT + ", " + REFLECTION_COEFFICIENT);
    }
    final DerivativeStructure kP = absorptionCoeffDS.subtract(1).multiply(specularReflectionCoeffDS.subtract(1)).multiply(4.0 / 9.0).add(1).multiply(crossSection);
    return new FieldVector3D<>(kP.divide(mass), flux);
}
Also used : DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) OrekitException(org.orekit.errors.OrekitException) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D)

Example 69 with OrekitException

use of org.orekit.errors.OrekitException in project Orekit by CS-SI.

the class SolarRadiationPressure method getEclipseAngles.

/**
 * Get the useful angles for eclipse computation.
 * @param sunPosition Sun position in the selected frame
 * @param position the satellite's position in the selected frame
 * @return the 3 angles {(satCentral, satSun), Central body apparent radius, Sun apparent radius}
 * @exception OrekitException if the trajectory is inside the central body
 */
private double[] getEclipseAngles(final Vector3D sunPosition, final Vector3D position) throws OrekitException {
    final double[] angle = new double[3];
    final Vector3D satSunVector = sunPosition.subtract(position);
    // Sat-Sun / Sat-CentralBody angle
    angle[0] = Vector3D.angle(satSunVector, position.negate());
    // Central body apparent radius
    final double r = position.getNorm();
    if (r <= equatorialRadius) {
        throw new OrekitException(OrekitMessages.TRAJECTORY_INSIDE_BRILLOUIN_SPHERE, r);
    }
    angle[1] = FastMath.asin(equatorialRadius / r);
    // Sun apparent radius
    angle[2] = FastMath.asin(Constants.SUN_RADIUS / satSunVector.getNorm());
    return angle;
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) OrekitException(org.orekit.errors.OrekitException)

Example 70 with OrekitException

use of org.orekit.errors.OrekitException in project Orekit by CS-SI.

the class GeoMagneticField method transformModel.

/**
 * Time transform the model coefficients from the base year of the model
 * using a linear interpolation with a second model. The second model is
 * required to have an adjacent validity period.
 * @param otherModel the other magnetic field model
 * @param year the year to which the model shall be transformed
 * @return a time-transformed magnetic field model
 * @throws OrekitException if the specified year is outside the validity period of the
 *                         model or the model does not support time transformations
 *                         (i.e. no secular variations available)
 */
public GeoMagneticField transformModel(final GeoMagneticField otherModel, final double year) throws OrekitException {
    // the model can only be transformed within its validity period
    if (year < validityStart || year > validityEnd) {
        throw new OrekitException(OrekitMessages.OUT_OF_RANGE_TIME_TRANSFORM, modelName, String.valueOf(epoch), year, validityStart, validityEnd);
    }
    final double factor = (year - epoch) / (otherModel.epoch - epoch);
    final int maxNCommon = FastMath.min(maxN, otherModel.maxN);
    final int maxNCommonIndex = maxNCommon * (maxNCommon + 1) / 2 + maxNCommon;
    final int newMaxN = FastMath.max(maxN, otherModel.maxN);
    final GeoMagneticField transformed = new GeoMagneticField(modelName, year, newMaxN, 0, validityStart, validityEnd);
    for (int n = 1; n <= newMaxN; n++) {
        for (int m = 0; m <= n; m++) {
            final int index = n * (n + 1) / 2 + m;
            if (index <= maxNCommonIndex) {
                transformed.h[index] = h[index] + factor * (otherModel.h[index] - h[index]);
                transformed.g[index] = g[index] + factor * (otherModel.g[index] - g[index]);
            } else {
                if (maxN < otherModel.maxN) {
                    transformed.h[index] = factor * otherModel.h[index];
                    transformed.g[index] = factor * otherModel.g[index];
                } else {
                    transformed.h[index] = h[index] + factor * -h[index];
                    transformed.g[index] = g[index] + factor * -g[index];
                }
            }
        }
    }
    return transformed;
}
Also used : OrekitException(org.orekit.errors.OrekitException) GeodeticPoint(org.orekit.bodies.GeodeticPoint)

Aggregations

OrekitException (org.orekit.errors.OrekitException)332 AbsoluteDate (org.orekit.time.AbsoluteDate)150 Test (org.junit.Test)135 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)91 SpacecraftState (org.orekit.propagation.SpacecraftState)75 Frame (org.orekit.frames.Frame)62 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)59 ArrayList (java.util.ArrayList)48 Before (org.junit.Before)48 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)42 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)42 DateComponents (org.orekit.time.DateComponents)42 GeodeticPoint (org.orekit.bodies.GeodeticPoint)41 Orbit (org.orekit.orbits.Orbit)40 PVCoordinates (org.orekit.utils.PVCoordinates)37 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)36 IOException (java.io.IOException)32 InputStream (java.io.InputStream)31 Propagator (org.orekit.propagation.Propagator)30 UnivariateFunction (org.hipparchus.analysis.UnivariateFunction)28