heliographic_carrington coordinates

251 views
Skip to first unread message

Mat

unread,
Jul 4, 2020, 10:00:39 AM7/4/20
to SunPy
Hi,
I have a map in Helioprojective coordinates and I want to transform it in heliographic carrington with projection code "CEA". I obtaine the error:
"This transformation cannot be performed because the Heliographic Carrington frame has observer=None."
I attach you the code that i have used:

import matplotlib.pyplot as plt
from reproject import reproject_interp

import astropy.units as u
from astropy.coordinates import SkyCoord
from astropy.wcs import WCS
import sunpy.map


shape_out = [720, 1440] frame_out = SkyCoord(0, 0, unit=u.deg, frame="heliographic_carrington", obstime=my_map.date) header = sunpy.map.make_fitswcs_header(shape_out, frame_out, scale=[180 / shape_out[0], 360 / shape_out[1]] * u.deg / u.pix, projection_code="CEA") out_wcs = WCS(header)
array, footprint = reproject_interp(my_map, out_wcs, shape_out=shape_out)
outmap = sunpy.map.Map((array, header))

Thank you for the help


Stuart Mumford

unread,
Jul 4, 2020, 10:21:35 AM7/4/20
to su...@googlegroups.com
(Quick reply from my phone)

Set the observer= keyword in your call to SkyCoord

Stuart
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

Mat

unread,
Jul 4, 2020, 4:32:03 PM7/4/20
to SunPy
Hi,
thank you for the answer.
I have tried this:
frame_out = SkyCoord(0, 0, unit=u.deg,
                     frame="
heliographic_carrington",
                     obstime=my_map.date, observer='earth')
but it still doesn't work


Mat

Albert Y. Shih

unread,
Jul 4, 2020, 7:55:09 PM7/4/20
to su...@googlegroups.com
Hi, Mat,
     I think you've uncovered a bug: the WCS object created from the header isn't preserving the observer information as needed for `HeliographicCarrington`.  Until that bug is fixed, you can get your code to work by adding this line after `out_wcs` is created:
```
out_wcs.coordinate_frame = frame_out.frame
```
This line, which I emphasize shouldn't actually be necessary here, passes along an already created frame object so that one isn't constructed from the WCS information.

     Incidentally, you shouldn't specify `observer='earth'`, because that presumably is just an approximation to your actual observer location.  You imply that `my_map` is in `Helioprojective` coordinates, so there should be a defined observer that you can re-use for the `HeliographicCarrington` frame: `observer=my_map.observer_coordinate`.

Albert


--
You received this message because you are subscribed to the Google Groups "SunPy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sunpy+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sunpy/2d68aec2-784b-43a5-a9c6-84e4d6831e11o%40googlegroups.com.

Albert Y. Shih

unread,
Jul 4, 2020, 10:39:51 PM7/4/20
to su...@googlegroups.com
Hi, Mat,
     Sorry, I forgot that the WCS object currently doesn't understand the observer position for any coordinate frame, so it has to be manually set.  Rather than what I suggested in my previous email, you should add this line after creating `out_wcs`:
```
out_wcs.heliographic_observer = my_map.observer_coordinate
```

Albert
Reply all
Reply to author
Forward
0 new messages