Search in sources :

Example 1 with StreamingStatistics

use of org.hipparchus.stat.descriptive.StreamingStatistics in project Orekit by CS-SI.

the class DOPComputation method run.

private void run(final OneAxisEllipsoid shape, final List<GeodeticPoint> zone, final double meshSize, final double minElevation, final AbsoluteDate tStart, final AbsoluteDate tStop, final double tStep) throws IOException, OrekitException, ParseException {
    // Gets the GPS almanacs from the SEM file
    final SEMParser reader = new SEMParser(null);
    reader.loadData();
    final List<GPSAlmanac> almanacs = reader.getAlmanacs();
    // Creates the GPS propagators from the almanacs
    final List<Propagator> propagators = new ArrayList<Propagator>();
    for (GPSAlmanac almanac : almanacs) {
        // Only keeps almanac with health status ok
        if (almanac.getHealth() == 0) {
            propagators.add(new GPSPropagator.Builder(almanac).build());
        } else {
            System.out.println("GPS PRN " + almanac.getPRN() + " is not OK (Health status = " + almanac.getHealth() + ").");
        }
    }
    // Meshes the area of interest into a grid of geodetic points.
    final List<List<GeodeticPoint>> points = sample(shape, zone, meshSize);
    // Creates the DOP computers for all the locations of the sampled geographic zone
    final List<DOPComputer> computers = new ArrayList<DOPComputer>();
    for (List<GeodeticPoint> row : points) {
        for (GeodeticPoint point : row) {
            computers.add(DOPComputer.create(shape, point).withMinElevation(minElevation));
        }
    }
    // Computes the DOP for each point over the period
    final List<List<DOP>> allDop = new ArrayList<List<DOP>>();
    // Loops on the period
    AbsoluteDate tc = tStart;
    while (tc.compareTo(tStop) != 1) {
        // Loops on the grid points
        final List<DOP> dopAtDate = new ArrayList<DOP>();
        for (DOPComputer computer : computers) {
            try {
                final DOP dop = computer.compute(tc, propagators);
                dopAtDate.add(dop);
            } catch (OrekitException oe) {
                System.out.println(oe.getLocalizedMessage());
            }
        }
        allDop.add(dopAtDate);
        tc = tc.shiftedBy(tStep);
    }
    // Post-processing: gets the statistics of PDOP over the zone at each time
    System.out.println("                           PDOP");
    System.out.println("          Date           min  max");
    for (List<DOP> dopAtDate : allDop) {
        final StreamingStatistics pDoP = new StreamingStatistics();
        for (DOP dopAtLoc : dopAtDate) {
            pDoP.addValue(dopAtLoc.getPdop());
        }
        final AbsoluteDate date = dopAtDate.get(0).getDate();
        System.out.format(Locale.ENGLISH, "%s %.2f %.2f%n", date.toString(), pDoP.getMin(), pDoP.getMax());
    }
}
Also used : DOP(org.orekit.gnss.DOP) StreamingStatistics(org.hipparchus.stat.descriptive.StreamingStatistics) ArrayList(java.util.ArrayList) SEMParser(org.orekit.gnss.SEMParser) AbsoluteDate(org.orekit.time.AbsoluteDate) DOPComputer(org.orekit.gnss.DOPComputer) GPSAlmanac(org.orekit.gnss.GPSAlmanac) Propagator(org.orekit.propagation.Propagator) GPSPropagator(org.orekit.propagation.analytical.gnss.GPSPropagator) ArrayList(java.util.ArrayList) List(java.util.List) OrekitException(org.orekit.errors.OrekitException) GeodeticPoint(org.orekit.bodies.GeodeticPoint)

Example 2 with StreamingStatistics

use of org.hipparchus.stat.descriptive.StreamingStatistics in project Orekit by CS-SI.

the class SolidTidesFieldTest method testInterpolationAccuracy.

