Example #1
0
  @Test(expected = OrekitException.class)
  public void testOutsideValidityTransform() throws Exception {
    final GeoMagneticField model1 = GeoMagneticFieldFactory.getIGRF(2005);
    final GeoMagneticField model2 = GeoMagneticFieldFactory.getIGRF(2010);

    // the interpolation transformation is only allowed between 2005 and 2010
    model1.transformModel(model2, 2012);
  }
Example #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);
  }
Example #3
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);
  }
Example #4
0
  @Test
  public void testIGRF() 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.IGRF, "sample_coords.txt", "sample_out_IGRF12.txt");

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

      final Vector3D b = result.getFieldVector();

      // X
      Assert.assertEquals(igrfTestValues[i][4], b.getX(), eps);
      // Y
      Assert.assertEquals(igrfTestValues[i][5], b.getY(), eps);
      // Z
      Assert.assertEquals(igrfTestValues[i][6], b.getZ(), eps);
      // H
      Assert.assertEquals(igrfTestValues[i][7], result.getHorizontalIntensity(), eps);
      // F
      Assert.assertEquals(igrfTestValues[i][8], result.getTotalIntensity(), eps);
      // inclination
      Assert.assertEquals(igrfTestValues[i][9], result.getInclination(), degreeEps);
      // declination
      Assert.assertEquals(igrfTestValues[i][10], result.getDeclination(), degreeEps);
    }
  }
Example #5
0
  @Test(expected = OrekitException.class)
  public void testUnsupportedTransform() throws Exception {
    final GeoMagneticField model = GeoMagneticFieldFactory.getIGRF(1910);

    // the IGRF model of 1910 does not have secular variation, thus time transformation is not
    // supported
    model.transformModel(1950);
  }
Example #6
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);
  }
Example #7
0
  @Test
  public void testValidTransform() throws Exception {
    final GeoMagneticField model = GeoMagneticFieldFactory.getWMM(2015);

    Assert.assertTrue(model.supportsTimeTransform());

    final GeoMagneticField transformedModel = model.transformModel(2017);

    Assert.assertEquals(2015, transformedModel.validFrom(), 1e0);
    Assert.assertEquals(2020, transformedModel.validTo(), 1e0);
    Assert.assertEquals(2017, transformedModel.getEpoch(), 1e0);
  }
Example #8
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());
    }
  }
Example #9
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);
    }
  }
Example #10
0
 @Test(expected = OrekitException.class)
 public void testTransformationOutsideValidityPeriod() throws OrekitException {
   double decimalYear = GeoMagneticField.getDecimalYear(10, 1, 2020);
   @SuppressWarnings("unused")
   GeoMagneticField field = GeoMagneticFieldFactory.getIGRF(decimalYear);
 }