class CheckGamma(unittest.TestCase):
    B_lab_dir = [0, 90, 1]
    B_lab_cart = lib_direct.dir2cart(
        B_lab_dir)  # [  6.12323400e-17,   0.00000000e+00,   1.00000000e+00]

    #[3,2,1] --> array([ 33.69006753,  15.50135957,   3.74165739])
    pTRM_dir = [3, 2, 1]
    pTRM_cart = lib_direct.dir2cart(pTRM_dir)

    ref_gamma = 88.

    def testGamma(self):
        result = lib_direct.get_gamma(self.B_lab_dir, self.pTRM_dir)
        self.assertAlmostEqual(87.999999999999986, 88.)
        self.assertAlmostEqual(self.ref_gamma, result)
Esempio n. 2
0
 def get_gamma(self):
     B_lab_dir = [self.B_lab_dir[0], self.B_lab_dir[1], 1.] 
     ind = self.t_Arai.index(self.tmax)
     ptrm_dir = [self.PTRMS[ind][1], self.PTRMS[ind][2], self.PTRMS[ind][3] / self.specimen_Data['NRM']] 
     ptrm_cart = lib_direct.dir2cart(ptrm_dir)
     gamma = lib_direct.get_gamma(B_lab_dir, ptrm_dir)
     self.pars['ptrm_dir'] = ptrm_dir
     self.pars['ptrm_cart'] = ptrm_cart
     self.pars['gamma'] = gamma
     return gamma
Esempio n. 3
0
 def get_gamma(self):
     B_lab_dir = [self.B_lab_dir[0], self.B_lab_dir[1], 1.]
     ind = self.t_Arai.index(self.tmax)
     ptrm_dir = [self.PTRMS[ind][1], self.PTRMS[ind][2], old_div(self.PTRMS[ind][3], self.specimen_Data['NRM'])]
     ptrm_cart = lib_direct.dir2cart(ptrm_dir)
     gamma = lib_direct.get_gamma(B_lab_dir, ptrm_dir)
     self.pars['ptrm_dir'] = ptrm_dir
     self.pars['ptrm_cart'] = ptrm_cart
     self.pars['gamma'] = gamma
     return gamma
Esempio n. 4
0
 def get_ptrm_dec_and_inc(self):
     """not included in spd."""
     PTRMS = self.PTRMS[1:]
     CART_pTRMS_orig = numpy.array([lib_direct.dir2cart(row[1:4]) for row in PTRMS])
     #B_lab_dir = [self.B_lab_dir[0], self.B_lab_dir[1], 1.] # dir
     tmin, tmax = self.t_Arai[0], self.t_Arai[-1]
     ptrms_dec_Free, ptrms_inc_Free, ptrm_best_fit_vector_Free, ptrm_tau_Free, ptrm_v_Free, ptrm_mass_center_Free, ptrm_PCA_sigma_Free = lib_direct.get_dec_and_inc(CART_pTRMS_orig, self.t_Arai, tmin, tmax, anchored=False)
     ptrms_angle = lib_direct.get_ptrms_angle(ptrm_best_fit_vector_Free, self.B_lab_cart)
     self.pars['ptrms_dec_Free'], self.pars['ptrms_inc_Free'] = ptrms_dec_Free, ptrms_inc_Free
     self.pars['ptrms_tau_Free'] = ptrm_tau_Free
     self.pars['ptrms_angle_Free'] = ptrms_angle
Esempio n. 5
0
 def get_ptrm_dec_and_inc(self):
     """not included in spd."""
     PTRMS = self.PTRMS[1:]
     CART_pTRMS_orig = numpy.array([lib_direct.dir2cart(row[1:4]) for row in PTRMS])
     #B_lab_dir = [self.B_lab_dir[0], self.B_lab_dir[1], 1.] # dir
     tmin, tmax = self.t_Arai[0], self.t_Arai[-1]
     ptrms_dec_Free, ptrms_inc_Free, ptrm_best_fit_vector_Free, ptrm_tau_Free, ptrm_v_Free, ptrm_mass_center_Free, ptrm_PCA_sigma_Free = lib_direct.get_dec_and_inc(CART_pTRMS_orig, self.t_Arai, tmin, tmax, anchored=False)
     ptrms_angle = lib_direct.get_ptrms_angle(ptrm_best_fit_vector_Free, self.B_lab_cart)
     self.pars['ptrms_dec_Free'], self.pars['ptrms_inc_Free'] = ptrms_dec_Free, ptrms_inc_Free
     self.pars['ptrms_tau_Free'] = ptrm_tau_Free
     self.pars['ptrms_angle_Free'] = ptrms_angle
