skyproj modules
skyproj
- class skyproj.skyproj.AlbersSkyproj(ax=None, *, gridlines=True, celestial=True, extent=None, longitude_ticks='positive', autorescale=True, galactic=False, rcparams={}, n_grid_lon=None, n_grid_lat=None, min_lon_ticklabel_delta=0.1, lon_0=0, lat_1=15.0, lat_2=45.0, **kwargs)[source]
Bases:
_Skyproj
,_Stadium
An Albers Equal Area Skyproj map.
- Parameters:
ax (matplotlib.axes.Axes, optional) – Axis object to replace with a skyproj axis.
gridlines (bool, optional) – Draw gridlines?
celestial (bool, optional) – Do celestial plotting (e.g. invert longitude axis).
extent (iterable, optional) – Default exent of the map, [lon_min, lon_max, lat_min, lat_max]. Note that lon_min, lon_max can be specified in any order, the orientation of the map is set by
celestial
.longitude_ticks (str, optional) – Label longitude ticks from 0 to 360 degrees (
positive
) or from -180 to 180 degrees (symmetric
).autorescale (bool, optional) – Automatically rescale color bars when zoomed?
galactic (bool, optional) – Plotting in Galactic coordinates? Recommendation for Galactic plots is to have longitude_ticks set to
symmetric
and celestial = True.rcparams (dict, optional) – Dictionary of matplotlib rc parameters to override. In particular, the code will use
xtick.labelsize
andytick.labelsize
for the x and y tick labels, andaxes.linewidth
for the map boundary.n_grid_lon (int, optional) – Number of gridlines to use in the longitude direction (default is axis_ratio * n_grid_lat).
n_grid_lat (int, optional) – Number of gridlines to use in the latitude direction (default is 6).
min_lon_ticklabel_delta (float, optional) – Minimum relative spacing between longitude tick labels (relative to width of axis). Smaller values yield closer tick labels (and potential for clashes) and larger values yield further tick labels.
lon_0 (float, optional) – Central longitude of the projection.
lat_1 (float, optional) – First standard parallel of the projection.
lat_2 (float, optional) – Second standard parallel of the projection.
**kwargs (dict, optional) – Additional arguments to send to cartosky/proj4 projection CRS initialization.
- compute_extent(lon, lat)[source]
Compute plotting extent for a set of lon/lat points.
Uses a simple looping algorithm to find the ideal range so that all the points fit within the projected frame, with a small border.
- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
- Returns:
extent – Plotting extent [lon_max, lon_min, lat_min, lat_max]
- Return type:
list
- draw_colorbar(label=None, ticks=None, fontsize=11, fraction=0.15, location='right', pad=0.0, ax=None, **kwargs)[source]
Draw a colorbar.
- Parameters:
label (str, optional) – Label to attach to colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
fraction (float, optional) – Fraction of original axes to use for colorbar.
location (str, optional) – Colorbar location (
right
,bottom
,left
,top
).pad (float, optional) – Fraction of original axes between colorbar and original axes.
ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to send to colorbar().
- Returns:
colorbar
- Return type:
matplotlib.colorbar.Colorbar
- draw_hpxbin(lon, lat, C=None, nside=256, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Create a healpix histogram of counts in lon, lat.
Related to
hexbin
from matplotlib.If
C
array is specified then the mean is taken from the C values.- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
C (np.ndarray, optional) – Array of values to average in each pixel.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxmap(hpxmap, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healpix map.
- Parameters:
hpxmap (np.ndarray) – Healpix map to plot, with length 12*nside*nside and UNSEEN for illegal values.
nest (bool, optional) – Map in nest ordering?
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxpix(nside, pixels, values, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healpix map made of pixels and values.
- Parameters:
nside (int) – Healpix nside of pixels to plot.
pixels (np.ndarray) – Array of pixels to plot.
values (np.ndarray) – Array of values associated with pixels.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hspmap(hspmap, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, valid_mask=False, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healsparse map.
- Parameters:
hspmap (healsparse.HealSparseMap) – Healsparse map to plot.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_inset_colorbar(format=None, label=None, ticks=None, fontsize=11, width='25%', height='5%', loc=7, bbox_to_anchor=(0.0, -0.04, 1, 1), orientation='horizontal', ax=None, **kwargs)[source]
Draw an inset colorbar.
- Parameters:
format (str, optional) – Format string for tick labels.
label (str, optional) – Label to attach to inset colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
width (str, optional) – Fraction of total axis width for inset colorbar.
height (str, optional) – Fraction of total axis height for inset colorbar.
loc (int, optional) – Matplotlib location code.
bbox_to_anchor (tuple, optional) – Where to put inset colorbar bbox.
orientation (str, optional) – Inset colorbar orientation (
horizontal
orvertical
).ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to pass to inset_axes or colorbar.
- Returns:
colorbar (matplotlib.colorbar.Colorbar)
colorbar_axis (mpl_toolkits.axes_grid1.parasite_axes.AxesHostAxes)
- draw_milky_way(width=10, linewidth=1.5, color='black', linestyle='-', **kwargs)[source]
Draw the Milky Way galaxy.
- Parameters:
width (float) – Number of degrees north and south to draw dotted lines.
linewidth (float) – Width of line along the plane.
color (str) – Color of Milky Way plane.
linestyle (str) – Style of line.
**kwargs (dict) – Additional kwargs to pass to plot.
- draw_polygon(lon, lat, edgecolor='red', linestyle='solid', facecolor=None, **kwargs)[source]
Plot a polygon from a list of lon, lat coordinates.
This routine is a convenience wrapper around plot() and fill(), both of which work in geodesic coordinates.
- Parameters:
lon (np.ndarray) – Array of longitude points in polygon.
lat (np.ndarray) – Array of latitude points in polygon.
edgecolor (str, optional) – Color of polygon boundary. Set to None for no boundary.
linestyle (str, optional) – Line style for boundary.
facecolor (str, optional) – Color of polygon face. Set to None for no fill color.
**kwargs (dict, optional) – Additional keywords passed to plot.
- draw_polygon_file(filename, reverse=True, edgecolor='red', linestyle='solid', **kwargs)[source]
Draw a text file containing lon, lat coordinates of polygon(s).
- Parameters:
filename (str) – Name of file containing the polygon(s) [lon, lat, poly]
reverse (bool) – Reverse drawing order of points in each polygon.
edgecolor (str) – Color of polygon boundary.
linestyle (str, optional) – Line style for boundary.
**kwargs (dict) – Additional keywords passed to plot.
- get_extent()[source]
Get the extent in lon/lat coordinates.
- Returns:
extent – Extent as [lon_min, lon_max, lat_min, lat_max].
- Return type:
list
- proj(lon, lat)[source]
Apply forward projection to a set of lon/lat positions.
Convert from lon/lat to x/y.
- Parameters:
lon (float or list or np.ndarray) – Array of longitude(s) (degrees).
lat (float or list or np.ndarray) – Array of latitudes(s) (degrees).
- Returns:
x (np.ndarray) – Array of x values.
y (np.ndarray) – Array of y values.
- proj_inverse(x, y)[source]
Apply inverse projection to a set of points.
Convert from x/y to lon/lat.
- Parameters:
x (float or list or np.ndarray) – Projected x values.
y (float or list or np.ndarray) – Projected y values.
- Returns:
lon (np.ndarray) – Array of longitudes (degrees).
lat (np.ndarray) – Array of latitudes (degrees).
- set_autorescale(autorescale)[source]
Set automatic rescaling after zoom.
- Parameters:
autorescale (bool) – Automatically rescale after zoom?
- set_extent(extent)[source]
Set the extent.
Axes will be properly inverted if Skyproj was initialized with
celestial=True
.- Parameters:
extent (array-like) – Extent as [lon_min, lon_max, lat_min, lat_max].
- set_xlabel(text, side='bottom', **kwargs)[source]
Set the label on the x axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
bottom
ortop
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- set_ylabel(text, side='left', **kwargs)[source]
Set the label on the y axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
left
orright
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- tissot_indicatrices(radius=5.0, num_lon=9, num_lat=5, color='red', alpha=0.5)[source]
Draw Tissot indicatrices.
See https://en.wikipedia.org/wiki/Tissot%27s_indicatrix for details.
- Parameters:
radius (float) – Radius of each indicatrix circle.
num_lon (int) – Number of indicatrices in the longitude direction.
num_lat (int) – Number of indicatrices in the latitude direction.
color (str, optional) – Color of indicatrices.
alpha (float, optional) – Alpha of indicatrices.
- class skyproj.skyproj.EqualEarthSkyproj(ax=None, *, lon_0=0.0, gridlines=True, celestial=True, extent=None, longitude_ticks='positive', autorescale=True, galactic=False, rcparams={}, n_grid_lon=None, n_grid_lat=None, min_lon_ticklabel_delta=0.1, **kwargs)[source]
Bases:
_Skyproj
,_Stadium
An Equal Earth projection Skyproj map.
- Parameters:
ax (matplotlib.axes.Axes, optional) – Axis object to replace with a skyproj axis.
lon_0 (float, optional) – Central longitude of projection.
gridlines (bool, optional) – Draw gridlines?
celestial (bool, optional) – Do celestial plotting (e.g. invert longitude axis).
extent (iterable, optional) – Default exent of the map, [lon_min, lon_max, lat_min, lat_max]. Note that lon_min, lon_max can be specified in any order, the orientation of the map is set by
celestial
.longitude_ticks (str, optional) – Label longitude ticks from 0 to 360 degrees (
positive
) or from -180 to 180 degrees (symmetric
).autorescale (bool, optional) – Automatically rescale color bars when zoomed?
galactic (bool, optional) – Plotting in Galactic coordinates? Recommendation for Galactic plots is to have longitude_ticks set to
symmetric
and celestial = True.rcparams (dict, optional) – Dictionary of matplotlib rc parameters to override. In particular, the code will use
xtick.labelsize
andytick.labelsize
for the x and y tick labels, andaxes.linewidth
for the map boundary.n_grid_lon (int, optional) – Number of gridlines to use in the longitude direction (default is axis_ratio * n_grid_lat).
n_grid_lat (int, optional) – Number of gridlines to use in the latitude direction (default is 6).
min_lon_ticklabel_delta (float, optional) – Minimum relative spacing between longitude tick labels (relative to width of axis). Smaller values yield closer tick labels (and potential for clashes) and larger values yield further tick labels.
**kwargs (dict, optional) – Additional arguments to send to cartosky/proj4 projection CRS initialization.
- compute_extent(lon, lat)[source]
Compute plotting extent for a set of lon/lat points.
Uses a simple looping algorithm to find the ideal range so that all the points fit within the projected frame, with a small border.
- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
- Returns:
extent – Plotting extent [lon_max, lon_min, lat_min, lat_max]
- Return type:
list
- draw_colorbar(label=None, ticks=None, fontsize=11, fraction=0.15, location='right', pad=0.0, ax=None, **kwargs)[source]
Draw a colorbar.
- Parameters:
label (str, optional) – Label to attach to colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
fraction (float, optional) – Fraction of original axes to use for colorbar.
location (str, optional) – Colorbar location (
right
,bottom
,left
,top
).pad (float, optional) – Fraction of original axes between colorbar and original axes.
ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to send to colorbar().
- Returns:
colorbar
- Return type:
matplotlib.colorbar.Colorbar
- draw_hpxbin(lon, lat, C=None, nside=256, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Create a healpix histogram of counts in lon, lat.
Related to
hexbin
from matplotlib.If
C
array is specified then the mean is taken from the C values.- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
C (np.ndarray, optional) – Array of values to average in each pixel.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxmap(hpxmap, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healpix map.
- Parameters:
hpxmap (np.ndarray) – Healpix map to plot, with length 12*nside*nside and UNSEEN for illegal values.
nest (bool, optional) – Map in nest ordering?
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxpix(nside, pixels, values, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healpix map made of pixels and values.
- Parameters:
nside (int) – Healpix nside of pixels to plot.
pixels (np.ndarray) – Array of pixels to plot.
values (np.ndarray) – Array of values associated with pixels.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hspmap(hspmap, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, valid_mask=False, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healsparse map.
- Parameters:
hspmap (healsparse.HealSparseMap) – Healsparse map to plot.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_inset_colorbar(format=None, label=None, ticks=None, fontsize=11, width='25%', height='5%', loc=7, bbox_to_anchor=(0.0, -0.04, 1, 1), orientation='horizontal', ax=None, **kwargs)[source]
Draw an inset colorbar.
- Parameters:
format (str, optional) – Format string for tick labels.
label (str, optional) – Label to attach to inset colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
width (str, optional) – Fraction of total axis width for inset colorbar.
height (str, optional) – Fraction of total axis height for inset colorbar.
loc (int, optional) – Matplotlib location code.
bbox_to_anchor (tuple, optional) – Where to put inset colorbar bbox.
orientation (str, optional) – Inset colorbar orientation (
horizontal
orvertical
).ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to pass to inset_axes or colorbar.
- Returns:
colorbar (matplotlib.colorbar.Colorbar)
colorbar_axis (mpl_toolkits.axes_grid1.parasite_axes.AxesHostAxes)
- draw_milky_way(width=10, linewidth=1.5, color='black', linestyle='-', **kwargs)[source]
Draw the Milky Way galaxy.
- Parameters:
width (float) – Number of degrees north and south to draw dotted lines.
linewidth (float) – Width of line along the plane.
color (str) – Color of Milky Way plane.
linestyle (str) – Style of line.
**kwargs (dict) – Additional kwargs to pass to plot.
- draw_polygon(lon, lat, edgecolor='red', linestyle='solid', facecolor=None, **kwargs)[source]
Plot a polygon from a list of lon, lat coordinates.
This routine is a convenience wrapper around plot() and fill(), both of which work in geodesic coordinates.
- Parameters:
lon (np.ndarray) – Array of longitude points in polygon.
lat (np.ndarray) – Array of latitude points in polygon.
edgecolor (str, optional) – Color of polygon boundary. Set to None for no boundary.
linestyle (str, optional) – Line style for boundary.
facecolor (str, optional) – Color of polygon face. Set to None for no fill color.
**kwargs (dict, optional) – Additional keywords passed to plot.
- draw_polygon_file(filename, reverse=True, edgecolor='red', linestyle='solid', **kwargs)[source]
Draw a text file containing lon, lat coordinates of polygon(s).
- Parameters:
filename (str) – Name of file containing the polygon(s) [lon, lat, poly]
reverse (bool) – Reverse drawing order of points in each polygon.
edgecolor (str) – Color of polygon boundary.
linestyle (str, optional) – Line style for boundary.
**kwargs (dict) – Additional keywords passed to plot.
- get_extent()[source]
Get the extent in lon/lat coordinates.
- Returns:
extent – Extent as [lon_min, lon_max, lat_min, lat_max].
- Return type:
list
- proj(lon, lat)[source]
Apply forward projection to a set of lon/lat positions.
Convert from lon/lat to x/y.
- Parameters:
lon (float or list or np.ndarray) – Array of longitude(s) (degrees).
lat (float or list or np.ndarray) – Array of latitudes(s) (degrees).
- Returns:
x (np.ndarray) – Array of x values.
y (np.ndarray) – Array of y values.
- proj_inverse(x, y)[source]
Apply inverse projection to a set of points.
Convert from x/y to lon/lat.
- Parameters:
x (float or list or np.ndarray) – Projected x values.
y (float or list or np.ndarray) – Projected y values.
- Returns:
lon (np.ndarray) – Array of longitudes (degrees).
lat (np.ndarray) – Array of latitudes (degrees).
- set_autorescale(autorescale)[source]
Set automatic rescaling after zoom.
- Parameters:
autorescale (bool) – Automatically rescale after zoom?
- set_extent(extent)[source]
Set the extent.
Axes will be properly inverted if Skyproj was initialized with
celestial=True
.- Parameters:
extent (array-like) – Extent as [lon_min, lon_max, lat_min, lat_max].
- set_xlabel(text, side='bottom', **kwargs)[source]
Set the label on the x axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
bottom
ortop
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- set_ylabel(text, side='left', **kwargs)[source]
Set the label on the y axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
left
orright
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- tissot_indicatrices(radius=5.0, num_lon=9, num_lat=5, color='red', alpha=0.5)[source]
Draw Tissot indicatrices.
See https://en.wikipedia.org/wiki/Tissot%27s_indicatrix for details.
- Parameters:
radius (float) – Radius of each indicatrix circle.
num_lon (int) – Number of indicatrices in the longitude direction.
num_lat (int) – Number of indicatrices in the latitude direction.
color (str, optional) – Color of indicatrices.
alpha (float, optional) – Alpha of indicatrices.
- class skyproj.skyproj.GnomonicSkyproj(ax=None, *, gridlines=True, celestial=True, extent=None, longitude_ticks='positive', autorescale=True, galactic=False, rcparams={}, n_grid_lon=None, n_grid_lat=None, min_lon_ticklabel_delta=0.1, lon_0=0, lat_0=0, **kwargs)[source]
Bases:
_Skyproj
,_Circle
A Gnomonic (tangent plane) projection Skyproj map.
This projection is not equal area and is not available for full sky plots. It should only be used for small zoomed regions.
- Parameters:
ax (matplotlib.axes.Axes, optional) – Axis object to replace with a skyproj axis.
gridlines (bool, optional) – Draw gridlines?
celestial (bool, optional) – Do celestial plotting (e.g. invert longitude axis).
extent (iterable, optional) – Default exent of the map, [lon_min, lon_max, lat_min, lat_max]. Note that lon_min, lon_max can be specified in any order, the orientation of the map is set by
celestial
.longitude_ticks (str, optional) – Label longitude ticks from 0 to 360 degrees (
positive
) or from -180 to 180 degrees (symmetric
).autorescale (bool, optional) – Automatically rescale color bars when zoomed?
galactic (bool, optional) – Plotting in Galactic coordinates? Recommendation for Galactic plots is to have longitude_ticks set to
symmetric
and celestial = True.rcparams (dict, optional) – Dictionary of matplotlib rc parameters to override. In particular, the code will use
xtick.labelsize
andytick.labelsize
for the x and y tick labels, andaxes.linewidth
for the map boundary.n_grid_lon (int, optional) – Number of gridlines to use in the longitude direction (default is axis_ratio * n_grid_lat).
n_grid_lat (int, optional) – Number of gridlines to use in the latitude direction (default is 6).
min_lon_ticklabel_delta (float, optional) – Minimum relative spacing between longitude tick labels (relative to width of axis). Smaller values yield closer tick labels (and potential for clashes) and larger values yield further tick labels.
lon_0 (float, optional) – Central longitude of the Gnomonic projection.
lat_0 (float, optional) – Central latitude of the Gnomonic projection.
**kwargs (dict, optional) – Additional arguments to send to cartosky/proj4 projection CRS initialization.
- compute_extent(lon, lat)[source]
Compute plotting extent for a set of lon/lat points.
Uses a simple looping algorithm to find the ideal range so that all the points fit within the projected frame, with a small border.
- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
- Returns:
extent – Plotting extent [lon_max, lon_min, lat_min, lat_max]
- Return type:
list
- draw_colorbar(label=None, ticks=None, fontsize=11, fraction=0.15, location='right', pad=0.0, ax=None, **kwargs)[source]
Draw a colorbar.
- Parameters:
label (str, optional) – Label to attach to colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
fraction (float, optional) – Fraction of original axes to use for colorbar.
location (str, optional) – Colorbar location (
right
,bottom
,left
,top
).pad (float, optional) – Fraction of original axes between colorbar and original axes.
ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to send to colorbar().
- Returns:
colorbar
- Return type:
matplotlib.colorbar.Colorbar
- draw_hpxbin(lon, lat, C=None, nside=256, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Create a healpix histogram of counts in lon, lat.
Related to
hexbin
from matplotlib.If
C
array is specified then the mean is taken from the C values.- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
C (np.ndarray, optional) – Array of values to average in each pixel.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxmap(hpxmap, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healpix map.
- Parameters:
hpxmap (np.ndarray) – Healpix map to plot, with length 12*nside*nside and UNSEEN for illegal values.
nest (bool, optional) – Map in nest ordering?
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxpix(nside, pixels, values, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healpix map made of pixels and values.
- Parameters:
nside (int) – Healpix nside of pixels to plot.
pixels (np.ndarray) – Array of pixels to plot.
values (np.ndarray) – Array of values associated with pixels.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hspmap(hspmap, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, valid_mask=False, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healsparse map.
- Parameters:
hspmap (healsparse.HealSparseMap) – Healsparse map to plot.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_inset_colorbar(format=None, label=None, ticks=None, fontsize=11, width='25%', height='5%', loc=7, bbox_to_anchor=(0.0, -0.04, 1, 1), orientation='horizontal', ax=None, **kwargs)[source]
Draw an inset colorbar.
- Parameters:
format (str, optional) – Format string for tick labels.
label (str, optional) – Label to attach to inset colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
width (str, optional) – Fraction of total axis width for inset colorbar.
height (str, optional) – Fraction of total axis height for inset colorbar.
loc (int, optional) – Matplotlib location code.
bbox_to_anchor (tuple, optional) – Where to put inset colorbar bbox.
orientation (str, optional) – Inset colorbar orientation (
horizontal
orvertical
).ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to pass to inset_axes or colorbar.
- Returns:
colorbar (matplotlib.colorbar.Colorbar)
colorbar_axis (mpl_toolkits.axes_grid1.parasite_axes.AxesHostAxes)
- draw_milky_way(width=10, linewidth=1.5, color='black', linestyle='-', **kwargs)[source]
Draw the Milky Way galaxy.
- Parameters:
width (float) – Number of degrees north and south to draw dotted lines.
linewidth (float) – Width of line along the plane.
color (str) – Color of Milky Way plane.
linestyle (str) – Style of line.
**kwargs (dict) – Additional kwargs to pass to plot.
- draw_polygon(lon, lat, edgecolor='red', linestyle='solid', facecolor=None, **kwargs)[source]
Plot a polygon from a list of lon, lat coordinates.
This routine is a convenience wrapper around plot() and fill(), both of which work in geodesic coordinates.
- Parameters:
lon (np.ndarray) – Array of longitude points in polygon.
lat (np.ndarray) – Array of latitude points in polygon.
edgecolor (str, optional) – Color of polygon boundary. Set to None for no boundary.
linestyle (str, optional) – Line style for boundary.
facecolor (str, optional) – Color of polygon face. Set to None for no fill color.
**kwargs (dict, optional) – Additional keywords passed to plot.
- draw_polygon_file(filename, reverse=True, edgecolor='red', linestyle='solid', **kwargs)[source]
Draw a text file containing lon, lat coordinates of polygon(s).
- Parameters:
filename (str) – Name of file containing the polygon(s) [lon, lat, poly]
reverse (bool) – Reverse drawing order of points in each polygon.
edgecolor (str) – Color of polygon boundary.
linestyle (str, optional) – Line style for boundary.
**kwargs (dict) – Additional keywords passed to plot.
- get_extent()[source]
Get the extent in lon/lat coordinates.
- Returns:
extent – Extent as [lon_min, lon_max, lat_min, lat_max].
- Return type:
list
- proj(lon, lat)[source]
Apply forward projection to a set of lon/lat positions.
Convert from lon/lat to x/y.
- Parameters:
lon (float or list or np.ndarray) – Array of longitude(s) (degrees).
lat (float or list or np.ndarray) – Array of latitudes(s) (degrees).
- Returns:
x (np.ndarray) – Array of x values.
y (np.ndarray) – Array of y values.
- proj_inverse(x, y)[source]
Apply inverse projection to a set of points.
Convert from x/y to lon/lat.
- Parameters:
x (float or list or np.ndarray) – Projected x values.
y (float or list or np.ndarray) – Projected y values.
- Returns:
lon (np.ndarray) – Array of longitudes (degrees).
lat (np.ndarray) – Array of latitudes (degrees).
- set_autorescale(autorescale)[source]
Set automatic rescaling after zoom.
- Parameters:
autorescale (bool) – Automatically rescale after zoom?
- set_extent(extent)[source]
Set the extent.
Axes will be properly inverted if Skyproj was initialized with
celestial=True
.- Parameters:
extent (array-like) – Extent as [lon_min, lon_max, lat_min, lat_max].
- set_xlabel(text, side='bottom', **kwargs)[source]
Set the label on the x axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
bottom
ortop
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- set_ylabel(text, side='left', **kwargs)[source]
Set the label on the y axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
left
orright
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- tissot_indicatrices(radius=5.0, num_lon=9, num_lat=5, color='red', alpha=0.5)[source]
Draw Tissot indicatrices.
See https://en.wikipedia.org/wiki/Tissot%27s_indicatrix for details.
- Parameters:
radius (float) – Radius of each indicatrix circle.
num_lon (int) – Number of indicatrices in the longitude direction.
num_lat (int) – Number of indicatrices in the latitude direction.
color (str, optional) – Color of indicatrices.
alpha (float, optional) – Alpha of indicatrices.
- class skyproj.skyproj.HammerSkyproj(ax=None, *, lon_0=0.0, gridlines=True, celestial=True, extent=None, longitude_ticks='positive', autorescale=True, galactic=False, rcparams={}, n_grid_lon=None, n_grid_lat=None, min_lon_ticklabel_delta=0.1, **kwargs)[source]
Bases:
_Skyproj
,_Ellipse21
A Hammer-Aitoff projection Skyproj map.
- Parameters:
ax (matplotlib.axes.Axes, optional) – Axis object to replace with a skyproj axis.
lon_0 (float, optional) – Central longitude of projection.
gridlines (bool, optional) – Draw gridlines?
celestial (bool, optional) – Do celestial plotting (e.g. invert longitude axis).
extent (iterable, optional) – Default exent of the map, [lon_min, lon_max, lat_min, lat_max]. Note that lon_min, lon_max can be specified in any order, the orientation of the map is set by
celestial
.longitude_ticks (str, optional) – Label longitude ticks from 0 to 360 degrees (
positive
) or from -180 to 180 degrees (symmetric
).autorescale (bool, optional) – Automatically rescale color bars when zoomed?
galactic (bool, optional) – Plotting in Galactic coordinates? Recommendation for Galactic plots is to have longitude_ticks set to
symmetric
and celestial = True.rcparams (dict, optional) – Dictionary of matplotlib rc parameters to override. In particular, the code will use
xtick.labelsize
andytick.labelsize
for the x and y tick labels, andaxes.linewidth
for the map boundary.n_grid_lon (int, optional) – Number of gridlines to use in the longitude direction (default is axis_ratio * n_grid_lat).
n_grid_lat (int, optional) – Number of gridlines to use in the latitude direction (default is 6).
min_lon_ticklabel_delta (float, optional) – Minimum relative spacing between longitude tick labels (relative to width of axis). Smaller values yield closer tick labels (and potential for clashes) and larger values yield further tick labels.
**kwargs (dict, optional) – Additional arguments to send to cartosky/proj4 projection CRS initialization.
- compute_extent(lon, lat)[source]
Compute plotting extent for a set of lon/lat points.
Uses a simple looping algorithm to find the ideal range so that all the points fit within the projected frame, with a small border.
- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
- Returns:
extent – Plotting extent [lon_max, lon_min, lat_min, lat_max]
- Return type:
list
- draw_colorbar(label=None, ticks=None, fontsize=11, fraction=0.15, location='right', pad=0.0, ax=None, **kwargs)[source]
Draw a colorbar.
- Parameters:
label (str, optional) – Label to attach to colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
fraction (float, optional) – Fraction of original axes to use for colorbar.
location (str, optional) – Colorbar location (
right
,bottom
,left
,top
).pad (float, optional) – Fraction of original axes between colorbar and original axes.
ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to send to colorbar().
- Returns:
colorbar
- Return type:
matplotlib.colorbar.Colorbar
- draw_hpxbin(lon, lat, C=None, nside=256, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Create a healpix histogram of counts in lon, lat.
Related to
hexbin
from matplotlib.If
C
array is specified then the mean is taken from the C values.- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
C (np.ndarray, optional) – Array of values to average in each pixel.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxmap(hpxmap, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healpix map.
- Parameters:
hpxmap (np.ndarray) – Healpix map to plot, with length 12*nside*nside and UNSEEN for illegal values.
nest (bool, optional) – Map in nest ordering?
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxpix(nside, pixels, values, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healpix map made of pixels and values.
- Parameters:
nside (int) – Healpix nside of pixels to plot.
pixels (np.ndarray) – Array of pixels to plot.
values (np.ndarray) – Array of values associated with pixels.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hspmap(hspmap, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, valid_mask=False, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healsparse map.
- Parameters:
hspmap (healsparse.HealSparseMap) – Healsparse map to plot.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_inset_colorbar(format=None, label=None, ticks=None, fontsize=11, width='25%', height='5%', loc=7, bbox_to_anchor=(0.0, -0.04, 1, 1), orientation='horizontal', ax=None, **kwargs)[source]
Draw an inset colorbar.
- Parameters:
format (str, optional) – Format string for tick labels.
label (str, optional) – Label to attach to inset colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
width (str, optional) – Fraction of total axis width for inset colorbar.
height (str, optional) – Fraction of total axis height for inset colorbar.
loc (int, optional) – Matplotlib location code.
bbox_to_anchor (tuple, optional) – Where to put inset colorbar bbox.
orientation (str, optional) – Inset colorbar orientation (
horizontal
orvertical
).ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to pass to inset_axes or colorbar.
- Returns:
colorbar (matplotlib.colorbar.Colorbar)
colorbar_axis (mpl_toolkits.axes_grid1.parasite_axes.AxesHostAxes)
- draw_milky_way(width=10, linewidth=1.5, color='black', linestyle='-', **kwargs)[source]
Draw the Milky Way galaxy.
- Parameters:
width (float) – Number of degrees north and south to draw dotted lines.
linewidth (float) – Width of line along the plane.
color (str) – Color of Milky Way plane.
linestyle (str) – Style of line.
**kwargs (dict) – Additional kwargs to pass to plot.
- draw_polygon(lon, lat, edgecolor='red', linestyle='solid', facecolor=None, **kwargs)[source]
Plot a polygon from a list of lon, lat coordinates.
This routine is a convenience wrapper around plot() and fill(), both of which work in geodesic coordinates.
- Parameters:
lon (np.ndarray) – Array of longitude points in polygon.
lat (np.ndarray) – Array of latitude points in polygon.
edgecolor (str, optional) – Color of polygon boundary. Set to None for no boundary.
linestyle (str, optional) – Line style for boundary.
facecolor (str, optional) – Color of polygon face. Set to None for no fill color.
**kwargs (dict, optional) – Additional keywords passed to plot.
- draw_polygon_file(filename, reverse=True, edgecolor='red', linestyle='solid', **kwargs)[source]
Draw a text file containing lon, lat coordinates of polygon(s).
- Parameters:
filename (str) – Name of file containing the polygon(s) [lon, lat, poly]
reverse (bool) – Reverse drawing order of points in each polygon.
edgecolor (str) – Color of polygon boundary.
linestyle (str, optional) – Line style for boundary.
**kwargs (dict) – Additional keywords passed to plot.
- get_extent()[source]
Get the extent in lon/lat coordinates.
- Returns:
extent – Extent as [lon_min, lon_max, lat_min, lat_max].
- Return type:
list
- proj(lon, lat)[source]
Apply forward projection to a set of lon/lat positions.
Convert from lon/lat to x/y.
- Parameters:
lon (float or list or np.ndarray) – Array of longitude(s) (degrees).
lat (float or list or np.ndarray) – Array of latitudes(s) (degrees).
- Returns:
x (np.ndarray) – Array of x values.
y (np.ndarray) – Array of y values.
- proj_inverse(x, y)[source]
Apply inverse projection to a set of points.
Convert from x/y to lon/lat.
- Parameters:
x (float or list or np.ndarray) – Projected x values.
y (float or list or np.ndarray) – Projected y values.
- Returns:
lon (np.ndarray) – Array of longitudes (degrees).
lat (np.ndarray) – Array of latitudes (degrees).
- set_autorescale(autorescale)[source]
Set automatic rescaling after zoom.
- Parameters:
autorescale (bool) – Automatically rescale after zoom?
- set_extent(extent)[source]
Set the extent.
Axes will be properly inverted if Skyproj was initialized with
celestial=True
.- Parameters:
extent (array-like) – Extent as [lon_min, lon_max, lat_min, lat_max].
- set_xlabel(text, side='bottom', **kwargs)[source]
Set the label on the x axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
bottom
ortop
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- set_ylabel(text, side='left', **kwargs)[source]
Set the label on the y axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
left
orright
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- tissot_indicatrices(radius=5.0, num_lon=9, num_lat=5, color='red', alpha=0.5)[source]
Draw Tissot indicatrices.
See https://en.wikipedia.org/wiki/Tissot%27s_indicatrix for details.
- Parameters:
radius (float) – Radius of each indicatrix circle.
num_lon (int) – Number of indicatrices in the longitude direction.
num_lat (int) – Number of indicatrices in the latitude direction.
color (str, optional) – Color of indicatrices.
alpha (float, optional) – Alpha of indicatrices.
- class skyproj.skyproj.LaeaSkyproj(ax=None, *, gridlines=True, celestial=True, extent=None, longitude_ticks='positive', autorescale=True, galactic=False, rcparams={}, n_grid_lon=None, n_grid_lat=None, min_lon_ticklabel_delta=0.1, lon_0=0.0, lat_0=0.0, **kwargs)[source]
Bases:
_Skyproj
,_Circle
A Lambert Azimuthal Equal Area projection Skyproj map.
- Parameters:
ax (matplotlib.axes.Axes, optional) – Axis object to replace with a skyproj axis.
gridlines (bool, optional) – Draw gridlines?
celestial (bool, optional) – Do celestial plotting (e.g. invert longitude axis).
extent (iterable, optional) – Default exent of the map, [lon_min, lon_max, lat_min, lat_max]. Note that lon_min, lon_max can be specified in any order, the orientation of the map is set by
celestial
.longitude_ticks (str, optional) – Label longitude ticks from 0 to 360 degrees (
positive
) or from -180 to 180 degrees (symmetric
).autorescale (bool, optional) – Automatically rescale color bars when zoomed?
galactic (bool, optional) – Plotting in Galactic coordinates? Recommendation for Galactic plots is to have longitude_ticks set to
symmetric
and celestial = True.rcparams (dict, optional) – Dictionary of matplotlib rc parameters to override. In particular, the code will use
xtick.labelsize
andytick.labelsize
for the x and y tick labels, andaxes.linewidth
for the map boundary.n_grid_lon (int, optional) – Number of gridlines to use in the longitude direction (default is axis_ratio * n_grid_lat).
n_grid_lat (int, optional) – Number of gridlines to use in the latitude direction (default is 6).
min_lon_ticklabel_delta (float, optional) – Minimum relative spacing between longitude tick labels (relative to width of axis). Smaller values yield closer tick labels (and potential for clashes) and larger values yield further tick labels.
lon_0 (float, optional) – Central longitude of the LAEA projection.
lat_0 (float, optional) – Central latitude of the LAEA projection.
- compute_extent(lon, lat)[source]
Compute plotting extent for a set of lon/lat points.
Uses a simple looping algorithm to find the ideal range so that all the points fit within the projected frame, with a small border.
- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
- Returns:
extent – Plotting extent [lon_max, lon_min, lat_min, lat_max]
- Return type:
list
- draw_colorbar(label=None, ticks=None, fontsize=11, fraction=0.15, location='right', pad=0.0, ax=None, **kwargs)[source]
Draw a colorbar.
- Parameters:
label (str, optional) – Label to attach to colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
fraction (float, optional) – Fraction of original axes to use for colorbar.
location (str, optional) – Colorbar location (
right
,bottom
,left
,top
).pad (float, optional) – Fraction of original axes between colorbar and original axes.
ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to send to colorbar().
- Returns:
colorbar
- Return type:
matplotlib.colorbar.Colorbar
- draw_hpxbin(lon, lat, C=None, nside=256, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Create a healpix histogram of counts in lon, lat.
Related to
hexbin
from matplotlib.If
C
array is specified then the mean is taken from the C values.- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
C (np.ndarray, optional) – Array of values to average in each pixel.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxmap(hpxmap, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healpix map.
- Parameters:
hpxmap (np.ndarray) – Healpix map to plot, with length 12*nside*nside and UNSEEN for illegal values.
nest (bool, optional) – Map in nest ordering?
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxpix(nside, pixels, values, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healpix map made of pixels and values.
- Parameters:
nside (int) – Healpix nside of pixels to plot.
pixels (np.ndarray) – Array of pixels to plot.
values (np.ndarray) – Array of values associated with pixels.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hspmap(hspmap, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, valid_mask=False, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healsparse map.
- Parameters:
hspmap (healsparse.HealSparseMap) – Healsparse map to plot.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_inset_colorbar(format=None, label=None, ticks=None, fontsize=11, width='25%', height='5%', loc=7, bbox_to_anchor=(0.0, -0.04, 1, 1), orientation='horizontal', ax=None, **kwargs)[source]
Draw an inset colorbar.
- Parameters:
format (str, optional) – Format string for tick labels.
label (str, optional) – Label to attach to inset colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
width (str, optional) – Fraction of total axis width for inset colorbar.
height (str, optional) – Fraction of total axis height for inset colorbar.
loc (int, optional) – Matplotlib location code.
bbox_to_anchor (tuple, optional) – Where to put inset colorbar bbox.
orientation (str, optional) – Inset colorbar orientation (
horizontal
orvertical
).ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to pass to inset_axes or colorbar.
- Returns:
colorbar (matplotlib.colorbar.Colorbar)
colorbar_axis (mpl_toolkits.axes_grid1.parasite_axes.AxesHostAxes)
- draw_milky_way(width=10, linewidth=1.5, color='black', linestyle='-', **kwargs)[source]
Draw the Milky Way galaxy.
- Parameters:
width (float) – Number of degrees north and south to draw dotted lines.
linewidth (float) – Width of line along the plane.
color (str) – Color of Milky Way plane.
linestyle (str) – Style of line.
**kwargs (dict) – Additional kwargs to pass to plot.
- draw_polygon(lon, lat, edgecolor='red', linestyle='solid', facecolor=None, **kwargs)[source]
Plot a polygon from a list of lon, lat coordinates.
This routine is a convenience wrapper around plot() and fill(), both of which work in geodesic coordinates.
- Parameters:
lon (np.ndarray) – Array of longitude points in polygon.
lat (np.ndarray) – Array of latitude points in polygon.
edgecolor (str, optional) – Color of polygon boundary. Set to None for no boundary.
linestyle (str, optional) – Line style for boundary.
facecolor (str, optional) – Color of polygon face. Set to None for no fill color.
**kwargs (dict, optional) – Additional keywords passed to plot.
- draw_polygon_file(filename, reverse=True, edgecolor='red', linestyle='solid', **kwargs)[source]
Draw a text file containing lon, lat coordinates of polygon(s).
- Parameters:
filename (str) – Name of file containing the polygon(s) [lon, lat, poly]
reverse (bool) – Reverse drawing order of points in each polygon.
edgecolor (str) – Color of polygon boundary.
linestyle (str, optional) – Line style for boundary.
**kwargs (dict) – Additional keywords passed to plot.
- get_extent()[source]
Get the extent in lon/lat coordinates.
- Returns:
extent – Extent as [lon_min, lon_max, lat_min, lat_max].
- Return type:
list
- proj(lon, lat)[source]
Apply forward projection to a set of lon/lat positions.
Convert from lon/lat to x/y.
- Parameters:
lon (float or list or np.ndarray) – Array of longitude(s) (degrees).
lat (float or list or np.ndarray) – Array of latitudes(s) (degrees).
- Returns:
x (np.ndarray) – Array of x values.
y (np.ndarray) – Array of y values.
- proj_inverse(x, y)[source]
Apply inverse projection to a set of points.
Convert from x/y to lon/lat.
- Parameters:
x (float or list or np.ndarray) – Projected x values.
y (float or list or np.ndarray) – Projected y values.
- Returns:
lon (np.ndarray) – Array of longitudes (degrees).
lat (np.ndarray) – Array of latitudes (degrees).
- set_autorescale(autorescale)[source]
Set automatic rescaling after zoom.
- Parameters:
autorescale (bool) – Automatically rescale after zoom?
- set_extent(extent)[source]
Set the extent.
Axes will be properly inverted if Skyproj was initialized with
celestial=True
.- Parameters:
extent (array-like) – Extent as [lon_min, lon_max, lat_min, lat_max].
- set_xlabel(text, side='bottom', **kwargs)[source]
Set the label on the x axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
bottom
ortop
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- set_ylabel(text, side='left', **kwargs)[source]
Set the label on the y axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
left
orright
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- tissot_indicatrices(radius=5.0, num_lon=9, num_lat=5, color='red', alpha=0.5)[source]
Draw Tissot indicatrices.
See https://en.wikipedia.org/wiki/Tissot%27s_indicatrix for details.
- Parameters:
radius (float) – Radius of each indicatrix circle.
num_lon (int) – Number of indicatrices in the longitude direction.
num_lat (int) – Number of indicatrices in the latitude direction.
color (str, optional) – Color of indicatrices.
alpha (float, optional) – Alpha of indicatrices.
- class skyproj.skyproj.McBrydeSkyproj(ax=None, *, lon_0=0.0, gridlines=True, celestial=True, extent=None, longitude_ticks='positive', autorescale=True, galactic=False, rcparams={}, n_grid_lon=None, n_grid_lat=None, min_lon_ticklabel_delta=0.1, **kwargs)[source]
Bases:
_Skyproj
,_Stadium
A McBryde-Thomas Flat Polar Quartic projection Skyproj map.
- Parameters:
ax (matplotlib.axes.Axes, optional) – Axis object to replace with a skyproj axis.
lon_0 (float, optional) – Central longitude of projection.
gridlines (bool, optional) – Draw gridlines?
celestial (bool, optional) – Do celestial plotting (e.g. invert longitude axis).
extent (iterable, optional) – Default exent of the map, [lon_min, lon_max, lat_min, lat_max]. Note that lon_min, lon_max can be specified in any order, the orientation of the map is set by
celestial
.longitude_ticks (str, optional) – Label longitude ticks from 0 to 360 degrees (
positive
) or from -180 to 180 degrees (symmetric
).autorescale (bool, optional) – Automatically rescale color bars when zoomed?
galactic (bool, optional) – Plotting in Galactic coordinates? Recommendation for Galactic plots is to have longitude_ticks set to
symmetric
and celestial = True.rcparams (dict, optional) – Dictionary of matplotlib rc parameters to override. In particular, the code will use
xtick.labelsize
andytick.labelsize
for the x and y tick labels, andaxes.linewidth
for the map boundary.n_grid_lon (int, optional) – Number of gridlines to use in the longitude direction (default is axis_ratio * n_grid_lat).
n_grid_lat (int, optional) – Number of gridlines to use in the latitude direction (default is 6).
min_lon_ticklabel_delta (float, optional) – Minimum relative spacing between longitude tick labels (relative to width of axis). Smaller values yield closer tick labels (and potential for clashes) and larger values yield further tick labels.
**kwargs (dict, optional) – Additional arguments to send to cartosky/proj4 projection CRS initialization.
- compute_extent(lon, lat)[source]
Compute plotting extent for a set of lon/lat points.
Uses a simple looping algorithm to find the ideal range so that all the points fit within the projected frame, with a small border.
- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
- Returns:
extent – Plotting extent [lon_max, lon_min, lat_min, lat_max]
- Return type:
list
- draw_colorbar(label=None, ticks=None, fontsize=11, fraction=0.15, location='right', pad=0.0, ax=None, **kwargs)[source]
Draw a colorbar.
- Parameters:
label (str, optional) – Label to attach to colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
fraction (float, optional) – Fraction of original axes to use for colorbar.
location (str, optional) – Colorbar location (
right
,bottom
,left
,top
).pad (float, optional) – Fraction of original axes between colorbar and original axes.
ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to send to colorbar().
- Returns:
colorbar
- Return type:
matplotlib.colorbar.Colorbar
- draw_hpxbin(lon, lat, C=None, nside=256, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Create a healpix histogram of counts in lon, lat.
Related to
hexbin
from matplotlib.If
C
array is specified then the mean is taken from the C values.- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
C (np.ndarray, optional) – Array of values to average in each pixel.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxmap(hpxmap, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healpix map.
- Parameters:
hpxmap (np.ndarray) – Healpix map to plot, with length 12*nside*nside and UNSEEN for illegal values.
nest (bool, optional) – Map in nest ordering?
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxpix(nside, pixels, values, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healpix map made of pixels and values.
- Parameters:
nside (int) – Healpix nside of pixels to plot.
pixels (np.ndarray) – Array of pixels to plot.
values (np.ndarray) – Array of values associated with pixels.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hspmap(hspmap, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, valid_mask=False, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healsparse map.
- Parameters:
hspmap (healsparse.HealSparseMap) – Healsparse map to plot.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_inset_colorbar(format=None, label=None, ticks=None, fontsize=11, width='25%', height='5%', loc=7, bbox_to_anchor=(0.0, -0.04, 1, 1), orientation='horizontal', ax=None, **kwargs)[source]
Draw an inset colorbar.
- Parameters:
format (str, optional) – Format string for tick labels.
label (str, optional) – Label to attach to inset colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
width (str, optional) – Fraction of total axis width for inset colorbar.
height (str, optional) – Fraction of total axis height for inset colorbar.
loc (int, optional) – Matplotlib location code.
bbox_to_anchor (tuple, optional) – Where to put inset colorbar bbox.
orientation (str, optional) – Inset colorbar orientation (
horizontal
orvertical
).ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to pass to inset_axes or colorbar.
- Returns:
colorbar (matplotlib.colorbar.Colorbar)
colorbar_axis (mpl_toolkits.axes_grid1.parasite_axes.AxesHostAxes)
- draw_milky_way(width=10, linewidth=1.5, color='black', linestyle='-', **kwargs)[source]
Draw the Milky Way galaxy.
- Parameters:
width (float) – Number of degrees north and south to draw dotted lines.
linewidth (float) – Width of line along the plane.
color (str) – Color of Milky Way plane.
linestyle (str) – Style of line.
**kwargs (dict) – Additional kwargs to pass to plot.
- draw_polygon(lon, lat, edgecolor='red', linestyle='solid', facecolor=None, **kwargs)[source]
Plot a polygon from a list of lon, lat coordinates.
This routine is a convenience wrapper around plot() and fill(), both of which work in geodesic coordinates.
- Parameters:
lon (np.ndarray) – Array of longitude points in polygon.
lat (np.ndarray) – Array of latitude points in polygon.
edgecolor (str, optional) – Color of polygon boundary. Set to None for no boundary.
linestyle (str, optional) – Line style for boundary.
facecolor (str, optional) – Color of polygon face. Set to None for no fill color.
**kwargs (dict, optional) – Additional keywords passed to plot.
- draw_polygon_file(filename, reverse=True, edgecolor='red', linestyle='solid', **kwargs)[source]
Draw a text file containing lon, lat coordinates of polygon(s).
- Parameters:
filename (str) – Name of file containing the polygon(s) [lon, lat, poly]
reverse (bool) – Reverse drawing order of points in each polygon.
edgecolor (str) – Color of polygon boundary.
linestyle (str, optional) – Line style for boundary.
**kwargs (dict) – Additional keywords passed to plot.
- get_extent()[source]
Get the extent in lon/lat coordinates.
- Returns:
extent – Extent as [lon_min, lon_max, lat_min, lat_max].
- Return type:
list
- proj(lon, lat)[source]
Apply forward projection to a set of lon/lat positions.
Convert from lon/lat to x/y.
- Parameters:
lon (float or list or np.ndarray) – Array of longitude(s) (degrees).
lat (float or list or np.ndarray) – Array of latitudes(s) (degrees).
- Returns:
x (np.ndarray) – Array of x values.
y (np.ndarray) – Array of y values.
- proj_inverse(x, y)[source]
Apply inverse projection to a set of points.
Convert from x/y to lon/lat.
- Parameters:
x (float or list or np.ndarray) – Projected x values.
y (float or list or np.ndarray) – Projected y values.
- Returns:
lon (np.ndarray) – Array of longitudes (degrees).
lat (np.ndarray) – Array of latitudes (degrees).
- set_autorescale(autorescale)[source]
Set automatic rescaling after zoom.
- Parameters:
autorescale (bool) – Automatically rescale after zoom?
- set_extent(extent)[source]
Set the extent.
Axes will be properly inverted if Skyproj was initialized with
celestial=True
.- Parameters:
extent (array-like) – Extent as [lon_min, lon_max, lat_min, lat_max].
- set_xlabel(text, side='bottom', **kwargs)[source]
Set the label on the x axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
bottom
ortop
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- set_ylabel(text, side='left', **kwargs)[source]
Set the label on the y axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
left
orright
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- tissot_indicatrices(radius=5.0, num_lon=9, num_lat=5, color='red', alpha=0.5)[source]
Draw Tissot indicatrices.
See https://en.wikipedia.org/wiki/Tissot%27s_indicatrix for details.
- Parameters:
radius (float) – Radius of each indicatrix circle.
num_lon (int) – Number of indicatrices in the longitude direction.
num_lat (int) – Number of indicatrices in the latitude direction.
color (str, optional) – Color of indicatrices.
alpha (float, optional) – Alpha of indicatrices.
- class skyproj.skyproj.MollweideSkyproj(ax=None, *, lon_0=0.0, gridlines=True, celestial=True, extent=None, longitude_ticks='positive', autorescale=True, galactic=False, rcparams={}, n_grid_lon=None, n_grid_lat=None, min_lon_ticklabel_delta=0.1, **kwargs)[source]
Bases:
_Skyproj
,_Ellipse21
A Mollweide projection Skyproj map.
- Parameters:
ax (matplotlib.axes.Axes, optional) – Axis object to replace with a skyproj axis.
lon_0 (float, optional) – Central longitude of projection.
gridlines (bool, optional) – Draw gridlines?
celestial (bool, optional) – Do celestial plotting (e.g. invert longitude axis).
extent (iterable, optional) – Default exent of the map, [lon_min, lon_max, lat_min, lat_max]. Note that lon_min, lon_max can be specified in any order, the orientation of the map is set by
celestial
.longitude_ticks (str, optional) – Label longitude ticks from 0 to 360 degrees (
positive
) or from -180 to 180 degrees (symmetric
).autorescale (bool, optional) – Automatically rescale color bars when zoomed?
galactic (bool, optional) – Plotting in Galactic coordinates? Recommendation for Galactic plots is to have longitude_ticks set to
symmetric
and celestial = True.rcparams (dict, optional) – Dictionary of matplotlib rc parameters to override. In particular, the code will use
xtick.labelsize
andytick.labelsize
for the x and y tick labels, andaxes.linewidth
for the map boundary.n_grid_lon (int, optional) – Number of gridlines to use in the longitude direction (default is axis_ratio * n_grid_lat).
n_grid_lat (int, optional) – Number of gridlines to use in the latitude direction (default is 6).
min_lon_ticklabel_delta (float, optional) – Minimum relative spacing between longitude tick labels (relative to width of axis). Smaller values yield closer tick labels (and potential for clashes) and larger values yield further tick labels.
**kwargs (dict, optional) – Additional arguments to send to cartosky/proj4 projection CRS initialization.
- compute_extent(lon, lat)[source]
Compute plotting extent for a set of lon/lat points.
Uses a simple looping algorithm to find the ideal range so that all the points fit within the projected frame, with a small border.
- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
- Returns:
extent – Plotting extent [lon_max, lon_min, lat_min, lat_max]
- Return type:
list
- draw_colorbar(label=None, ticks=None, fontsize=11, fraction=0.15, location='right', pad=0.0, ax=None, **kwargs)[source]
Draw a colorbar.
- Parameters:
label (str, optional) – Label to attach to colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
fraction (float, optional) – Fraction of original axes to use for colorbar.
location (str, optional) – Colorbar location (
right
,bottom
,left
,top
).pad (float, optional) – Fraction of original axes between colorbar and original axes.
ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to send to colorbar().
- Returns:
colorbar
- Return type:
matplotlib.colorbar.Colorbar
- draw_hpxbin(lon, lat, C=None, nside=256, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Create a healpix histogram of counts in lon, lat.
Related to
hexbin
from matplotlib.If
C
array is specified then the mean is taken from the C values.- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
C (np.ndarray, optional) – Array of values to average in each pixel.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxmap(hpxmap, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healpix map.
- Parameters:
hpxmap (np.ndarray) – Healpix map to plot, with length 12*nside*nside and UNSEEN for illegal values.
nest (bool, optional) – Map in nest ordering?
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxpix(nside, pixels, values, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healpix map made of pixels and values.
- Parameters:
nside (int) – Healpix nside of pixels to plot.
pixels (np.ndarray) – Array of pixels to plot.
values (np.ndarray) – Array of values associated with pixels.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hspmap(hspmap, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, valid_mask=False, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healsparse map.
- Parameters:
hspmap (healsparse.HealSparseMap) – Healsparse map to plot.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_inset_colorbar(format=None, label=None, ticks=None, fontsize=11, width='25%', height='5%', loc=7, bbox_to_anchor=(0.0, -0.04, 1, 1), orientation='horizontal', ax=None, **kwargs)[source]
Draw an inset colorbar.
- Parameters:
format (str, optional) – Format string for tick labels.
label (str, optional) – Label to attach to inset colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
width (str, optional) – Fraction of total axis width for inset colorbar.
height (str, optional) – Fraction of total axis height for inset colorbar.
loc (int, optional) – Matplotlib location code.
bbox_to_anchor (tuple, optional) – Where to put inset colorbar bbox.
orientation (str, optional) – Inset colorbar orientation (
horizontal
orvertical
).ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to pass to inset_axes or colorbar.
- Returns:
colorbar (matplotlib.colorbar.Colorbar)
colorbar_axis (mpl_toolkits.axes_grid1.parasite_axes.AxesHostAxes)
- draw_milky_way(width=10, linewidth=1.5, color='black', linestyle='-', **kwargs)[source]
Draw the Milky Way galaxy.
- Parameters:
width (float) – Number of degrees north and south to draw dotted lines.
linewidth (float) – Width of line along the plane.
color (str) – Color of Milky Way plane.
linestyle (str) – Style of line.
**kwargs (dict) – Additional kwargs to pass to plot.
- draw_polygon(lon, lat, edgecolor='red', linestyle='solid', facecolor=None, **kwargs)[source]
Plot a polygon from a list of lon, lat coordinates.
This routine is a convenience wrapper around plot() and fill(), both of which work in geodesic coordinates.
- Parameters:
lon (np.ndarray) – Array of longitude points in polygon.
lat (np.ndarray) – Array of latitude points in polygon.
edgecolor (str, optional) – Color of polygon boundary. Set to None for no boundary.
linestyle (str, optional) – Line style for boundary.
facecolor (str, optional) – Color of polygon face. Set to None for no fill color.
**kwargs (dict, optional) – Additional keywords passed to plot.
- draw_polygon_file(filename, reverse=True, edgecolor='red', linestyle='solid', **kwargs)[source]
Draw a text file containing lon, lat coordinates of polygon(s).
- Parameters:
filename (str) – Name of file containing the polygon(s) [lon, lat, poly]
reverse (bool) – Reverse drawing order of points in each polygon.
edgecolor (str) – Color of polygon boundary.
linestyle (str, optional) – Line style for boundary.
**kwargs (dict) – Additional keywords passed to plot.
- get_extent()[source]
Get the extent in lon/lat coordinates.
- Returns:
extent – Extent as [lon_min, lon_max, lat_min, lat_max].
- Return type:
list
- proj(lon, lat)[source]
Apply forward projection to a set of lon/lat positions.
Convert from lon/lat to x/y.
- Parameters:
lon (float or list or np.ndarray) – Array of longitude(s) (degrees).
lat (float or list or np.ndarray) – Array of latitudes(s) (degrees).
- Returns:
x (np.ndarray) – Array of x values.
y (np.ndarray) – Array of y values.
- proj_inverse(x, y)[source]
Apply inverse projection to a set of points.
Convert from x/y to lon/lat.
- Parameters:
x (float or list or np.ndarray) – Projected x values.
y (float or list or np.ndarray) – Projected y values.
- Returns:
lon (np.ndarray) – Array of longitudes (degrees).
lat (np.ndarray) – Array of latitudes (degrees).
- set_autorescale(autorescale)[source]
Set automatic rescaling after zoom.
- Parameters:
autorescale (bool) – Automatically rescale after zoom?
- set_extent(extent)[source]
Set the extent.
Axes will be properly inverted if Skyproj was initialized with
celestial=True
.- Parameters:
extent (array-like) – Extent as [lon_min, lon_max, lat_min, lat_max].
- set_xlabel(text, side='bottom', **kwargs)[source]
Set the label on the x axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
bottom
ortop
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- set_ylabel(text, side='left', **kwargs)[source]
Set the label on the y axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
left
orright
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- tissot_indicatrices(radius=5.0, num_lon=9, num_lat=5, color='red', alpha=0.5)[source]
Draw Tissot indicatrices.
See https://en.wikipedia.org/wiki/Tissot%27s_indicatrix for details.
- Parameters:
radius (float) – Radius of each indicatrix circle.
num_lon (int) – Number of indicatrices in the longitude direction.
num_lat (int) – Number of indicatrices in the latitude direction.
color (str, optional) – Color of indicatrices.
alpha (float, optional) – Alpha of indicatrices.
- class skyproj.skyproj.ObliqueMollweideSkyproj(ax=None, *, gridlines=True, celestial=True, extent=None, longitude_ticks='positive', autorescale=True, galactic=False, rcparams={}, n_grid_lon=None, n_grid_lat=None, min_lon_ticklabel_delta=0.1, lon_0=0.0, lat_p=90.0, lon_p=0.0, **kwargs)[source]
Bases:
_Skyproj
,_Ellipse21
An Oblique Mollweide projection Skyproj map.
- Parameters:
ax (matplotlib.axes.Axes, optional) – Axis object to replace with a skyproj axis.
gridlines (bool, optional) – Draw gridlines?
celestial (bool, optional) – Do celestial plotting (e.g. invert longitude axis).
extent (iterable, optional) – Default exent of the map, [lon_min, lon_max, lat_min, lat_max]. Note that lon_min, lon_max can be specified in any order, the orientation of the map is set by
celestial
.longitude_ticks (str, optional) – Label longitude ticks from 0 to 360 degrees (
positive
) or from -180 to 180 degrees (symmetric
).autorescale (bool, optional) – Automatically rescale color bars when zoomed?
galactic (bool, optional) – Plotting in Galactic coordinates? Recommendation for Galactic plots is to have longitude_ticks set to
symmetric
and celestial = True.rcparams (dict, optional) – Dictionary of matplotlib rc parameters to override. In particular, the code will use
xtick.labelsize
andytick.labelsize
for the x and y tick labels, andaxes.linewidth
for the map boundary.n_grid_lon (int, optional) – Number of gridlines to use in the longitude direction (default is axis_ratio * n_grid_lat).
n_grid_lat (int, optional) – Number of gridlines to use in the latitude direction (default is 6).
min_lon_ticklabel_delta (float, optional) – Minimum relative spacing between longitude tick labels (relative to width of axis). Smaller values yield closer tick labels (and potential for clashes) and larger values yield further tick labels.
lon_0 (float, optional) – Central longitude of the underlying Mollweide projection.
lat_p (float, optional) – Latitude of the North Pole of the unrotated coordinate system.
lon_p (float, optional) – Longitude of the North Pole of the unrotated coordinate system.
**kwargs (dict, optional) – Additional arguments to send to cartosky/proj4 projection CRS initialization.
- compute_extent(lon, lat)[source]
Compute plotting extent for a set of lon/lat points.
Uses a simple looping algorithm to find the ideal range so that all the points fit within the projected frame, with a small border.
- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
- Returns:
extent – Plotting extent [lon_max, lon_min, lat_min, lat_max]
- Return type:
list
- draw_colorbar(label=None, ticks=None, fontsize=11, fraction=0.15, location='right', pad=0.0, ax=None, **kwargs)[source]
Draw a colorbar.
- Parameters:
label (str, optional) – Label to attach to colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
fraction (float, optional) – Fraction of original axes to use for colorbar.
location (str, optional) – Colorbar location (
right
,bottom
,left
,top
).pad (float, optional) – Fraction of original axes between colorbar and original axes.
ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to send to colorbar().
- Returns:
colorbar
- Return type:
matplotlib.colorbar.Colorbar
- draw_hpxbin(lon, lat, C=None, nside=256, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Create a healpix histogram of counts in lon, lat.
Related to
hexbin
from matplotlib.If
C
array is specified then the mean is taken from the C values.- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
C (np.ndarray, optional) – Array of values to average in each pixel.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxmap(hpxmap, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healpix map.
- Parameters:
hpxmap (np.ndarray) – Healpix map to plot, with length 12*nside*nside and UNSEEN for illegal values.
nest (bool, optional) – Map in nest ordering?
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxpix(nside, pixels, values, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healpix map made of pixels and values.
- Parameters:
nside (int) – Healpix nside of pixels to plot.
pixels (np.ndarray) – Array of pixels to plot.
values (np.ndarray) – Array of values associated with pixels.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hspmap(hspmap, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, valid_mask=False, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healsparse map.
- Parameters:
hspmap (healsparse.HealSparseMap) – Healsparse map to plot.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_inset_colorbar(format=None, label=None, ticks=None, fontsize=11, width='25%', height='5%', loc=7, bbox_to_anchor=(0.0, -0.04, 1, 1), orientation='horizontal', ax=None, **kwargs)[source]
Draw an inset colorbar.
- Parameters:
format (str, optional) – Format string for tick labels.
label (str, optional) – Label to attach to inset colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
width (str, optional) – Fraction of total axis width for inset colorbar.
height (str, optional) – Fraction of total axis height for inset colorbar.
loc (int, optional) – Matplotlib location code.
bbox_to_anchor (tuple, optional) – Where to put inset colorbar bbox.
orientation (str, optional) – Inset colorbar orientation (
horizontal
orvertical
).ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to pass to inset_axes or colorbar.
- Returns:
colorbar (matplotlib.colorbar.Colorbar)
colorbar_axis (mpl_toolkits.axes_grid1.parasite_axes.AxesHostAxes)
- draw_milky_way(width=10, linewidth=1.5, color='black', linestyle='-', **kwargs)[source]
Draw the Milky Way galaxy.
- Parameters:
width (float) – Number of degrees north and south to draw dotted lines.
linewidth (float) – Width of line along the plane.
color (str) – Color of Milky Way plane.
linestyle (str) – Style of line.
**kwargs (dict) – Additional kwargs to pass to plot.
- draw_polygon(lon, lat, edgecolor='red', linestyle='solid', facecolor=None, **kwargs)[source]
Plot a polygon from a list of lon, lat coordinates.
This routine is a convenience wrapper around plot() and fill(), both of which work in geodesic coordinates.
- Parameters:
lon (np.ndarray) – Array of longitude points in polygon.
lat (np.ndarray) – Array of latitude points in polygon.
edgecolor (str, optional) – Color of polygon boundary. Set to None for no boundary.
linestyle (str, optional) – Line style for boundary.
facecolor (str, optional) – Color of polygon face. Set to None for no fill color.
**kwargs (dict, optional) – Additional keywords passed to plot.
- draw_polygon_file(filename, reverse=True, edgecolor='red', linestyle='solid', **kwargs)[source]
Draw a text file containing lon, lat coordinates of polygon(s).
- Parameters:
filename (str) – Name of file containing the polygon(s) [lon, lat, poly]
reverse (bool) – Reverse drawing order of points in each polygon.
edgecolor (str) – Color of polygon boundary.
linestyle (str, optional) – Line style for boundary.
**kwargs (dict) – Additional keywords passed to plot.
- get_extent()[source]
Get the extent in lon/lat coordinates.
- Returns:
extent – Extent as [lon_min, lon_max, lat_min, lat_max].
- Return type:
list
- proj(lon, lat)[source]
Apply forward projection to a set of lon/lat positions.
Convert from lon/lat to x/y.
- Parameters:
lon (float or list or np.ndarray) – Array of longitude(s) (degrees).
lat (float or list or np.ndarray) – Array of latitudes(s) (degrees).
- Returns:
x (np.ndarray) – Array of x values.
y (np.ndarray) – Array of y values.
- proj_inverse(x, y)[source]
Apply inverse projection to a set of points.
Convert from x/y to lon/lat.
- Parameters:
x (float or list or np.ndarray) – Projected x values.
y (float or list or np.ndarray) – Projected y values.
- Returns:
lon (np.ndarray) – Array of longitudes (degrees).
lat (np.ndarray) – Array of latitudes (degrees).
- set_autorescale(autorescale)[source]
Set automatic rescaling after zoom.
- Parameters:
autorescale (bool) – Automatically rescale after zoom?
- set_extent(extent)[source]
Set the extent.
Axes will be properly inverted if Skyproj was initialized with
celestial=True
.- Parameters:
extent (array-like) – Extent as [lon_min, lon_max, lat_min, lat_max].
- set_xlabel(text, side='bottom', **kwargs)[source]
Set the label on the x axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
bottom
ortop
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- set_ylabel(text, side='left', **kwargs)[source]
Set the label on the y axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
left
orright
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- tissot_indicatrices(radius=5.0, num_lon=9, num_lat=5, color='red', alpha=0.5)[source]
Draw Tissot indicatrices.
See https://en.wikipedia.org/wiki/Tissot%27s_indicatrix for details.
- Parameters:
radius (float) – Radius of each indicatrix circle.
num_lon (int) – Number of indicatrices in the longitude direction.
num_lat (int) – Number of indicatrices in the latitude direction.
color (str, optional) – Color of indicatrices.
alpha (float, optional) – Alpha of indicatrices.
- class skyproj.skyproj.Skyproj(ax=None, *, lon_0=0.0, gridlines=True, celestial=True, extent=None, longitude_ticks='positive', autorescale=True, galactic=False, rcparams={}, n_grid_lon=None, n_grid_lat=None, min_lon_ticklabel_delta=0.1, **kwargs)[source]
Bases:
_Skyproj
,_Stadium
A Plate Carree cylindrical projection Skyproj map.
- Parameters:
ax (matplotlib.axes.Axes, optional) – Axis object to replace with a skyproj axis.
lon_0 (float, optional) – Central longitude of projection.
gridlines (bool, optional) – Draw gridlines?
celestial (bool, optional) – Do celestial plotting (e.g. invert longitude axis).
extent (iterable, optional) – Default exent of the map, [lon_min, lon_max, lat_min, lat_max]. Note that lon_min, lon_max can be specified in any order, the orientation of the map is set by
celestial
.longitude_ticks (str, optional) – Label longitude ticks from 0 to 360 degrees (
positive
) or from -180 to 180 degrees (symmetric
).autorescale (bool, optional) – Automatically rescale color bars when zoomed?
galactic (bool, optional) – Plotting in Galactic coordinates? Recommendation for Galactic plots is to have longitude_ticks set to
symmetric
and celestial = True.rcparams (dict, optional) – Dictionary of matplotlib rc parameters to override. In particular, the code will use
xtick.labelsize
andytick.labelsize
for the x and y tick labels, andaxes.linewidth
for the map boundary.n_grid_lon (int, optional) – Number of gridlines to use in the longitude direction (default is axis_ratio * n_grid_lat).
n_grid_lat (int, optional) – Number of gridlines to use in the latitude direction (default is 6).
min_lon_ticklabel_delta (float, optional) – Minimum relative spacing between longitude tick labels (relative to width of axis). Smaller values yield closer tick labels (and potential for clashes) and larger values yield further tick labels.
**kwargs (dict, optional) – Additional arguments to send to cartosky/proj4 projection CRS initialization.
- compute_extent(lon, lat)[source]
Compute plotting extent for a set of lon/lat points.
Uses a simple looping algorithm to find the ideal range so that all the points fit within the projected frame, with a small border.
- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
- Returns:
extent – Plotting extent [lon_max, lon_min, lat_min, lat_max]
- Return type:
list
- draw_colorbar(label=None, ticks=None, fontsize=11, fraction=0.15, location='right', pad=0.0, ax=None, **kwargs)[source]
Draw a colorbar.
- Parameters:
label (str, optional) – Label to attach to colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
fraction (float, optional) – Fraction of original axes to use for colorbar.
location (str, optional) – Colorbar location (
right
,bottom
,left
,top
).pad (float, optional) – Fraction of original axes between colorbar and original axes.
ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to send to colorbar().
- Returns:
colorbar
- Return type:
matplotlib.colorbar.Colorbar
- draw_hpxbin(lon, lat, C=None, nside=256, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Create a healpix histogram of counts in lon, lat.
Related to
hexbin
from matplotlib.If
C
array is specified then the mean is taken from the C values.- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
C (np.ndarray, optional) – Array of values to average in each pixel.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxmap(hpxmap, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healpix map.
- Parameters:
hpxmap (np.ndarray) – Healpix map to plot, with length 12*nside*nside and UNSEEN for illegal values.
nest (bool, optional) – Map in nest ordering?
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxpix(nside, pixels, values, nest=False, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healpix map made of pixels and values.
- Parameters:
nside (int) – Healpix nside of pixels to plot.
pixels (np.ndarray) – Array of pixels to plot.
values (np.ndarray) – Array of values associated with pixels.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hspmap(hspmap, zoom=True, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, valid_mask=False, norm='linear', **kwargs)[source]
Use pcolormesh to draw a healsparse map.
- Parameters:
hspmap (healsparse.HealSparseMap) – Healsparse map to plot.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_inset_colorbar(format=None, label=None, ticks=None, fontsize=11, width='25%', height='5%', loc=7, bbox_to_anchor=(0.0, -0.04, 1, 1), orientation='horizontal', ax=None, **kwargs)[source]
Draw an inset colorbar.
- Parameters:
format (str, optional) – Format string for tick labels.
label (str, optional) – Label to attach to inset colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
width (str, optional) – Fraction of total axis width for inset colorbar.
height (str, optional) – Fraction of total axis height for inset colorbar.
loc (int, optional) – Matplotlib location code.
bbox_to_anchor (tuple, optional) – Where to put inset colorbar bbox.
orientation (str, optional) – Inset colorbar orientation (
horizontal
orvertical
).ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to pass to inset_axes or colorbar.
- Returns:
colorbar (matplotlib.colorbar.Colorbar)
colorbar_axis (mpl_toolkits.axes_grid1.parasite_axes.AxesHostAxes)
- draw_milky_way(width=10, linewidth=1.5, color='black', linestyle='-', **kwargs)[source]
Draw the Milky Way galaxy.
- Parameters:
width (float) – Number of degrees north and south to draw dotted lines.
linewidth (float) – Width of line along the plane.
color (str) – Color of Milky Way plane.
linestyle (str) – Style of line.
**kwargs (dict) – Additional kwargs to pass to plot.
- draw_polygon(lon, lat, edgecolor='red', linestyle='solid', facecolor=None, **kwargs)[source]
Plot a polygon from a list of lon, lat coordinates.
This routine is a convenience wrapper around plot() and fill(), both of which work in geodesic coordinates.
- Parameters:
lon (np.ndarray) – Array of longitude points in polygon.
lat (np.ndarray) – Array of latitude points in polygon.
edgecolor (str, optional) – Color of polygon boundary. Set to None for no boundary.
linestyle (str, optional) – Line style for boundary.
facecolor (str, optional) – Color of polygon face. Set to None for no fill color.
**kwargs (dict, optional) – Additional keywords passed to plot.
- draw_polygon_file(filename, reverse=True, edgecolor='red', linestyle='solid', **kwargs)[source]
Draw a text file containing lon, lat coordinates of polygon(s).
- Parameters:
filename (str) – Name of file containing the polygon(s) [lon, lat, poly]
reverse (bool) – Reverse drawing order of points in each polygon.
edgecolor (str) – Color of polygon boundary.
linestyle (str, optional) – Line style for boundary.
**kwargs (dict) – Additional keywords passed to plot.
- get_extent()[source]
Get the extent in lon/lat coordinates.
- Returns:
extent – Extent as [lon_min, lon_max, lat_min, lat_max].
- Return type:
list
- proj(lon, lat)[source]
Apply forward projection to a set of lon/lat positions.
Convert from lon/lat to x/y.
- Parameters:
lon (float or list or np.ndarray) – Array of longitude(s) (degrees).
lat (float or list or np.ndarray) – Array of latitudes(s) (degrees).
- Returns:
x (np.ndarray) – Array of x values.
y (np.ndarray) – Array of y values.
- proj_inverse(x, y)[source]
Apply inverse projection to a set of points.
Convert from x/y to lon/lat.
- Parameters:
x (float or list or np.ndarray) – Projected x values.
y (float or list or np.ndarray) – Projected y values.
- Returns:
lon (np.ndarray) – Array of longitudes (degrees).
lat (np.ndarray) – Array of latitudes (degrees).
- set_autorescale(autorescale)[source]
Set automatic rescaling after zoom.
- Parameters:
autorescale (bool) – Automatically rescale after zoom?
- set_extent(extent)[source]
Set the extent.
Axes will be properly inverted if Skyproj was initialized with
celestial=True
.- Parameters:
extent (array-like) – Extent as [lon_min, lon_max, lat_min, lat_max].
- set_xlabel(text, side='bottom', **kwargs)[source]
Set the label on the x axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
bottom
ortop
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- set_ylabel(text, side='left', **kwargs)[source]
Set the label on the y axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
left
orright
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- tissot_indicatrices(radius=5.0, num_lon=9, num_lat=5, color='red', alpha=0.5)[source]
Draw Tissot indicatrices.
See https://en.wikipedia.org/wiki/Tissot%27s_indicatrix for details.
- Parameters:
radius (float) – Radius of each indicatrix circle.
num_lon (int) – Number of indicatrices in the longitude direction.
num_lat (int) – Number of indicatrices in the latitude direction.
color (str, optional) – Color of indicatrices.
alpha (float, optional) – Alpha of indicatrices.
Skyproj
A Plate Carree cylindrical projection Skyproj map.
- param ax:
Axis object to replace with a skyproj axis.
- type ax:
matplotlib.axes.Axes, optional
- param lon_0:
Central longitude of projection.
- type lon_0:
float, optional
- param gridlines:
Draw gridlines?
- type gridlines:
bool, optional
- param celestial:
Do celestial plotting (e.g. invert longitude axis).
- type celestial:
bool, optional
- param extent:
Default exent of the map, [lon_min, lon_max, lat_min, lat_max]. Note that lon_min, lon_max can be specified in any order, the orientation of the map is set by
celestial
.- type extent:
iterable, optional
- param longitude_ticks:
Label longitude ticks from 0 to 360 degrees (
positive
) or from -180 to 180 degrees (symmetric
).- type longitude_ticks:
str, optional
- param autorescale:
Automatically rescale color bars when zoomed?
- type autorescale:
bool, optional
- param galactic:
Plotting in Galactic coordinates? Recommendation for Galactic plots is to have longitude_ticks set to
symmetric
and celestial = True.- type galactic:
bool, optional
- param rcparams:
Dictionary of matplotlib rc parameters to override. In particular, the code will use
xtick.labelsize
andytick.labelsize
for the x and y tick labels, andaxes.linewidth
for the map boundary.- type rcparams:
dict, optional
- param n_grid_lon:
Number of gridlines to use in the longitude direction (default is axis_ratio * n_grid_lat).
- type n_grid_lon:
int, optional
- param n_grid_lat:
Number of gridlines to use in the latitude direction (default is 6).
- type n_grid_lat:
int, optional
- param min_lon_ticklabel_delta:
Minimum relative spacing between longitude tick labels (relative to width of axis). Smaller values yield closer tick labels (and potential for clashes) and larger values yield further tick labels.
- type min_lon_ticklabel_delta:
float, optional
- param **kwargs:
Additional arguments to send to cartosky/proj4 projection CRS initialization.
- type **kwargs:
dict, optional
Survey
- class skyproj.survey.BlissSkyproj(ax=None, *, lon_0=100.0, gridlines=True, celestial=True, extent=[-60, 250, -55, 0], longitude_ticks='positive', autorescale=True, galactic=False, rcparams={}, n_grid_lon=10, n_grid_lat=6, min_lon_ticklabel_delta=0.1, **kwargs)[source]
Bases:
_Survey
,McBrydeSkyproj
A projection for the BLISS Survey using a McBryde-Thomas Flat Polar Quartic projection.
- Parameters:
ax (matplotlib.axes.Axes, optional) – Axis object to replace with a skyproj axis.
gridlines (bool, optional) – Draw gridlines?
celestial (bool, optional) – Do celestial plotting (e.g. invert longitude axis).
extent (iterable, optional) – Default exent of the map, [lon_min, lon_max, lat_min, lat_max]. Note that lon_min, lon_max can be specified in any order, the orientation of the map is set by
celestial
.longitude_ticks (str, optional) – Label longitude ticks from 0 to 360 degrees (
positive
) or from -180 to 180 degrees (symmetric
).autorescale (bool, optional) – Automatically rescale color bars when zoomed?
galactic (bool, optional) – Plotting in Galactic coordinates? Recommendation for Galactic plots is to have longitude_ticks set to
symmetric
and celestial = True.rcparams (dict, optional) – Dictionary of matplotlib rc parameters to override. In particular, the code will use
xtick.labelsize
andytick.labelsize
for the x and y tick labels, andaxes.linewidth
for the map boundary.n_grid_lon (int, optional) – Number of gridlines to use in the longitude direction (default is axis_ratio * n_grid_lat).
n_grid_lat (int, optional) – Number of gridlines to use in the latitude direction (default is 6).
min_lon_ticklabel_delta (float, optional) – Minimum relative spacing between longitude tick labels (relative to width of axis). Smaller values yield closer tick labels (and potential for clashes) and larger values yield further tick labels.
**kwargs (dict, optional) – Additional arguments to send to cartosky/proj4 projection CRS initialization.
- compute_extent(lon, lat)[source]
Compute plotting extent for a set of lon/lat points.
Uses a simple looping algorithm to find the ideal range so that all the points fit within the projected frame, with a small border.
- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
- Returns:
extent – Plotting extent [lon_max, lon_min, lat_min, lat_max]
- Return type:
list
- draw_colorbar(label=None, ticks=None, fontsize=11, fraction=0.15, location='right', pad=0.0, ax=None, **kwargs)[source]
Draw a colorbar.
- Parameters:
label (str, optional) – Label to attach to colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
fraction (float, optional) – Fraction of original axes to use for colorbar.
location (str, optional) – Colorbar location (
right
,bottom
,left
,top
).pad (float, optional) – Fraction of original axes between colorbar and original axes.
ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to send to colorbar().
- Returns:
colorbar
- Return type:
matplotlib.colorbar.Colorbar
- draw_hpxbin(lon, lat, C=None, nside=256, nest=False, zoom=False, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, **kwargs)[source]
Create a healpix histogram of counts in lon, lat.
Related to
hexbin
from matplotlib.If
C
array is specified then the mean is taken from the C values.- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
C (np.ndarray, optional) – Array of values to average in each pixel.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxmap(hpxmap, nest=False, zoom=False, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, **kwargs)[source]
Use pcolormesh to draw a healpix map.
- Parameters:
hpxmap (np.ndarray) – Healpix map to plot, with length 12*nside*nside and UNSEEN for illegal values.
nest (bool, optional) – Map in nest ordering?
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxpix(nside, pixels, values, nest=False, zoom=False, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, **kwargs)[source]
Use pcolormesh to draw a healpix map made of pixels and values.
- Parameters:
nside (int) – Healpix nside of pixels to plot.
pixels (np.ndarray) – Array of pixels to plot.
values (np.ndarray) – Array of values associated with pixels.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hspmap(hspmap, zoom=False, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, **kwargs)[source]
Use pcolormesh to draw a healsparse map.
- Parameters:
hspmap (healsparse.HealSparseMap) – Healsparse map to plot.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_inset_colorbar(format=None, label=None, ticks=None, fontsize=11, width='25%', height='5%', loc=7, bbox_to_anchor=(0.0, -0.04, 1, 1), orientation='horizontal', ax=None, **kwargs)[source]
Draw an inset colorbar.
- Parameters:
format (str, optional) – Format string for tick labels.
label (str, optional) – Label to attach to inset colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
width (str, optional) – Fraction of total axis width for inset colorbar.
height (str, optional) – Fraction of total axis height for inset colorbar.
loc (int, optional) – Matplotlib location code.
bbox_to_anchor (tuple, optional) – Where to put inset colorbar bbox.
orientation (str, optional) – Inset colorbar orientation (
horizontal
orvertical
).ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to pass to inset_axes or colorbar.
- Returns:
colorbar (matplotlib.colorbar.Colorbar)
colorbar_axis (mpl_toolkits.axes_grid1.parasite_axes.AxesHostAxes)
- draw_milky_way(width=10, linewidth=1.5, color='black', linestyle='-', **kwargs)[source]
Draw the Milky Way galaxy.
- Parameters:
width (float) – Number of degrees north and south to draw dotted lines.
linewidth (float) – Width of line along the plane.
color (str) – Color of Milky Way plane.
linestyle (str) – Style of line.
**kwargs (dict) – Additional kwargs to pass to plot.
- draw_polygon(lon, lat, edgecolor='red', linestyle='solid', facecolor=None, **kwargs)[source]
Plot a polygon from a list of lon, lat coordinates.
This routine is a convenience wrapper around plot() and fill(), both of which work in geodesic coordinates.
- Parameters:
lon (np.ndarray) – Array of longitude points in polygon.
lat (np.ndarray) – Array of latitude points in polygon.
edgecolor (str, optional) – Color of polygon boundary. Set to None for no boundary.
linestyle (str, optional) – Line style for boundary.
facecolor (str, optional) – Color of polygon face. Set to None for no fill color.
**kwargs (dict, optional) – Additional keywords passed to plot.
- draw_polygon_file(filename, reverse=True, edgecolor='red', linestyle='solid', **kwargs)[source]
Draw a text file containing lon, lat coordinates of polygon(s).
- Parameters:
filename (str) – Name of file containing the polygon(s) [lon, lat, poly]
reverse (bool) – Reverse drawing order of points in each polygon.
edgecolor (str) – Color of polygon boundary.
linestyle (str, optional) – Line style for boundary.
**kwargs (dict) – Additional keywords passed to plot.
- get_extent()[source]
Get the extent in lon/lat coordinates.
- Returns:
extent – Extent as [lon_min, lon_max, lat_min, lat_max].
- Return type:
list
- proj(lon, lat)[source]
Apply forward projection to a set of lon/lat positions.
Convert from lon/lat to x/y.
- Parameters:
lon (float or list or np.ndarray) – Array of longitude(s) (degrees).
lat (float or list or np.ndarray) – Array of latitudes(s) (degrees).
- Returns:
x (np.ndarray) – Array of x values.
y (np.ndarray) – Array of y values.
- proj_inverse(x, y)[source]
Apply inverse projection to a set of points.
Convert from x/y to lon/lat.
- Parameters:
x (float or list or np.ndarray) – Projected x values.
y (float or list or np.ndarray) – Projected y values.
- Returns:
lon (np.ndarray) – Array of longitudes (degrees).
lat (np.ndarray) – Array of latitudes (degrees).
- set_autorescale(autorescale)[source]
Set automatic rescaling after zoom.
- Parameters:
autorescale (bool) – Automatically rescale after zoom?
- set_extent(extent)[source]
Set the extent.
Axes will be properly inverted if Skyproj was initialized with
celestial=True
.- Parameters:
extent (array-like) – Extent as [lon_min, lon_max, lat_min, lat_max].
- set_xlabel(text, side='bottom', **kwargs)[source]
Set the label on the x axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
bottom
ortop
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- set_ylabel(text, side='left', **kwargs)[source]
Set the label on the y axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
left
orright
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- tissot_indicatrices(radius=5.0, num_lon=9, num_lat=5, color='red', alpha=0.5)[source]
Draw Tissot indicatrices.
See https://en.wikipedia.org/wiki/Tissot%27s_indicatrix for details.
- Parameters:
radius (float) – Radius of each indicatrix circle.
num_lon (int) – Number of indicatrices in the longitude direction.
num_lat (int) – Number of indicatrices in the latitude direction.
color (str, optional) – Color of indicatrices.
alpha (float, optional) – Alpha of indicatrices.
- class skyproj.survey.DESAlbersSkyproj(ax=None, *, gridlines=True, celestial=True, extent=[80, -40, -80, 10], longitude_ticks='positive', autorescale=True, galactic=False, rcparams={}, n_grid_lon=10, n_grid_lat=6, min_lon_ticklabel_delta=0.1, lon_0=30.0, lat_1=-15.0, lat_2=-50.0, **kwargs)[source]
Bases:
_Survey
,AlbersSkyproj
A projection for the DES Survey using an Albers Equal Area projection.
- Parameters:
ax (matplotlib.axes.Axes, optional) – Axis object to replace with a skyproj axis.
gridlines (bool, optional) – Draw gridlines?
celestial (bool, optional) – Do celestial plotting (e.g. invert longitude axis).
extent (iterable, optional) – Default exent of the map, [lon_min, lon_max, lat_min, lat_max]. Note that lon_min, lon_max can be specified in any order, the orientation of the map is set by
celestial
.longitude_ticks (str, optional) – Label longitude ticks from 0 to 360 degrees (
positive
) or from -180 to 180 degrees (symmetric
).autorescale (bool, optional) – Automatically rescale color bars when zoomed?
galactic (bool, optional) – Plotting in Galactic coordinates? Recommendation for Galactic plots is to have longitude_ticks set to
symmetric
and celestial = True.rcparams (dict, optional) – Dictionary of matplotlib rc parameters to override. In particular, the code will use
xtick.labelsize
andytick.labelsize
for the x and y tick labels, andaxes.linewidth
for the map boundary.n_grid_lon (int, optional) – Number of gridlines to use in the longitude direction (default is axis_ratio * n_grid_lat).
n_grid_lat (int, optional) – Number of gridlines to use in the latitude direction (default is 6).
min_lon_ticklabel_delta (float, optional) – Minimum relative spacing between longitude tick labels (relative to width of axis). Smaller values yield closer tick labels (and potential for clashes) and larger values yield further tick labels.
**kwargs (dict, optional) – Additional arguments to send to cartosky/proj4 projection CRS initialization.
- compute_extent(lon, lat)[source]
Compute plotting extent for a set of lon/lat points.
Uses a simple looping algorithm to find the ideal range so that all the points fit within the projected frame, with a small border.
- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
- Returns:
extent – Plotting extent [lon_max, lon_min, lat_min, lat_max]
- Return type:
list
- draw_colorbar(label=None, ticks=None, fontsize=11, fraction=0.15, location='right', pad=0.0, ax=None, **kwargs)[source]
Draw a colorbar.
- Parameters:
label (str, optional) – Label to attach to colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
fraction (float, optional) – Fraction of original axes to use for colorbar.
location (str, optional) – Colorbar location (
right
,bottom
,left
,top
).pad (float, optional) – Fraction of original axes between colorbar and original axes.
ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to send to colorbar().
- Returns:
colorbar
- Return type:
matplotlib.colorbar.Colorbar
- draw_hpxbin(lon, lat, C=None, nside=256, nest=False, zoom=False, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, **kwargs)[source]
Create a healpix histogram of counts in lon, lat.
Related to
hexbin
from matplotlib.If
C
array is specified then the mean is taken from the C values.- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
C (np.ndarray, optional) – Array of values to average in each pixel.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxmap(hpxmap, nest=False, zoom=False, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, **kwargs)[source]
Use pcolormesh to draw a healpix map.
- Parameters:
hpxmap (np.ndarray) – Healpix map to plot, with length 12*nside*nside and UNSEEN for illegal values.
nest (bool, optional) – Map in nest ordering?
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxpix(nside, pixels, values, nest=False, zoom=False, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, **kwargs)[source]
Use pcolormesh to draw a healpix map made of pixels and values.
- Parameters:
nside (int) – Healpix nside of pixels to plot.
pixels (np.ndarray) – Array of pixels to plot.
values (np.ndarray) – Array of values associated with pixels.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hspmap(hspmap, zoom=False, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, **kwargs)[source]
Use pcolormesh to draw a healsparse map.
- Parameters:
hspmap (healsparse.HealSparseMap) – Healsparse map to plot.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_inset_colorbar(format=None, label=None, ticks=None, fontsize=11, width='25%', height='5%', loc=7, bbox_to_anchor=(0.0, -0.04, 1, 1), orientation='horizontal', ax=None, **kwargs)[source]
Draw an inset colorbar.
- Parameters:
format (str, optional) – Format string for tick labels.
label (str, optional) – Label to attach to inset colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
width (str, optional) – Fraction of total axis width for inset colorbar.
height (str, optional) – Fraction of total axis height for inset colorbar.
loc (int, optional) – Matplotlib location code.
bbox_to_anchor (tuple, optional) – Where to put inset colorbar bbox.
orientation (str, optional) – Inset colorbar orientation (
horizontal
orvertical
).ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to pass to inset_axes or colorbar.
- Returns:
colorbar (matplotlib.colorbar.Colorbar)
colorbar_axis (mpl_toolkits.axes_grid1.parasite_axes.AxesHostAxes)
- draw_milky_way(width=10, linewidth=1.5, color='black', linestyle='-', **kwargs)[source]
Draw the Milky Way galaxy.
- Parameters:
width (float) – Number of degrees north and south to draw dotted lines.
linewidth (float) – Width of line along the plane.
color (str) – Color of Milky Way plane.
linestyle (str) – Style of line.
**kwargs (dict) – Additional kwargs to pass to plot.
- draw_polygon(lon, lat, edgecolor='red', linestyle='solid', facecolor=None, **kwargs)[source]
Plot a polygon from a list of lon, lat coordinates.
This routine is a convenience wrapper around plot() and fill(), both of which work in geodesic coordinates.
- Parameters:
lon (np.ndarray) – Array of longitude points in polygon.
lat (np.ndarray) – Array of latitude points in polygon.
edgecolor (str, optional) – Color of polygon boundary. Set to None for no boundary.
linestyle (str, optional) – Line style for boundary.
facecolor (str, optional) – Color of polygon face. Set to None for no fill color.
**kwargs (dict, optional) – Additional keywords passed to plot.
- draw_polygon_file(filename, reverse=True, edgecolor='red', linestyle='solid', **kwargs)[source]
Draw a text file containing lon, lat coordinates of polygon(s).
- Parameters:
filename (str) – Name of file containing the polygon(s) [lon, lat, poly]
reverse (bool) – Reverse drawing order of points in each polygon.
edgecolor (str) – Color of polygon boundary.
linestyle (str, optional) – Line style for boundary.
**kwargs (dict) – Additional keywords passed to plot.
- get_extent()[source]
Get the extent in lon/lat coordinates.
- Returns:
extent – Extent as [lon_min, lon_max, lat_min, lat_max].
- Return type:
list
- proj(lon, lat)[source]
Apply forward projection to a set of lon/lat positions.
Convert from lon/lat to x/y.
- Parameters:
lon (float or list or np.ndarray) – Array of longitude(s) (degrees).
lat (float or list or np.ndarray) – Array of latitudes(s) (degrees).
- Returns:
x (np.ndarray) – Array of x values.
y (np.ndarray) – Array of y values.
- proj_inverse(x, y)[source]
Apply inverse projection to a set of points.
Convert from x/y to lon/lat.
- Parameters:
x (float or list or np.ndarray) – Projected x values.
y (float or list or np.ndarray) – Projected y values.
- Returns:
lon (np.ndarray) – Array of longitudes (degrees).
lat (np.ndarray) – Array of latitudes (degrees).
- set_autorescale(autorescale)[source]
Set automatic rescaling after zoom.
- Parameters:
autorescale (bool) – Automatically rescale after zoom?
- set_extent(extent)[source]
Set the extent.
Axes will be properly inverted if Skyproj was initialized with
celestial=True
.- Parameters:
extent (array-like) – Extent as [lon_min, lon_max, lat_min, lat_max].
- set_xlabel(text, side='bottom', **kwargs)[source]
Set the label on the x axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
bottom
ortop
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- set_ylabel(text, side='left', **kwargs)[source]
Set the label on the y axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
left
orright
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- tissot_indicatrices(radius=5.0, num_lon=9, num_lat=5, color='red', alpha=0.5)[source]
Draw Tissot indicatrices.
See https://en.wikipedia.org/wiki/Tissot%27s_indicatrix for details.
- Parameters:
radius (float) – Radius of each indicatrix circle.
num_lon (int) – Number of indicatrices in the longitude direction.
num_lat (int) – Number of indicatrices in the latitude direction.
color (str, optional) – Color of indicatrices.
alpha (float, optional) – Alpha of indicatrices.
- class skyproj.survey.DESMcBrydeSkyproj(ax=None, *, lon_0=30.0, gridlines=True, celestial=True, extent=[90, -50, -74, 10], longitude_ticks='positive', autorescale=True, galactic=False, rcparams={}, n_grid_lon=10, n_grid_lat=6, min_lon_ticklabel_delta=0.1, **kwargs)[source]
Bases:
_Survey
,McBrydeSkyproj
A projection for the DES Survey using a McBryde-Thomas Flat Polar Quartic projection.
- Parameters:
ax (matplotlib.axes.Axes, optional) – Axis object to replace with a skyproj axis.
lon_0 (float, optional) – Central longitude of projection.
gridlines (bool, optional) – Draw gridlines?
celestial (bool, optional) – Do celestial plotting (e.g. invert longitude axis).
extent (iterable, optional) – Default exent of the map, [lon_min, lon_max, lat_min, lat_max]. Note that lon_min, lon_max can be specified in any order, the orientation of the map is set by
celestial
.longitude_ticks (str, optional) – Label longitude ticks from 0 to 360 degrees (
positive
) or from -180 to 180 degrees (symmetric
).autorescale (bool, optional) – Automatically rescale color bars when zoomed?
galactic (bool, optional) – Plotting in Galactic coordinates? Recommendation for Galactic plots is to have longitude_ticks set to
symmetric
and celestial = True.rcparams (dict, optional) – Dictionary of matplotlib rc parameters to override. In particular, the code will use
xtick.labelsize
andytick.labelsize
for the x and y tick labels, andaxes.linewidth
for the map boundary.n_grid_lon (int, optional) – Number of gridlines to use in the longitude direction (default is axis_ratio * n_grid_lat).
n_grid_lat (int, optional) – Number of gridlines to use in the latitude direction (default is 6).
min_lon_ticklabel_delta (float, optional) – Minimum relative spacing between longitude tick labels (relative to width of axis). Smaller values yield closer tick labels (and potential for clashes) and larger values yield further tick labels.
**kwargs (dict, optional) – Additional arguments to send to cartosky/proj4 projection CRS initialization.
- compute_extent(lon, lat)[source]
Compute plotting extent for a set of lon/lat points.
Uses a simple looping algorithm to find the ideal range so that all the points fit within the projected frame, with a small border.
- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
- Returns:
extent – Plotting extent [lon_max, lon_min, lat_min, lat_max]
- Return type:
list
- draw_colorbar(label=None, ticks=None, fontsize=11, fraction=0.15, location='right', pad=0.0, ax=None, **kwargs)[source]
Draw a colorbar.
- Parameters:
label (str, optional) – Label to attach to colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
fraction (float, optional) – Fraction of original axes to use for colorbar.
location (str, optional) – Colorbar location (
right
,bottom
,left
,top
).pad (float, optional) – Fraction of original axes between colorbar and original axes.
ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to send to colorbar().
- Returns:
colorbar
- Return type:
matplotlib.colorbar.Colorbar
- draw_hpxbin(lon, lat, C=None, nside=256, nest=False, zoom=False, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, **kwargs)[source]
Create a healpix histogram of counts in lon, lat.
Related to
hexbin
from matplotlib.If
C
array is specified then the mean is taken from the C values.- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
C (np.ndarray, optional) – Array of values to average in each pixel.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxmap(hpxmap, nest=False, zoom=False, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, **kwargs)[source]
Use pcolormesh to draw a healpix map.
- Parameters:
hpxmap (np.ndarray) – Healpix map to plot, with length 12*nside*nside and UNSEEN for illegal values.
nest (bool, optional) – Map in nest ordering?
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxpix(nside, pixels, values, nest=False, zoom=False, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, **kwargs)[source]
Use pcolormesh to draw a healpix map made of pixels and values.
- Parameters:
nside (int) – Healpix nside of pixels to plot.
pixels (np.ndarray) – Array of pixels to plot.
values (np.ndarray) – Array of values associated with pixels.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hspmap(hspmap, zoom=False, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, **kwargs)[source]
Use pcolormesh to draw a healsparse map.
- Parameters:
hspmap (healsparse.HealSparseMap) – Healsparse map to plot.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_inset_colorbar(format=None, label=None, ticks=None, fontsize=11, width='25%', height='5%', loc=7, bbox_to_anchor=(0.0, -0.04, 1, 1), orientation='horizontal', ax=None, **kwargs)[source]
Draw an inset colorbar.
- Parameters:
format (str, optional) – Format string for tick labels.
label (str, optional) – Label to attach to inset colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
width (str, optional) – Fraction of total axis width for inset colorbar.
height (str, optional) – Fraction of total axis height for inset colorbar.
loc (int, optional) – Matplotlib location code.
bbox_to_anchor (tuple, optional) – Where to put inset colorbar bbox.
orientation (str, optional) – Inset colorbar orientation (
horizontal
orvertical
).ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to pass to inset_axes or colorbar.
- Returns:
colorbar (matplotlib.colorbar.Colorbar)
colorbar_axis (mpl_toolkits.axes_grid1.parasite_axes.AxesHostAxes)
- draw_milky_way(width=10, linewidth=1.5, color='black', linestyle='-', **kwargs)[source]
Draw the Milky Way galaxy.
- Parameters:
width (float) – Number of degrees north and south to draw dotted lines.
linewidth (float) – Width of line along the plane.
color (str) – Color of Milky Way plane.
linestyle (str) – Style of line.
**kwargs (dict) – Additional kwargs to pass to plot.
- draw_polygon(lon, lat, edgecolor='red', linestyle='solid', facecolor=None, **kwargs)[source]
Plot a polygon from a list of lon, lat coordinates.
This routine is a convenience wrapper around plot() and fill(), both of which work in geodesic coordinates.
- Parameters:
lon (np.ndarray) – Array of longitude points in polygon.
lat (np.ndarray) – Array of latitude points in polygon.
edgecolor (str, optional) – Color of polygon boundary. Set to None for no boundary.
linestyle (str, optional) – Line style for boundary.
facecolor (str, optional) – Color of polygon face. Set to None for no fill color.
**kwargs (dict, optional) – Additional keywords passed to plot.
- draw_polygon_file(filename, reverse=True, edgecolor='red', linestyle='solid', **kwargs)[source]
Draw a text file containing lon, lat coordinates of polygon(s).
- Parameters:
filename (str) – Name of file containing the polygon(s) [lon, lat, poly]
reverse (bool) – Reverse drawing order of points in each polygon.
edgecolor (str) – Color of polygon boundary.
linestyle (str, optional) – Line style for boundary.
**kwargs (dict) – Additional keywords passed to plot.
- get_extent()[source]
Get the extent in lon/lat coordinates.
- Returns:
extent – Extent as [lon_min, lon_max, lat_min, lat_max].
- Return type:
list
- proj(lon, lat)[source]
Apply forward projection to a set of lon/lat positions.
Convert from lon/lat to x/y.
- Parameters:
lon (float or list or np.ndarray) – Array of longitude(s) (degrees).
lat (float or list or np.ndarray) – Array of latitudes(s) (degrees).
- Returns:
x (np.ndarray) – Array of x values.
y (np.ndarray) – Array of y values.
- proj_inverse(x, y)[source]
Apply inverse projection to a set of points.
Convert from x/y to lon/lat.
- Parameters:
x (float or list or np.ndarray) – Projected x values.
y (float or list or np.ndarray) – Projected y values.
- Returns:
lon (np.ndarray) – Array of longitudes (degrees).
lat (np.ndarray) – Array of latitudes (degrees).
- set_autorescale(autorescale)[source]
Set automatic rescaling after zoom.
- Parameters:
autorescale (bool) – Automatically rescale after zoom?
- set_extent(extent)[source]
Set the extent.
Axes will be properly inverted if Skyproj was initialized with
celestial=True
.- Parameters:
extent (array-like) – Extent as [lon_min, lon_max, lat_min, lat_max].
- set_xlabel(text, side='bottom', **kwargs)[source]
Set the label on the x axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
bottom
ortop
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- set_ylabel(text, side='left', **kwargs)[source]
Set the label on the y axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
left
orright
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- tissot_indicatrices(radius=5.0, num_lon=9, num_lat=5, color='red', alpha=0.5)[source]
Draw Tissot indicatrices.
See https://en.wikipedia.org/wiki/Tissot%27s_indicatrix for details.
- Parameters:
radius (float) – Radius of each indicatrix circle.
num_lon (int) – Number of indicatrices in the longitude direction.
num_lat (int) – Number of indicatrices in the latitude direction.
color (str, optional) – Color of indicatrices.
alpha (float, optional) – Alpha of indicatrices.
- skyproj.survey.DESSkyproj[source]
alias of
DESMcBrydeSkyproj
- class skyproj.survey.DecalsSkyproj(ax=None, *, lon_0=105.0, gridlines=True, celestial=True, extent=[180, -180, -30, 40], longitude_ticks='positive', autorescale=True, galactic=False, rcparams={}, n_grid_lon=10, n_grid_lat=6, min_lon_ticklabel_delta=0.1, **kwargs)[source]
Bases:
_Survey
,McBrydeSkyproj
A projection for the DECaLS Survey using a McBryde-Thomas Flat Polar Quartic projection.
- Parameters:
ax (matplotlib.axes.Axes, optional) – Axis object to replace with a skyproj axis.
gridlines (bool, optional) – Draw gridlines?
celestial (bool, optional) – Do celestial plotting (e.g. invert longitude axis).
extent (iterable, optional) – Default exent of the map, [lon_min, lon_max, lat_min, lat_max]. Note that lon_min, lon_max can be specified in any order, the orientation of the map is set by
celestial
.longitude_ticks (str, optional) – Label longitude ticks from 0 to 360 degrees (
positive
) or from -180 to 180 degrees (symmetric
).autorescale (bool, optional) – Automatically rescale color bars when zoomed?
galactic (bool, optional) – Plotting in Galactic coordinates? Recommendation for Galactic plots is to have longitude_ticks set to
symmetric
and celestial = True.rcparams (dict, optional) – Dictionary of matplotlib rc parameters to override. In particular, the code will use
xtick.labelsize
andytick.labelsize
for the x and y tick labels, andaxes.linewidth
for the map boundary.n_grid_lon (int, optional) – Number of gridlines to use in the longitude direction (default is axis_ratio * n_grid_lat).
n_grid_lat (int, optional) – Number of gridlines to use in the latitude direction (default is 6).
min_lon_ticklabel_delta (float, optional) – Minimum relative spacing between longitude tick labels (relative to width of axis). Smaller values yield closer tick labels (and potential for clashes) and larger values yield further tick labels.
**kwargs (dict, optional) – Additional arguments to send to cartosky/proj4 projection CRS initialization.
- compute_extent(lon, lat)[source]
Compute plotting extent for a set of lon/lat points.
Uses a simple looping algorithm to find the ideal range so that all the points fit within the projected frame, with a small border.
- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
- Returns:
extent – Plotting extent [lon_max, lon_min, lat_min, lat_max]
- Return type:
list
- draw_colorbar(label=None, ticks=None, fontsize=11, fraction=0.15, location='right', pad=0.0, ax=None, **kwargs)[source]
Draw a colorbar.
- Parameters:
label (str, optional) – Label to attach to colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
fraction (float, optional) – Fraction of original axes to use for colorbar.
location (str, optional) – Colorbar location (
right
,bottom
,left
,top
).pad (float, optional) – Fraction of original axes between colorbar and original axes.
ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to send to colorbar().
- Returns:
colorbar
- Return type:
matplotlib.colorbar.Colorbar
- draw_hpxbin(lon, lat, C=None, nside=256, nest=False, zoom=False, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, **kwargs)[source]
Create a healpix histogram of counts in lon, lat.
Related to
hexbin
from matplotlib.If
C
array is specified then the mean is taken from the C values.- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
C (np.ndarray, optional) – Array of values to average in each pixel.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxmap(hpxmap, nest=False, zoom=False, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, **kwargs)[source]
Use pcolormesh to draw a healpix map.
- Parameters:
hpxmap (np.ndarray) – Healpix map to plot, with length 12*nside*nside and UNSEEN for illegal values.
nest (bool, optional) – Map in nest ordering?
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxpix(nside, pixels, values, nest=False, zoom=False, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, **kwargs)[source]
Use pcolormesh to draw a healpix map made of pixels and values.
- Parameters:
nside (int) – Healpix nside of pixels to plot.
pixels (np.ndarray) – Array of pixels to plot.
values (np.ndarray) – Array of values associated with pixels.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hspmap(hspmap, zoom=False, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, **kwargs)[source]
Use pcolormesh to draw a healsparse map.
- Parameters:
hspmap (healsparse.HealSparseMap) – Healsparse map to plot.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_inset_colorbar(format=None, label=None, ticks=None, fontsize=11, width='25%', height='5%', loc=7, bbox_to_anchor=(0.0, -0.04, 1, 1), orientation='horizontal', ax=None, **kwargs)[source]
Draw an inset colorbar.
- Parameters:
format (str, optional) – Format string for tick labels.
label (str, optional) – Label to attach to inset colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
width (str, optional) – Fraction of total axis width for inset colorbar.
height (str, optional) – Fraction of total axis height for inset colorbar.
loc (int, optional) – Matplotlib location code.
bbox_to_anchor (tuple, optional) – Where to put inset colorbar bbox.
orientation (str, optional) – Inset colorbar orientation (
horizontal
orvertical
).ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to pass to inset_axes or colorbar.
- Returns:
colorbar (matplotlib.colorbar.Colorbar)
colorbar_axis (mpl_toolkits.axes_grid1.parasite_axes.AxesHostAxes)
- draw_milky_way(width=10, linewidth=1.5, color='black', linestyle='-', **kwargs)[source]
Draw the Milky Way galaxy.
- Parameters:
width (float) – Number of degrees north and south to draw dotted lines.
linewidth (float) – Width of line along the plane.
color (str) – Color of Milky Way plane.
linestyle (str) – Style of line.
**kwargs (dict) – Additional kwargs to pass to plot.
- draw_polygon(lon, lat, edgecolor='red', linestyle='solid', facecolor=None, **kwargs)[source]
Plot a polygon from a list of lon, lat coordinates.
This routine is a convenience wrapper around plot() and fill(), both of which work in geodesic coordinates.
- Parameters:
lon (np.ndarray) – Array of longitude points in polygon.
lat (np.ndarray) – Array of latitude points in polygon.
edgecolor (str, optional) – Color of polygon boundary. Set to None for no boundary.
linestyle (str, optional) – Line style for boundary.
facecolor (str, optional) – Color of polygon face. Set to None for no fill color.
**kwargs (dict, optional) – Additional keywords passed to plot.
- draw_polygon_file(filename, reverse=True, edgecolor='red', linestyle='solid', **kwargs)[source]
Draw a text file containing lon, lat coordinates of polygon(s).
- Parameters:
filename (str) – Name of file containing the polygon(s) [lon, lat, poly]
reverse (bool) – Reverse drawing order of points in each polygon.
edgecolor (str) – Color of polygon boundary.
linestyle (str, optional) – Line style for boundary.
**kwargs (dict) – Additional keywords passed to plot.
- get_extent()[source]
Get the extent in lon/lat coordinates.
- Returns:
extent – Extent as [lon_min, lon_max, lat_min, lat_max].
- Return type:
list
- proj(lon, lat)[source]
Apply forward projection to a set of lon/lat positions.
Convert from lon/lat to x/y.
- Parameters:
lon (float or list or np.ndarray) – Array of longitude(s) (degrees).
lat (float or list or np.ndarray) – Array of latitudes(s) (degrees).
- Returns:
x (np.ndarray) – Array of x values.
y (np.ndarray) – Array of y values.
- proj_inverse(x, y)[source]
Apply inverse projection to a set of points.
Convert from x/y to lon/lat.
- Parameters:
x (float or list or np.ndarray) – Projected x values.
y (float or list or np.ndarray) – Projected y values.
- Returns:
lon (np.ndarray) – Array of longitudes (degrees).
lat (np.ndarray) – Array of latitudes (degrees).
- set_autorescale(autorescale)[source]
Set automatic rescaling after zoom.
- Parameters:
autorescale (bool) – Automatically rescale after zoom?
- set_extent(extent)[source]
Set the extent.
Axes will be properly inverted if Skyproj was initialized with
celestial=True
.- Parameters:
extent (array-like) – Extent as [lon_min, lon_max, lat_min, lat_max].
- set_xlabel(text, side='bottom', **kwargs)[source]
Set the label on the x axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
bottom
ortop
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- set_ylabel(text, side='left', **kwargs)[source]
Set the label on the y axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
left
orright
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- tissot_indicatrices(radius=5.0, num_lon=9, num_lat=5, color='red', alpha=0.5)[source]
Draw Tissot indicatrices.
See https://en.wikipedia.org/wiki/Tissot%27s_indicatrix for details.
- Parameters:
radius (float) – Radius of each indicatrix circle.
num_lon (int) – Number of indicatrices in the longitude direction.
num_lat (int) – Number of indicatrices in the latitude direction.
color (str, optional) – Color of indicatrices.
alpha (float, optional) – Alpha of indicatrices.
- class skyproj.survey.MaglitesSkyproj(ax=None, *, gridlines=True, celestial=True, extent=[-150, 70, -85, -50], longitude_ticks='positive', autorescale=True, galactic=False, rcparams={}, n_grid_lon=10, n_grid_lat=6, min_lon_ticklabel_delta=0.1, lon_0=0.0, lat_0=-90.0, **kwargs)[source]
Bases:
_Survey
,LaeaSkyproj
A projection for the MagLiteS Survey using a Lambert Azimuthal Equal Area projection.
- Parameters:
ax (matplotlib.axes.Axes, optional) – Axis object to replace with a skyproj axis.
gridlines (bool, optional) – Draw gridlines?
celestial (bool, optional) – Do celestial plotting (e.g. invert longitude axis).
extent (iterable, optional) – Default exent of the map, [lon_min, lon_max, lat_min, lat_max]. Note that lon_min, lon_max can be specified in any order, the orientation of the map is set by
celestial
.longitude_ticks (str, optional) – Label longitude ticks from 0 to 360 degrees (
positive
) or from -180 to 180 degrees (symmetric
).autorescale (bool, optional) – Automatically rescale color bars when zoomed?
galactic (bool, optional) – Plotting in Galactic coordinates? Recommendation for Galactic plots is to have longitude_ticks set to
symmetric
and celestial = True.rcparams (dict, optional) – Dictionary of matplotlib rc parameters to override. In particular, the code will use
xtick.labelsize
andytick.labelsize
for the x and y tick labels, andaxes.linewidth
for the map boundary.n_grid_lon (int, optional) – Number of gridlines to use in the longitude direction (default is axis_ratio * n_grid_lat).
n_grid_lat (int, optional) – Number of gridlines to use in the latitude direction (default is 6).
min_lon_ticklabel_delta (float, optional) – Minimum relative spacing between longitude tick labels (relative to width of axis). Smaller values yield closer tick labels (and potential for clashes) and larger values yield further tick labels.
**kwargs (dict, optional) – Additional arguments to send to cartosky/proj4 projection CRS initialization.
- compute_extent(lon, lat)[source]
Compute plotting extent for a set of lon/lat points.
Uses a simple looping algorithm to find the ideal range so that all the points fit within the projected frame, with a small border.
- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
- Returns:
extent – Plotting extent [lon_max, lon_min, lat_min, lat_max]
- Return type:
list
- draw_colorbar(label=None, ticks=None, fontsize=11, fraction=0.15, location='right', pad=0.0, ax=None, **kwargs)[source]
Draw a colorbar.
- Parameters:
label (str, optional) – Label to attach to colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
fraction (float, optional) – Fraction of original axes to use for colorbar.
location (str, optional) – Colorbar location (
right
,bottom
,left
,top
).pad (float, optional) – Fraction of original axes between colorbar and original axes.
ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to send to colorbar().
- Returns:
colorbar
- Return type:
matplotlib.colorbar.Colorbar
- draw_hpxbin(lon, lat, C=None, nside=256, nest=False, zoom=False, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, **kwargs)[source]
Create a healpix histogram of counts in lon, lat.
Related to
hexbin
from matplotlib.If
C
array is specified then the mean is taken from the C values.- Parameters:
lon (np.ndarray) – Array of longitude values.
lat (np.ndarray) – Array of latitude values.
C (np.ndarray, optional) – Array of values to average in each pixel.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxmap(hpxmap, nest=False, zoom=False, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, **kwargs)[source]
Use pcolormesh to draw a healpix map.
- Parameters:
hpxmap (np.ndarray) – Healpix map to plot, with length 12*nside*nside and UNSEEN for illegal values.
nest (bool, optional) – Map in nest ordering?
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hpxpix(nside, pixels, values, nest=False, zoom=False, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, **kwargs)[source]
Use pcolormesh to draw a healpix map made of pixels and values.
- Parameters:
nside (int) – Healpix nside of pixels to plot.
pixels (np.ndarray) – Array of pixels to plot.
values (np.ndarray) – Array of values associated with pixels.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_hspmap(hspmap, zoom=False, xsize=1000, vmin=None, vmax=None, rasterized=True, lon_range=None, lat_range=None, **kwargs)[source]
Use pcolormesh to draw a healsparse map.
- Parameters:
hspmap (healsparse.HealSparseMap) – Healsparse map to plot.
zoom (bool, optional) – Optimally zoom in projection to computed map.
xsize (int, optional) – Number of rasterized pixels in the x direction.
vmin (float, optional) – Minimum value for color scale. Defaults to 2.5th percentile.
vmax (float, optional) – Maximum value for color scale. Defaults to 97.5th percentile.
rasterized (bool, optional) – Plot with rasterized graphics.
lon_range (tuple [float, float], optional) – Longitude range to plot [
lon_min
,lon_max
].lat_range (tuple [float, float], optional) – Latitude range to plot [
lat_min
,lat_max
].norm (str or matplotlib.colors.Normalize, optional) – The normalization method used to scale the data. By default a linear scaling is used. This may be an instance of Normalize or a scale name, such as
linear
,log
,symlog
,logit
.**kwargs (dict) – Additional args to pass to pcolormesh.
- Returns:
im (matplotlib.collections.QuadMesh) – Image that was displayed
lon_raster (np.ndarray) – 2D array of rasterized longitude values.
lat_raster (np.ndarray) – 2D array of rasterized latitude values.
values_raster (np.ma.MaskedArray) – Masked array of rasterized values.
- draw_inset_colorbar(format=None, label=None, ticks=None, fontsize=11, width='25%', height='5%', loc=7, bbox_to_anchor=(0.0, -0.04, 1, 1), orientation='horizontal', ax=None, **kwargs)[source]
Draw an inset colorbar.
- Parameters:
format (str, optional) – Format string for tick labels.
label (str, optional) – Label to attach to inset colorbar.
ticks (list, optional) – List of tick values.
fontsize (int, optional) – Font size to use for ticks.
width (str, optional) – Fraction of total axis width for inset colorbar.
height (str, optional) – Fraction of total axis height for inset colorbar.
loc (int, optional) – Matplotlib location code.
bbox_to_anchor (tuple, optional) – Where to put inset colorbar bbox.
orientation (str, optional) – Inset colorbar orientation (
horizontal
orvertical
).ax (SkyAxesSubplot, optional) – Axis associated with inset colorbar. If None, use skyaxes associated with map.
**kwargs (dict, optional) – Additional kwargs to pass to inset_axes or colorbar.
- Returns:
colorbar (matplotlib.colorbar.Colorbar)
colorbar_axis (mpl_toolkits.axes_grid1.parasite_axes.AxesHostAxes)
- draw_milky_way(width=10, linewidth=1.5, color='black', linestyle='-', **kwargs)[source]
Draw the Milky Way galaxy.
- Parameters:
width (float) – Number of degrees north and south to draw dotted lines.
linewidth (float) – Width of line along the plane.
color (str) – Color of Milky Way plane.
linestyle (str) – Style of line.
**kwargs (dict) – Additional kwargs to pass to plot.
- draw_polygon(lon, lat, edgecolor='red', linestyle='solid', facecolor=None, **kwargs)[source]
Plot a polygon from a list of lon, lat coordinates.
This routine is a convenience wrapper around plot() and fill(), both of which work in geodesic coordinates.
- Parameters:
lon (np.ndarray) – Array of longitude points in polygon.
lat (np.ndarray) – Array of latitude points in polygon.
edgecolor (str, optional) – Color of polygon boundary. Set to None for no boundary.
linestyle (str, optional) – Line style for boundary.
facecolor (str, optional) – Color of polygon face. Set to None for no fill color.
**kwargs (dict, optional) – Additional keywords passed to plot.
- draw_polygon_file(filename, reverse=True, edgecolor='red', linestyle='solid', **kwargs)[source]
Draw a text file containing lon, lat coordinates of polygon(s).
- Parameters:
filename (str) – Name of file containing the polygon(s) [lon, lat, poly]
reverse (bool) – Reverse drawing order of points in each polygon.
edgecolor (str) – Color of polygon boundary.
linestyle (str, optional) – Line style for boundary.
**kwargs (dict) – Additional keywords passed to plot.
- get_extent()[source]
Get the extent in lon/lat coordinates.
- Returns:
extent – Extent as [lon_min, lon_max, lat_min, lat_max].
- Return type:
list
- proj(lon, lat)[source]
Apply forward projection to a set of lon/lat positions.
Convert from lon/lat to x/y.
- Parameters:
lon (float or list or np.ndarray) – Array of longitude(s) (degrees).
lat (float or list or np.ndarray) – Array of latitudes(s) (degrees).
- Returns:
x (np.ndarray) – Array of x values.
y (np.ndarray) – Array of y values.
- proj_inverse(x, y)[source]
Apply inverse projection to a set of points.
Convert from x/y to lon/lat.
- Parameters:
x (float or list or np.ndarray) – Projected x values.
y (float or list or np.ndarray) – Projected y values.
- Returns:
lon (np.ndarray) – Array of longitudes (degrees).
lat (np.ndarray) – Array of latitudes (degrees).
- set_autorescale(autorescale)[source]
Set automatic rescaling after zoom.
- Parameters:
autorescale (bool) – Automatically rescale after zoom?
- set_extent(extent)[source]
Set the extent.
Axes will be properly inverted if Skyproj was initialized with
celestial=True
.- Parameters:
extent (array-like) – Extent as [lon_min, lon_max, lat_min, lat_max].
- set_xlabel(text, side='bottom', **kwargs)[source]
Set the label on the x axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
bottom
ortop
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- set_ylabel(text, side='left', **kwargs)[source]
Set the label on the y axis.
- Parameters:
text (str) – x label string.
side (str, optional) – Side to set the label. Can be
left
orright
.**kwargs (dict) – Additional keyword arguments accepted by ax.set_xlabel().
- tissot_indicatrices(radius=5.0, num_lon=9, num_lat=5, color='red', alpha=0.5)[source]
Draw Tissot indicatrices.
See https://en.wikipedia.org/wiki/Tissot%27s_indicatrix for details.
- Parameters:
radius (float) – Radius of each indicatrix circle.
num_lon (int) – Number of indicatrices in the longitude direction.
num_lat (int) – Number of indicatrices in the latitude direction.
color (str, optional) – Color of indicatrices.
alpha (float, optional) – Alpha of indicatrices.
SkyAxes
An Axes object encapsulates all the elements of an individual (sub-)plot in a figure.
It contains most of the (sub-)plot elements: ~.axis.Axis, ~.axis.Tick, ~.lines.Line2D, ~.text.Text, ~.patches.Polygon, etc., and sets the coordinate system.
Like all visible elements in a figure, Axes is an .Artist subclass.
The Axes instance supports callbacks through a callbacks attribute which is a ~.cbook.CallbackRegistry instance. The events you can connect to are ‘xlim_changed’ and ‘ylim_changed’ and the callback will be called with func(ax) where ax is the Axes instance.
Note
As a user, you do not instantiate Axes directly, but use Axes creation methods instead; e.g. from .pyplot or .Figure: ~.pyplot.subplots, ~.pyplot.subplot_mosaic or .Figure.add_axes.
- skyproj.SkyAxes.dataLim
The bounding box enclosing all data displayed in the Axes.
- Type:
.Bbox
- skyproj.SkyAxes.viewLim
The view limits in data coordinates.
- Type:
.Bbox
SkyCRS
Coordinate Reference System (CRS) class describing sky projections.
This is a specialized subclass of a pyproj.CRS Coordinate Reference System object. Unlike a general earth-based CRS it uses a fixed reference radius instead of a generalized ellipsoidal model. And it has additional routines used by SkyProj.
- param name:
Name of projection CRS type.
- type name:
str, optional
- param radius:
Radius of projected sphere.
- type radius:
float, optional
- param **kwargs:
Additional kwargs for PROJ4 parameters.
- type **kwargs:
dict, optional