I agree with Erik on all points below. I've now spent a few hours
messing around with a couple of different dtype implementations in
https://github.com/numpy/numpy-dtypes. There is a huge amount of
overhead and complexity that comes with a dtype. I also discovered
the answer to a question that was nagging me, which is whether custom
attributes in a dtype object get propagated to an array of that dtype.
Example:
>>> import numpy as np
>>> import quaternion
>>> q1 = np.quaternion(1,2,3,4)
>>> q1.w # quaternion components are (w, x, y, z)
1.0
>>> arr = np.array([q1])
>>> arr.dtype
dtype(quaternion)
>>> arr.w
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'numpy.ndarray' object has no attribute 'w'
I guess I should not have expected miracles, but I wanted arr.w to
return an array of the "w" attributes. Without that feature then an
array of astropy.Time dtype is less special because you can't
efficiently do vectorized format conversions (e.g. internal => JD)
without resorting to Python wrapper code. So why bother for our case,
where converting representations is most of the battle.
Now *maybe* the quaternion class just isn't doing something right, but
it's development was guided by a core developer (Mark Weibe) at a
sprint, so maybe that's just the way it is. If you look at datetime64
the way to change representation is basically by making a new array
view with a dtype syntax like dtype="datetime_astro[JD]". This won't
fly for our needs, even for datetime. For coords I think it would be
insane.
+MANY on getting things rolling on a straightforward vectorized
solution that we can code today.
- Tom