-
Notifications
You must be signed in to change notification settings - Fork 0
Description
The Quantity types are mapped to astropy.units.Quantity, on which you can add a 'name' attribute.
The others, map to base types (float, int, bool), which can not be modified/appended with a 'name'.
Use Case:
* Not sure there is a use case, but noting the disparity in the code.
* The current usage (cube.py) is that column names from FIELD element are used
as the key in a hash storing the column values (Quantity, or MaskedColumn? instance).
However, in this context as Measurements, the columns map to the
corresponding Axes of the coordinate space, and the name should
map back to the meas.coord.coordsys.coordspace.axis[n].name
** This is something to explore more thoroughly **
o perhaps coords/meas needs shortcut methods to access coordspace info.
o should meas implementation collapse coords?? making access to content at the meas level?
rama/rama/models/ivoa/__init__.py
Lines 53 to 104 in c1fc61a
| @VO("ivoa:integer") | |
| class VOInteger: | |
| def __new__(cls, value, _): | |
| return int(value) | |
| @VO("ivoa:nonnegativeInteger") | |
| class VONonNegativeInteger: | |
| def __new__(cls, value, _): | |
| value = int(value) | |
| if value < 0: | |
| raise ValueError(f"Value must be positive: {value}") | |
| return value | |
| @VO("ivoa:real") | |
| class VOReal: | |
| def __new__(cls, value, _): | |
| return float(value) | |
| @VO("ivoa:datetime") | |
| class VODateTime: | |
| """ | |
| Handled as a Python datetime instance. | |
| """ | |
| def __new__(cls, value, _): | |
| return parser.parse(value) | |
| @VO("ivoa:IntegerQuantity") | |
| class IntegerQuantity: | |
| """ | |
| Handled by AstroPy Quantity. | |
| NOTE: The value is converted to floating point.. | |
| """ | |
| def __new__(cls, value, unit): | |
| value = int(value) | |
| try: | |
| quantity = value * u.Unit(unit) | |
| except (ValueError, TypeError): | |
| quantity = value * u.dimensionless_unscaled | |
| return quantity | |
| @VO("ivoa:RealQuantity") | |
| class RealQuantity: | |
| """ | |
| Handled by AstroPy Quantity. | |
| """ | |
| def __new__(cls, value, unit): | |
| value = float(value) | |
| try: | |
| quantity = value * u.Unit(unit) | |
| except (ValueError, TypeError): | |
| quantity = value * u.dimensionless_unscaled | |
| return quantity |