Skip to content

Conversation

@pllim
Copy link
Member

@pllim pllim commented Oct 10, 2013

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:

  • pllim/astropy@8602dbe is a result of squashing a couple of commits I wish to forget.
  • Added wave number to spectral() equivalencies and related tests.
  • Fixed a bug in spectral() that left out conversion from u.J back to u.Hz. Added a test for it.
  • spectral_density() now takes Quantity and not unit and value separately.
  • Added PHOTLAM and PHOTNU conversions in spectral_density() and related tests.
  • Added physical types for PHOTLAM and PHOTNU, and related tests.
  • Updated related documentations and some outdated examples.
  • The rest are minor PEP8 changes and my Emacs being awesome in auto-deleting trailing whitespace.

Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member

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.

@eteq
Copy link
Member

eteq commented Oct 16, 2013

This looks good to me @pllim, except can you also add an item about this in CHANGES.rst?

Also, it looks like there's a commit in here by @mhvk - do you know why that is? Is it just that this isn't based directly on master?

@mhvk
Copy link
Contributor

mhvk commented Oct 16, 2013

Very weird, that commit is not something I remember! (not proof positive it is not mine, but I would be truly surprised...).

@pllim
Copy link
Member Author

pllim commented Oct 17, 2013

Yeah... About that commit, it happened like this:

Last commit from rebase
Commit that I regret 1 = squashed
Commit that I regret 2 = squashed
Useful commit

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.

@pllim
Copy link
Member Author

pllim commented Oct 17, 2013

@eteq @astrofrog @mdboom - Applied your comments and #1590 . Travis passed. If that weird commit is not an issue, you can merge.

@eteq
Copy link
Member

eteq commented Oct 17, 2013

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.

@pllim
Copy link
Member Author

pllim commented Oct 17, 2013

👍 Thank you very much, @eteq . Looks like magic!

@pllim
Copy link
Member Author

pllim commented Oct 18, 2013

@eteq , please make a note here when you merged from your branch, so I can delete this branch. Thank you!

eteq added a commit to eteq/astropy that referenced this pull request Oct 18, 2013
Rebased in eteq/expand-flux-conv to clean up commit log a bit
@eteq
Copy link
Member

eteq commented Oct 18, 2013

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.

@eteq
Copy link
Member

eteq commented Oct 18, 2013

Alright, I merged this into master in d26b432 - but because it was based on my branch, github wasn't smart enough to auto-close this. So I'll close it manually now, but it was indeed merged. Thanks @pllim !

@eteq eteq closed this Oct 18, 2013
@pllim pllim deleted the expand-flux-conv branch October 18, 2013 20:10
@pllim
Copy link
Member Author

pllim commented Oct 18, 2013

👍 Great. Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants