Пример #1
0
  @Test
  public void testInterpolationAtEndOfValidity() throws OrekitException {
    double decimalYear = GeoMagneticField.getDecimalYear(1, 1, 2020);
    GeoMagneticField field = GeoMagneticFieldFactory.getIGRF(decimalYear);

    GeoMagneticElements e = field.calculateField(0, 0, 0);
    Assert.assertEquals(-4.7446, e.getDeclination(), 1.0e-4);
  }
Пример #2
0
  @Test
  public void testInterpolationYYY5() throws OrekitException {
    double decimalYear = GeoMagneticField.getDecimalYear(1, 1, 2005);
    GeoMagneticField field = GeoMagneticFieldFactory.getIGRF(decimalYear);
    GeoMagneticElements e = field.calculateField(1.2, 0.7, -2.5);
    Assert.assertEquals(-6.0032, e.getDeclination(), 1.0e-4);

    decimalYear = GeoMagneticField.getDecimalYear(2, 1, 2005);
    field = GeoMagneticFieldFactory.getIGRF(decimalYear);
    e = field.calculateField(1.2, 0.7, -2.5);
    Assert.assertEquals(-6.0029, e.getDeclination(), 1.0e-4);
  }
Пример #3
0
  @Test
  public void testWMM() throws Exception {
    // test values from sample coordinate file
    // provided as part of the geomag 7.0 distribution available at
    // http://www.ngdc.noaa.gov/IAGA/vmod/igrf.html
    // modification: the julian day calculation of geomag is slightly different
    // to the one from the WMM code, we use the WMM convention thus the outputs
    // have been adapted.
    runSampleFile(FieldModel.WMM, "sample_coords.txt", "sample_out_WMM2015.txt");

    final double eps = 1e-1;
    final double degreeEps = 1e-2;
    for (int i = 0; i < wmmTestValues.length; i++) {
      final GeoMagneticField model = GeoMagneticFieldFactory.getWMM(wmmTestValues[i][0]);
      final GeoMagneticElements result =
          model.calculateField(wmmTestValues[i][2], wmmTestValues[i][3], wmmTestValues[i][1]);

      // X
      Assert.assertEquals(wmmTestValues[i][4], result.getFieldVector().getX(), eps);
      // Y
      Assert.assertEquals(wmmTestValues[i][5], result.getFieldVector().getY(), eps);
      // Z
      Assert.assertEquals(wmmTestValues[i][6], result.getFieldVector().getZ(), eps);
      // H
      Assert.assertEquals(wmmTestValues[i][7], result.getHorizontalIntensity(), eps);
      // F
      Assert.assertEquals(wmmTestValues[i][8], result.getTotalIntensity(), eps);
      // inclination
      Assert.assertEquals(wmmTestValues[i][9], result.getInclination(), degreeEps);
      // declination
      Assert.assertEquals(wmmTestValues[i][10], result.getDeclination(), degreeEps);
    }
  }
Пример #4
0
  @Test
  public void testInterpolationAtEndOfEpoch() throws OrekitException {
    double decimalYear = GeoMagneticField.getDecimalYear(31, 12, 2009);
    GeoMagneticField field1 = GeoMagneticFieldFactory.getIGRF(decimalYear);
    GeoMagneticField field2 = GeoMagneticFieldFactory.getIGRF(2010.0);

    Assert.assertNotEquals(field1.getEpoch(), field2.getEpoch());

    GeoMagneticElements e1 = field1.calculateField(0, 0, 0);
    Assert.assertEquals(-6.1068, e1.getDeclination(), 1.0e-4);

    GeoMagneticElements e2 = field2.calculateField(0, 0, 0);
    Assert.assertEquals(-6.1064, e2.getDeclination(), 1.0e-4);
  }
Пример #5
0
  public void runSampleFile(final FieldModel type, final String inputFile, final String outputFile)
      throws Exception {

    final BufferedReader inReader =
        new BufferedReader(new InputStreamReader(getResource(inputFile)));
    final BufferedReader outReader =
        new BufferedReader(new InputStreamReader(getResource(outputFile)));

    // read header line
    outReader.readLine();

    String line = null;
    while ((line = inReader.readLine()) != null) {
      if (line.trim().length() == 0) {
        break;
      }

      final StringTokenizer st = new StringTokenizer(line);

      final double year = getYear(st.nextToken());
      final String heightType = st.nextToken();
      final String heightStr = st.nextToken();
      final double lat = getLatLon(st.nextToken());
      final double lon = getLatLon(st.nextToken());

      final GeoMagneticField field = GeoMagneticFieldFactory.getField(type, year);

      double height = Double.valueOf(heightStr.substring(1));
      if (heightStr.startsWith("M")) {
        // convert from m to km
        height /= 1000d;
      } else if (heightStr.startsWith("F")) {
        // convert from feet to km
        height *= 3.048e-4;
      }

      final GeoMagneticElements ge = field.calculateField(lat, lon, height);
      final String validateLine = outReader.readLine();
      // geocentric altitude is not yet supported, ignore by now
      if (!heightType.startsWith("C")) {
        validate(ge, validateLine);
      }

      String geString = ge.toString();
      Assert.assertNotNull(geString);
      Assert.assertFalse(geString.isEmpty());
    }
  }
