Example #1
0
def test():
    data = 'test_data/MUCSPN_afdemag.jr6'

    S = Sample(name='VB')

    M = S.add_measurement(mtype='afdemag', machine='jr6', mfile=data)
    # M.plt_afdemag(norm=True)
    M.calc_all()
    print M.results
Example #2
0
def test():
    data = 'test_data/MUCSUSH_af_test.af'
    S = Sample(name='WURM')
    M = S.add_measurement(mtype='afdemag', mfile=data, machine='SushiBar')
    # M.plt_afdemag()
    # print M.result_mdf(interpolation='smooth_spline')
    demag.AfDemag(S,
                  norm='max',
                  mdf_text=True,
                  mdf_line=True,
                  diff_fill=True,
                  plot='save',
                  smoothing=1,
                  diff=1)
Example #3
0
def test():
    start = time.clock()
    cryomag_file = 'test_data/NLCRY_Thellier_test.TT'

    # creating a sample
    sample = Sample(name='1a')

    C = CryoMag(dfile=cryomag_file, sample_name=sample.name)
    interm = time.clock() - start
    print interm
Example #4
0
    def setUp(self):
        # sample data files
        self.jr6_file = "../tutorials.rst/test_data/MUCSPN_afdemag.jr6"
        self.cryomag_file = "../tutorials.rst/test_data/NLCRYO_test.af"
        self.sushibar_file = "../tutorials.rst/test_data/MUCSUSH_af_test.af"

        # creating samples
        self.jr6_sample = Sample(name="VA")
        self.sushibar_sample = Sample(name="WURM")
        self.cryomag_sample = Sample(name="DA6B")

        # adding measurements
        self.jr6_af = self.jr6_sample.add_measurement(mtype="afdemag", mfile=self.jr6_file, machine="jr6")
        self.cryomag_af = self.cryomag_sample.add_measurement(
            mtype="afdemag", mfile=self.cryomag_file, machine="cryomag", demag_type="x"
        )
        self.sushibar_af = self.sushibar_sample.add_measurement(
            mtype="afdemag", mfile=self.sushibar_file, machine="sushibar"
        )
def test():
    # thellier output file from cryomag
    cryomag_file = 'test_data/NLCRY_Thellier_test.TT'
    cryomag_is_file = 'test_data/NLCRY_Thellier_is_test.TT'
    # creating a sample
    sample = Sample(name='1a')
    M = sample.add_measurement(mtype='thellier', mfile=cryomag_file, machine='cryomag')
    M.set_initial_state(mtype='trm', mfile=cryomag_is_file, machine='cryomag')
    M.add_sval(stype='pressure', sval=0.0)
    M.series[0].add_value('max_p', 0.6)
    M.series[0].add_value('tonnage', 3)
    M.series[0].add_value('release_time', 30.0)

    # M.plt_arai(norm='is')

    print M.th
    print M.initial_state.data

    print M.th / M.initial_state.data
    print M.initial_state.data['m'][0]
    print M.th / M.initial_state.data['m'][0]
def test():
    # thellier output file from cryomag
    cryomag_file = 'test_data/NLCRY_Thellier_test.TT'
    cryomag_is_file = 'test_data/NLCRY_Thellier_is_test.TT'
    # creating a sample
    sample = Sample(name='1a')
    M = sample.add_measurement(mtype='thellier',
                               mfile=cryomag_file,
                               machine='cryomag')
    M.set_initial_state(mtype='trm', mfile=cryomag_is_file, machine='cryomag')
    M.add_sval(stype='pressure', sval=0.0)
    M.series[0].add_value('max_p', 0.6)
    M.series[0].add_value('tonnage', 3)
    M.series[0].add_value('release_time', 30.0)

    # M.plt_arai(norm='is')

    print M.th
    print M.initial_state.data

    print M.th / M.initial_state.data
    print M.initial_state.data['m'][0]
    print M.th / M.initial_state.data['m'][0]
