BaseWWTWidget¶
- class pywwt.core.BaseWWTWidget(**kwargs: Any)[source]¶
Bases:
HasTraits
A class that can control a WWT viewer from Python.
You should not create instances of this class directly. Instead, you should obtain obtain an instance through one of the following mechanisms, depending on the environment in which you’re running Python and WWT:
In JupyterLab (the recommended approach), use
pywwt.jupyter.connect_to_app()
. This requires that you have set up the WWT JupyterLab extension.In plain Jupyter, or if you want to use WWT in its widget mode, create an instance of
pywwt.jupyter.WWTJupyterWidget
. This requires that you have set up the pywwt Jupyter widget.If using Qt, create an instance of
pywwt.qt.WWTQtClient
.If you want to control the WWT Windows application, see the
pywwt.windows
module.
Attributes:
If you modify most of the attributes listed below, your changes will automatically be reflected in the WWT view. However, there are a few special attributes that collect important pieces of WWT functionality:
layers
(pywwt.layers.LayerManager
) allows you to add new data layers to the view.solar_system
(pywwt.solar_system.SolarSystem
) provides controls related to WWT’s 3D “solar system” mode (which can display much more than just the solar system!)
The following attributes collect information about data and modes that are available in the connected WWT viewer:
available_layers
(list ofstr
) lists available image sets in a flat arrayavailable_views
(list ofstr
) lists available view modes ("solar system"
,"jupiter"
, etc.) in a flat arrayimagery
(pywwt.imagery.ImageryLayers
) lists available imageryinstruments
(pywwt.instruments.Instruments
) lists available instrument FOVs
Attributes Summary
Whether to show planets to scale or as points with a fixed size (
bool
)Whether to show an altitude-azimuth grid (
bool
)Whether to show labels for the altitude-azimuth grid's text (
bool
)A list of the names of HiPS catalog layers that are currently available in the viewer.
A list of the layers that are currently available in the viewer.
A list of the modes that are currently available in the viewer.
The layer to show in the background (
str
)Whether to show boundaries for the selected constellations (
bool
)Whether to show the constellations (
bool
)Whether to show labels for constellations (
bool
)Whether to show pictures of the constellations' mythological representations (
bool
)Whether to only show boundaries for the selected constellation (
bool
)Whether to show crosshairs at the center of the field (
bool
)The current rendering mode of the engine
Whether to show the path of the ecliptic (
bool
)Whether to show a grid relative to the ecliptic plane (
bool
)Whether to show labels for the ecliptic grid (
bool
)The layer to show in the foreground (
str
)The opacity of the foreground layer (
float
)Whether to show a grid relative to the galactic plane (
bool
)Whether the galactic plane should be horizontal in the viewer (
bool
)Whether to show labels for the galactic grid's text (
bool
)Whether to show the equatorial grid (
bool
)Whether to show labels for the equatorial grid (
bool
)Access to the engine's available imagesets
A list of instruments available for use in
add_fov
.Access to the active rendering layers
Whether the view should be that of a local latitude, longitude, and altitude (
bool
)The altitude of the viewing location in local horizon mode (
Quantity
)The latitude of the viewing location in local horizon mode (
Quantity
)The longitude of the viewing location in local horizon mode (
Quantity
)The most recent source selected in the viewer, represented as a dictionary.
Whether to show the precession chart (
bool
)A list of the selected sources, with each source represented as a dictionary.
Access to solar-system settings and data
Methods Summary
add_circle
([center])Add a circle annotation to the current view.
add_collection
(points, **kwargs)Add a CircleCollection to the current view.
add_fov
(telescope[, center, rotate])Add a telescope's field of view (FOV) to the current view.
add_line
([points])Add a line annotation to the current view.
add_polygon
([points])Add a polygon annotation to the current view.
becomes_ready
([timeout])An async function that finishes when the WWT app becomes ready.
center_on_coordinates
(coord[, fov, roll, ...])Center the view on a particular object or point in the sky.
Clears all annotations from the current view.
Return the view's current right ascension and declination in degrees.
Return the viewer's current time as an
Time
object.get_fov
()Return the view's current field of view in degrees.
get_roll
()Return the view's roll angle in degrees.
load_image_collection
(url[, recursive, ...])Load a collection of layers for possible use in the viewer.
load_tour
(url)Load and begin playing a tour based on the URL to a .wtt file from the WorldWideTelescope website.
Pause the progression of time in the viewer.
Pause a loaded tour.
play_time
([rate])Resume the progression of time in the viewer.
reset
()Reset WWT to initial state.
Reset the current view mode's coordinates and field of view to their original states.
Resume a paused tour.
save_as_html_bundle
(dest[, title, ...])Save the current view as a web page with supporting files.
set_current_time
([dt])Set WWT's internal clock.
set_selection_change_callback
(callback)Set a callback function that will be executed when the widget receives a selection change message.
set_view
(mode)Change the view mode.
Attributes Documentation
- available_hips_catalog_names¶
A list of the names of HiPS catalog layers that are currently available in the viewer.
- available_layers¶
A list of the layers that are currently available in the viewer.
- available_views¶
A list of the modes that are currently available in the viewer.
- constellation_pictures¶
Whether to show pictures of the constellations’ mythological representations (
bool
)
- current_mode = None¶
The current rendering mode of the engine
- imagery = None¶
Access to the engine’s available imagesets
- layers = None¶
Access to the active rendering layers
- local_horizon_mode¶
Whether the view should be that of a local latitude, longitude, and altitude (
bool
)
- most_recent_source¶
The most recent source selected in the viewer, represented as a dictionary. The items of this dictionary match the entries of the Source object detailed here.
- selected_sources¶
A list of the selected sources, with each source represented as a dictionary. The items of these dictionaries match the entries of the Source object detailed here.
- solar_system = None¶
Access to solar-system settings and data
Methods Documentation
- add_circle(center=None, **kwargs)[source]¶
Add a circle annotation to the current view.
- Parameters:
- center
Quantity
, optional The coordinates of desired center of the circle. If blank, defaults to the center of the current view.
- kwargs
Optional arguments that allow corresponding Circle or Annotation attributes to be set upon shape initialization.
- center
- add_collection(points, **kwargs)[source]¶
Add a CircleCollection to the current view.
- Parameters:
- points
Quantity
The desired points that will serve as the centers of the circles that make up the collection. Requires at least two sets of coordinates for initialization.
- kwargs
Optional arguments that allow corresponding Circle or Annotation attributes to be set upon shape initialization.
- points
- add_fov(telescope, center=None, rotate=<Quantity 0. rad>, **kwargs)[source]¶
Add a telescope’s field of view (FOV) to the current view.
- Parameters:
- telescope
str
The telescope whose field of view will be displayed. Be sure to use the
instruments
attribute to see and select from the preset list of instruments available in pyWWT.- center
Quantity
, optional The coordinates of desired center of the FOV. If blank, defaults to the center of the current view.
- rotate
Quantity
, optional The amount to rotate the FOV. Both radians and degrees are accepted. If blank, defaults to 0 radians (no rotation).
- kwargs
Optional arguments that allow corresponding Polygon or Annotation attributes to be set upon shape initialization.
- telescope
- add_line(points=None, **kwargs)[source]¶
Add a line annotation to the current view.
- Parameters:
- points
Quantity
, optional The desired points that make up the line. If blank or just one point, the annotation will be initialized but will not be visible until more points are added.
- kwargs
Optional arguments that allow corresponding Line or Annotation attributes to be set upon shape initialization.
- points
- add_polygon(points=None, **kwargs)[source]¶
Add a polygon annotation to the current view.
- Parameters:
- points
Quantity
, optional The desired points that make up the polygon. If blank or just one point, the annotation will be initialized but will not be visible until more points are added. Note that the points should be specified in counter-clockwise order on the sky if you intend to fill the polygon.
- kwargs
Optional arguments that allow corresponding Polygon or Annotation attributes to be set upon shape initialization.
- points
- async becomes_ready(timeout=30)[source]¶
An async function that finishes when the WWT app becomes ready.
- Returns:
- self
Notes
The web browser running WWT needs to initialize the application and download some initial data files, which can take an indeterminate amount of time. This async function will complete once the WWT app has initialized and is ready to respond to control messages from pywwt. After this has happened the first time, this function will complete instantly.
- center_on_coordinates(coord, fov=<Quantity 60. deg>, roll=None, instant=True)[source]¶
Center the view on a particular object or point in the sky.
- Parameters:
- coord
Quantity
The set of coordinates the view should center on.
- fov
Quantity
, optional The desired field of view.
- roll: `~astropy.units.Quantity`, optional
The desired roll angle of the camera. If not specified, the roll angle is not changed.
- instant
bool
, optional Whether the view changes instantly or smoothly scrolls to the desired location.
- coord
- load_image_collection(url, recursive=False, remote_only=False)[source]¶
Load a collection of layers for possible use in the viewer.
- Parameters:
- url
str
The URL of the desired image collection.
- recursiveoptional
bool
If true, will also load any child folders referenced in the specified WTML file. The default behavior is only to load the single file and not recurse into subfolders. Recursive loading can potentially be very time-consuming.
- remote_onlyoptional
bool
ADASS hack! If true, will only send the load request to the app, and not attempt to open the URL locally.
- url
Notes
The request to load the image collection must be relayed to the WWT JavaScript code, which will then issue a web request and process the response that it gets. Therefore, you can’t rely on this function to take immediate effect; to use an image in a collection that you’ve loaded, you’ll need to pause and give WWT time to receive and process your request.
- load_tour(url)[source]¶
Load and begin playing a tour based on the URL to a .wtt file from the WorldWideTelescope website.
- Parameters:
- url
str
The URL of the chosen tour – must be a .wtt file.
- url
- play_time(rate=1)[source]¶
Resume the progression of time in the viewer.
- Parameters:
- rateint or float
The rate at which time passes (1 meaning real-time)
- reset_view()[source]¶
Reset the current view mode’s coordinates and field of view to their original states.
- save_as_html_bundle(dest, title=None, max_width=None, max_height=None)[source]¶
Save the current view as a web page with supporting files.
This feature is currently under development, so not all settings/features that can be set in pyWWT will be saved
- Parameters:
- dest
str
The path to output the bundle to. The path must represent a directory (which will be created if it does not exist) or a zip file.
- title
str
, optional The desired title for the HTML page. If blank, a generic title will be used.
- max_width
int
, optional The maximum width of the WWT viewport on the exported HTML page in pixels. If left blank, the WWT viewport will fill the enitre width of the browser.
- max_height
int
, optional The maximum height of the WWT viewport on the exported HTML page in pixels. If left blank, the WWT viewport will fill the enitre height of the browser.
- dest
- set_current_time(dt=None)[source]¶
Set WWT’s internal clock.
- Parameters:
- dt
datetime
orTime
A time, either as a
datetime.datetime
object or an astropyastropy.time.Time
object. If not specified, this uses the current time.
- dt
Notes
If you call this function and then immediately call
get_current_time()
, the results will not necessarily agree. This is because this function has to send a command to WWT to tell it to update its internal clock, and in some environments this operation is not instantaneous.
- set_selection_change_callback(callback)[source]¶
Set a callback function that will be executed when the widget receives a selection change message.
- Parameters:
- callback:
A callable object which takes two arguments: the WWT widget instance, and a list of updated properties.
- set_view(mode)[source]¶
Change the view mode.
Valid options include the default sky mode, a 3D universe mode with different viewing levels (the solar system, the Milky Way, and the observed universe), individual views of major solar system objects, and panoramas from lunar missions and NASA’s Mars rovers.
To find the list of available views, use the
available_views
.- Parameters:
- mode
str
The desired view mode. (default: ‘sky’)
- mode