-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
BlackBody model #9282
BlackBody model #9282
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not merge until I have a chance to review this fully and test synphot against it. Thanks!
@pllim - please remove the label once you're happy with it downstream. todo for the bot: stop the merge button to appear while a PR has the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll start with nitpicking the change log. 😉
More to come...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial review on user documentation
During the hack day, we also talked about maybe examples of more advanced usage like redshifted and modified blackbodies would be nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial review on tests
I don't see any tests that apply non-default scales with different units.
Might also want to run test_blackbody.py
with warning suppression off (see setup.cfg
) and actively catch and test for AstropyDeprecationWarning
(a grep
for this in tests in other submodules should give you an idea).
EDIT: On warning suppression, also see this:
Line 22 in 09b7796
include_astropy_deprecations=False, |
As discussed offline, the overflow test needs to be adapted for the refactored module as well. Also, I wonder if this test needs to be ported over as well. It was originally adapted from #1480. astropy/astropy/modeling/tests/test_blackbody.py Lines 56 to 73 in 09b7796
|
Note for the future: This refactoring gets rid of the ability to fit by bolometric flux (#4855) and also the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have done a full review and given (probably even too much?) feedback here. I have a companion synphot
PR at spacetelescope/synphot_refactor#224 . I'll review again when all comments have been addressed.
@pllim : review (all of it) much appreciated. I'm doing a bit of work on the PR right now. You may be happy to learn that our in room conversations did convince me to put in lambda_max (and nu_max) as properties. Sometimes, I just need time. ;-) |
@astrofrog Since you wrote the original one - do you have time to review this? |
I don't understand the issue with building the docs. They work fine when I create them on my laptop. Maybe a version issue? And I can't figure out the units issue from the error log. |
Any situation where your example would generate something in
Did you clean your doc build before rebuilding? Sometimes you could be skipping that example because an older (successful) cache already exists. Anyway, looks like you need a rebase, as there is a conflict in change log. |
Just did this earlier today for the same reason. Then another modeling PR was merged making a conflict reappear. I'll wait a little bit and see if there are any other changes needed and then rebase. :-) |
Cleaned, rebuild fine. Checked plotting code manually by running it in file. No idea where this error is from. I'm going to rebase, squash down to a reasonable set of commits, and then push. Maybe the error will go away (unlikely). If it doesn't, I don't know what to try next. Maybe someone else can clone this branch and investigate? |
I haven't yet tested the failing stuff with this branch, but couldn't not notice that you add docs for the deprecated functionality? Is that necessary? I mean we shouldn't really advertize and thus document now deprecated stuff when there is another suggested way to get to the same result. |
OK, my local docs build is not working (due to other reasons), but the example plots works as expected on python3.7 and numpy dev and mpl dev. |
Based on the tracebacks and generated artefacts, I'm fairly certain that the failure is triggered by the first example, specifically this rendering of it: I cannot make it fail locally though with any of the version combinations I tried so far. |
Ah, I get it! Somewhere else in the documentation build (remember that namespace is shared for all the documentation pages), this happened: >>> from astropy.visualization import quantity_support
>>> quantity_support() As a result, it tried to convert That said, if |
Oh, great. Once we find some of those infinite free time we might want to fix that docs pages are independent, etc. However, my question about advertizing the deprecated behaviour still stands. Shouldn't it be removed fully? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To answer @bsipocz , "However, my question about advertizing the deprecated behaviour still stands. Shouldn't it be removed fully?" My answer is, maybe not this round, as it is @astrofrog 's request for examples to illustrate how the new BlackBody
model can replace deprecated class and functions. Perhaps we can open a follow up issue to remove the deprecated examples in 4.1 or 4.2?
I agree with @nden that this is pretty much ready, except that the broken HTML job needs to be fixed first.
bb_nu = BlackBody(temperature) | ||
|
||
# use scale to change results units for Blackbody to match blackbody_lambda | ||
bb_lam = BlackBody(temperature, scale=1.0 * u.erg / (u.cm ** 2 * u.AA * u.s * u.sr)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting... I wouldn't have thought of using scale
in that way. I would have done something more involved, like:
bb_nu(wavelengths).to(u.erg / (u.cm ** 2 * u.AA * u.s * u.sr), u.spectral_density(wavelengths))
So, thanks for including this example!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using scale this way make it "easier" for the user and (after my latest commit) also means that the scale units can be used to set the output units even during fitting. This can't be done using the return_units functionality of modeling as spectral_density equivalencies is needed and this isn't supported by return_units at this point.
Latest commit should fix the html docs bug (if I understood it correctly). Minor text cleanup as well. This commit also means that the results are returned in scale units even during fitting (been trying to figure out how to make this happen for sometime and a solution finally dropped into my brain). Hopefully this is the last commit needed (fingers-crossed). |
Everything looks in order and approved, so I'm merging it. Thanks @karllark ! |
WIP: tech debt gallore 🔥 [ci skip]
WIP: Work on spectrum.py next [ci skip]
WIP: Work on spectrum.py next [ci skip]
WIP: Work on spectrum.py next [ci skip]
WIP: Work on spectrum.py next [ci skip]
BlackBody model that is a straightforward implementation of Planck's Law. This implementation is more flexible than the existing BlackBody1D model.
Added surface brightness equivalencies to the spectral_density equivalencies. Useful for BlackBody and in general.
Docs and tests are included in this PR.
The BlackBody is the 1st model located in physical_models.py. Other physics motivated models should go in this file (distinguished from functional_models.py that are those that are more mathematically motivated). A later PR can/could move some models from functional to physical as appropriate.
This new function replaces the existing blackbody_lambda and blackbody_nu functions and BlackBody1D model. See #9066 for discussion of why this is desirable. These existing functions have been deprecated as part of this PR. Documentation showing how to reproduce the results from all three with BlackBody has been included.
Closes #9066