Example #7
0
class TestAfDemag(TestCase):
    def setUp(self):
        # sample data files
        self.jr6_file = '../tutorials.rst/test_data/MUCSPN_afdemag.jr6'
        self.cryomag_file = '../tutorials.rst/test_data/NLCRYO_test.af'
        self.sushibar_file = '../tutorials.rst/test_data/MUCSUSH_af_test.af'

        # creating samples
        self.jr6_sample = Sample(name='VA')
        self.sushibar_sample = Sample(name='WURM')
        self.cryomag_sample = Sample(name='DA6B')

        # adding measurements
        self.jr6_af = self.jr6_sample.add_measurement(mtype='afdemag', mfile=self.jr6_file, machine='jr6')
        self.cryomag_af = self.cryomag_sample.add_measurement(mtype='afdemag', mfile=self.cryomag_file,
                                                              machine='cryomag',
                                                              demag_type='x')
        self.sushibar_af = self.sushibar_sample.add_measurement(mtype='afdemag', mfile=self.sushibar_file,
                                                                machine='sushibar')

    def test_calculate_mdf(self):
        self.cryomag_af.calculate_mdf()
        self.assertAlmostEqual(self.cryomag_af.result_mdf().v, 24.40, places=1)


    def test_format_jr6(self):
        m = self.jr6_sample.add_measurement(mtype='afdemag', mfile=self.jr6_file, machine='jr6')  #
        self.assertEqual(m.data['data']['field'].v[0], 0)

    def test_format_sushibar(self):
        m = self.sushibar_sample.add_measurement(mtype='afdemag', mfile=self.sushibar_file, machine='sushibar')  #
        self.assertEqual(m.data['data']['field'].v[0], 0)

    def test_format_cryomag(self):
        m = self.cryomag_sample.add_measurement(mtype='afdemag', mfile=self.cryomag_file, machine='cryomag')  #
        self.assertEqual(m.data['data']['field'].v[0], 0)

    def test_result_mdf(self):
        self.assertAlmostEqual(self.cryomag_af.result_mdf().v, 24.40, places=1)
    #
    # def test_interpolate_smoothing_spline(self):
    #     self.fail()
    #
    # def test_interpolation_spline(self):
    #     self.fail()
    #
    # def test_plt_afdemag(self):
    #     self.fail()
Example #8
0
    def setUp(self):
        # sample data files
        self.jr6_file = '../tutorials.rst/test_data/MUCSPN_afdemag.jr6'
        self.cryomag_file = '../tutorials.rst/test_data/NLCRYO_test.af'
        self.sushibar_file = '../tutorials.rst/test_data/MUCSUSH_af_test.af'

        # creating samples
        self.jr6_sample = Sample(name='VA')
        self.sushibar_sample = Sample(name='WURM')
        self.cryomag_sample = Sample(name='DA6B')

        # adding measurements
        self.jr6_af = self.jr6_sample.add_measurement(mtype='afdemag', mfile=self.jr6_file, machine='jr6')
        self.cryomag_af = self.cryomag_sample.add_measurement(mtype='afdemag', mfile=self.cryomag_file,
                                                              machine='cryomag',
                                                              demag_type='x')
        self.sushibar_af = self.sushibar_sample.add_measurement(mtype='afdemag', mfile=self.sushibar_file,
                                                                machine='sushibar')
Example #9
0
class TestAfDemag(TestCase):
    def setUp(self):
        # sample data files
        self.jr6_file = "../tutorials.rst/test_data/MUCSPN_afdemag.jr6"
        self.cryomag_file = "../tutorials.rst/test_data/NLCRYO_test.af"
        self.sushibar_file = "../tutorials.rst/test_data/MUCSUSH_af_test.af"

        # creating samples
        self.jr6_sample = Sample(name="VA")
        self.sushibar_sample = Sample(name="WURM")
        self.cryomag_sample = Sample(name="DA6B")

        # adding measurements
        self.jr6_af = self.jr6_sample.add_measurement(mtype="afdemag", mfile=self.jr6_file, machine="jr6")
        self.cryomag_af = self.cryomag_sample.add_measurement(
            mtype="afdemag", mfile=self.cryomag_file, machine="cryomag", demag_type="x"
        )
        self.sushibar_af = self.sushibar_sample.add_measurement(
            mtype="afdemag", mfile=self.sushibar_file, machine="sushibar"
        )

    def test_calculate_mdf(self):
        self.cryomag_af.calculate_mdf()
        self.assertAlmostEqual(self.cryomag_af.result_mdf().v, 24.40, places=1)

    def test_format_jr6(self):
        m = self.jr6_sample.add_measurement(mtype="afdemag", mfile=self.jr6_file, machine="jr6")  #
        self.assertEqual(m.data["data"]["field"].v[0], 0)

    def test_format_sushibar(self):
        m = self.sushibar_sample.add_measurement(mtype="afdemag", mfile=self.sushibar_file, machine="sushibar")  #
        self.assertEqual(m.data["data"]["field"].v[0], 0)

    def test_format_cryomag(self):
        m = self.cryomag_sample.add_measurement(mtype="afdemag", mfile=self.cryomag_file, machine="cryomag")  #
        self.assertEqual(m.data["data"]["field"].v[0], 0)

    def test_result_mdf(self):
        self.assertAlmostEqual(self.cryomag_af.result_mdf().v, 24.40, places=1)
