API¶
Base classes for sky maps made using bokeh.
- class uranography.spheremap.SphereMap(plot=None, mjd=None, location='Cerro Pachon')[source]¶
Bases:
object
Base for maps of the sphere.
- Parameters:
plot (
bokeh.plotting._figure.figure
, optional) – Figure to which to add the map, by default Nonemjd (
float
, optional) – The Modified Julian Datelocation (
EarthLocation
orstr
, optional) – The location of the observatory, defaults to lsst.
- add_circle(center_ra, center_decl, circle_kwargs=None, line_kwargs=None)[source]¶
Draw a circle on the map.
- Parameters:
center_ra (
float
) – R.A. of the center of the circle (deg.)center_decl (
float
) – Decl. of the center of the circle (deg.)circle_kwargs (dict, optional) – Keywords to be passed to
SphereMap.make_circle_points
, by default {}line_kwargs (dict, optional) – Keywords to be passed to
bokeh.plotting.figure.line
, by default {}
- Returns:
circle_points – The bokeh data source with points defining the circle.
- Return type:
bokeh.models.ColumnDataSource
- add_ecliptic(**kwargs)[source]¶
Map the ecliptic.
- Returns:
points – The bokeh data source with points on the ecliptic.
- Return type:
bokeh.models.ColumnDataSource
- add_galactic_plane(**kwargs)[source]¶
Map the galactic plane
- Returns:
points – The bokeh data source with points on the galactic plane.
- Return type:
bokeh.models.ColumnDataSource
- add_graticules(graticule_kwargs=None, line_kwargs=None)[source]¶
Add graticules to the map
- Parameters:
graticule_kwargs (dict, optional) – Keywords to be passed to
SphereMap.make_graticule_points
, by default {}line_kwargs (dict, optional) – Keywords to be passed to
bokeh.plotting.figure.line
, by default {}
- Returns:
graticules – The bokeh data source with points defining the graticules.
- Return type:
`
bokeh.models.ColumnDataSource
- add_healpix(data, cmap=None, nside=16, bound_step=1, ds_name='hpix_ds', name='hpix_renderer')[source]¶
Add healpix values to the map
- Parameters:
data (
numpy.ndarray
) – Healpixel values (RING pixel ordering)cmap (
dict
, optional) –With the following keys:
"field"
The field to map to color (
str
)"transform"
The transform from value to color (
bokeh.models.mappers.ColorMapper
)
by default None
nside (
int
, optional) – Healpix nside to use for display, by default 16bound_step (
int
, optional) – number of boundary points for each side of each healpixel, by default 1ds_name (
str
, optional) – The bokeh name for the data source, defaults to hpix_ds.name (
str
, optional) – The bokeh name for the bokeh glyph, defaults ho hpix_glyph.
- Returns:
data_sounce (
bokeh.models.ColumnDataSource
) – The data source with the healpix values and bounds.cmap (
dict
) – With the following keys:"field"
The field to map to color (
str
)"transform"
The transform from value to color (
bokeh.models.mappers.ColorMapper
)
hp_glyph (
bokeh.models.glyphs.Patches
) – The bokeh glyphs for the plotted patches.
- add_horizon(zd=np.float64(89.99999999999989), data_source=None, circle_kwargs=None, line_kwargs=None)[source]¶
Add a circle parallel to the horizon.
- Parameters:
zd (int, optional) – Zenith distance of the circle (deg), by default (almost) 90
data_source (
bokeh.models.ColumnDataSource
, optional) – Bokeh data source for points on the circle, None if the should be generated. By default, Nonecircle_kwargs (dict, optional) – Keywords to be passed to
SphereMap.make_circle_points
, by default {}line_kwargs (dict, optional) – Keywords to be passed to
bokeh.plotting.figure.line
, by default {}
- Returns:
circle_points – The bokeh data source with points defining the circle.
- Return type:
bokeh.models.ColumnDataSource
- add_horizon_graticules(graticule_kwargs=None, line_kwargs=None)[source]¶
Add graticules to the map
- Parameters:
graticule_kwargs (dict, optional) – Keywords to be passed to
SphereMap.make_graticule_points
, by default {}line_kwargs (dict, optional) – Keywords to be passed to
bokeh.plotting.figure.line
, by default {}
- Returns:
graticules – The bokeh data source with points defining the graticules.
- Return type:
`
bokeh.models.ColumnDataSource
- add_hp_hovertool(coordinates=True, value='Value', ds_name='hpix_ds', renderer_name='hpix_renderer', extra_data=None, name='hpix_hovertool')[source]¶
Add a hovertool to an existing healpix map
- Parameters:
coordinates (
bool
, optional) – Show the coordinates in the hovertool, by default Truevalue (
str
, optional) – Label for the healpix value in the hovertool, by default “Value”ds_name (
str
, optional) – Bokeh data source name for the healpix map, by default “hpix_ds” (which is the default for add_healpix)renderer_name (
str
, optional) – Bokeh data source name for the healpix renderer, by default “hpix_renderer”, (which is the default for add_healpix).extra_data (
dict
, optional) – A dictionary of healpix arrays with additional values to be included in the hoverplot. The keys will be the labels for those values. By default None (for no extra data).name (
str
, optional) – The bokeh name for the hovertool, by default “hpix_hovertool”
- Returns:
hovertool – The new hovertool instance.
- Return type:
bokeh.models.Hovertool
- add_marker(ra=None, decl=None, name='anonymous', glyph_size=5, min_mjd=None, max_mjd=None, data_source=None, circle_kwargs=None)[source]¶
Add one or more circular marker(s) to the map.
- Parameters:
ra (
float
orIterable
, optional) – R.A. of the marker (deg.), by default Nonedecl (
float
orIterable
, optional) – Declination of the marker (deg.), by default Nonename (
str
orIterable
, optional) – Name for the thing marked, by default “anonymous”glyph_size (
int
orIterable
, optional) – Size of the marker, by default 5min_mjd (
float
orIterable
, optional) – Earliest time for which to show the marker.max_mjd (
float
orIterable
, optional) – Latest time for which to show the marker.data_source (
bokeh.models.ColumnDataSource
, optional) – Data source for the marker, None if a new one is to be generated. By default, Nonecircle_kwargs (dict, optional) – Keywords to be passed to
bokeh.plotting.figure.circle
, by default {}
- Returns:
data_source – A data source with marker locations, including projected coords.
- Return type:
bokeh.models.ColumnDataSource
- add_stars(points_data=None, data_source=None, mag_limit_slider=False, star_kwargs=None)[source]¶
Add stars to the map
- Parameters:
points_data (
Iterable
,dict
, orpandas.DataFrame
) –A source of data (anything that can be passed to
pandas.DataFrame
) Must contain the following columns or keys:"ra"
The Right Ascension in degrees.
"decl"
The declination in degrees.
data_source (
bokeh.models.ColumnDataSource
, optional) – The bokeh data source to use (None to generate a new one). By default, None.mag_limit_slider (
bool
, optional) – Generate a slider limiting the magnitude of stars to plot, by default Falsestar_kwargs (
dict
, optional) – _description_, by default {}
- Returns:
data_source – The bokeh data source with points defining star locations.
- Return type:
bokeh.models.ColumnDataSource
- connect_controls(data_source)[source]¶
Connect map controls to a data source so it updates.
- Parameters:
data_source (
Bokeh.models.DataSource
) – A data source that needs to update automatically in response to changes to the map controls.
- eq_to_horizon(ra, decl, degrees=True, cart=True)[source]¶
Convert equatorial to horizon coordinates
- Parameters:
ra (
numpy.ndarray
) – Values for Right Ascensiondecl (
numpy.ndarray
) – Values for declinationdegrees (bool, optional) – Values are in degrees (if False, values are in radians), by default True
cart (bool, optional) – Return cartesion coordinates rather than alt, az, by default True
- Returns:
coords (
list
[np.ndarray
]) – Either alt, az (if cart=False) with az measured east of north, or x, y with +x pointing west and +y pointing northAzimuth is east of north
- property figure¶
Return the bokeh figure for the map.
- Returns:
figure – A viewable bokeh figure.
- Return type:
bokeh.models.layouts.LayoutDOM
- limit_stars(attr, old_limit, mag_limit)[source]¶
Apply a magnitude limit to mapped stars
- Parameters:
attr (
str
) – Attribute of the slider to use (ignored)old_limit (
float
) – Old value for the magnitude limit (ignored)mag_limit (
float
) – Now value for the magnitude limit
Note
This method is intended to be called as a callback by bokeh.
- property lst¶
Return the Local Sidereal Time.
- make_healpix_data_source(hpvalues, nside=32, bound_step=1, nest=False, name='hpix_ds')[source]¶
Make a data source of healpix values, corners, and projected coords.
- Parameters:
hpvalues (
numpy.ndarray
orhealsparse.HealSparseMap
) – Healpixel values (RING pixel ordering unless a HealSparseMap is provided.)nside (int, optional) – healpixel nside for display, by default 32
bound_step (int, optional) – number of boundary points for each side of each healpixel, by default 1
nest (
bool
, optionol) – Is the healpix array provided in NEST ordering? Defaults to False. (if hpvalues is a HealSparseMap, nest is always True)name (
str
, option) – The bokeh name for the data source model, defaults tohpix_ds
- Returns:
hpix_datasource – Data source for healpixel values and bounds.
- Return type:
bokeh.models.ColumnDataSource
- proj_transform(proj_coord, data_source=None, column_name=None)[source]¶
Return a bokeh projection transformer.
- Parameters:
proj_coord (
str
) – ‘x’ or ‘y’, the projection coodinate to computedata_source (
bokeh.models.ColumnDataSource
) – The data source to project. Must have either ‘ra’ and ‘decl’ columns, or ‘alt’ and ‘az’. All in degrees. Defaults to None, in which case the transform takes a column of ra, decl pairs.column_name (
str
) – The name of the column with ra, decl pairs. If None, columns with ‘ra’ and ‘decl’ or ‘alt’ and ‘az’ names instead. Defaults to None.
- Returns:
transform – With keys
field
andtransform
, suitable for passing to bokeh plotting functions.- Return type:
dict
- set_emit_update_func(data_source)[source]¶
Set a javascript update functions for each slider to do nothing
- Parameters:
data_source (
bokeh.models.ColumnDataSource
) – The bokeh data source to update.
- set_js_update_func(data_source)[source]¶
Set the javascript update functions for each slider
- Parameters:
data_source (
bokeh.models.ColumnDataSource
) – The bokeh data source to update.
- update(viewable=None)[source]¶
Trigger the javascript update callback.
- Parameters:
viewable (
panel.viewable.Viewable
) – If not None, push the notebook to the frontend set by the viewable. Defaults to self.viewable
- property update_js¶
Return javascript code to update the plots.
- Returns:
js_code – Javascript code to update the bokeh model.
- Return type:
str
- property viewable¶
A panel viewable that shows the figure.
Interactive sky map in a Mollweide projection.
- class uranography.mollweide.MollweideMap(plot=None, mjd=None, location='Cerro Pachon')[source]¶
Bases:
SphereMap
Mollweide projection of the sky.
- Parameters:
plot (
bokeh.plotting.figure
, optional) – Figure to which to add the map, by default Nonemjd (
float
, optional) – The Modified Julian Datelocation (
EarthLocation
orstr
, optional) – The location of the observatory, defaults to lsst.
Interactive sky map in horizon (alt/az) coordinates.
- class uranography.horizon.HorizonMap(plot=None, mjd=None, location='Cerro Pachon')[source]¶
Bases:
MovingSphereMap
Horizon map of the sky, with zenith at center. Not equal area.
- Parameters:
plot (
bokeh.plotting.figure
, optional) – Figure to which to add the map, by default Nonemjd (
float
, optional) – The Modified Julian Datelocation (
EarthLocation
orstr
, optional) – The location of the observatory, defaults to lsst.
Interactive planisphere (Lambert Azimuthal Equal Area projection).
- class uranography.planisphere.Planisphere(plot=None, mjd=None, location='Cerro Pachon', laea_limit_mag=88.0)[source]¶
Bases:
SphereMap
Lambert azimuthal equal area projection of the sky, presented like a planisphere.
- Parameters:
plot (
bokeh.plotting.figure
, optional) – Figure to which to add the map, by default Nonemjd (
float
, optional) – The Modified Julian Datelocation (
EarthLocation
orstr
, optional) – The location of the observatory, defaults to lsst.
- property laea_limit¶
Return the lat. furthest from the center for the LAEA projection.
- Returns:
`limit` – The maximum (or minimum) value for the latitude shown in the Lambert Azimuthal Equal Area plot.
- Return type:
float
- property laea_rot¶
Return the
rot
tuple to be used in the Lambert EA projection- Returns:
rot – The
rot
tuple to be passed tohealpy.projector.AzimuthalProj
.- Return type:
tuple
[float
]
Interactive sky map that works like an armillary sphere.
- class uranography.armillary.ArmillarySphere(plot=None, mjd=None, location='Cerro Pachon')[source]¶
Bases:
MovingSphereMap
Orthographic projection of the sky, presented like an armillary sphere.
- Parameters:
plot (
bokeh.plotting.figure
, optional) – Figure to which to add the map, by default Nonemjd (
float
, optional) – The Modified Julian Datelocation (
EarthLocation
orstr
, optional) – The location of the observatory, defaults to lsst.
- set_js_update_func(data_source)[source]¶
Set the javascript update functions for each slider
- Parameters:
data_source (
bokeh.models.ColumnDataSource
) – The bokeh data source to update.
- to_orth_zenith(hpx, hpy, hpz)[source]¶
Convert healpy vector coordinates to orthographic coordinates
- Parameters:
hpx (
numpy.ndarray
) – Healpy vector x coordinates x=1, y=0, z=0 corresponds to R.A.=0 deg, Decl=0 deg. x=-1, y=0, z=0 corresponds to R.A.=180 deg, Decl=0 deg.hpy (
numpy.ndarray
) – Healpy vector y coordinates x=0, y=1, z=0 corresponds to R.A.=90 deg, Decl=0 deg. x=0, y=-1, z=0 corresponds to R.A.=270 deg, Decl=0 deg.hpz (
numpy.ndarray
) – Healpy vector z coordinates x=0, y=0, z=1 corresponds to Decl=90 deg. x=0, y=0, z=-1 corresponds to Decl=-90 deg.
- Returns:
x (
numpy.ndarray
) – Orthographic x coordinate (positive to the right)y (
numpy.ndarray
) – Orthographic y coordinate (positive up)z (
numpy.ndarray
) – Orthographic z coordinate (positive toward the viewer)
Tool for computing an outline of a camera footprint.
- class uranography.camera.CameraFootprintPerimeter(file_name)[source]¶
Compute outline of an exposure with a camera.
- __call__(ra, decl, rotation=0)[source]¶
Compute vertices for a single pair of equatorial coordinates
- Parameters:
ra (
np.ndarray
) – The R.A. of pointings (in degrees)decl (
np.ndarray
) – The declination of pointings (in degrees)rotation (
float
ornp.ndarray
) – The camera rotation(s) (in degrees)
- Returns:
ra (
numpy.ndarray
) – An array of the R.A. of the vertices of the polygon surrounding the camera footprints (degrees).decl (
numpy.ndarray
) – An array of the declinations of the vertices of the polygon surrounding the camera footprints (degrees).
- single_eq_vertices(ra, decl, rotation=0)[source]¶
Compute vertices for a single pair of equatorial coordinates
- Parameters:
ra (
float
) – The R.A. (in degrees)decl (
float
) – The declination (in degrees)rotation (
float
) – The camera rotation (in degrees)
- Returns:
ra (
numpy.ndarray
) – An array of the R.A. of the vertices of the polygon surrounding the camera footprint (degrees).decl (
numpy.ndarray
) – An array of the declinations of the vertices of the polygon surrounding the camera footprint (degrees).
Load the Yale Bright Star catalog into a pandas.DataFrame.