Getting Started

The widgyts package is designed to work with yt, but it can also work without a yt import.

Components of widgyts

Presently widgyts has three widgets that a user can interact with: ImageCanvas, FRBViewer, and ColorMaps. Each widget has a number of traitlets that sync back to the javascript (and potentially webassembly) that can be updated through the widget API. These traitlets can be linked (see our Examples for some demonstrations of this in practice) so that widget instances can update together.

API Documentation

class widgyts.ImageCanvas(**kwargs)

An example widget.

class widgyts.FRBViewer(**kwargs)

View of a fixed resolution buffer.

FRBViewer(width, height, px, py, pdx, pdy, val)

This widget creates a view of a fixed resolution buffer of size (width, height) given data variables px, py, pdx, pdy, and val. Updates on the view of the fixed reolution buffer can be made by modifying traitlets view_center, view_width, or Colormaps

width : integer
The width of the fixed resolution buffer output, in pixels
height : integer
The height of the fixed resolution buffer, in pixels
px : array of floats
x coordinates for the center of each grid box
py : array of floats
y coordinates for the center of each grid box
pdx : array of floats
Values of the half-widths for each grid box
pdy : array of floats
Values of the half-heights for each grid box
val : array of floats
Data values for each grid box The data values to be visualized in the fixed resolution buffer.
colormaps : :class: widgyts.Colormaps
This is the widgyt that controls traitlets associated with the colormap.
view_center : tuple
This is a length two tuple that represents the normalized center of the resulting FRBView.
view_width : tuple
This is a length two tuple that represents the height and with of the view, normalized to the original size of the image. (0.5, 0.5) represents a view of half the total data with and half the total data height.

To create a fixed resolution buffer view of a density field with this widget, and then to display it:

>>> ds = yt.load("IsolatedGalaxy")
>>> proj = ds.proj("density", "z")
>>> frb1 = widgyts.FRBViewer(height=512, width=512, px=proj["px"],
...                          py=proj["py"], pdx=proj["pdx"],
...                          pdy=proj["pdy"], val = proj["density"])
>>> display(frb1)
widgyts.display_yt(data_object, field)
class widgyts.ColorMaps(*args, **kwargs)

Colormapping widget used to collect available colormaps


The example notebooks illustrate different functionality of the widgyts package. Each is intended to show how widgyts can be used for your own workflow.

  • galaxy_display.ipynb shows the monkeypatching feature between yt and widgyts to enable you to do interactive visualization directly on any yt dataset.
  • FRBViewer_tutorial.ipynb shows using the FRBViewer module of widgyts in conjunction with yt’s data manipulation features. It illustrates some traitlet manipulation in the Colormaps module as well as traitlet linking between views of different fields.