Changeset 038c00cf in sasview
- Timestamp:
- Mar 2, 2015 4:38:00 PM (10 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- f06d7fc
- Parents:
- 13e46abe
- Location:
- src/sas/pr
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/pr/distance_explorer.py
r79492222 r038c00cf 3 3 #This software was developed by the University of Tennessee as part of the 4 4 #Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 5 #project funded by the US National Science Foundation. 5 #project funded by the US National Science Foundation. 6 6 # 7 7 #See the license text in license.txt … … 19 19 20 20 21 class Results :21 class Results(object): 22 22 """ 23 23 Class to hold the inversion output parameters … … 40 40 ## List of errors found during the last exploration 41 41 self.errors = [] 42 43 42 43 44 44 class DistExplorer(object): 45 45 """ 46 46 The explorer class 47 47 """ 48 48 49 49 def __init__(self, pr_state): 50 50 """ 51 51 Initialization. 52 52 53 53 :param pr_state: sas.pr.invertor.Invertor object 54 54 55 55 """ 56 56 self.pr_state = pr_state 57 57 self._default_min = 0.8 * self.pr_state.d_max 58 58 self._default_max = 1.2 * self.pr_state.d_max 59 59 60 60 def __call__(self, dmin=None, dmax=None, npts=10): 61 61 """ 62 62 Compute the outputs as a function of D_max. 63 63 64 64 :param dmin: minimum value for D_max 65 65 :param dmax: maximum value for D_max 66 66 :param npts: number of points for D_max 67 67 68 68 """ 69 69 # Take care of the defaults if needed 70 70 if dmin is None: 71 71 dmin = self._default_min 72 72 73 73 if dmax is None: 74 74 dmax = self._default_max 75 75 76 76 # Results object to store the computation outputs. 77 77 results = Results() 78 78 79 79 # Loop over d_max values 80 80 for i in range(npts): … … 83 83 try: 84 84 out, cov = self.pr_state.invert(self.pr_state.nfunc) 85 85 86 86 # Store results 87 87 iq0 = self.pr_state.iq0(out) … … 90 90 pos_err = self.pr_state.get_pos_err(out, cov) 91 91 osc = self.pr_state.oscillations(out) 92 92 93 93 results.d_max.append(self.pr_state.d_max) 94 94 results.bck.append(self.pr_state.background) … … 104 104 msg += "D_max=%s\n %s" % (str(d), sys.exc_value) 105 105 results.errors.append(msg) 106 106 107 107 return results -
src/sas/pr/num_term.py
r79492222 r038c00cf 17 17 self.nterm_max = 50 18 18 self.isquit_func = None 19 19 20 20 self.osc_list = [] 21 21 self.err_list = [] 22 22 self.alpha_list = [] 23 23 self.mess_list = [] 24 25 24 self.dataset = [] 26 25 27 26 def is_odd(self, n): 28 27 """ … … 41 40 lis.append(re) 42 41 return lis 43 42 44 43 def median_osc(self): 45 44 """ … … 78 77 self.alpha_list.append(inver.alpha) 79 78 self.mess_list.append(message) 80 79 81 80 new_osc1 = [] 82 81 new_osc2 = [] … … 84 83 flag9 = False 85 84 flag8 = False 86 flag7 = False87 85 for i in range(len(self.err_list)): 88 86 if self.err_list[i] <= 1.0 and self.err_list[i] >= 0.9: … … 94 92 if self.err_list[i] < 0.8 and self.err_list[i] >= 0.7: 95 93 new_osc3.append(self.osc_list[i]) 96 flag7 = True 97 94 98 95 if flag9 == True: 99 96 self.dataset = new_osc1 … … 102 99 else: 103 100 self.dataset = new_osc3 104 101 105 102 return self.dataset 106 103 107 104 def ls_osc(self): 108 105 """ 109 106 """ 110 107 # Generate data 111 ls_osc = self.get0_out()108 # ls_osc = self.get0_out() 112 109 med = self.median_osc() 113 110 114 111 #TODO: check 1 115 112 ls_osc = self.dataset … … 124 121 """ 125 122 ls = self.ls_osc() 126 #print "ls", ls127 123 nt_ls = [] 128 124 for i in range(len(ls)): 129 125 r = ls[i] 130 126 n = self.osc_list.index(r) + 10 131 #er = self.err_list[n]132 #nt = self.osc_list.index(r) + 10133 127 nt_ls.append(n) 134 #print "nt list", nt_ls135 128 return nt_ls 136 129 … … 142 135 nts = self.compare_err() 143 136 div = len(nts) 144 tem = float(div) /2.0137 tem = float(div) / 2.0 145 138 odd = self.is_odd(div) 146 139 if odd == True: … … 148 141 else: 149 142 nt = nts[int(tem) - 1] 150 return nt, self.alpha_list[nt - 10], self.mess_list[nt -10]143 return nt, self.alpha_list[nt - 10], self.mess_list[nt - 10] 151 144 except: 152 145 return self.nterm_min, self.alpha_list[10], self.mess_list[10] … … 156 149 def load(path): 157 150 # Read the data from the data file 158 data_x 159 data_y 151 data_x = numpy.zeros(0) 152 data_y = numpy.zeros(0) 160 153 data_err = numpy.zeros(0) 161 scale 162 min_err 154 scale = None 155 min_err = 0.0 163 156 if not path == None: 164 input_f = open(path, 'r')165 buff 166 lines 157 input_f = open(path, 'r') 158 buff = input_f.read() 159 lines = buff.split('\n') 167 160 for line in lines: 168 161 try: … … 179 172 err = scale * math.sqrt(test_y) + min_err 180 173 #err = 0 181 174 182 175 data_x = numpy.append(data_x, test_x) 183 176 data_y = numpy.append(data_y, test_y) … … 185 178 except: 186 179 pass 187 180 188 181 return data_x, data_y, data_err 189 182
Note: See TracChangeset
for help on using the changeset viewer.