hscmap.window module¶
- class hscmap.window.Window(*, title=None, layout=None, angle_unit='degree', comm_options=None)[source]¶
Bases:
object
The main class of the hscmap library. This class represents a viewer window. You can manipulate the window and its contents by this object.
This class is exported as a top-level object of the hscmap module.
import hscmap window = hscmap.Window(title='My Window') M31_position = (10.68470833, 41.26916667) window.jump_to(*M31_position, fov=2)
- Parameters:
layout (Literal['merge-bottom', 'merge-left', 'merge-right', 'merge-top', 'split-bottom', 'split-left', 'split-right', 'split-top', 'tab-after', 'tab-before'] | None) – The layout of the window. (JupyterLab only)
title (str | None) – The title of the window.
angle_unit (Literal['degree', 'radian']) – The unit of the angle. ‘degree’ or ‘radian’.
comm_options (Any | None) – Passed to the comm implementation.
- reopen(*, layout=None)[source]¶
Reopen the window when it is closed.
- Parameters:
layout (Literal['merge-bottom', 'merge-left', 'merge-right', 'merge-top', 'split-bottom', 'split-left', 'split-right', 'split-top', 'tab-after', 'tab-before'] | None) –
- Return type:
None
- property camera: Camera¶
The camera of the window. You can manipulate the display area of the window by this object.
- property regions: RegionManager¶
The region manager of the window. You can add, remove, and manipulate regions by this object.
- property catalogs: CatalogManager¶
The catalog manager of the window. You can add, remove, and manipulate catalogs by this object.
- property dataset: DatasetManager¶
An object that manages datasets. You can add, remove, and manipulate datasets using this object. You also use this object to manipulate HiPS data.
- property watchers: WatcherManager¶
The watcher manager of the window. You can register callback functions to be called when the watched value changes.
- property title: str¶
The title of the window.
window.title = 'My Window' print(window.title)
- jump_to(ra, dec, *, fov=None, duration=0.2, non_block=False, easing=None)[source]¶
Shortcut for
hscmap.camera.Camera.jump_to()
.- Parameters:
ra (float) –
dec (float) –
fov (float | None) –
easing (Literal['fastStart2', 'fastStart4', 'linear', 'slowStart2', 'slowStart4', 'slowStartStop2', 'slowStartStop4'] | None) –
- Return type:
None
- lock(*windows)[source]¶
Lock cameras of 2 or more windows to synchronize their display areas.
w1 = hscmap.Window(title='Window 1') w2 = hscmap.Window(title='Window 2') unlock = w1.lock(w2) # Do some operations on the windows unlock() # Unlock the frame
- Parameters:
windows (Window) –
- Return type:
Callable[[], None]
- snapshot_bytes(*, aspect_ratio=None)[source]¶
Take a snapshot of the window and return the image as bytes in PNG format.
image_bytes = window.snapshot_bytes() with open('snapshot.png', 'wb') as f: f.write(image_bytes)
- Parameters:
aspect_ratio (float | None) –
- Return type:
bytes
- snapshot_image(*, aspect_ratio=None)[source]¶
Take a snapshot of the window and return the image as an IPython Image object. This is useful when you are using Jupyter Notebook or JupyterLab.
window.snapshot_image() # Show the snapshot in the notebook
- Parameters:
aspect_ratio (float | None) –
- watch(*, watch_on, on_change)[source]¶
Shortcut for
hscmap.watcher.WatcherManager.new()
.- Parameters:
watch_on (Callable) –
on_change (Callable) –
- Return type:
- sync(*, force=False, full=False)[source]¶
Synchronize the state of the window with the frontend. You don’t need to call this method in most cases because the state is automatically synchronized when you call a method that changes the state.
- Parameters:
force – If True, the state is synchronized even if it is already synchronized.
full – If True, the full state is synchronized. If False, only the changes are synchronized.
- Return type:
None