Skip to content
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

Star without parallax_mas using from_dataframe for hipparcos #266

Closed
lirw1984 opened this issue Jul 10, 2019 · 3 comments
Closed

Star without parallax_mas using from_dataframe for hipparcos #266

lirw1984 opened this issue Jul 10, 2019 · 3 comments
Assignees

Comments

@lirw1984
Copy link

Great project, thanks!

I have a suggestion, or maybe it can be called a bug.

Since 1.7, use pandas to load the Hipparcos star catalog as a Pandas dataframe, then use Star.from_dataframe to get a specified star. It is very convenient. BUT, the parallax_mas is ignored (ps: I am using v1.10).

from skyfield.api import Star, load
from skyfield.data import hipparcos

with load.open(hipparcos.URL) as f:
    df = hipparcos.load_dataframe(f)

barnards_star = Star.from_dataframe(df.loc[87937])
print(barnards_star)

giving the following result:
Star(ra_hours=17.963601536666665, dec_degrees=4.66828815, ra_mas_per_year=-797.84, dec_mas_per_year=10326.93, epoch=2448349.0625)

While the parallax of HIP87937 is 549.01mas.

So in the method Star.from_dataframe, I suggest to add one line to use parallax value:

    @classmethod
    def from_dataframe(cls, df):
        epoch = 1721045.0 + _unwrap(df['epoch_year']) * 365.25
        return cls(
            ra_hours=_unwrap(df['ra_hours']),
            dec_degrees=_unwrap(df['dec_degrees']),
            ra_mas_per_year=_unwrap(df.get('ra_mas_per_year', 0)),
            dec_mas_per_year=_unwrap(df.get('dec_mas_per_year', 0)),

            # add the following one line to use parallax value
            parallax_mas=_unwrap(df.get('parallax_mas', 0)),

            epoch=epoch,
        )
@brandon-rhodes
Copy link
Member

I agree, and I'm not sure how that got left out. Would you like to offer a pull request to get credit for the line of code, or should I add it myself?

@brandon-rhodes brandon-rhodes self-assigned this Jul 13, 2019
@lirw1984
Copy link
Author

lirw1984 commented Jul 16, 2019

I agree, and I'm not sure how that got left out. Would you like to offer a pull request to get credit for the line of code, or should I add it myself?

I am not sure how to do that. I am a newer to use github. Please do it by you. Thanks.

@brandon-rhodes
Copy link
Member

The next version of Skyfield that's released will include the fix. Thanks!

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

No branches or pull requests

2 participants