Exemple #1
0
 def reqd_stats(self):  
     stats_run = []
     #print 'self.calculate: ', self.calculate
     for stat in self.calculate: # iterate through all stats that should be calculated
         func = self.statistics[stat]
         #print 'func', func
         if func: # sometimes this will be none, since statistics like tmin are generated during __init__ and don't require a function to be run
             if func.__name__ == 'York_Regression':
                 #print 'York_Regression'
                 if 'York_Regression' not in stats_run:
                     func(self)
                     stats_run.append(func.__name__)
             elif func.__name__ in self.dependencies: 
                 for d in self.dependencies[func.__name__]:
                     if d == None: continue
                     #print 'd: ', d,
                     if d.__name__ not in stats_run: # if the dependency has not already been run, run it
                         d(self)
                         stats_run.append(d.__name__)
                 if func.__name__ not in stats_run:
                     func(self) # all dependencies have been satisfied, so run the main function
                     stats_run.append(func.__name__)
             else:
                 #print 'alert: did not find dependencies, now attempting to run'
                 try:
                     func(self) # this will work if the function has no dependencies
                     stats_run.append(func.__name__)
                 except:
                     self.calculate_all_statistics() # if no dependency info can be found, just run all statistics
                     return 0 # since all possible statistics have been run, the function ends
     #print 'stats run: ', stats_run
     if self.mapping == 'magic':
         self.pars = map_magic.mapping(self.pars, map_magic.spd2magic_map)
     if len(stats_run) != len(set(stats_run)):
         raise Exception('lengths were off')
Exemple #2
0
 def calculate_all_statistics(self):
     #print "calling calculate_all_statistics in spd.py"
     if self.n < 3:
         print "-W- Cannot run statistics with only {} points".format(self.n)
         self.pars = {}
         return None
     self.York_Regression()
     self.get_vds()
     self.get_FRAC()
     self.get_curve()
     self.get_curve_prime()
     self.get_SCAT()
     self.get_R_corr2()
     self.get_R_det2()
     self.get_Z()
     self.get_Zstar()
     self.get_IZZI_MD()
     # directional statistics
     self.get_dec_and_inc()
     self.get_ptrm_dec_and_inc()
     self.get_MAD()
     self.get_ptrm_MAD()
     self.get_alpha()
     self.get_DANG()
     self.get_NRM_dev()
     self.get_theta() 
     self.get_gamma()
     # ptrm check statistics
     self.get_n_ptrm()
     if self.pars['n_ptrm'] == 0:
         self.pars['max_ptrm_check'], self.pars['delta_CK'], self.pars['get_DRAT'], self.pars['DRAT'], self.pars['DRATS'], self.pars['CDRAT'], self.pars['mean_DRAT'], self.pars['mean_DEV'], self.pars['max_DEV'], self.pars['delta_pal'] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
         self.get_length_best_fit_line()
     else:
         self.get_max_ptrm_check()
         self.get_delta_CK()
         self.get_DRAT()
         self.get_max_DEV()
         self.get_CDRAT()
         self.get_DRATS()
         self.get_mean_DRAT()
         self.get_mean_DEV()
         self.get_delta_pal()
     # tail check statistics
     self.get_n_tail()
     self.get_max_tail_check()
     self.get_DRAT_tail()
     self.get_delta_TR()
     self.get_MD_VDS()
     # additivity check statistics
     self.get_n_add()
     self.get_delta_AC()
     # stats that require an independent chrm or are not yet coded
     self.get_alpha_prime()
     self.get_CRM_percent()
     self.get_delta_t_star()
     if self.mapping == 'magic':
         self.pars = map_magic.mapping(self.pars, map_magic.spd2magic_map)