@Test
public void testInterpolationAccuracy() throws OrekitException {
    // The shortest periods are slightly below one half day for the tidal waves
    // considered here. This implies the sampling rate should be fast enough.
    // The tuning parameters we have finally settled correspond to a two hours
    // sample containing 12 points (i.e. one new point is computed every 10 minutes).
    // The observed relative interpolation error with these settings are essentially
    // due to Runge phenomenon at points sampling rate. Plotting the errors shows
    // singular peaks pointing out of merely numerical noise.
    final IERSConventions conventions = IERSConventions.IERS_2010;
    Frame itrf = FramesFactory.getITRF(conventions, true);
    TimeScale utc = TimeScalesFactory.getUTC();
    UT1Scale ut1 = TimeScalesFactory.getUT1(conventions, true);
    NormalizedSphericalHarmonicsProvider gravityField = GravityFieldFactory.getConstantNormalizedProvider(5, 5);
    SolidTidesField raw = new SolidTidesField(conventions.getLoveNumbers(), conventions.getTideFrequencyDependenceFunction(ut1), conventions.getPermanentTide(), conventions.getSolidPoleTide(ut1.getEOPHistory()), itrf, gravityField.getAe(), gravityField.getMu(), gravityField.getTideSystem(), CelestialBodyFactory.getSun(), CelestialBodyFactory.getMoon());
    int step = 600;
    int nbPoints = 12;
    CachedNormalizedSphericalHarmonicsProvider interpolated = new CachedNormalizedSphericalHarmonicsProvider(raw, step, nbPoints, OrekitConfiguration.getCacheSlotsNumber(), 7 * Constants.JULIAN_DAY, 0.5 * Constants.JULIAN_DAY);
    // the following time range is located around the maximal observed error
    AbsoluteDate start = new AbsoluteDate(2003, 6, 12, utc);
    AbsoluteDate end = start.shiftedBy(3 * Constants.JULIAN_DAY);
    StreamingStatistics stat = new StreamingStatistics();
    for (AbsoluteDate date = start; date.compareTo(end) < 0; date = date.shiftedBy(60)) {
        NormalizedSphericalHarmonics rawHarmonics = raw.onDate(date);
        NormalizedSphericalHarmonics interpolatedHarmonics = interpolated.onDate(date);
        for (int n = 2; n < 5; ++n) {
            for (int m = 0; m <= n; ++m) {
                if (n < 4 || m < 3) {
                    double cnmRaw = rawHarmonics.getNormalizedCnm(n, m);
                    double cnmInterp = interpolatedHarmonics.getNormalizedCnm(n, m);
                    double errorC = (cnmInterp - cnmRaw) / FastMath.abs(cnmRaw);
                    stat.addValue(errorC);
                    if (m > 0) {
                        double snmRaw = rawHarmonics.getNormalizedSnm(n, m);
                        double snmInterp = interpolatedHarmonics.getNormalizedSnm(n, m);
                        double errorS = (snmInterp - snmRaw) / FastMath.abs(snmRaw);
                        stat.addValue(errorS);
                    }
                }
            }
        }
    }
    Assert.assertEquals(0.0, stat.getMean(), 2.0e-12);
    Assert.assertTrue(stat.getStandardDeviation() < 2.0e-9);
    Assert.assertTrue(stat.getMin() > -9.0e-8);
    Assert.assertTrue(stat.getMax() < 2.2e-7);
}
Also used : Frame(org.orekit.frames.Frame) UT1Scale(org.orekit.time.UT1Scale) StreamingStatistics(org.hipparchus.stat.descriptive.StreamingStatistics) IERSConventions(org.orekit.utils.IERSConventions) NormalizedSphericalHarmonics(org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider.NormalizedSphericalHarmonics) CachedNormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.CachedNormalizedSphericalHarmonicsProvider) NormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider) CachedNormalizedSphericalHarmonicsProvider(org.orekit.forces.gravity.potential.CachedNormalizedSphericalHarmonicsProvider) TimeScale(org.orekit.time.TimeScale) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Aggregations

StreamingStatistics (org.hipparchus.stat.descriptive.StreamingStatistics)2 AbsoluteDate (org.orekit.time.AbsoluteDate)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Test (org.junit.Test)1 GeodeticPoint (org.orekit.bodies.GeodeticPoint)1 OrekitException (org.orekit.errors.OrekitException)1 CachedNormalizedSphericalHarmonicsProvider (org.orekit.forces.gravity.potential.CachedNormalizedSphericalHarmonicsProvider)1 NormalizedSphericalHarmonicsProvider (org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider)1 NormalizedSphericalHarmonics (org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider.NormalizedSphericalHarmonics)1 Frame (org.orekit.frames.Frame)1 DOP (org.orekit.gnss.DOP)1 DOPComputer (org.orekit.gnss.DOPComputer)1 GPSAlmanac (org.orekit.gnss.GPSAlmanac)1 SEMParser (org.orekit.gnss.SEMParser)1 Propagator (org.orekit.propagation.Propagator)1 GPSPropagator (org.orekit.propagation.analytical.gnss.GPSPropagator)1 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)1 TimeScale (org.orekit.time.TimeScale)1 UT1Scale (org.orekit.time.UT1Scale)1