Example #10
0
__author__ = 'volk'
from Structure.sample import Sample
from Readin.cryo_mag import CryoMag
import matplotlib.pyplot as plt

# specify data file
cryomag_file = '../test_data/NLCRY_Thellier_test.TT'

# create new Sample
sample = Sample(name='1a')

# Readin of sample data, all other samples will not get processed
CM = CryoMag(cryomag_file, sample)

# raw data of positions can be accessed like
CM.pos2
# raw data of baselines can also be accessed with
CM.baseline

# raw float data can be accessed like this
CM.float_data()
# also for the different positions
CM.float_data(mode='pos1')

# raw sting data like this
CM.str_data()

#calculating the error weighted mean of data
CM.weighted_mean()

# quick plotting of data
Example #11
0
__author__ = 'volk'
from Structure.sample import Sample
import matplotlib.pyplot as plt
import numpy as np

dfile = 'test_data/MICROSENSE_HYS-test.VHD'

sample = Sample(name='microsense_test')

M = sample.add_measurement(mtype='hys', mfile=dfile, machine='microsense')

M.plt_hys()
def speed_test_nl():
    from Structure.sample import Sample

    d_file = '/Users/mike/Google Drive/__code/RockPyV3/test_data/NLCRY-LF4C_P2-140801.TT'
    sample = Sample(name='1a')
    sample.add_measurement(mtype='palint', machine='cryo_nl', mfile=d_file)
def speed_test_sushi():
    from Structure.sample import Sample
    d_file = '/Users/mike/Google Drive/__code/RockPyV3/test_data/LF4c-6c_pdemag_P00.AF'
    sample = Sample(name='6c')
    af = sample.add_measurement(mtype='af-demag', machine='sushibar', mfile=d_file, mag_method='IRM')
    af.plot()
