BlackBody model: deprecate non-dimensionless scale and add support for flux units#12304
BlackBody model: deprecate non-dimensionless scale and add support for flux units#12304kecnry wants to merge 9 commits intoastropy:mainfrom
Conversation
* move towards scale being a dimensionless parameter with deprecated support for stripping any pass unit and passing to output_units instead. * output_units can be SNU (default), SLAM, FNU, FLAM (or equivalent) * warnings when passing scale with units AND when calling bolometric flux after passing scale with units.
* but not exactly one of the supported "native" output units. As noted by astropy#11547 (comment) this can result in confusing behavior. The behavior is much clearer when forcing to separate the unitless scale from the desired output_units.
and cleanup comments
* see case described in astropy#11547 (comment) * if scale is passed with units that are equivalent to the valid output units (SNU, SLAM, FNU, FLAM), the scale is first converted to the native units and adopted as a float, with the original units adopted as output_units. * new behavior is different, but consistent with stripping pi out of passed flux units
There was a problem hiding this comment.
Welcome to Astropy 👋 and congratulations on your first pull request! 🎉
A project member will respond to you as soon as possible; in the meantime, please have a look over the Checklist for Contributed Code and make sure you've addressed as many of the questions there as possible.
If you feel that this pull request has not been responded to in a timely manner, please leave a comment mentioning our software support engineer @embray, or send a message directly to the development mailing list. If the issue is urgent or sensitive in nature (e.g., a security vulnerability) please send an e-mail directly to the private e-mail [email protected].
lpsinger
left a comment
There was a problem hiding this comment.
The new feature in which there is a conditional multiplication by pi depending on the value of output_units is an added footgun. I suggest removing it. The patch will become drastically simpler without it.
As I explained in #11547 (comment), the black body is not a special case because you need the factor of pi whenever you have an isotropic spherical emitter.
A case could be made that there should be an opt-in equivalency in astropy.units for converting from SNU to FNU assuming isotropy, but that conversion does not belong in the BlackBody class.
|
Although I'm not entirely opposed to removing the multiplication of pi (I think its more of a philosophical decision than anything else and can change it if that's the consensus), I think the factor of pi will have to show up somewhere - it's either considered not to be included in If the decision is that FNU/FLAM support does not belong in BlackBody for these reasons, I can isolate just the fix for dimensionless (but not unscaled) to at least fix that bug. I'm not sure splitting |
|
The factor of pi is present in |
|
I am re-milestoning to v5.1 as we've now branched v5.0.x |
|
The factor of pi is one that should definitely be discussed separately. There are pros and cons on this topic and there is no easy answer. We should do something quite explicit to make it clear when the factor of pi is being included or not. |
|
Hi humans 👋 - this pull request hasn't had any new commits for approximately 4 months. I plan to close this in 30 days if the pull request doesn't have any new commits by then. In lieu of a stalled pull request, please consider closing this and open an issue instead if a reminder is needed to revisit in the future. Maintainers may also choose to add keep-open label to keep this PR open but it is discouraged unless absolutely necessary. If this PR still needs to be reviewed, as an author, you can rebase it to reset the clock. If you believe I commented on this pull request incorrectly, please report this here. |
|
This PR is marked stale and there are conflicts, so I am remilestoning. FYI. |
|
I'm going to close this pull request as per my previous message. If you think what is being added/fixed here is still important, please remember to open an issue to keep track of it. Thanks! If this is the first time I am commenting on this issue, or if you believe I closed this issue incorrectly, please report this here. |
Description
This pull request deprecates non-dimensionless
scaleinmodels.BlackBodyand replaces the functionality withoutput_units, with added support for flux (density) units. This also fixes the case where dimensionless (but not unscaled) units are passed toscale.Until support for non-dimensionless
scaleis removed in the future, a warning is raised at both__init__and future calls tobolometric_flux(both warning about deprecation and the possible ambiguous treatment). The inputscalequantity is first converted to one of the supported native output units and stored internally as a float, with the originally passed units being passed to the newoutput_unitsparameter. In doing so, this also "fixes" the case mentioned in #11547 (comment)... although the expected behavior is still ambiguous (thus the deprecation). If the units onscaleare flux units, then pi is also removed as it is added internally withinevaluate(see example below).Revisiting the cases in #11547:
now returns the expected output (the passed scale with units of cm ** 2 / Mpc **2 are converted to dimensionless_unscaled before being applied):
The second example now gives the expected results (change from previous behavior) with deprecation warnings for passing non-dimensionless quantities to
scale:The new preferred (non-ambiguous) version of this same example would be:
and the previous (unexpected) behavior can now be reproduced with (note the difference in
scalepassed tobb2: one with unit conversion, the other without):Additionally, flux units are now supported by passing valid flux units to
output_units, with a factor ofpimultiplied in addition to the dimensionlessscale:To be consistent, passing flux units to
scaleare temporarily supported (with a deprecation warning), in which case the units are converted as above but a factor ofpiis removed (as solid angle are in the units):Fixes #11547
Checklist for package maintainer(s)
This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.
Extra CIlabel.no-changelog-entry-neededlabel. If this is a manual backport, use theskip-changelog-checkslabel unless special changelog handling is necessary.astropy-botcheck might be missing; do not let the green checkmark fool you.backport-X.Y.xlabel(s) before merge.