Esempio n. 6
0
    def __init__(self, Data, specimen_name, tmin, tmax, mapping=None, calculate=None):
        self.s = specimen_name
        self.mapping = mapping
        ####
        if calculate:
            self.calculate = []
            for stat in calculate:
                try:
                    ind = map_magic.magic.index('specimen_' + stat)
                    new_stat = map_magic.spd[ind]
                    self.calculate.append(new_stat)
                except ValueError:
                    self.calculate.append(stat)
        ####
        self.specimen_Data = Data[self.s]
        self.datablock = self.specimen_Data['datablock']

        self.x_Arai = self.specimen_Data['x_Arai']
        self.y_Arai = self.specimen_Data['y_Arai']
        self.t_Arai = self.specimen_Data['t_Arai']

        self.zdata = self.specimen_Data['zdata']

        self.x_tail_check=self.specimen_Data['x_tail_check']
        self.y_tail_check=self.specimen_Data['y_tail_check']
        self.tail_checks_temperatures = self.specimen_Data['tail_check_temperatures']
#        self.x_tail_check_starting_point = self.specimen_Data['x_tail_check_starting_point']
#        self.y_tail_check_starting_point = self.specimen_Data['y_tail_check_starting_point']
        self.tail_checks_starting_temperatures = self.specimen_Data['tail_checks_starting_temperatures']

# pTRM checks ("triangles")
        self.x_ptrm_check = self.specimen_Data['x_ptrm_check'] # a list of x coordinates of pTRM checks
        self.y_ptrm_check = self.specimen_Data['y_ptrm_check'] # a list of y coordinates of pTRM checks      
        self.ptrm_checks_temperatures= self.specimen_Data['ptrm_checks_temperatures'] # a list of pTRM checks temperature 
#        Data[s]['x_ptrm_check_starting_point'] # a list of x coordinates of the point ehere the pTRM checks started from
#         Data[s]['y_ptrm_check_starting_point'] # a list of y coordinates of the point ehere the pTRM checks started from     
        self.ptrm_checks_starting_temperatures = self.specimen_Data['ptrm_checks_starting_temperatures'] # a list of temperatures from which the pTRM checks started from 

        # AC checks
        self.x_add_check = self.specimen_Data['x_additivity_check']
        self.y_add_check = self.specimen_Data['y_additivity_check']
        self.add_checks_temperatures = self.specimen_Data['additivity_check_temperatures']
        self.add_checks_starting_temperatures = self.specimen_Data['additivity_check_starting_temperatures']
        self.x_add_check_starting_point = self.specimen_Data['x_additivity_check_starting_point']
        self.y_add_check_starting_point = self.specimen_Data['y_additivity_check_starting_point']
        
        # Data in Temp/Dec/Inc/Int format
        self.PTRMS = self.specimen_Data['PTRMS']
        self.NRMS = self.specimen_Data['NRMS']
        self.NRM = self.specimen_Data['NRM']
        self.PTRM_Checks = self.specimen_Data['PTRM_Checks']
        self.TAIL_Checks = self.specimen_Data['TAIL_Checks']
        self.AC_Diffs = self.specimen_Data['AC']
#        self.ADD_Checks = self.specimen_Data['ADD_Checks'] # removed this from new_lj_thellier_gui

        self.zijdblock=self.specimen_Data['zijdblock']        
        self.z_temperatures=self.specimen_Data['z_temp']

        self.start=self.t_Arai.index(tmin)
        self.end=self.t_Arai.index(tmax)

        self.pars={}

        self.pars['specimen_lab_dc_field'] = self.specimen_Data['pars']['lab_dc_field']
 #       self.pars['specimen_lab_ac_field'] = self.specimen_Data['pars']['lab_ac_field']
        self.B_lab_dir = [self.specimen_Data['Thellier_dc_field_phi'], self.specimen_Data['Thellier_dc_field_theta'], 
                          self.specimen_Data['Thellier_dc_field_uT']]  # 
        self.B_lab_cart = lib_direct.dir2cart(self.B_lab_dir)

  #      self.pars['magic_method_codes']=Data[self.s]['pars']['magic_method_codes']
        self.pars['specimen_int_n']=self.end-self.start+1
        self.pars['specimen_n_total']=len(self.x_Arai)

 
        #LJ ADDING stats:
        self.steps_Arai = self.specimen_Data['steps_Arai']
        self.n = float(self.end-self.start+1)
        self.n_max = len(self.t_Arai)
        self.tmin = tmin 
        self.tmax = tmax
        self.tmin_K = tmin - 273. 
        self.tmax_K = tmax - 273
        self.x_Arai_segment = self.x_Arai[self.start:self.end+1] 
        self.y_Arai_segment = self.y_Arai[self.start:self.end+1]
        self.x_Arai_mean = numpy.mean(self.x_Arai_segment)
        self.y_Arai_mean = numpy.mean(self.y_Arai_segment)
        # try
        self.pars['x_Arai_mean'] = self.x_Arai_mean
        self.pars['y_Arai_mean'] = self.y_Arai_mean
        self.pars['tmin'] = tmin
        self.pars['tmax'] = tmax
        #
        self.xy_Arai = lib_arai.get_xy_array(self.x_Arai, self.y_Arai)
        self.xy_Arai_segment = lib_arai.get_xy_array(self.x_Arai_segment, self.y_Arai_segment)
Esempio n. 7
0
    def __init__(self, Data, specimen_name, tmin=None, tmax=None,
                 mapping=None, calculate=None,acceptance_criteria={},
                 tmin_ind=None, tmax_ind=None):
        #print("MAKING PINTPARS")
        self.acceptance_criteria=acceptance_criteria
        self.s = specimen_name
        self.mapping = mapping
        ####
        if calculate:
            self.calculate = []
            for stat in calculate:
                try:
                    ind = map_magic.magic.index('specimen_' + stat)
                    new_stat = map_magic.spd[ind]
                    self.calculate.append(new_stat)
                except ValueError:
                    print("doesn't start with 'specimen'", stat)
                    #self.calculate.append(stat)
        ####
        self.specimen_Data = Data[self.s]
        self.datablock = self.specimen_Data['datablock']

        self.x_Arai = self.specimen_Data['x_Arai']
        self.y_Arai = self.specimen_Data['y_Arai']
        self.t_Arai = self.specimen_Data['t_Arai']

        self.zdata = self.specimen_Data['zdata']

        self.x_tail_check=self.specimen_Data['x_tail_check']
        self.y_tail_check=self.specimen_Data['y_tail_check']
        self.tail_checks_temperatures = self.specimen_Data['tail_check_temperatures']
#        self.x_tail_check_starting_point = self.specimen_Data['x_tail_check_starting_point']
#        self.y_tail_check_starting_point = self.specimen_Data['y_tail_check_starting_point']
        self.tail_checks_starting_temperatures = self.specimen_Data['tail_checks_starting_temperatures']

# pTRM checks ("triangles")
        self.x_ptrm_check = self.specimen_Data['x_ptrm_check'] # a list of x coordinates of pTRM checks
        self.y_ptrm_check = self.specimen_Data['y_ptrm_check'] # a list of y coordinates of pTRM checks
        self.ptrm_checks_temperatures= self.specimen_Data['ptrm_checks_temperatures'] # a list of pTRM checks temperature
