Changeset 7241d56 in sasview
- Timestamp:
- Dec 21, 2010 9:46:10 AM (14 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:
- 98eefdb
- Parents:
- 7342634
- Location:
- DataLoader
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
DataLoader/extensions/smearer.cpp
rf867cd9 r7241d56 285 285 // Normalize counts 286 286 iq_out[q_i] = (counts>0.0) ? sum/counts : 0; 287 //printf("\n iii=%g,%g ",iq_out[q_i], q_i);288 287 } 289 288 } -
DataLoader/qsmearing.py
rf867cd9 r7241d56 167 167 if first_bin < 0: 168 168 first_bin = 0 169 169 170 170 # With a model given, compute I for the extrapolated points and append 171 171 # to the iq_in … … 175 175 first_bin, last_bin) 176 176 iq_in_low = self.model.evalDistribution( \ 177 self.qvalues[0:self.nbins_low])177 numpy.fabs(self.qvalues[0:self.nbins_low])) 178 178 iq_in_high = self.model.evalDistribution( \ 179 179 self.qvalues[(len(self.qvalues) - \ 180 self.nbins_high - 1): -1]) 180 self.nbins_high - 1):]) 181 # Todo: find out who is sending iq[last_poin] = 0. 182 if iq_in[len(iq_in) - 1] == 0: 183 iq_in[len(iq_in) - 1] = iq_in_high[0] 184 # Append the extrapolated points to the data points 181 185 if self.nbins_low > 0: 182 186 iq_in_temp = numpy.append(iq_in_low, iq_in) 183 187 if self.nbins_high > 0: 184 iq_in_temp = numpy.append(iq_in_temp, iq_in_high )188 iq_in_temp = numpy.append(iq_in_temp, iq_in_high[1:]) 185 189 else: 186 190 temp_first = first_bin 187 191 temp_last = last_bin 188 192 iq_in_temp = iq_in 193 189 194 # Sanity check 190 195 if len(iq_in_temp) != self.nbins: … … 203 208 msg = "_BaseSmearer: could not smear, code = %g" % smear_output 204 209 raise RuntimeError, msg 205 206 210 207 211 temp_first += self.nbins_low 208 temp_last = self.nbins - (self.nbins_high + 1)209 210 return iq_out[temp_first: (temp_last + 1)]212 temp_last = self.nbins - self.nbins_high 213 214 return iq_out[temp_first: temp_last] 211 215 212 216 def _initialize_smearer(self): … … 256 260 """ 257 261 # For the first bin 258 if first_bin > 0: 259 # In the case that doesn't need lower q extrapolation data 260 first_bin += self.nbins_low 261 else: 262 # In the case that needs low extrapolation data 263 first_bin = 0 262 # In the case that needs low extrapolation data 263 first_bin = 0 264 264 # For last bin 265 265 if last_bin >= self.nbins - (self.nbins_high + self.nbins_low + 1): … … 489 489 # Length of the width 490 490 length = len(width) 491 max_width = max(width) 491 width_low = math.fabs(width[0]) 492 width_high = math.fabs(width[length -1]) 492 493 # Find bin sizes 493 494 bin_size_low = math.fabs(data_x[1] - data_x[0]) 494 bin_size_high = math.fabs(data_x[length -1] - data_x[length -2]) 495 bin_size_high = math.fabs(data_x[length - 1] - data_x[length - 2]) 496 # Compare width(dQ) to the data bin size and take smaller one as the bin 497 # size of the extrapolation; this will correct some weird behavior 498 # at the edge 499 if width_low < (bin_size_low): 500 bin_size_low = width_low / 2.0 501 if width_high < (bin_size_high): 502 bin_size_high = width_high / 2.0 503 495 504 # Number of q points required below the 1st data point in order to extend 496 505 # them 3 times of the width (std) 497 nbins_low = math.ceil(3 * max_width/ bin_size_low)506 nbins_low = math.ceil(3 * width_low / bin_size_low) 498 507 # Number of q points required above the last data point 499 nbins_high = math.ceil(3 * max_width / (bin_size_high))508 nbins_high = math.ceil(3 * width_high / (bin_size_high)) 500 509 # Make null q points 501 510 extra_low = numpy.zeros(nbins_low) … … 509 518 ind += 1 510 519 # Remove the points <= 0 511 extra_low = extra_low[extra_low > 0]512 nbins_low = len(extra_low)520 #extra_low = extra_low[extra_low > 0] 521 #nbins_low = len(extra_low) 513 522 # Reset ind for another extrapolation 514 523 ind = 0 … … 521 530 data_x_ext = numpy.append(extra_low, data_x) 522 531 data_x_ext = numpy.append(data_x_ext, extra_high) 532 523 533 # Redefine extra_low and high based on corrected nbins 524 534 # And note that it is not necessary for extra_width to be a non-zero
Note: See TracChangeset
for help on using the changeset viewer.