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

Allow Stars to have epochs of position other than T0. #166

Merged
merged 3 commits into from
Apr 23, 2018

Conversation

pkgw
Copy link
Contributor

@pkgw pkgw commented Mar 28, 2018

Pursuant to issue #125. I have documented the new keyword but not added test coverage.

Copy link
Member

@brandon-rhodes brandon-rhodes left a comment

Choose a reason for hiding this comment

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

This looks good! I've made one or two quick comments.

@@ -40,7 +40,7 @@ class Star(object):

def __init__(self, ra=None, dec=None, ra_hours=None, dec_degrees=None,
ra_mas_per_year=0.0, dec_mas_per_year=0.0,
parallax_mas=0.0, radial_km_per_s=0.0, names=()):
parallax_mas=0.0, radial_km_per_s=0.0, jd_of_position=T0, names=()):
Copy link
Member

Choose a reason for hiding this comment

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

What would you think of naming this epoch to agree with the terminology of the Hipparcos catalog?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I chose this version because it makes clear the units of the input value, in the same way the _km_per_s suffixes on some of the arguments to this function do.

Copy link
Member

Choose a reason for hiding this comment

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

  1. Maybe epoch_jd, then?
  2. Drat, now I'm thinking of the much bigger question of whether this should take a Time object :) It doesn't need to, right? There's other places in the code already where the interface just sticks to a plain jd?

Copy link
Member

Choose a reason for hiding this comment

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

(Just checking back in: before we land, do you have an opinion on the spelling here, and the question of allowing a Time vs just a float?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the nudge. I don't like epoch as the root word of the name for this parameter since in my opinion it's more vague to the uninitiated — but I'm not sure how to make that choice anything more than a matter of opinion. In which case I think "package owner's opinion wins" is the only sensible resolution process ...

And, yeahhhh, if there are Time objects, it should probably take a Time object. It was sheer laziness on my part not to look into how to make that work. I'd presume it's pretty easy — just convert it to a JD and save that?

Copy link
Member

Choose a reason for hiding this comment

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

Let's try epoch and I'll see what it looks like as I try using it after it lands! If they pass a float, then just keep it untouched; but if they pass a time object from Skyfield's timelib, I think you can ask it for its .tt attribute to get the float you need. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The epoch value is subtracted from a TDB time. Should I ask for the Time's .tdb attribute instead? (I am wondering if maybe asking for TDB opens up a can of worms.)

Copy link
Member

Choose a reason for hiding this comment

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

Oh! Yes, then .tdb is the correct attribute, thanks!

barnard = Star(ra_hours=(17, 57, 48.49803),
dec_degrees=(4, 41, 36.2072),
ra_mas_per_year=-798.71,
dec_mas_per_year=+10337.77,
parallax_mas=545.4,
radial_km_per_s=-110.6)
radial_km_per_s=-110.6,
jd_of_position=T0)
Copy link
Member

Choose a reason for hiding this comment

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

I suspect we should expand this to two separate examples, one without, and one with the new keyword, since many users cut-and-paste without reading the text. But I can do that after this lands if you don't get around to it!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As per Twitter conversion from yesterday and today, I suspect? I mostly avoided this since an example that was almost entirely redundant seemed a bit lame, but I didn't want to go to the work of coming up with and validating another example :-)

Cf [the GitHub pull request](skyfielders#166):

- Rename the parameter to just `epoch`
- Allow Time objects to be provided, pulling out their TDB values.
@pkgw
Copy link
Contributor Author

pkgw commented Apr 22, 2018

OK, this PR should now include the asked-for changes, as I understand them.

Copy link
Member

@brandon-rhodes brandon-rhodes left a comment

Choose a reason for hiding this comment

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

I have just one last tweak to ask for, something I didn't notice before.

@@ -40,7 +41,7 @@ class Star(object):

def __init__(self, ra=None, dec=None, ra_hours=None, dec_degrees=None,
ra_mas_per_year=0.0, dec_mas_per_year=0.0,
parallax_mas=0.0, radial_km_per_s=0.0, names=()):
parallax_mas=0.0, radial_km_per_s=0.0, epoch=T0, names=()):
Copy link
Member

Choose a reason for hiding this comment

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

Oh, there's one final adjustment needed — I should have noticed before: epoch needs to go last, else any code that folks have written that supplies plain non-keyword arguments for a Star will break if we take the argument that was once names and use that same slot for epoch instead. Try moving epoch= to the end so that existing calls keep working. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@brandon-rhodes
Copy link
Member

Thanks!

@brandon-rhodes brandon-rhodes merged commit 10b9fcb into skyfielders:master Apr 23, 2018
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.

None yet

2 participants