In this chapter we introduce the cartosky.Skymap
base class and some of it's features.
# Basic notebook imports
%matplotlib inline
import matplotlib
import matplotlib.ticker as mticker
import pylab as plt
import numpy as np
import healpy as hp
Matplotlib is building the font cache; this may take a moment.
We start by importing several classes from the skymap module and setting a few constants that we will use in this example.
# Import cartosky
import cartosky
At it's core, cartosky
is a wrapper around cartopy
. The core class cartosky.Skymap
has its roots in the skymap
package, which inherited from mpl_toolkits.basemap
. When basemap
reached EoL, cartosky
was born!
Following basemap
, the default projection for a cartosky.Skymap
is Plate-Carree or "Cylindrical Equidistant" ('cyl') projection, which you may commonly think of as Cartesian mapping. Creating a basic map of the sky is as easy as creating a instance of the cartosky.Skymap
class.
smap = cartosky.Skymap()
def skymap_test(smap):
""" Some simple test cases. """
# Draw some scatter points
smap.scatter([0,45,-30],[0,-45,-30])
# Draw a color mesh image (careful, basemap is quirky)
x = y = np.arange(30,60)
xx,yy = np.meshgrid(x,y)
zz = xx*yy
smap.pcolormesh(xx,yy,zz,cmap='gray_r')
skymap_test(smap)
The example above is not very impressive in the 'cyl' projection, but the power of cartopy
is that it allows you a much broader range of projections.
fig,axes = plt.subplots(2,2,figsize=(14,8))
# A nice projection for plotting the visible sky
plt.sca(axes[0,0])
smap = cartosky.Skymap(projection='ortho',lon_0=0, lat_0=0)
skymap_test(smap)
plt.title('Orthographic')
# A common equal area all-sky projection
plt.sca(axes[1,0])
smap = cartosky.Skymap(projection='hammer',lon_0=0, lat_0=0)
skymap_test(smap)
plt.title("Hammer-Aitoff")
# Something wacky that I've never used
plt.sca(axes[0,1])
smap = cartosky.Skymap(projection='sinu')
skymap_test(smap)
plt.title("Sinusoidal")
# My favorite projection for DES
plt.sca(axes[1,1])
smap = cartosky.Skymap(projection='mbtfpq')
skymap_test(smap)
plt.title("McBryde-Thomas Flat Polar Quartic")
Text(0.5, 1.0, 'McBryde-Thomas Flat Polar Quartic')
/home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/cartopy/mpl/gridliner.py:842: ShapelyDeprecationWarning: __len__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Check the length of the `geoms` property instead to get the number of parts of a multi-part geometry. elif len(intersection) > 4: /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/cartopy/mpl/gridliner.py:848: ShapelyDeprecationWarning: __getitem__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry. xy = np.append(intersection[0], intersection[-1], /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/cartopy/mpl/gridliner.py:848: ShapelyDeprecationWarning: __getitem__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry. xy = np.append(intersection[0], intersection[-1], /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/numpy/lib/function_base.py:4739: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead. arr = asanyarray(arr) /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/numpy/lib/function_base.py:4745: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead. return concatenate((arr, values), axis=axis) /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/cartopy/mpl/gridliner.py:842: ShapelyDeprecationWarning: __len__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Check the length of the `geoms` property instead to get the number of parts of a multi-part geometry. elif len(intersection) > 4: /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/cartopy/mpl/gridliner.py:848: ShapelyDeprecationWarning: __getitem__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry. xy = np.append(intersection[0], intersection[-1], /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/cartopy/mpl/gridliner.py:848: ShapelyDeprecationWarning: __getitem__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry. xy = np.append(intersection[0], intersection[-1], /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/numpy/lib/function_base.py:4739: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead. arr = asanyarray(arr) /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/numpy/lib/function_base.py:4745: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead. return concatenate((arr, values), axis=axis) /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/cartopy/mpl/gridliner.py:842: ShapelyDeprecationWarning: __len__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Check the length of the `geoms` property instead to get the number of parts of a multi-part geometry. elif len(intersection) > 4: /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/cartopy/mpl/gridliner.py:848: ShapelyDeprecationWarning: __getitem__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry. xy = np.append(intersection[0], intersection[-1], /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/cartopy/mpl/gridliner.py:848: ShapelyDeprecationWarning: __getitem__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry. xy = np.append(intersection[0], intersection[-1], /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/numpy/lib/function_base.py:4739: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead. arr = asanyarray(arr) /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/numpy/lib/function_base.py:4745: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead. return concatenate((arr, values), axis=axis) /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/cartopy/mpl/gridliner.py:842: ShapelyDeprecationWarning: __len__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Check the length of the `geoms` property instead to get the number of parts of a multi-part geometry. elif len(intersection) > 4: /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/cartopy/mpl/gridliner.py:848: ShapelyDeprecationWarning: __getitem__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry. xy = np.append(intersection[0], intersection[-1], /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/cartopy/mpl/gridliner.py:848: ShapelyDeprecationWarning: __getitem__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry. xy = np.append(intersection[0], intersection[-1], /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/numpy/lib/function_base.py:4739: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead. arr = asanyarray(arr) /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/numpy/lib/function_base.py:4745: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead. return concatenate((arr, values), axis=axis) /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/cartopy/mpl/gridliner.py:842: ShapelyDeprecationWarning: __len__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Check the length of the `geoms` property instead to get the number of parts of a multi-part geometry. elif len(intersection) > 4: /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/cartopy/mpl/gridliner.py:848: ShapelyDeprecationWarning: __getitem__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry. xy = np.append(intersection[0], intersection[-1], /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/cartopy/mpl/gridliner.py:848: ShapelyDeprecationWarning: __getitem__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry. xy = np.append(intersection[0], intersection[-1], /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/numpy/lib/function_base.py:4739: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead. arr = asanyarray(arr) /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/numpy/lib/function_base.py:4745: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead. return concatenate((arr, values), axis=axis) /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/cartopy/mpl/gridliner.py:842: ShapelyDeprecationWarning: __len__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Check the length of the `geoms` property instead to get the number of parts of a multi-part geometry. elif len(intersection) > 4: /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/cartopy/mpl/gridliner.py:848: ShapelyDeprecationWarning: __getitem__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry. xy = np.append(intersection[0], intersection[-1], /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/cartopy/mpl/gridliner.py:848: ShapelyDeprecationWarning: __getitem__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry. xy = np.append(intersection[0], intersection[-1], /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/numpy/lib/function_base.py:4739: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead. arr = asanyarray(arr) /home/docs/checkouts/readthedocs.org/user_builds/cartosky/conda/latest/lib/python3.9/site-packages/numpy/lib/function_base.py:4745: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead. return concatenate((arr, values), axis=axis)