Skip to content

Differential frame attributes can't be serialized to YAML #6447

@eteq

Description

@eteq

This was first reported in #6446, although #6446 is actually two related issues - this one and a slightly different one (which I am declaring #6446 to actually be about).

This issue is that differential objects can't get written out to ECSV. To see this in operation:

import io
from astropy.coordinates import SkyCoord
from astropy.table import Table
sc = SkyCoord([1], [2], unit='deg', galcen_v_sun=None)
t = Table([sc])
t.write(io.StringIO(), format='ascii.ecsv', overwrite=True)

This raises a RepresenterError: cannot represent an object: ( 11.1, 232.24, 7.25) km / s

(if the galcen_v_sun=None business isn't obvious, it's that it sets that attribute to the default value:)


>>> sc1 = SkyCoord([1], [2], unit='deg')
>>> sc1.galcen_v_sun
>>> sc2 = SkyCoord([1], [2], unit='deg', galcen_v_sun=None)
>>> sc2.galcen_v_sun
<CartesianDifferential (d_x, d_y, d_z) in km / s
    ( 11.1,  232.24,  7.25)>

So the core problem seems to be that CartesianDifferential isn't something that ECSV can handle. @taldcroft, is this because these features were being implemented in parallel and therefore it's an oversight? CartesianDifferential is very similar to CartesianRepresentation, so I'd think it would be pretty straightforward to include?

cc @larrybradley @adrn

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions