Example #1
0
 def test_callable_all_zero(self):
     coeff, degree = self.eval_coeff(decimal_year_to_mjd2000(2018.5),
                                     min_degree=3)
     assert_allclose(coeff, [
         [0, 0],
     ])
     self.assertEqual(degree, 0)
Example #2
0
class TestCHAOS6CoreWithOverridenValidity(TestCHAOS6Core):
    validity = decimal_year_to_mjd2000((2000.0, 2018.0))

    def load(self):
        return load_model_shc(CHAOS6_CORE_LATEST,
                              validity_start=2000.0,
                              validity_end=2018.0)
Example #3
0
class TestCHAOS6CombinedOverridenValidity(TestCHAOS6Combined):
    validity = decimal_year_to_mjd2000((2000.0, 2018.0))

    def load(self):
        return load_model_shc_combined(CHAOS6_CORE_LATEST,
                                       CHAOS6_STATIC,
                                       validity_start=2000.0,
                                       validity_end=2018.0)
Example #4
0
class TestCoeffEMM2010(TestCase, CoefficietLoaderTestMixIn):
    class_ = CombinedSHCoefficients
    degree = 739
    min_degree = 1
    validity = decimal_year_to_mjd2000((2010.0, 2015.0))

    @staticmethod
    def load():
        return load_coeff_emm(EMM_2010_STATIC, EMM_2010_SECVAR)
Example #5
0
class TestCoeffIGRF11(TestCase, CoefficietLoaderTestMixIn):
    class_ = SparseSHCoefficientsTimeDependentDecimalYear
    degree = 13
    min_degree = 1
    validity = decimal_year_to_mjd2000((1900.0, 2015.0))

    @staticmethod
    def load():
        return load_coeff_igrf(IGRF11)
Example #6
0
class TestCoeffIGRF12(TestCase, ShcTestMixIn):
    class_ = SparseSHCoefficientsTimeDependentDecimalYear
    path = IGRF12
    degree = 13
    min_degree = 1
    kwargs = {
        "interpolate_in_decimal_years": True,
    }
    validity = decimal_year_to_mjd2000((1900.0, 2020.0))
Example #7
0
class TestCoeffSIFM(TestCase, ShcTestMixIn):
    class_ = SparseSHCoefficientsTimeDependentDecimalYear
    path = SIFM
    degree = 70
    min_degree = 1
    kwargs = {
        "interpolate_in_decimal_years": True,
    }
    validity = decimal_year_to_mjd2000((2013.4976, 2015.4962))
Example #8
0
class TestWMM2015(TestCase, SHModelTestMixIn):
    reference_values = (6392.0, (30.0, 40.0, 8000.0),
                        (15124.421927514817, 532.3321104099762,
                         -14755.455538253298))
    degree = 12
    min_degree = 1
    validity = decimal_year_to_mjd2000((2015.0, 2020.0))

    def load(self):
        return load_model_wmm(WMM_2015)
Example #9
0
class TestIGRF11(TestCase, SHModelTestMixIn):
    reference_values = (-14609.5, (30.0, 40.0, 8000.0),
                        (15265.918081037888, -142.6442876878355,
                         -14044.282413158882))
    degree = 13
    min_degree = 1
    validity = decimal_year_to_mjd2000((1900.0, 2015.0))

    def load(self):
        return load_model_igrf(IGRF11)
Example #10
0
class TestIGRF12(TestCase, SHModelTestMixIn):
    reference_values = (-15522.5, (30.0, 40.0, 8000.0),
                        (15259.57386772841, -159.00767967612023,
                         -14015.952721753336))
    degree = 13
    min_degree = 1
    validity = decimal_year_to_mjd2000((1900.0, 2020.0))

    def load(self):
        return load_model_shc(IGRF12, interpolate_in_decimal_years=True)
Example #11
0
class TestSIFM(TestCase, SHModelTestMixIn):
    reference_values = (5295.36, (30.0, 40.0, 8000.0),
                        (15122.448070753977, 474.14615304317635,
                         -14669.16289251053))
    degree = 70
    min_degree = 1
    validity = decimal_year_to_mjd2000((2013.4976, 2015.4962))

    def load(self):
        return load_model_shc(SIFM)
Example #12
0
class TestCHAOS6Core(TestCase, SHModelTestMixIn):
    reference_values = (2503.33, (30.0, 40.0, 8000.0),
                        (15127.023594737328, 318.5295048927941,
                         -14493.86656020781))
    degree = 20
    min_degree = 1
    validity = decimal_year_to_mjd2000((1997.102, 2019.7002))

    def load(self):
        return load_model_shc(CHAOS6_CORE_LATEST)
Example #13
0
class TestCHAOS6Combined(TestCase, SHModelTestMixIn):
    reference_values = (2685.9, (30.0, 40.0, 8000.0),
                        (15127.078702047753, 328.58833488534174,
                         -14503.610818133817))
    degree = 110
    min_degree = 1
    validity = decimal_year_to_mjd2000((1997.102, 2019.7002))

    def load(self):
        return load_model_shc_combined(CHAOS6_CORE_LATEST, CHAOS6_STATIC)
Example #14
0
 def test_callable_max_degree(self):
     coeff, degree = self.eval_coeff(decimal_year_to_mjd2000(2018.5),
                                     max_degree=1)
     assert_allclose(coeff, [
         (0, 0),
         (0.11415226, 0),
         (-0.22361224, -0.02624283),
     ],
                     atol=1e-8)
     self.assertEqual(degree, 1)
Example #15
0
 def test_callable(self):
     coeff, degree = self.eval_coeff(decimal_year_to_mjd2000(2018.5))
     assert_allclose(coeff, [
         (0, 0),
         (0.11415226, 0),
         (-0.22361224, -0.02624283),
         (-0.23244221, 0),
         (-0.34379927, -0.81524805),
         (0.01412196, -0.18049787),
     ],
                     atol=1e-8)
     self.assertEqual(degree, self.degree)
Example #16
0
 def test_callable(self):
     coeff, degree = self.eval_coeff(decimal_year_to_mjd2000(2018.5))
     assert_allclose(coeff, [
         (0, 0),
         (-1.44080531, 0),
         (-0.27711333, -0.25918073),
         (-0.63645813, 0),
         (-0.22583255, -2.02305245),
         (0.05941826, -0.24358544),
     ],
                     atol=1e-8)
     self.assertEqual(degree, self.degree)
Example #17
0
class TestEMM2010(TestCase, SHModelTestMixIn):
    reference_values = (4566.0, (30.0, 40.0, 8000.0),
                        (15124.606019372684, 442.2376840179962,
                         -14612.282120230499))
    # The EMM models is huge and the test ranges have to be reduced.
    range_lat = range(-90, 91, 30)
    range_lon = range(-180, 181, 60)
    degree = 739
    min_degree = 1
    validity = decimal_year_to_mjd2000((2010.0, 2015.0))
    options = {"max_degree": 300}

    def load(self):
        return load_model_emm(EMM_2010_STATIC, EMM_2010_SECVAR)
Example #18
0
 def test_extra_sub_solar_point(self):
     coeff, degree = self.eval_coeff(
         decimal_year_to_mjd2000(2018.5),
         lat_sol=0.0,
         lon_sol=0.0,
     )
     assert_allclose(coeff, [
         (0.0, 0.0),
         (0.12120376078924046, 0.0),
         (-0.22660807757361834, 0.008720797143766132),
         (-0.2485487953382298, 0.0),
         (-0.40755502000159416, -0.7608326017305439),
         (-0.04181600178841578, -0.16655581670562275),
     ],
                     atol=1e-8)
     self.assertEqual(degree, self.degree)
Example #19
0
class TestCoeffCHAOS6Core(TestCase, ShcTestMixIn):
    class_ = SparseSHCoefficientsTimeDependent
    path = CHAOS6_CORE_LATEST
    degree = 20
    min_degree = 1
    validity = decimal_year_to_mjd2000((1997.102, 2019.7002))
Example #20
0
loc = (45.0, 105.0, 1.0)
options = {"f107": 70, "scale": [1, 1, -1]}  #-1 is Z direction

# load DIFI4 model
difi4 = load_model_swarm_mio_external(DIFI4)
difi42 = load_model_swarm_mio_internal(DIFI4)

