Go back to the [Index](https://github.com/kadrlica/skymap/tree/master/examples/README.md)

Chapter 1: Skymap Base Class

In this chapter we introduce the skymap.Skymap base class and some of it's features.

In [1]:
# Basic notebook imports
%matplotlib inline

import matplotlib
import pylab as plt
import numpy as np
import healpy as hp

We start by importing several classes from the skymap module and setting a few constants that we will use in this example.

In [2]:
# Import skymap and some of it's basic map classes
import skymap

At it's core, skymap is just a wrapper around basemap. The core skymap class skymap.Skymap is just a subclass of basemap.Basemap. It keeps all the core functionality (and most of the quirks) of basemap.Basemap, but adds a few celestially oriented features.

Following the basemap.Basemap convention, the default projection for a skymap.Skymap is "Cylindrical Equidistant" ('cyl'), which you may commonly think of as Cartesian. Creating a basic map of the sky is as easy as creating a instance of the skymap.Skymap class. Once you have a Skymap, you can call any of the methods inherited from basemap API (see here for details).

In [3]:
smap = skymap.Skymap()

def skymap_test(smap):
    """ Some simple test cases. """
    # Draw some scatter points

    # Draw a tissot (projected circle)

    # Draw a color mesh image (careful, basemap is quirky)
    x = y = np.arange(30,60)
    xx,yy = np.meshgrid(x,y)
    z = xx*yy

The example above is not very impressive in the 'cyl' projection, but the power of basemap means that you can "$\sim$seamlessly" switch between projections.

In [4]:
fig,axes = plt.subplots(2,2,figsize=(14,8))

# A nice projection for plotting the visible sky
smap = skymap.Skymap(projection='ortho',lon_0=0, lat_0=0)

# A common equal area all-sky projection
smap = skymap.Skymap(projection='hammer',lon_0=0, lat_0=0)

# Something wacky that I've never used
smap = skymap.Skymap(projection='sinu',lon_0=0, lat_0=0)

# My favorite projection for DES
smap = skymap.Skymap(projection='mbtfpq',lon_0=0, lat_0=0)
plt.title("McBryde-Thomas Flat Polar Quartic")

<matplotlib.text.Text at 0x11935bf10>

If you are an experienced user of basemap you may have noticed a few features that differ in skymap. First, we are implicitly creating and labeling the parallels and meridians when we build the map (basemap requires you to explicitly call drawparallels and drawmeridians). Another is that we have set the map orientation to be in the "standard astronomical" convention with longitude increasing to the left.

Go back to the [Index](https://github.com/kadrlica/skymap/tree/master/examples/README.md)