[AstroPy] API question: Instantiating of time/coord and similar

Wolfgang Kerzendorf wkerzendorf at gmail.com
Tue May 1 20:05:33 EDT 2012


Hello guys,

I've just worked on the time package in astropy (PR https://github.com/astropy/astropy/pull/212) which generated some discussion about the general API for instantiating time/coord (and similar).

There are multiple ideas and issues. I'll use the coordinates as an example as it demonstrates the problems rather well:

Imagine a class coord that somehow takes a coordinate stores it in an internal format (let's say x, y, z for coords) and then can convert it into any other format (galactic, equatorial, my fancy system). 



Instantiation:

(1) The instantiation can happen through different keywords: mycoord = coord(equatorial=(200, 20)); mycoord = coord(galactic=(200,20)).

(2) The instantiation can happen through classmethods: mycoord = coord.from_equatorial(200,20); mycoord = coord.from_galactic(200,20)

the next question is how flexible should this be (using notation (1)):

mycoord = coord(equatorial=(200, 20)) and mycoord = coord(equatorial=('15:20:44.5', '3d5m7s')).

or should we require that it is spelt out what is read (format and units would have defaults):

mycoord = coord(equatorial=(200, 20), format='num', units='degree') and mycoord = coord(equatorial=('15:20:44.5', '3d5m7s'), format='sex', units='hour')

There are many other implementation possibilities. Brainstorm! ;-)

But please stay on topic, we are only talking about the API exposed to the user here.

Cheers
    Wolfgang



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20120501/a4a061f0/attachment.html>


More information about the AstroPy mailing list