#get_ipython().run_line_magic('matplotlib', 'inline')
import matplotlib.pyplot as plt
import numpy as np
magdifi = np.zeros(3 * 24).reshape(24, 3)
magdifi2 = np.zeros(3 * 24).reshape(24, 3)

for i in range(24):
    t1 = decimal_year_to_mjd2000(
        datetime_to_decimal_year(dt.datetime(2019, 1, 1, i, 0, 30)))
    magdifi[i] = difi4.eval(t1, loc, 0, 0, **options)
    magdifi2[i] = difi42.eval(t1, loc, 0, 0, **options)

plt.title("DIFI-4 IONOSPHERE MAGNETIC FIELD MODEL")
plt.xlabel("UTC time/h")
plt.ylabel("Sq intensity/nT")
plt.plot(magdifi[:, 0], 'bo', label="North-X")
plt.plot(magdifi[:, 1], 'ro', label="East-Y")
plt.plot(magdifi[:, 2], 'go', label="Vertical-Z")
plt.plot(magdifi[:, 0] + magdifi2[:, 0], 'b', label="North-X2")
plt.plot(magdifi[:, 1] + magdifi2[:, 1], 'r', label="East-Y2")
plt.plot(magdifi[:, 2] + magdifi2[:, 2], 'g', label="Vertical-Z2")
plt.legend()
plt.show()
Example #21
0
class TestCoeffCHAOS6Combined(TestCase, CombinedShcTestMixIn):
    path_core = CHAOS6_CORE_LATEST
    path_static = CHAOS6_STATIC
    degree = 110
    min_degree = 1
    validity = decimal_year_to_mjd2000((1997.1020, 2019.7002))
Example #22
0
class TestCoeffWMM2015(TestCase, WmmTestMixIn):
    class_ = SparseSHCoefficientsTimeDependentDecimalYear
    path = WMM_2015
    degree = 12
    min_degree = 1
    validity = decimal_year_to_mjd2000((2015., 2020.))
Example #23
0
loc = (30.0, 40.0, 1000.0)
wmm2015 = load_model_wmm(WMM_2015)  #load wmm2015 model
igrf11 = load_model_igrf(IGRF11)  #load igrf11 model
igrf12 = load_model_shc(IGRF12,
                        interpolate_in_decimal_years=True)  #load igrf12 model

igrf13 = load_model_igrf(IGRF13)
wmm2020 = load_model_wmm(WMM_2020)

emm = load_model_emm(EMM_2010_STATIC, EMM_2010_SECVAR)  #load emm model
options = {"scale": [1, 1, -1]}  #-1 is Z direction

## renew for the IGRF13 and WMM2020 models on 2020-03-22
d2 = 2022.5
loc1 = (80.0, 0.0, 100.0)
wmm2020.eval(decimal_year_to_mjd2000(d2), loc1, 0, 0, **options)
igrf13.eval(decimal_year_to_mjd2000(d2), loc1, 0, 0, **options)
## the result has been checked with WMM2020testvalues.pdf

wmm2015.eval(decimal_year_to_mjd2000(d11), loc, 0, 0,
             **options)  # 0,0 mean input,output using GEODETIC_ABOVE_WGS84
igrf11.eval(decimal_year_to_mjd2000(d11), loc, 0, 0, **options)
igrf12.eval(decimal_year_to_mjd2000(d11), loc, 0, 0,
            **options)  #North-X, East-Y, Vertical-Z
vnorm(igrf12.eval(decimal_year_to_mjd2000(d11), (30.0, 40.0, 1000.0), 0,
                  0))  #Total intensity
mjd2000_to_decimal_year([5479., 7305., 6392.0])

emm.eval(decimal_year_to_mjd2000(d11), loc, 0, 0, **options)

# load mio model
Example #24
0
 def times(self):
     return uniform(decimal_year_to_mjd2000(1990),
                    decimal_year_to_mjd2000(2030), self.shape)
Example #25
0
 def _constrain_validity(time_min, time_max):
     return (
         max(time_min, decimal_year_to_mjd2000(1920)),
         min(time_max, decimal_year_to_mjd2000(2120)),
     )