[AstroPy] question about coordinate transformation

Evangelia Samara evangelia.sam at gmail.com
Tue Jan 26 10:21:03 EST 2021


Dear Madison,

Thank you very much for your detailed answer! I really appreciate it :)
Everything is clear now and make more sense!

Cheers,
Evangelia

On Mon, Jan 25, 2021 at 10:49 AM E. Madison Bray <erik.m.bray at gmail.com>
wrote:

> On Fri, Jan 22, 2021 at 5:04 PM Evangelia Samara
> <evangelia.sam at gmail.com> wrote:
> >
> > Dear,
> >
> > I am writing this email because I deal with a very peculiar problem (at
> least, peculiar for me!).
> > I want to transform my coordinates from heliographic_stonyhurst to
> heliographic_carrington in python 3, as follows:
> >
> > import astropy.units as u
> > from astropy.coordinates import SkyCoord
> > from sunpy.coordinates import frames
> >
> > c = SkyCoord(0*u.arcsec, 0*u.arcsec, obstime='2016-6-4T12:00:00',
> frame=frames.HeliographicStonyhurst )
> > d = c.transform_to(frames.HeliographicCarrington)
> >
> > But I get the error:
> >
> > ConvertError: This transformation cannot be performed because the
> HeliographicCarrington frame has observer=None.
> >
> > The observer should not be "None" since I define the "obstime" parameter
> above. Could you please explain me why this happens and how it should be
> fixed?
>
>
> Hi Evangelina,
>
> I'm not a SunPy expert so hopefully someone else can chime in with
> more details, but I read in the changelog for SunPy 2.0 [1] :
>
> > ~sunpy.coordinates.frames.HeliographicCarrington is now an
> observer-based frame, where the observer location (specifically, the
> distance from the Sun) is used to account for light travel time when
> determining apparent Carrington longitudes. Coordinate transformations
> using this frame now require an observer to be specified. (#3782)
>
> If you look up issue #3782 there are more details too, as well as
> additions to the documentation about this.  But in short, something
> like this seems to work:
>
> >>> c = SkyCoord(0*u.arcsec, 0*u.arcsec, obstime='2016-6-4T12:00:00',
> frame=frames.HeliographicStonyhurst, observer='earth')
> >>> d = c.transform_to(frames.HeliographicCarrington)
> >>> d
> <SkyCoord (HeliographicCarrington: obstime=2016-06-04T12:00:00.000,
> observer=<HeliographicStonyhurst Coordinate for 'earth'>): (lon, lat,
> radius) in (deg, deg, km)
>     (23.09482023, 0., 695700.)>
>
>
> > BTW, it runs fine with Python 2 if i change "obstime" to "dateobs".
>
> As a general note (since it may help you in finding solutions in the
> future) you will usually find it more useful to think of this not as a
> Python 2 vs Python 3 comparison, but rather check the versions of the
> libraries you're using.  Although neither Astropy nor SunPy still
> support Python 2 in newer versions, when they did they strove to keep
> the code compatible between 2 and 3, so you would not see radical API
> differences depending on which Python version you're using *if* you're
> using the same version of SunPy.  More likely, your Python 2
> installation had an older version of SunPy.  Probably pre-v0.8 since
> the changelog for v0.8 [2] says:
>
> > The time attribute for SunPy coordinate frames has been renamed from
> dateobs to obstime.
>
> TL;DR you can check the version like
>
> >>> import sunpy
> >>> sunpy.__version__
> '2.0.7'
>
> and likewise for Astropy.  This will usually be more interesting to
> compare.  Then if there are apparently differences you can try to look
> up in the changelog why something appears to work differently between
> versions (which admittedly is not always clear even from the
> changelog, but sometimes it can help).
>
> Best,
> Madison
>
>
> [1]
> https://github.com/sunpy/sunpy/blob/242de49f01c04e40bc3120e26bc137b62e5b6012/CHANGELOG.rst#backwards-incompatible-changes
> [2]
> https://github.com/sunpy/sunpy/blob/242de49f01c04e40bc3120e26bc137b62e5b6012/CHANGELOG.rst#new-features-1
> _______________________________________________
> AstroPy mailing list
> AstroPy at python.org
> https://mail.python.org/mailman/listinfo/astropy
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/astropy/attachments/20210126/f0a68582/attachment.html>


More information about the AstroPy mailing list