1
$\begingroup$

Using the Python package Skyfield I thought that I could get the RA expressed in degrees simply by doing ra.degrees, but I get the following message

this angle is usually expressed in hours, not degrees; if you want to use degrees anyway, then please use the attribute _degrees

I tried a few things, but cannot find a solution. Could anyone help me?

$\endgroup$
3
  • $\begingroup$ I run v1.37, Python 3.27. I used your trick and it worked. Thanks. $\endgroup$ Commented Feb 19, 2021 at 16:31
  • $\begingroup$ See astrosnapper's comment; better not use my trick (I've deleted it) but use one of those instead. $\endgroup$
    – uhoh
    Commented Feb 19, 2021 at 21:13
  • $\begingroup$ Or use ra.hours * 15.0... ? Seems a weird flex on the part of Skyfield to not let you use certain, perfectly valid units - the use of RA and Dec in decimal degrees is becoming much more common $\endgroup$ Commented Feb 19, 2021 at 23:00

1 Answer 1

2
$\begingroup$

The text is trying to suggest that you do ra._degrees. How could the message be phrased better to make clear that the suggestion is to change the attribute name you are asking for from .degrees to ._degrees? Would a leading . in front of the name help?

$\endgroup$
7
  • 1
    $\begingroup$ By convention, single underscores indicate that the attribute is intended as internal/private variable (dbader.org/blog/meaning-of-underscores-in-python). So end users shouldn't be using these in general. Also re the original Q comments: for converting radians to degrees, better to use math.degrees() or numpy.degrees() rather than hand-rolling the conversion. $\endgroup$ Commented Feb 19, 2021 at 17:17
  • $\begingroup$ I would never use ._degrees for exactly the reason astrosnapper points out. As a user I assume the underscore indicating "semi-privateness" is there for a reason; perhaps it won't work as expected now, or in the future, or may disappear later, or something else... $\endgroup$
    – uhoh
    Commented Feb 19, 2021 at 21:12
  • $\begingroup$ @astrosnapper yes indeed, I've deleted that and pointed here. $\endgroup$
    – uhoh
    Commented Feb 19, 2021 at 21:15
  • 1
    $\begingroup$ @astrosnapper and @uhoh — Thank you for explaining your reluctance to follow Skyfield’s guidance in this case! I’ll go design a replacement name. (Originally I considered .degrees_dammit but that didn’t feel professional, so I tried the simple leading underscore, like Python’s own namedtuple uses for several methods that it invites users to call.) While I could also simply remove the restriction, my experience with an older library (PyEphem) suggests that letting users say ra.degrees without a warning message would lead to lots of confused users and user questions. $\endgroup$ Commented Feb 20, 2021 at 8:58
  • 1
    $\begingroup$ (Any advice on the name? It was apparently .degrees_anyway until July 2014 when, while Skyfield was still pre-1.0, I switched to the plain underscore.) $\endgroup$ Commented Feb 20, 2021 at 9:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .