|
| 1 | +# src/modacor/dataclasses/processingdata.py |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | +__author__ = "Brian R. Pauw" |
| 4 | +__copyright__ = "MoDaCor team" |
| 5 | +__license__ = "BSD3" |
| 6 | +__date__ = "22/05/2025" |
| 7 | +__version__ = "20250522.1" |
| 8 | +__status__ = "Development" # "Development", "Production" |
| 9 | + |
| 10 | + |
| 11 | +from typing import Any |
| 12 | + |
| 13 | +import numpy as np |
| 14 | + |
| 15 | +from modacor.dataclasses.databundle import DataBundle |
| 16 | +from modacor.dataclasses.process_step import ProcessStep |
| 17 | +from modacor.dataclasses.process_step_describer import ProcessStepDescriber |
| 18 | + |
| 19 | + |
| 20 | +class PoissonUncertainties(ProcessStep): |
| 21 | + """ |
| 22 | + Adding Poisson uncertainties to the data |
| 23 | + """ |
| 24 | + |
| 25 | + documentation = ProcessStepDescriber( |
| 26 | + calling_name="Add Poisson Uncertainties", |
| 27 | + calling_id="PoissonUncertainties", |
| 28 | + calling_module_path=__file__, |
| 29 | + calling_version=__version__, |
| 30 | + required_data_keys=["signal"], |
| 31 | + works_on={"variances": ["Poisson"]}, |
| 32 | + step_keywords=["uncertainties", "Poisson"], |
| 33 | + step_doc="Add Poisson uncertainties to the data", |
| 34 | + step_reference="DOI 10.1088/0953-8984/25/38/383201", |
| 35 | + step_note="This is a simple Poisson uncertainty calculation based on the signal intensity", |
| 36 | + ) |
| 37 | + |
| 38 | + def calculate(self, data: DataBundle, **kwargs: Any): |
| 39 | + """ |
| 40 | + Calculate the Poisson uncertainties for the data |
| 41 | + """ |
| 42 | + |
| 43 | + # Get the data |
| 44 | + signal = data["signal"].signal |
| 45 | + |
| 46 | + # Add the variance to the data |
| 47 | + data["signal"].variances["Poisson"] = np.clip(signal, 1, None) |
0 commit comments