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

Create better resampling #13

Merged
merged 3 commits into from
Jun 28, 2024
Merged

Create better resampling #13

merged 3 commits into from
Jun 28, 2024

Conversation

jeremykubica
Copy link
Contributor

Currently TDAstro requires the creation of a new PhysicalModels anytime we resample the parameters. This might be expensive. This PR adds a slightly more flexible model where the PhysicalModel can pull attributes samples from functions. It is still a bit awkward because the function parameters need different names.

A next step will be to extend this to take in a DAG of sampling effects and do the sampling based on that DAG.

@jeremykubica jeremykubica requested a review from OliviaLynn June 28, 2024 14:11
Copy link
Member

@OliviaLynn OliviaLynn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just the one question

src/tdastro/base_models.py Outdated Show resolved Hide resolved
@jeremykubica jeremykubica merged commit 072c885 into main Jun 28, 2024
All the keyword arguments, including the values needed to sample parameters.
"""
if self.host is not None:
self.host.sample_parameters(**kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused why we need a separate recipe for host and can't just do

host = PhysicalModel()
host_parameters = host.sample_parameters()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking is that when we resampled the PhysicalModel's parameters, we would always want to make sure to resampled the host's parameters as well. However if we'd prefer to separate the two, then we could use the approach you suggest. What would be the most useful from the user perspective?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still confused about why host is being referred to here as a special named part of the PhysicalModel. To me it's just another node in the DAG even if the physical meaning is special for extragalactic sources, but if it also represents the static background, then that would be a more meaningful distinction, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can definitely change the name. The basic idea behind special casing host is to allow: 1) the source to read information that isn't provided in the source (RA, dec, etc.) and 2) provide a name for sources to refer back to their host. We could rename it to something like "background" or get rid of the special casing altogether and just have it be an attribute.

@jeremykubica jeremykubica deleted the dag_example branch July 8, 2024 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants