%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import sunpy
sunpy.system_info()
========================================================== SunPy Installation Information ========================================================== ########### General ########### Time : Wednesday, 02. July 2014 12:47PM UT System : Linux Processor : Arch : 64bit SunPy : 0.5.0 SunPy_git : v0.5.0-52-g8e31a33 OS: (Linux 3.15.2-1-ARCH ) ########### Required Libraries ########### Python: 2.7.7 NumPy: 1.8.1 SciPy: 0.14.0 matplotlib: 1.3.1 Astropy: 0.4.dev9353 Pandas: 0.14.0 ########### Recommended Libraries ########### beautifulsoup: 4.3.2 PyQt: NOT INSTALLED SUDS: 0.4 Sqlalchemy: 0.9.6 Requests: 2.3.0
/home/stuart/.virtualenvs/wcsaxes/lib/python2.7/site-packages/pandas/io/excel.py:626: UserWarning: Installed openpyxl is not supported at this time. Use >=1.6.1 and <2.0.0. .format(openpyxl_compat.start_ver, openpyxl_compat.stop_ver))
import wcsaxes
wcsaxes.__version__
u'0.0.dev268'
import sunpy.coordinates
import astropy.units as u
from astropy.coordinates import SkyCoord
SkyCoord(100*u.arcsec, 200*u.arcsec, frame='helioprojective')
WARNING: AstropyDeprecationWarning: Config parameter 'default_cosmology' in section [astropy.cosmology.core] is deprecated. Use science state astropy.cosmology.core.default_cosmology instead. [astropy.utils.state] WARNING:astropy:AstropyDeprecationWarning: Config parameter 'default_cosmology' in section [astropy.cosmology.core] is deprecated. Use science state astropy.cosmology.core.default_cosmology instead.
<SkyCoord (HelioProjective): d=149597870.7 km, D0=149597870.7 km, Tx=100.0 arcsec, Ty=200.0 arcsec, zeta=0.0 km>
import sunpy.map
hmimap = sunpy.map.Map('/home/stuart/SyncBox/Programming/SunPy/hmi_m_45s_2014_03_01_00_01_30_tai_magnetogram_fits.fits')
WARNING: AstropyDeprecationWarning: Config parameter 'enabled_record_valued_keyword_cards' in section [io.fits] of the file '/home/stuart/.astropy/config/astropy.cfg' is deprecated. Use 'enable_record_valued_keyword_cards' in section [fits] instead. [astropy.config.configuration] WARNING:astropy:AstropyDeprecationWarning: Config parameter 'enabled_record_valued_keyword_cards' in section [io.fits] of the file '/home/stuart/.astropy/config/astropy.cfg' is deprecated. Use 'enable_record_valued_keyword_cards' in section [fits] instead.
%matplotlib inline
hmimap.plot()
/home/stuart/GitHub/sunpy/sunpy/map/mapbase.py:1038: Warning: This map is not aligned. Plot axes may be incorrect Warning)
<matplotlib.image.AxesImage at 0x7f4af765fad0>
from astropy.wcs import WCS
def get_wcs(smap):
"""
Use map properties to generate an astropy WCS object
"""
w2 = WCS(naxis=2)
w2.wcs.crpix = [smap.reference_pixel['x'], smap.reference_pixel['y']]
w2.wcs.cdelt = [smap.scale['x'], smap.scale['y']]
w2.wcs.crval = [smap.reference_coordinate['x'], smap.reference_coordinate['y']]
w2.wcs.ctype = [smap.coordinate_system['x'], smap.coordinate_system['y']]
w2.wcs.pc = smap.rotation_matrix
w2.wcs.cunit = [smap.units['x'], smap.units['y']]
return w2
hmimap.wcs = get_wcs(hmimap)
def frame_hpln_hplt(wcs):
if wcs.wcs.ctype[0].find('HPLN') != -1 and wcs.wcs.ctype[1].find('HPLT') != -1:
return sunpy.coordinates.HelioProjective
from wcsaxes.utils import register_coordinate_system_identifier
register_coordinate_system_identifier(frame_hpln_hplt)
coordmap = {'type': ['longitude', 'latitude'], 'wrap':[180, None], 'unit':['arcsec', 'arcsec'], 'name':['lon', 'lat']}
# Make colorscale figure
fig = plt.figure(figsize=(6,6))
# Create axes
ax = wcsaxes.WCSAxes(fig, [0.1, 0.1, 0.8, 0.8], wcs=hmimap.wcs)
fig.add_axes(ax)
# Show colormap
hmimap.plot(axes=ax, extent=None, vmin=np.nanmin(hmimap), vmax=np.nanmax(hmimap)*0.3)
x = ax.coords[0]
y = ax.coords[1]
x.set_major_formatter('s.s')
y.set_major_formatter('s.s')
ax.coords.grid(color='black', alpha=0.9)
overlay = ax.get_coords_overlay('heliocentric', coord_meta=coordmap)
lon = overlay[0]
lat = overlay[1]
lon.coord_wrap = 180
lon.set_major_formatter('dd')
lon.set_ticklabel(size='x-small')
lat.set_ticklabel(size='x-small')
lon.set_axislabel('Solar Longitude', weight='bold')
lat.set_axislabel('Solar Latitude', weight='bold')
lon.set_ticks_position('tr')
lat.set_ticks_position('tr')
lon.set_ticks(spacing=5. * u.deg, color='white')
lat.set_ticks(spacing=5. * u.deg, color='white')
overlay.grid(color='black', alpha=1)
/home/stuart/.virtualenvs/wcsaxes/lib/python2.7/site-packages/IPython/core/formatters.py:239: FormatterWarning: Exception in image/png formatter: lon should be a Quantity, Angle, or Longitude FormatterWarning,
<matplotlib.figure.Figure at 0x7f4af75a69d0>
overlay
<wcsaxes.coordinates_map.CoordinatesMap at 0x7f4af7670cd0>