Skip to content

Add spectral flux equivalency property to SpectralQuantity#10263

Closed
eteq wants to merge 3 commits intoastropy:mainfrom
eteq:add-spectral-flux
Closed

Add spectral flux equivalency property to SpectralQuantity#10263
eteq wants to merge 3 commits intoastropy:mainfrom
eteq:add-spectral-flux

Conversation

@eteq
Copy link
Copy Markdown
Member

@eteq eteq commented May 2, 2020

This is a follow-on from #10185 - in #10185 (review) I suggested this idea, issued it as a PR to @astrofrog's #10185 branch via astrofrog#100, but then in #10185 (comment) @mhvk rightly brought up some questions, so I've re-worked it as a PR against master since #10185 was ready to merge. So this has already gotten some review from @astrofrog, but it would be good to hear what @mhvk thinks.

(I've labeled in no-changelog-entry-needed on the theory we might get it in for 4.1, but that will have to be revised if it gets pushed to 4.2).

@eteq eteq added this to the v4.1 milestone May 2, 2020
@eteq eteq requested review from astrofrog and mhvk May 2, 2020 00:49
@eteq eteq changed the title Add spectral flux Add spectral flux equivalency property to SpectralQuantity May 2, 2020
@pllim pllim added Affects-dev PRs and issues that do not impact an existing Astropy release and removed no-changelog-entry-needed labels May 2, 2020
Copy link
Copy Markdown
Member

@pllim pllim left a comment

Choose a reason for hiding this comment

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

I changed the label to "affects-dev" because it is more accurate from your description.

Does this needs to be advertised under https://docs.astropy.org/en/latest/units/equivalencies.html ?

def test_flux_density(self):
sq1 = SpectralQuantity([10, 20, 30] * u.AA)

f_lamb = [1, 1, 1] * u.erg / u.cm**2 / u.s / u.AA
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
f_lamb = [1, 1, 1] * u.erg / u.cm**2 / u.s / u.AA
f_lamb = [1, 1, 1] * (u.erg / u.cm**2 / u.s / u.AA)


to_fnu = f_lamb.to(u.erg / u.cm**2 / u.s / u.Hz,
equivalencies=sq1.spectral_density_equivalency)
assert_quantity_allclose(to_fnu, [1, 2**2, 3**2]*(3.33e-17 * u.erg / u.cm**2 / u.s / u.Hz), rtol=.01)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nitpick:

Suggested change
assert_quantity_allclose(to_fnu, [1, 2**2, 3**2]*(3.33e-17 * u.erg / u.cm**2 / u.s / u.Hz), rtol=.01)
assert_quantity_allclose(to_fnu, [1, 2**2, 3**2] * (3.33e-17 * (u.erg / u.cm**2 / u.s / u.Hz)), rtol=.01)

Also, why is the rtol so high?

@mhvk
Copy link
Copy Markdown
Contributor

mhvk commented May 2, 2020

Seeing it again, on its own, I'm still not really convinced, as it is so easy to do separately and would seem to below in specutils. On the other hand, arguably this way is more discoverable than via the equivalencies, and of course a large advantage of SpectralQuantity is already that one does not have to know about equivalencies. The two more or less balance out to a +0.1. If we go ahead, though, I think it should be documented briefly in the new page on spectral coordinates. (Since SpectralCoord will inherit it, the example can use that.)

@mhvk mhvk removed this from the v4.1 milestone May 3, 2020
@mhvk
Copy link
Copy Markdown
Contributor

mhvk commented May 3, 2020

Removing the milestone as it is not urgent.

@astropy-bot
Copy link
Copy Markdown

astropy-bot bot commented Oct 6, 2020

Hi humans 👋 - this pull request hasn't had any new commits for approximately 5 months. I plan to close this in a month 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.

@pllim pllim removed the Affects-dev PRs and issues that do not impact an existing Astropy release label May 4, 2021
@nstarman
Copy link
Copy Markdown
Member

arguably this way is more discoverable than via the equivalencies, and of course a large advantage of SpectralQuantity is already that one does not have to know about equivalencies

I agree. Having relevant equivalencies easily accessible seems a nice feature. Something similar for dimensionless angles might be worthwhile on Angle and for distances in #11776.

@github-actions github-actions bot added the Close? Tell stale bot that this issue/PR is stale label Sep 3, 2021
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 4, 2021

Hi humans 👋 - this pull request hasn't had any new commits for approximately 1 year, 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.

@github-actions github-actions bot added the closed-by-bot Closed by stale bot label Oct 5, 2021
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 5, 2021

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.

@github-actions github-actions bot closed this Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Close? Tell stale bot that this issue/PR is stale closed-by-bot Closed by stale bot coordinates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants