Plot the range of energies selected for processing. The range may be optionally provided as arguments. The range values that are not provided, are read from globally accessible dictionary of parameters. The values passed as arguments are mainly used if the function i
(self, *, axes, barh_existing, e_low=None, e_high=None, n_points=4096)
| 1438 | return max_size |
| 1439 | |
| 1440 | def plot_selected_energy_range(self, *, axes, barh_existing, e_low=None, e_high=None, n_points=4096): |
| 1441 | """ |
| 1442 | Plot the range of energies selected for processing. The range may be optionally |
| 1443 | provided as arguments. The range values that are not provided, are read from |
| 1444 | globally accessible dictionary of parameters. The values passed as arguments |
| 1445 | are mainly used if the function is called during interactive update of the |
| 1446 | range, when the order of update is undetermined and the parameter dictionary |
| 1447 | may be updated after the function is called. |
| 1448 | """ |
| 1449 | # The range of energy selected for analysis |
| 1450 | if e_low is None: |
| 1451 | e_low = self.param_model.param_new["non_fitting_values"]["energy_bound_low"]["value"] |
| 1452 | if e_high is None: |
| 1453 | e_high = self.param_model.param_new["non_fitting_values"]["energy_bound_high"]["value"] |
| 1454 | |
| 1455 | # Model coefficients for the energy axis |
| 1456 | c0 = self.param_model.param_new["e_offset"]["value"] |
| 1457 | c1 = self.param_model.param_new["e_linear"]["value"] |
| 1458 | c2 = self.param_model.param_new["e_quadratic"]["value"] |
| 1459 | |
| 1460 | # Generate the values for 'energy' axis |
| 1461 | x_v = c0 + np.arange(n_points) * c1 + np.arange(n_points) ** 2 * c2 |
| 1462 | ss = (x_v < e_high + c1) & (x_v > e_low - c1) |
| 1463 | |
| 1464 | # Trim both arrays to minimize the number of points |
| 1465 | x_v = x_v[ss] |
| 1466 | ss = ss[ss] |
| 1467 | ss[0] = False |
| 1468 | ss[-1] = False |
| 1469 | |
| 1470 | # Negative values will work for semilog plot as well |
| 1471 | y_min, y_max = -1e30, 1e30 # Select the max and min values for plotted rectangles |
| 1472 | |
| 1473 | # Remove the plot if it exists |
| 1474 | if barh_existing in axes.collections: |
| 1475 | barh_existing.remove() |
| 1476 | |
| 1477 | # Create the new plot (based on new parameters if necessary |
| 1478 | # barh_new = PolyCollection.span_where( |
| 1479 | # x_v, ymin=y_min, ymax=y_max, where=ss, facecolor="white", edgecolor="yellow", alpha=1 |
| 1480 | # ) |
| 1481 | # axes.add_collection(barh_new) |
| 1482 | barh_new = axes.fill_between( |
| 1483 | x_v, y1=y_min, y2=y_max, where=ss, facecolor="white", edgecolor="yellow", alpha=1 |
| 1484 | ) |
| 1485 | |
| 1486 | return barh_new |
| 1487 | |
| 1488 | def prepare_preview_spectrum_plot(self): |
| 1489 | if self._ax_preview: |
no outgoing calls
no test coverage detected