Parameters ---------- fit_x : array energy axis fit_y : array fitted spectrum fit_all : dict dict of individual line residual : array residual between fit and exp
(self, fit_x, fit_y, fit_all, residual=None)
| 1229 | self.param_model.add_element_intensity = round(intensity, 2) |
| 1230 | |
| 1231 | def plot_fit(self, fit_x, fit_y, fit_all, residual=None): |
| 1232 | """ |
| 1233 | Parameters |
| 1234 | ---------- |
| 1235 | fit_x : array |
| 1236 | energy axis |
| 1237 | fit_y : array |
| 1238 | fitted spectrum |
| 1239 | fit_all : dict |
| 1240 | dict of individual line |
| 1241 | residual : array |
| 1242 | residual between fit and exp |
| 1243 | """ |
| 1244 | if fit_x is None or fit_y is None: |
| 1245 | return |
| 1246 | |
| 1247 | while len(self.plot_fit_obj): |
| 1248 | self.plot_fit_obj.pop().remove() |
| 1249 | |
| 1250 | (ln,) = self._ax.plot( |
| 1251 | fit_x, |
| 1252 | fit_y, |
| 1253 | color=self.plot_style["fit"]["color"], |
| 1254 | label=self.plot_style["fit"]["label"], |
| 1255 | linewidth=self.plot_style["fit"]["linewidth"], |
| 1256 | ) |
| 1257 | self.plot_fit_obj.append(ln) |
| 1258 | |
| 1259 | if residual is not None: |
| 1260 | # shiftv = 1.5 # move residual down by some amount |
| 1261 | (ln,) = self._ax.plot( |
| 1262 | fit_x, |
| 1263 | residual - 0.15 * self.max_v, # shiftv*(np.max(np.abs(self.residual))), |
| 1264 | label=self.plot_style["residual"]["label"], |
| 1265 | color=self.plot_style["residual"]["color"], |
| 1266 | ) |
| 1267 | self.plot_fit_obj.append(ln) |
| 1268 | |
| 1269 | k_num = 0 |
| 1270 | l_num = 0 |
| 1271 | m_num = 0 |
| 1272 | p_num = 0 |
| 1273 | for k, v in fit_all.items(): |
| 1274 | if k == "background": |
| 1275 | (ln,) = self._ax.plot( |
| 1276 | fit_x, |
| 1277 | v, |
| 1278 | color=self.plot_style["background"]["color"], |
| 1279 | # marker=self.plot_style['background']['marker'], |
| 1280 | # markersize=self.plot_style['background']['markersize'], |
| 1281 | label=self.plot_style["background"]["label"], |
| 1282 | ) |
| 1283 | self.plot_fit_obj.append(ln) |
| 1284 | elif k == "compton": |
| 1285 | (ln,) = self._ax.plot( |
| 1286 | fit_x, |
| 1287 | v, |
| 1288 | color=self.plot_style["compton"]["color"], |
no test coverage detected