Skip to content

Commit 7f088ed

Browse files
authored
Merge pull request #28 from BAMresearch/modifying_databundle_and_associates
adding a new poisson uncertainties estimator
2 parents 5045ae9 + 22c2233 commit 7f088ed

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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

Comments
 (0)