Пример #6
0
  @SuppressWarnings("unused")
  private void validate(final GeoMagneticElements ge, final String outputLine) throws Exception {

    final StringTokenizer st = new StringTokenizer(outputLine);

    final double year = getYear(st.nextToken());

    final String coord = st.nextToken();
    final String heightStr = st.nextToken();
    final String latStr = st.nextToken();
    final String lonStr = st.nextToken();

    final double dec = getDegree(st.nextToken(), st.nextToken());
    final double inc = getDegree(st.nextToken(), st.nextToken());

    final double h = Double.valueOf(st.nextToken());
    final double x = Double.valueOf(st.nextToken());
    final double y = Double.valueOf(st.nextToken());
    final double z = Double.valueOf(st.nextToken());
    final double f = Double.valueOf(st.nextToken());

    final double eps = 1e-1;
    Assert.assertEquals(h, ge.getHorizontalIntensity(), eps);
    Assert.assertEquals(f, ge.getTotalIntensity(), eps);
    Assert.assertEquals(x, ge.getFieldVector().getX(), eps);
    Assert.assertEquals(y, ge.getFieldVector().getY(), eps);
    Assert.assertEquals(z, ge.getFieldVector().getZ(), eps);
    Assert.assertEquals(dec, ge.getDeclination(), eps);
    Assert.assertEquals(inc, ge.getInclination(), eps);
  }
Пример #7
0
  @Test
  public void testWMMWithHeightAboveMSL() throws Exception {
    // test results for test values provided as part of the WMM2015 Report
    // using height above MSL instead of height above ellipsoid
    // the results have been obtained from the NOAA online calculator:
    // http://www.ngdc.noaa.gov/geomag-web/#igrfwmm
    final double[][] testValues = {
      // Date  Alt  Lat  Lon        X        Y         Z        H        F       I      D
      //        km  deg  deg       nT       nT        nT       nT       nT     deg    deg
      {2015.0, 100, 80, 0, 6314.2, -471.6, 52269.1, 6331.8, 52651.2, 83.093, -4.271},
      {2015.0, 100, 0, 120, 37534.4, 364.3, -10773.1, 37536.2, 39051.6, -16.013, 0.556},
      {2015.0, 100, -80, 240, 5613.2, 14791.9, -50379.6, 15821.1, 52805.4, -72.565, 69.219}
    };

    final Geoid geoid = new Geoid(potential, WGS84);

    final double eps = 1e-1;
    final double degreeEps = 1e-2;
    for (int i = 0; i < testValues.length; i++) {
      final AbsoluteDate date = new AbsoluteDate(2015, 1, 1, TimeScalesFactory.getUTC());
      final GeoMagneticField model = GeoMagneticFieldFactory.getWMM(testValues[i][0]);
      final double undulation =
          geoid.getUndulation(
              FastMath.toRadians(testValues[i][2]), FastMath.toRadians(testValues[i][3]), date);
      final GeoMagneticElements result =
          model.calculateField(
              testValues[i][2], testValues[i][3], testValues[i][1] + undulation / 1000d);

      // X
      Assert.assertEquals(testValues[i][4], result.getFieldVector().getX(), eps);
      // Y
      Assert.assertEquals(testValues[i][5], result.getFieldVector().getY(), eps);
      // Z
      Assert.assertEquals(testValues[i][6], result.getFieldVector().getZ(), eps);
      // H
      Assert.assertEquals(testValues[i][7], result.getHorizontalIntensity(), eps);
      // F
      Assert.assertEquals(testValues[i][8], result.getTotalIntensity(), eps);
      // inclination
      Assert.assertEquals(testValues[i][9], result.getInclination(), degreeEps);
      // declination
      Assert.assertEquals(testValues[i][10], result.getDeclination(), degreeEps);
    }
  }
Пример #8
0
  @Test
  public void testLoadOriginalWMMModel() throws Exception {
    GeoMagneticModelLoader loader = new GeoMagneticModelLoader();

    InputStream input = getResource("WMM2015.COF");
    loader.loadData(input, "WMM2015.COF");

    Collection<GeoMagneticField> models = loader.getModels();
    Assert.assertNotNull(models);
    Assert.assertEquals(1, models.size());

    GeoMagneticField wmmModel = models.iterator().next();
    Assert.assertEquals("WMM-2015", wmmModel.getModelName());
    Assert.assertEquals(2015, wmmModel.getEpoch(), 1e-9);

    final double eps = 1e-1;
    final double degreeEps = 1e-2;
    for (int i = 0; i < wmmTestValues.length; i++) {
      if (wmmTestValues[i][0] != wmmModel.getEpoch()) {
        continue;
      }
      final GeoMagneticElements result =
          wmmModel.calculateField(wmmTestValues[i][2], wmmTestValues[i][3], wmmTestValues[i][1]);

      // X
      Assert.assertEquals(wmmTestValues[i][4], result.getFieldVector().getX(), eps);
      // Y
      Assert.assertEquals(wmmTestValues[i][5], result.getFieldVector().getY(), eps);
      // Z
      Assert.assertEquals(wmmTestValues[i][6], result.getFieldVector().getZ(), eps);
      // H
      Assert.assertEquals(wmmTestValues[i][7], result.getHorizontalIntensity(), eps);
      // F
      Assert.assertEquals(wmmTestValues[i][8], result.getTotalIntensity(), eps);
      // inclination
      Assert.assertEquals(wmmTestValues[i][9], result.getInclination(), degreeEps);
      // declination
      Assert.assertEquals(wmmTestValues[i][10], result.getDeclination(), degreeEps);
    }
  }