Example #1
0
class TestSparseSHCoefficientsTimeDependentDecimalYearDefault(
        TestCase, SHCoefficinetTestMixIn):
    times = array([2012.0, 2016.0, 2014.0])
    indices = array([(1, 0), (1, 1), (1, -1)])
    coeff = array([
        [1, 3, 2],
        [5, 15, 10],
        [10, 30, 20],
    ])
    degree = 1
    min_degree = 1
    is_internal = True
    validity = tuple(decimal_year_to_mjd2000((2012.0, 2016.0)))
    options = {}

    @property
    def coefficients(self):
        return SparseSHCoefficientsTimeDependentDecimalYear(
            self.indices, self.coeff, self.times, **self.options)

    def test_callable(self):
        coeff, degree = self.coefficients(decimal_year_to_mjd2000(2013.0))
        assert_allclose(coeff, [[0., 0.], [1.5, 0], [7.5, 15.0]])
        self.assertEqual(degree, self.degree)

    def test_callable_before_first_time(self):
        coeff, degree = self.coefficients(decimal_year_to_mjd2000(2011.0))
        assert_allclose(coeff, [[0., 0.], [0.5, 0], [2.5, 5.0]])
        self.assertEqual(degree, self.degree)
Example #2
0
class TestFieldLineTracing(TestCase):
    time = decimal_year_to_mjd2000(2015.5)
    point = START_POINT
    points = FIELD_LINE_POINTS

    @property
    def model(self):
        if not hasattr(self, "_model"):
            self._model = load_model_shc(IGRF12,
                                         interpolate_in_decimal_years=True)
        return self._model

    def test_trace_field_line_wgs84(self):
        point = self.point
        points, vectors = trace_field_line(
            self.model,
            self.time,
            point,
            input_coordinate_system=GEODETIC_ABOVE_WGS84,
            output_coordinate_system=GEODETIC_ABOVE_WGS84,
        )
        assert_allclose(points, self.points)
        assert_allclose(
            vectors,
            self.model.eval(
                self.time,
                points,
                input_coordinate_system=GEODETIC_ABOVE_WGS84,
                output_coordinate_system=GEODETIC_ABOVE_WGS84,
            ))

    def test_trace_field_line_spherical(self):
        point = convert(self.point, GEODETIC_ABOVE_WGS84, GEOCENTRIC_SPHERICAL)
        points, vectors = trace_field_line(
            self.model,
            self.time,
            point,
            input_coordinate_system=GEOCENTRIC_SPHERICAL,
            output_coordinate_system=GEOCENTRIC_SPHERICAL,
        )
        assert_allclose(
            points,
            convert(self.points, GEODETIC_ABOVE_WGS84, GEOCENTRIC_SPHERICAL))
        assert_allclose(
            vectors,
            self.model.eval(
                self.time,
                points,
                input_coordinate_system=GEOCENTRIC_SPHERICAL,
                output_coordinate_system=GEOCENTRIC_SPHERICAL,
            ))

    def test_trace_field_line_cartesian(self):
        point = convert(self.point, GEODETIC_ABOVE_WGS84, GEOCENTRIC_CARTESIAN)
        points, vectors = trace_field_line(
            self.model,
            self.time,
            point,
            input_coordinate_system=GEOCENTRIC_CARTESIAN,
            output_coordinate_system=GEOCENTRIC_CARTESIAN,
        )
        assert_allclose(
            points,
            convert(self.points, GEODETIC_ABOVE_WGS84, GEOCENTRIC_CARTESIAN))
        assert_allclose(
            vectors,
            self.model.eval(
                self.time,
                points,
                input_coordinate_system=GEOCENTRIC_CARTESIAN,
                output_coordinate_system=GEOCENTRIC_CARTESIAN,
            ))
Example #3
0
class TestSparseSHCoefficientsTimeDependentDecimalYearExtendedValidity(
        TestSparseSHCoefficientsTimeDependentDecimalYearDefault):
    validity = tuple(decimal_year_to_mjd2000((2010.0, 2018.0)))
    options = {"validity_start": 2010.0, "validity_end": 2018.0}
Example #4
0
 def test_callable_before_first_time(self):
     coeff, degree = self.coefficients(decimal_year_to_mjd2000(2011.0))
     assert_allclose(coeff, [[0., 0.], [0.5, 0], [2.5, 5.0]])
     self.assertEqual(degree, self.degree)
Example #5
0
 def test_callable(self):
     coeff, degree = self.coefficients(decimal_year_to_mjd2000(2013.0))
     assert_allclose(coeff, [[0., 0.], [1.5, 0], [7.5, 15.0]])
     self.assertEqual(degree, self.degree)