#        Data[s]['x_ptrm_check_starting_point'] # a list of x coordinates of the point ehere the pTRM checks started from
#         Data[s]['y_ptrm_check_starting_point'] # a list of y coordinates of the point ehere the pTRM checks started from
        self.ptrm_checks_starting_temperatures = self.specimen_Data['ptrm_checks_starting_temperatures'] # a list of temperatures from which the pTRM checks started from

        # AC checks
        self.x_add_check = self.specimen_Data['x_additivity_check']
        self.y_add_check = self.specimen_Data['y_additivity_check']
        self.add_checks_temperatures = self.specimen_Data['additivity_check_temperatures']
        self.add_checks_starting_temperatures = self.specimen_Data['additivity_check_starting_temperatures']
        self.x_add_check_starting_point = self.specimen_Data['x_additivity_check_starting_point']
        self.y_add_check_starting_point = self.specimen_Data['y_additivity_check_starting_point']

        # Data in Temp/Dec/Inc/Int format
        self.PTRMS = self.specimen_Data['PTRMS']
        self.NRMS = self.specimen_Data['NRMS']
        self.NRM = self.specimen_Data['NRM']
        self.PTRM_Checks = self.specimen_Data['PTRM_Checks']
        self.TAIL_Checks = self.specimen_Data['TAIL_Checks']
        self.AC_Diffs = self.specimen_Data['AC']
#        self.ADD_Checks = self.specimen_Data['ADD_Checks'] # removed this from new_lj_thellier_gui

        self.zijdblock=self.specimen_Data['zijdblock']
        self.z_temperatures=self.specimen_Data['z_temp']


        # find index from start/end temperatures
        if tmin:
            self.start=self.t_Arai.index(tmin)
            self.end=self.t_Arai.index(tmax)
        # or find start/end temperatures from index
        else:
            if not tmin_ind:tmin_ind=0
            if not tmax_ind:tmax_ind=len(self.t_Arai)
            self.start = tmin_ind
            self.end = tmax_ind
            tmin = self.t_Arai[tmin_ind]
            try:
                tmax = self.t_Arai[tmax_ind]
            except IndexError:
                tmax = self.t_Arai[-1]

        self.pars={}

        self.pars['specimen_lab_dc_field'] = self.specimen_Data['pars']['lab_dc_field']
 #       self.pars['specimen_lab_ac_field'] = self.specimen_Data['pars']['lab_ac_field']
        self.B_lab_dir = [self.specimen_Data['Thellier_dc_field_phi'], self.specimen_Data['Thellier_dc_field_theta'],
                          self.specimen_Data['Thellier_dc_field_uT']]  #
        self.B_lab_cart = lib_direct.dir2cart(self.B_lab_dir)

  #      self.pars['magic_method_codes']=Data[self.s]['pars']['magic_method_codes']
        self.pars['specimen_int_n']=int(self.end-self.start+1)
        self.pars['specimen_n_total']=len(self.x_Arai)


        #LJ ADDING stats:
        self.steps_Arai = self.specimen_Data['steps_Arai']
        self.n = int(self.end-self.start+1)
        self.n_max = len(self.t_Arai)
        self.tmin = tmin
        self.tmax = tmax
        self.tmin_K = tmin - 273.
        self.tmax_K = tmax - 273
        self.x_Arai_segment = self.x_Arai[self.start:self.end+1]
        self.y_Arai_segment = self.y_Arai[self.start:self.end+1]
        self.x_Arai_mean = numpy.mean(self.x_Arai_segment)
        self.y_Arai_mean = numpy.mean(self.y_Arai_segment)
        # try
        self.pars['x_Arai_mean'] = self.x_Arai_mean
        self.pars['y_Arai_mean'] = self.y_Arai_mean
        self.pars['tmin'] = tmin
        self.pars['tmax'] = tmax
        #
        self.xy_Arai = lib_arai.get_xy_array(self.x_Arai, self.y_Arai)
        self.xy_Arai_segment = lib_arai.get_xy_array(self.x_Arai_segment, self.y_Arai_segment)
Esempio n. 8
0
    def __init__(self, Data,specimen_name,tmin,tmax):
        print "calling __init__ PintPars object"
        #print 'specimens', Data.keys()
        self.s=specimen_name
        self.specimen_Data=Data[self.s]
        self.datablock = self.specimen_Data['datablock']

        self.x_Arai=self.specimen_Data['x_Arai']
        self.y_Arai=self.specimen_Data['y_Arai']
        self.t_Arai=self.specimen_Data['t_Arai']

        self.zdata = self.specimen_Data['zdata'] # LJ add

        self.x_tail_check=self.specimen_Data['x_tail_check']
        self.y_tail_check=self.specimen_Data['y_tail_check']
        self.tail_checks_temperatures = self.specimen_Data['tail_check_temperatures']