Example #14
0
    def __init__(self, blocking_params=None, aniso_params=None, errors=None, **options):

        if not blocking_params: blocking_params = {}
        if not aniso_params: aniso_params = {}
        if not errors: errors = {}
        super(Sim_Thellier, self).__init__()

        default_blocking_params = {'lab_field': 35.0,
                                   'paleo_field': 35.0,
                                   'mean_nrm': 510.0,
                                   'skewness_nrm': -10,
                                   'skewness_ptrm': -10,  # - skewed to left
                                   'w_nrm': 50.0,
                                   'w_ptrm': 50.0,
                                   'ptrm_t_diff': 2.0}

        default_aniso_params = {'atrm_matrix': np.array([[1, 0., 0.],
                                                         [0., 1., 0.],
                                                         [0., 0., 1.]]),
                                'lab_field_direction': np.array([0, 0, 1]),
                                'paleo_field_direction': np.array([0, 0, 1]),
        }

        default_errors = {'alignment_error': 0,
                          'field_error': 0,
                          'temperature_error': 0}
        default_steps = [20.0, 60.0, 100.0, 140.0, 185.0, 225.0, 265.0, 310.0, 350.0, 390.0, 430.0, 475.0, 515.0, 555.0,
                         600.0, 680.0]

        ''' OPTIONS '''
        for key in default_blocking_params:
            if key not in blocking_params:
                blocking_params[key] = default_blocking_params[key]

        for key in default_aniso_params:
            if key not in aniso_params:
                aniso_params[key] = default_aniso_params[key]

        for key in default_errors:
            if key not in errors:
                errors[key] = default_errors[key]

        # lists = {key: value for key, value in parameters.iteritems() if type(parameters[key]) == list}

        self.__dict__.update(blocking_params)
        self.__dict__.update(aniso_params)
        self.__dict__.update(errors)

        self.t_steps = options.get('t_steps', default_steps)


        # this are the put in values for plots oven etc. There is no error yet
        ''' zero field steps '''
        self.th_steps = self.t_steps

        self.ac_steps = [self.th_steps[i] for i in range(1, len(self.t_steps), 3)]
        self.tr_steps = [self.th_steps[i] for i in range(1, len(self.t_steps), 3)]

        ''' in field steps '''
        self.pt_steps = self.t_steps
        self.ck_steps = [self.th_steps[i] for i in range(1, len(self.t_steps), 2)]

        ''' adding temperature error '''

        if not self.temperature_error <= 0:
            self.th_temps = self.th_steps + np.random.normal(0, self.temperature_error, len(self.th_steps))
            self.ac_temps = self.ac_steps + np.random.normal(0, self.temperature_error, len(self.ac_steps))
            self.tr_temps = self.tr_steps + np.random.normal(0, self.temperature_error, len(self.tr_steps))

            self.pt_temps = self.pt_steps + np.random.normal(0, self.temperature_error, len(self.pt_steps))
            self.ck_temps = self.ck_steps + np.random.normal(0, self.temperature_error, len(self.ck_steps))

        else:  # error cannot be <=0 -> no arror added
            self.th_temps = self.th_steps
            self.ac_temps = self.ac_steps
            self.tr_temps = self.tr_steps

            self.pt_temps = self.pt_steps
            self.ck_temps = self.ck_steps

        ''' field errors '''

        if not self.field_error <= 0:
            self.ptrm_fields = np.random.normal(0, self.field_error, len(self.pt_steps)) + self.lab_field
            self.ck_fields = np.random.normal(0, self.field_error, len(self.ck_steps)) + self.lab_field
        else:
            self.ptrm_fields = np.ones(len(self.pt_steps)) * self.lab_field
            self.ck_fields = np.ones(len(self.ck_steps)) * self.lab_field

        ''' field errors '''

        if not self.alignment_error <= 0:
            self.ptrm_field_directions = [rotate(xyz=self.lab_field_direction, degree=i) for i in
                                          np.random.normal(0, self.alignment_error, len(self.pt_steps))]
            self.ck_field_directions = [rotate(xyz=self.lab_field_direction, degree=i) for i in
                                        np.random.normal(0, self.alignment_error, len(self.ck_steps))]
        else:
            self.ptrm_field_directions = np.array([self.lab_field_direction for i in range(len(self.pt_steps))])
            self.ck_field_directions = np.array([self.lab_field_direction for i in range(len(self.ck_steps))])

        ''' generate sample and measurements '''
        self.sample = Sample(name='Thellier Simulation')
        self.sample.add_measurement(mtype='palint', mfile='', machine='simulation')

        N = len(self.th_steps) + len(self.ck_steps) + len(self.pt_steps) + len(self.ac_steps) + len(self.tr_steps)

        ''' TH Steps '''
        self.nrm = np.dot(self.atrm_matrix, self.paleo_field_direction) * self.paleo_field

        m_nrm, m_ptrm = self.data()
        self.th = np.array([self.nrm * m_nrm[np.argmin(abs(i - m_nrm[:, 0])), 1] for i in self.th_temps])
        th_m = [np.linalg.norm(i) for i in self.th]
        self.th = np.c_[self.th_steps, self.th[:, 0], self.th[:, 1], self.th[:, 2], th_m]

        ''' PTRM '''
        m_ptrm_calc = np.array([m_ptrm[np.argmin(abs(i - m_ptrm[:, 0])), 1] for i in self.pt_temps])
        self.ptrm = np.array(
            [np.dot(self.atrm_matrix, self.ptrm_field_directions[i]) * self.ptrm_fields[i] * m_ptrm_calc[i]
             for i in range(len(self.ptrm_field_directions))])
        self.ptrm = np.c_[
            self.pt_steps, self.ptrm[:, 0], self.ptrm[:, 1], self.ptrm[:, 2], map(np.linalg.norm, self.ptrm)]

        m_ck_calc = np.array([m_ptrm[np.argmin(abs(i - m_ptrm[:, 0])), 1] for i in self.ck_temps])
        ck = np.array([np.dot(self.atrm_matrix, self.ck_field_directions[i]) * self.ck_fields[i] * m_ck_calc[i]
                       for i in range(len(self.ck_field_directions))])

        ck = [ck[i] + self.th[j, 1:4] for i in range(len(self.ck_steps)) for j in range(len(self.th_steps))
              if self.th_steps[j] == self.ck_steps[i]]

        ''' SUM '''

        self.sum = self.th[:, 1:4] + self.ptrm[:, 1:4]
        self.sum = np.c_[self.pt_steps, self.sum[:, 0], self.sum[:, 1], self.sum[:, 2], map(np.linalg.norm, self.sum)]