Esempio n. 1
0
 def test_has_initial_state(self):
     # only initial states
     study = RockPy3.core.study.Study()
     s = study.add_sample(name='test')
     mean = RockPy3.Study.add_sample(name='mean')
     m0 = s.add_simulation(mtype='hysteresis', noise=5)
     m1 = s.add_simulation(mtype='hysteresis', noise=5)
     mi = m1.set_initial_state(mobj=m0)
     self.assertFalse(s.measurements[0].has_initial_state)
     self.assertTrue(s.measurements[1].has_initial_state)
Esempio n. 2
0
 def test_get_series(self):
     study = RockPy3.core.study.Study()
     s = study.add_sample(name='test')
     m0 = s.add_simulation(mtype='hysteresis', noise=5, series=[('s1', 1, 'A'), ('s2', 1, 'b')])
     m1 = s.add_simulation(mtype='hysteresis', noise=5, series=[('s1', 3, 'A'), ('s2', 4, 'b')])
     self.assertEqual([1], [s.sval for s in m0.get_series(stype='s1')])
     self.assertEqual([3], [s.sval for s in m1.get_series(stype='s1')])
     self.assertEqual(['s1', 's2'], [s.stype for s in m0.get_series(sval=1)])
     self.assertEqual(['s1'], [s.stype for s in m1.get_series(sval=3)])
     self.assertEqual(['s1'], [s.stype for s in m1.get_series(series=[('s1', 3), ('s2', 1)])])
Esempio n. 3
0
    def test_from_measurements(self):
        # 1. check that if there is no noise the data is the same
        study = RockPy3.core.study.Study()
        s = study.add_sample(name='test')
        m0 = s.add_simulation(mtype='hysteresis')  # simulation with no noise
        m1 = s.add_simulation(mtype='hysteresis')  # simulation with no noise

        mean = RockPy3.Study.add_sample(name='mean')
        mm = RockPy3.Packages.Mag.Measurements.hysteresis.Hysteresis.from_measurements_create_mean(mean, s.measurements)
        for other in s.measurements:
            self.assertTrue(all(mm.data['down_field']['mag'].v == other.data['down_field']['mag'].v))
            self.assertTrue(all(mm.data['up_field']['mag'].v == other.data['up_field']['mag'].v))
Esempio n. 4
0
 def test_set_initial_state(self):
     # only initial states
     study = RockPy3.core.study.Study()
     s = study.add_sample(name='test')
     mean = RockPy3.Study.add_sample(name='mean')
     m0 = s.add_simulation(mtype='hysteresis', noise=5)
     m1 = s.add_simulation(mtype='hysteresis', noise=5)
     mi = m1.set_initial_state(mobj=m0)
     # no deepcopy -> m0 == mi
     self.assertEqual(m0, mi)
     self.assertEqual([m0, m1], s.get_measurement(mtype='hysteresis'))
     self.assertEqual(2, len(s.measurements))
     self.assertFalse(s.measurements[0].has_initial_state)
     self.assertTrue(s.measurements[1].has_initial_state)
Esempio n. 5
0
    def test_set_recipe(self):
        study = RockPy3.core.study.Study()
        s = study.add_sample(name='test')
        m0 = s.add_simulation(mtype='hysteresis')
        m0.result_bc(no_points=8, check=False)
        print(m0.results)
        # direct
        self.assertEqual('direct', m0.result_category('mrs'))
        m0.set_recipe(res='mrs', recipe='nonlinear')
        self.assertEqual('default'.upper(), m0.result_recipe['mrs'])
        # direct_recipe
        self.assertEqual('direct_recipe', m0.result_category('bc'))
        m0.set_recipe(res='bc', recipe='nonlinear')
        self.assertEqual('nonlinear'.upper(), m0.result_recipe['bc'])
        print(m0.results)
        # indirect

        # indirect_recipe
        self.assertEqual('indirect_recipe', m0.result_category('hf_sus'))
        m0.set_recipe(res='hf_sus', recipe='app2sat')
        self.assertEqual('app2sat'.upper(), m0.result_recipe['ms'])
        self.assertEqual('app2sat'.upper(), m0.result_recipe['hf_sus'])