Skip to content

Conversation

@jeremykubica
Copy link
Collaborator

Closes #360

Uses that SED as a constant over all time steps.

@jeremykubica jeremykubica requested a review from mi-dai July 28, 2025 15:04
@codecov
Copy link

codecov bot commented Jul 28, 2025

Codecov Report

❌ Patch coverage is 98.18182% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.12%. Comparing base (2f1cc8c) to head (12b60d5).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
src/tdastro/sources/static_sed_source.py 97.05% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #364      +/-   ##
==========================================
+ Coverage   91.98%   92.12%   +0.14%     
==========================================
  Files          50       51       +1     
  Lines        3494     3532      +38     
==========================================
+ Hits         3214     3254      +40     
+ Misses        280      278       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link

github-actions bot commented Jul 28, 2025

Before [a6efcc9] After [8f73ba6] Ratio Benchmark (Parameter)
580±800μs 1.13±0.8ms ~1.94 benchmarks.TimeSuite.time_evaluate_simple_linear_wavelength_source
1.01±0.6ms 1.77±0.6ms ~1.75 benchmarks.TimeSuite.time_fnu_to_flam
7.73±0.2ms 8.16±0.3ms 1.06 benchmarks.TimeSuite.time_apply_white_noise
1.44±0.02ms 1.51±0.04ms 1.05 benchmarks.TimeSuite.time_apply_passbands
5.17±0.9ms 5.35±0.8ms 1.03 benchmarks.TimeSuite.time_lightcurve_source
1.01±0.02s 1.03±0.02s 1.02 benchmarks.TimeSuite.time_make_x1_from_hostmass
12.3±0.2μs 12.5±0.1μs 1.02 benchmarks.TimeSuite.time_sample_x1_from_hostmass
5.29±0.2ms 5.33±0.2ms 1.01 benchmarks.TimeSuite.time_evaluate_salt3_passbands
8.48±0.08ms 8.54±0.08ms 1.01 benchmarks.TimeSuite.time_load_passbands
113±0.8μs 112±1μs 1.00 benchmarks.TimeSuite.time_sample_x0_from_distmod

Click here to view all benchmarks.

self.sed_values[model_ind][1, :],
left=0.0,
right=0.0,
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will there be any extrapolation handled by PhysicalModel or should extrapolation be enabled here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The short answer is that this should be handed by PhysicalModel.

The longer answer is that I realized this won't work for randomly selected models because minwave and maxwave might be different. I updated the PR to support this in both the StatisSEDSource and in a few other models. So extrapolation should work better throughout the code now.

@jeremykubica jeremykubica requested a review from mi-dai August 1, 2025 12:53

def minwave(self, graph_state=None):
"""Get the minimum wavelength of the model. For additive models, this is
the minimum wavelength of all sources.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure about this. This may cause some artifacts if one of the model is truncated instead of physically having shorter coverage. If we'd like to use this approach, I would do the maximum of all minwaves for minwave and minimum of all maxwaves for maxwave. Or we should do extrapolations for each source indivicually so they end up having the same min/maxwaves.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is already doing the actual extrapolations one on each source individually (if wavelength extrapolation is turned on). And then adding them. This allows blended objects at radically different redshifts or a host model with a very different wavelength range than the source.

I changed minwave and maxwave to mark the bounds of the intersection of the wavelengths as you suggested. But the extrapolation will still work on a per-source basis.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But the extrapolations start at the shared min/maxwaves instead of individual ones. Am I understanding it correctly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No. The extrapolations will start at each individual model's min/maxwaves, because the additive model's _evaluate_single() function calls the individual source's _evaluate_single() functions. Each of those functions determines whether (and how) to do extrapolation based only on that source's information, including its specific min/max wavelengths.

So if we query 1000.0 for an additive model where the host model wavelength starts at 500.0 and the source model starts at 2000.0, we will use the sum of the actual value from the host model and the extrapolated value from the source.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This sounds great! But is this min/maxwave() in additive model used anywhere then?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is not currently. I considered having the functions for the additive model throw errors, but thought we might want to use it in some analysis. For example we could add a line to plots to show extrapolated vs none extrapolated regions (in which case the intersection approach you proposed and we now use would make the most sense). I can still remove the functions if you'd prefer.

Copy link
Collaborator

Choose a reason for hiding this comment

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

hmmm.. I see now it could be useful to keep it. Can we return a list with min/max for each source if it's not called in other places? That will be more helpful for the plotting case you mentioned.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@jeremykubica jeremykubica requested a review from mi-dai August 8, 2025 12:49
@jeremykubica jeremykubica merged commit 23d4231 into main Aug 8, 2025
9 checks passed
@jeremykubica jeremykubica deleted the static_sed branch August 8, 2025 19:54
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.

Static SED Model

3 participants