| @@ 283-299 (lines=17) @@ | ||
| 280 | spec += fun(weights[ii], widths[ii], x, positions[ii]) |
|
| 281 | return spec |
|
| 282 | ||
| 283 | def spectrum_sum_dfun(self, fun, multiplier, x, pos, *p): |
|
| 284 | rest = p |
|
| 285 | npts = len(p) // 2 |
|
| 286 | weights = rest[:npts] |
|
| 287 | widths = rest[npts:2*npts] |
|
| 288 | positions = pos |
|
| 289 | # print(len(positions)) |
|
| 290 | spec = np.zeros((npts, len(x))) |
|
| 291 | #print "len x is "+str(len(spec)) |
|
| 292 | # print len(spec), type(spec) |
|
| 293 | # print len(positions), type(positions) |
|
| 294 | # print len(weights), type(weights) |
|
| 295 | for ii in range(len(weights)): |
|
| 296 | spec[ii] = multiplier[ii]*fun(weights[ii], |
|
| 297 | widths[ii], |
|
| 298 | x, positions[ii]) |
|
| 299 | return spec |
|
| 300 | ||
| 301 | def lorentzian(a, w, x, c): |
|
| 302 | y = a / (1.0 + (2.0 * (c - x) / w) ** 2) |
|
| @@ 161-170 (lines=10) @@ | ||
| 158 | ))) |
|
| 159 | return weights, widths, np.array(areas) |
|
| 160 | ||
| 161 | def spectrum_sum_dfun(self, fun, multiplier, x, pos, *p): |
|
| 162 | rest = p |
|
| 163 | npts = len(p) // 2 |
|
| 164 | weights = rest[:npts] |
|
| 165 | widths = rest[npts:2*npts] |
|
| 166 | positions = pos |
|
| 167 | spec = np.zeros((npts, len(x))) |
|
| 168 | for ii in range(len(weights)): |
|
| 169 | spec[ii] = multiplier[ii]*fun(weights[ii], widths[ii], x, positions[ii]) |
|
| 170 | return spec |
|
| 171 | ||
| 172 | ||
| 173 | def lorentzian(a, w, x, c): |
|