#        self.x_tail_check_starting_point = self.specimen_Data['x_tail_check_starting_point']
#        self.y_tail_check_starting_point = self.specimen_Data['y_tail_check_starting_point']
        self.tail_checks_starting_temperatures = self.specimen_Data['tail_checks_starting_temperatures']

# pTRM checks ("triangles")
        self.x_ptrm_check = self.specimen_Data['x_ptrm_check'] # a list of x coordinates of pTRM checks
        self.y_ptrm_check = self.specimen_Data['y_ptrm_check'] # a list of y coordinates of pTRM checks      
        self.ptrm_checks_temperatures= self.specimen_Data['ptrm_checks_temperatures'] # a list of pTRM checks temperature 
#        Data[s]['x_ptrm_check_starting_point'] # a list of x coordinates of the point ehere the pTRM checks started from
#         Data[s]['y_ptrm_check_starting_point'] # a list of y coordinates of the point ehere the pTRM checks started from     
        self.ptrm_checks_starting_temperatures = self.specimen_Data['ptrm_checks_starting_temperatures'] # a list of temperatures from which the pTRM checks started from 

        # AC checks
        self.x_add_check = self.specimen_Data['x_additivity_check']
        self.y_add_check = self.specimen_Data['y_additivity_check']
        self.add_checks_temperatures = self.specimen_Data['additivity_check_temperatures']
        self.add_checks_starting_temperatures = self.specimen_Data['additivity_check_starting_temperatures']
        self.x_add_check_starting_point = self.specimen_Data['x_additivity_check_starting_point']
        self.y_add_check_starting_point = self.specimen_Data['y_additivity_check_starting_point']
        
        # Data in Temp/Dec/Inc/Int format
        self.PTRMS = self.specimen_Data['PTRMS']
        self.NRMS = self.specimen_Data['NRMS']
        self.NRM = self.specimen_Data['NRM']
        self.PTRM_Checks = self.specimen_Data['PTRM_Checks']
        self.TAIL_Checks = self.specimen_Data['TAIL_Checks']
        self.AC_Diffs = self.specimen_Data['AC']
#        self.ADD_Checks = self.specimen_Data['ADD_Checks'] # removed this from new_lj_thellier_gui

        self.zijdblock=self.specimen_Data['zijdblock']        
        self.z_temperatures=self.specimen_Data['z_temp']

        self.start=self.t_Arai.index(tmin)
        self.end=self.t_Arai.index(tmax)

        self.pars={}

        self.pars['lab_dc_field']=self.specimen_Data['pars']['lab_dc_field']
        self.B_lab_dir = [self.specimen_Data['Thellier_dc_field_phi'], self.specimen_Data['Thellier_dc_field_theta'], 
                          self.specimen_Data['Thellier_dc_field_uT']]  # 
        self.B_lab_cart = lib_direct.dir2cart(self.B_lab_dir)

  #      self.pars['magic_method_codes']=Data[self.s]['pars']['magic_method_codes']
        self.pars['specimen_n']=self.end-self.start+1

 
        #LJ ADDING stats:
        self.steps_Arai = self.specimen_Data['steps_Arai']
        self.n = float(self.end-self.start+1)
        self.n_max = len(self.t_Arai)
        self.tmin = tmin 
        self.tmax = tmax
        self.tmin_K = tmin - 273. 
        self.tmax_K = tmax - 273
        self.x_Arai_segment = self.x_Arai[self.start:self.end+1] 
        self.y_Arai_segment = self.y_Arai[self.start:self.end+1]
        self.x_Arai_mean = numpy.mean(self.x_Arai_segment)
        self.y_Arai_mean = numpy.mean(self.y_Arai_segment)
        # try
        self.pars['x_Arai_mean'] = self.x_Arai_mean
        self.pars['y_Arai_mean'] = self.y_Arai_mean
        self.pars['tmin'] = tmin
        self.pars['tmax'] = tmax
        #
        self.xy_Arai = lib_arai.get_xy_array(self.x_Arai, self.y_Arai)
        self.xy_Arai_segment = lib_arai.get_xy_array(self.x_Arai_segment, self.y_Arai_segment)