-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand spectral() and spectral_density() equivalencies #1560
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
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.
This is getting large enough that I almost feel like it should be organized as a class.
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 am pretty sure this is not a comprehensive list of all the different kinds of flux units used in Astronomy. If we are going to make a class just based on this, it won't be complete. And to complicate matters, flux definition with the same name has different units in Astronomy and in Optical Engineering. Are we opening a can of worms here?
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.
The way the equivalencies system is desined, I don't really see how a class would be helpful here - in the end it still has to look like a function.
What does make sense from the user perspective is to have this be a default equivalency for a Flux class. This was actually the primary use case that was in mind when the equivalencies system was designed. #1577 (or perhaps a follow-on PR built off that) should definitely implement that.
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.
Perhaps I can explain: That's starting to be a lot of conversion functions, and every time this equivalency is used those functions have to be redefined with the outer function is called. I'm not sure how aggressively Python caches those. Right now it's not a big deal and I'm sort of off in premature optimization land, but it might make sense to define all those converters outside the actual spectral_density function. And I was thinking, in order to keep things organized, might as well make it a class. Something like:
class SpectralDensityEquivalencies(object):
@staticmethod
def converter_photlam_fla(x):
return ...
etc...
def __call__(self):
return [ equivalencies list...]
spectral_density = SpectralDensityEquivalencies() # Basically a singleton
I should add: I wouldn't actually bother changing this right now. It's fine as it is. But something to keep in mind for the future maybe.
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.
👍 Ah, I misunderstood. This is a good idea.
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 do it if @eteq agrees.
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.
Now I get it, yeah, that seems sensible, but I agree that should be a separate follow-on PR.
|
Very weird, that commit is not something I remember! (not proof positive it is not mine, but I would be truly surprised...). |
|
Yeah... About that commit, it happened like this: I do not know how to undo it. If this is too ugly, I'll cancel this PR, create a new branch, and resubmit. Let me know. |
…NU. Added physical types for PHOTLAM and PHOTNU.
…stropy#1590 to this PR, as suggested by @astrofrog.
|
@eteq @astrofrog @mdboom - Applied your comments and #1590 . Travis passed. If that weird commit is not an issue, you can merge. |
|
Thanks @pllim - I think I managed to fix it up with a bit more rebase magic - see my fork's expand-flux-conv branch. I'll wait until tomorrow so we can see if there are any more suggestions, and then merge it from there unless there are more changes. |
|
👍 Thank you very much, @eteq . Looks like magic! |
|
@eteq , please make a note here when you merged from your branch, so I can delete this branch. Thank you! |
Rebased in eteq/expand-flux-conv to clean up commit log a bit
|
It's not quite merged yet - that's merging with master in my fork to make sure travis runs cleanly. Assuming that works, I will merge this. |
|
👍 Great. Thanks for the help! |
This work is a result of discussions with @eteq at Astropy Coordination Meeting 2013. The conversion functionality added is important to
pysynphot.Summary of changes:
spectral()equivalencies and related tests.spectral()that left out conversion fromu.Jback tou.Hz. Added a test for it.spectral_density()now takesQuantityand not unit and value separately.spectral_density()and related tests.