Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply_noise(flux, flux_err) #108

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/tdastro/pipeline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Utilities for running the simulation pipeline."""


import numpy as np


def apply_noise(flux, flux_err, rng=None):
"""Apply Gaussian noise to a flux measurement.

Parameters
----------
flux : ndarray of float
The flux measurement.
flux_err : ndarray of float
The flux measurement error.
rng : np.random.Generator, optional
The random number generator.

Returns
-------
ndarray of float
The noisy flux measurement.
"""
if rng is None:
rng = np.random.default_rng()

return rng.normal(loc=flux, scale=flux_err)
Loading