| @@ 297-313 (lines=17) @@ | ||
| 294 | spec += fun(weights[ii], widths[ii], x, positions[ii]) |
|
| 295 | return spec |
|
| 296 | ||
| 297 | def spectrum_sum_dfun(self, fun, multiplier, x, pos, *p): |
|
| 298 | rest = p |
|
| 299 | npts = len(p) // 2 |
|
| 300 | weights = rest[:npts] |
|
| 301 | widths = rest[npts:2*npts] |
|
| 302 | positions = pos |
|
| 303 | # print(len(positions)) |
|
| 304 | spec = np.zeros((npts, len(x))) |
|
| 305 | #print "len x is "+str(len(spec)) |
|
| 306 | # print len(spec), type(spec) |
|
| 307 | # print len(positions), type(positions) |
|
| 308 | # print len(weights), type(weights) |
|
| 309 | for ii in range(len(weights)): |
|
| 310 | spec[ii] = multiplier[ii]*fun(weights[ii], |
|
| 311 | widths[ii], |
|
| 312 | x, positions[ii]) |
|
| 313 | return spec |
|
| 314 | ||
| 315 | def lorentzian(a, w, x, c): |
|
| 316 | y = a / (1.0 + (2.0 * (c - x) / w) ** 2) |
|
| @@ 171-180 (lines=10) @@ | ||
| 168 | ))) |
|
| 169 | return weights, widths, np.array(areas) |
|
| 170 | ||
| 171 | def spectrum_sum_dfun(self, fun, multiplier, x, pos, *p): |
|
| 172 | rest = p |
|
| 173 | npts = len(p) // 2 |
|
| 174 | weights = rest[:npts] |
|
| 175 | widths = rest[npts:2*npts] |
|
| 176 | positions = pos |
|
| 177 | spec = np.zeros((npts, len(x))) |
|
| 178 | for ii in range(len(weights)): |
|
| 179 | spec[ii] = multiplier[ii]*fun(weights[ii], widths[ii], x, positions[ii]) |
|
| 180 | return spec |
|
| 181 | ||
| 182 | ||
| 183 | def lorentzian(a, w, x, c): |
|