Repository navigation
Conversation
|
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
|
Hello and thanks.
Is there any performance boost either way? I think that might be the main factor. Otherwise, if scipy is preferred, I think it would be acceptable to use but you will have to be more careful in handling "what if scipy is not installed" scenario. |
|
I'd like to avoid hardcoding a discretized grid for this integration, which means that scipy vs. numpy implementations are going to be different and thus not directly comparable. Scipy makes it really easy with In practice, the two methods agree to within very small tolerances (max rel. error of ~1e-9 (1e-14 typ.) for N=64 nodes and ~1e-10 (1e-15 typ.) for N=128 nodes). The Gauss-Legendre (numpy) way is faster by a fair margin for both N=64 and N=128. Does that make it your preference, at the cost of probably slightly less obvious code/implementation? |
|
I vaguely remember @karllark being passionate about our blackbody modeling, so maybe he has opinions. Also cc @astropy/modeling |
|
I do not have an opinion on how the integral is computed. Thanks for thinking of me though. |
|
Here's a scipy implementation for review. My thinking is that this is less obscure (thus easier to maintain), and wringing every ounce of performance out of this method isn't critical since it's not called at all during fitting or anything like that. |
This follows the pattern in `astropy.modeling.tabular` now
|
Sorry for the CI churn. I think this should basically be good to go now. |
Description
This pull request add a new
Fittable1DModelclass calledCutoffBlackBodythat implements a blackbody emission spectrum, with power-law suppression below a cutoff wavelength.Mathematically, the model is:
where$B_\lambda(T)$ is the Planck function for temperature $T$ , $A$ is a dimensionless scale factor, and $\beta$ is the index of the power-law suppression.
I am opening this as a draft PR at first because, as you may notice, I have left the bolometric flux implementation mostly blank. The integral of this function is significantly messier1 than that of a normal blackbody, and I think the cleanest way to compute it would probably be numerically with scipy. However I am not sure if it is acceptable to add a scipy dependency/import to this file/module. The calculation should also be doable with numpy alone, but it will not be as clean, so please let me know which way to go on this.The bolometric flux method uses
scipy.integrate.quadfor the integral, but I am open to changing this if desired.AI Disclosure
GPT-5.6 was used to generate the documentation updates and unit tests, and it helped with the implementation of the bolometric flux integral as well.
Merge method
Footnotes
For arbitrary values of β, the bolometric integral does not reduce to a finite closed-form expression and must be evaluated/approximated numerically anyway, since the solution involves an infinite sum (of gamma functions, no less!) ↩