Changeset 65883cf in sasview
- Timestamp:
- Sep 21, 2009 8:32:18 PM (15 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:
- a0bc608
- Parents:
- a65ffcb
- Location:
- DataLoader
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
DataLoader/extensions/smearer.cpp
r5859862 r65883cf 230 230 * 231 231 */ 232 voidBaseSmearer :: get_bin_range(int i, double* q, double* q_min, double* q_max) {232 int BaseSmearer :: get_bin_range(int i, double* q, double* q_min, double* q_max) { 233 233 if (even_binning) { 234 234 double step = (qmax-qmin)/((double)nbins-1.0); … … 236 236 *q_min = *q - 0.5*step; 237 237 *q_max = *q + 0.5*step; 238 } else { 238 return 1; 239 } else if (i>=0 && i<nbins) { 239 240 *q = q_values[i]; 240 241 if (i==0) { … … 250 251 *q_max = *q + (q_values[i+1]-q_values[i])/2.0; 251 252 } 252 } 253 return 1; 254 } 255 return -1; 253 256 } 254 257 -
DataLoader/extensions/smearer.hh
r5859862 r65883cf 50 50 int get_nbins() { return nbins; } 51 51 // Get the q range of a particular bin 52 virtual voidget_bin_range(int, double*, double*, double*);52 virtual int get_bin_range(int, double*, double*, double*); 53 53 }; 54 54 -
DataLoader/extensions/smearer_module.cpp
r5859862 r65883cf 161 161 BaseSmearer* s = static_cast<BaseSmearer *>(temp); 162 162 163 if(s->get_nbins()<=0 || s->get_nbins()<=bin) { 164 return NULL; 165 } 166 163 167 double q, q_min, q_max; 164 s->get_bin_range(bin, &q, &q_min, &q_max); 165 168 if (s->get_bin_range(bin, &q, &q_min, &q_max)<0) { 169 return NULL; 170 } 166 171 return Py_BuildValue("d", q); 167 172 } -
DataLoader/qsmearing.py
r5859862 r65883cf 106 106 @param q_max: maximum q-value to smear 107 107 """ 108 # If this is the first time we call for smearing, 109 # initialize the C++ smearer object first 110 if not self._init_complete: 111 self._initialize_smearer() 112 108 113 if q_min == None: 109 114 q_min = self.min … … 118 123 119 124 step = (self.max-self.min)/(self.nbins-1.0) 120 for i in range(self.nbins): 121 q_i = smearer.get_q(self._smearer, i) 122 if (q_i >= _qmin_unsmeared) and (q_i <= _qmax_unsmeared): 123 # Identify first and last bin 124 if _first_bin is None: 125 _first_bin = i 126 else: 127 _last_bin = i 125 try: 126 for i in range(self.nbins): 127 q_i = smearer.get_q(self._smearer, i) 128 if (q_i >= _qmin_unsmeared) and (q_i <= _qmax_unsmeared): 129 # Identify first and last bin 130 if _first_bin is None: 131 _first_bin = i 132 else: 133 _last_bin = i 134 except: 135 raise RuntimeError, "_BaseSmearer.get_bin_range: error getting range\n %s" % sys.exc_value 128 136 129 137 return _first_bin, _last_bin … … 151 159 # Storage for smeared I(q) 152 160 iq_out = numpy.zeros(self.nbins) 153 smearer.smear(self._smearer, iq_in, iq_out, first_bin, last_bin) 161 smear_output = smearer.smear(self._smearer, iq_in, iq_out, first_bin, last_bin) 162 if smear_output < 0: 163 raise RuntimeError, "_BaseSmearer: could not smear, code = %g" % smear_output 154 164 return iq_out 155 165 … … 184 194 ## Smearing matrix 185 195 self._weights = None 196 self.qvalues = None 186 197 187 198 def _initialize_smearer(self): … … 275 286 ## Smearing matrix 276 287 self._weights = None 288 self.qvalues = None 277 289 278 290 def _initialize_smearer(self):
Note: See TracChangeset
for help on using the changeset viewer.