Skip to content

Heliocentric velocity corrections for astronomical sources - #112

Closed
andycasey wants to merge 2 commits into
astropy:masterfrom
andycasey:master
Closed

andycasey wants to merge 2 commits into
astropy:masterfrom
andycasey:master

Conversation

@andycasey

Copy link
Copy Markdown
Member

Hola,

This pull request adds a utility function that will calculate heliocentric velocity corrections for astronomical sources. The helcorr and baryvel functions have been updated from the astrolibpy package which was written by Sergey Koposov (@segasai). Those astrolibpy functions were originally Fortran functions from the triassic period before they were updated to modern IDL. In helcorr.py I have credited authors who have contributed to these functions over the years, and @segasai has granted permission for these updated functions to be included in AstroPy.

If people have strong opinions about the input to the helcorr function then I'd like to hear them. At the moment it takes observatory longitude, latitude, altitude, source RA, source Dec and MJD, but in reality these could be replaced with just a astropy.coordinates.SkyCoord and a astropy.time.Time object with a specified location. What do people think?

We also need to drum up some test cases for this code. Perhaps someone would be kind enough to generate a few test cases using IRAF?

@andycasey

Copy link
Copy Markdown
Member Author

Travis is failing on 5/7 jobs in the build matrix, none of which seem to be related to the code in this PR.

@wkerzendorf

Copy link
Copy Markdown
Member

@andycasey it is likely to be a change in modeling which is currently undergoing restructuring. I'll have a look.

@keflavich

Copy link
Copy Markdown
Contributor

I'm entirely in favor of adding this functionality, but I thought ERFA was supposed to include some of these conversions as low-level methods? I might be entirely wrong about that, but I wanted to raise the point in case someone knows of another implementation. pyslalib (https://github.com/scottransom/pyslalib) might also be useful for generating test cases.

@wkerzendorf

Copy link
Copy Markdown
Member

@andycasey it's the new jinja2 requirement from astropy. Will add to TRAVIS.

@wkerzendorf

Copy link
Copy Markdown
Member

@andycasey the structure of nddata has changed and I needed to update specutils to that ( #113 ). I'm merging this now - can you rebase your branch?

@wkerzendorf

Copy link
Copy Markdown
Member

Ah: tests. Can you add some?

Comment thread specutils/helcorr.py

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.

I would only allow an astropy.time.Time object. If float is really important, please use ducktyping to differentiate between time and float.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I was following the convention set by the astropy.time and astropy.coordinates module where they would allow astropy objects or a float. I can ducktype for floatst if necessary, but checking against the Time baseclass would be sufficient to see if it's an astropy object or not

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.

For ducktyping I would use this piece of code (not doing type checks, such as type or isinstance:

if hasattr(dje, 'jd'):
    jd = dje.jd
else:
   jd = dje

@wkerzendorf

Copy link
Copy Markdown
Member

@andycasey For now there are no things left to do from my side, right? Let me know if there's other questions.

@andycasey

Copy link
Copy Markdown
Member Author

Yep, that looks fine; thanks for the feedback @wkerzendorf et al. I will get to this "soon".

@wkerzendorf

Copy link
Copy Markdown
Member

you mean "soon"(TM). 😉 . On a more serious note - there's no rush.

@rickyegeland

Copy link
Copy Markdown

This functionality looks useful. What's left to do?

@wkerzendorf

Copy link
Copy Markdown
Member

@rickyegeland see the inline comments

@crawfordsm

Copy link
Copy Markdown
Member

Any chance this can updated, @andycasey ? Or plans to? This is something I think a number of people would be interested in and a great thing to have a version of even if it eventually gets replaced with something else.

@mhvk

mhvk commented Oct 26, 2016

Copy link
Copy Markdown
Contributor

@crawfordsm - the machinery is now in place in astropy.coordinates.solar_system to get velocities -- all that is missing is a handy convenience function or method; see astropy/astropy#5231 (comment) (though note that the API was changed slightly; one gets position and velocity using get_body_barycentric_posvel). Indeed, I think the main question is where the convenience function should reside: Time? SkyCoord? Both?

@crawfordsm

Copy link
Copy Markdown
Member

@mhvk Oh good, I saw that was still on-going but had missed that was merged. My guess is with the coordinates is probably fine, however the need for the convenience function is critical.

@StuartLittlefair

Copy link
Copy Markdown
Contributor

Following the additions @mhvk has made to astropy 1.3, the convenience function is very simple.

This gist should cover it. Although you might want to change the function definition, for example to allow the user to set the ephemeris used to calculate the velocities, a la light_travel_time.

In terms of where we put this, just for consistency maybe it ought to be a method of the Time class, like light_travel_time?

@crawfordsm

Copy link
Copy Markdown
Member

Okay, perhaps we should move the discussion of where it should go back to astropy/astropy#3544, where it might be more useful to have it then here (Also yes truly awesome work by @mhvk and others to see this finally get implemented and how relatively few lines of code it takes).

I'll leave it up to @andycasey if he would like to see this still merged or closed. I think there is some value in having this in terms of another implementation at the very least for testing/comparison purposes (which will need to be extensive for this functionality) even if it gets replaced quickly by other implementations.

@migueldvb

Copy link
Copy Markdown
Member

@andycasey the helcorr function in this PR gives the radial velocity correction between topocentric and heliocentric frames, correct? I am comparing the results with the solar_system implementation.

@andycasey

Copy link
Copy Markdown
Member Author

@migueldvb yes, that's right.

Now that there is a better, Correct(tm) way to do barycentric/similar correction in astropy, then I think this should be closed. Part of the motivation for opening this was because I knew this would be something that people would immediately want when switching to astropy, and didn't already exist. At the time there was talk that this could be incorporated within the astropy ecosystem in a better way, but there wasn't a clear path forward. Hopefully this code was useful to some in the meantime.

I'd am going to close this, and recommend that a new PR is opened that expands on @StuartLittlefair's gist. Re-open if there is disagreement! Thanks all

@andycasey andycasey closed this Oct 30, 2016
SaOgaz pushed a commit that referenced this pull request Mar 25, 2019
Listen and add new components to layout dropdown.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants