Skip to content

Commit

Permalink
Merge branch 'main' into dust_map3
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremykubica committed Nov 7, 2024
2 parents a0894f5 + 9ea64af commit 2c80c85
Show file tree
Hide file tree
Showing 13 changed files with 799 additions and 135 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ jobs:
extra_args: --all-files --verbose
env:
SKIP: "check-lincc-frameworks-template-version,no-commit-to-branch,check-added-large-files,validate-pyproject,sphinx-build,pytest-check"
- uses: pre-commit-ci/lite-action@v1.0.3
- uses: pre-commit-ci/lite-action@v1.1.0
if: failure() && github.event_name == 'pull_request' && github.event.pull_request.draft == false
49 changes: 49 additions & 0 deletions src/tdastro/astro_utils/obs_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import numpy as np


def phot_eff_function(snr):
"""
Photometric detection efficiency as a simple step function of snr.
Parameters
----------
snr: `list` or `numpy.ndarray`
Signal to noise ratio of a list of observations.
Returns
-------
eff: `list` or `numpy.ndarray`
The photometric detection efficiency given snr.
"""

snr = np.array(snr)
eff = np.where(snr > 5, 1.0, 0.0)

return eff


def spec_eff_function(peak_imag):
"""
Spectroscopic follow-up efficiency as a function of peak i band magnitude.
Parameters
----------
peak_imag: `list` or `numpy.ndarray`
Peak magnitude in i band.
Returns
-------
eff: `list` or `numpy.ndarray`
The spectroscopic efficiency given peak i band magnitude.
Based on Equation (17) in Kessler et al. 2019
s0, s1, s2 are fitted using data from Figure 4 in Kessler et al. 2019
"""

s0 = 1.0
s1 = 2.36
s2 = 51.9

peak_imag = np.array(peak_imag)
eff = s0 * np.power((1.0 + np.exp(s1 * peak_imag - s2)), -1)

return eff
9 changes: 6 additions & 3 deletions src/tdastro/base_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def _sample_helper(self, graph_state, seen_nodes, rng_info=None):
An object mapping graph parameters to their values. This object is modified
in place as it is sampled.
seen_nodes : `dict`
A dictionary mapping nodes seen during this sampling run to their ID.
A dictionary mapping nodes strings seen during this sampling run to their object.
Used to avoid sampling nodes multiple times and to validity check the graph.
rng_info : numpy.random._generator.Generator, optional
A given numpy random number generator to use for this computation. If not
Expand All @@ -482,9 +482,12 @@ def _sample_helper(self, graph_state, seen_nodes, rng_info=None):
------
Raise a ``KeyError`` if the sampling encounters an error with the order of dependencies.
"""
if self in seen_nodes:
node_str = str(self)
if node_str in seen_nodes:
if seen_nodes[node_str] != self:
raise ValueError(f"Duplicate node label {node_str}.")
return # Nothing to do
seen_nodes[self] = self.node_pos
seen_nodes[node_str] = self

# Run through each parameter and sample it based on the given recipe.
# As of Python 3.7 dictionaries are guaranteed to preserve insertion ordering,
Expand Down
Loading

0 comments on commit 2c80c85

Please sign in to comment.