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)
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)
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)
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)
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))
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))
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
class TestCoeffCHAOS6Core(TestCase, ShcTestMixIn): class_ = SparseSHCoefficientsTimeDependent path = CHAOS6_CORE_LATEST degree = 20 min_degree = 1 validity = decimal_year_to_mjd2000((1997.102, 2019.7002))
def times(self): return uniform( decimal_year_to_mjd2000(1990), decimal_year_to_mjd2000(2030), self.shape )
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))
class TestCoeffWMM2015(TestCase, WmmTestMixIn): class_ = SparseSHCoefficientsTimeDependentDecimalYear path = WMM_2015 degree = 12 min_degree = 1 validity = decimal_year_to_mjd2000((2015., 2020.))
print(mjd2000_to_decimal_year(7305)) print(mjd2000_to_decimal_year([5479., 7305., 6392.0])) d1 = dt.datetime(2015,1,1) # import time , location(lat, lon) d11 = datetime_to_decimal_year(d1) # datetime to decimal year 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 wmm2020.eval(decimal_year_to_mjd2000(d11), loc, 0, 0, **options) igrf13.eval(decimal_year_to_mjd2000(d11), loc, 0, 0, **options) 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 mio = load_model_swarm_mio_internal(SWARM_MIO_SHA_2_TEST_DATA) options = {"f107": 70, "scale": [1, 1, -1]} mio.eval(decimal_year_to_mjd2000(d11), (30.0, 40.0, 1000.0), 0, 0, **options)
def _constrain_validity(time_min, time_max): return ( max(time_min, decimal_year_to_mjd2000(1920)), min(time_max, decimal_year_to_mjd2000(2120)), )
import magmod._pymm as pymm print(SWARM_MIO_SHA_2_TEST_DATA) #DIFI4 is a type of MIO SHA model print(mjd2000_to_decimal_year(7305)) print(mjd2000_to_decimal_year([5479., 7305., 6392.0])) d1 = dt.datetime(2015, 1, 1) # import time , location(lat, lon) d11 = datetime_to_decimal_year(d1) # datetime to decimal year 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 emm = load_model_emm(EMM_2010_STATIC, EMM_2010_SECVAR) #load emm model options = {"scale": [1, 1, -1]} #-1 is Z direction 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 mio = load_model_swarm_mio_internal(SWARM_MIO_SHA_2_TEST_DATA) options = {"f107": 70, "scale": [1, 1, -1]} mio.eval(decimal_year_to_mjd2000(d11), (30.0, 40.0, 1000.0), 0, 0, **options)