@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); }
@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); }
@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); }
@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); } }
@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); }
@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); }
@Test(expected = OrekitException.class) public void testTransformationOutsideValidityPeriod() throws OrekitException { double decimalYear = GeoMagneticField.getDecimalYear(10, 1, 2020); @SuppressWarnings("unused") GeoMagneticField field = GeoMagneticFieldFactory.getIGRF(decimalYear); }