Notebook Display#
This notebook demonstrates the html display of Nominals core objects when used with Jupyter notebook, VS Code, or Colab.
A ficticous dataset of a helicopter spin up test is used for demonstration.
The example needs the installed Nominal Python client and a default profile.
Generate Sample Data#
This examples demonstrate the typical lifecycle of piece of test equipment, called an asset. Let’s imagine, for example, that we fire up the rotor of a helicopter to measure its angular velocity.
The test records three minutes of data at 10 Hz: the rotor spins up, holds near 31 rad/s (about 300 rpm), and spins down. Telemetry and vibration go in separate tables:
Each table becomes a dataset on the rig, under its own data scope:
Each phase of the test becomes a run on the rig, and the gearbox overheating late in the hold becomes an event:
Create the Nominal Client#
A NominalClient provides the link to the Nominal Platform.
from nominal.core import NominalClient
client = NominalClient.from_profile("default")
rig = client.search_assets(
properties={"rig_id": "RTR-02", "example": "notebook_display"}
)[0]
An asset#
The rig’s Asset card lists its properties, its datasets, by data scope,
and its runs, newest first. Each section starts folded; click its title to open it.
Each name links to its page in Nominal, and its copy button copies its RID.
Open in Nominal opens the asset’s own page:
rig
Relationship diagrams#
The card above has a Relationships section, after the properties, with a diagram of the rig and the resources around it, drawn like the diagrams in Per-asset organization. Data flows from the bottom up: each dataset feeds the rig under its data scope’s ref name, and the rig’s runs sit above it. The rig’s own node has the thicker border. Each node links to its page in Nominal, and hovering over a node shows its full name.
Run, dataset, workbook, event and data review cards draw diagrams too. A diagram uses only what its card already loads, so it makes no requests of its own, and it needs no JavaScript, so it also displays in untrusted and saved notebooks.
An asset with hundreds of runs would make a diagram too large to read, so a diagram draws at most
graph_max_nodes nodes, 20 by default. Past that, each group shows its first few nodes and a
node counting the rest. That node links to the section of the card that lists them all.
The card’s own node and one node of each group always show, so a cap smaller than that is exceeded.
For example, with room for five nodes, the rig’s diagram draws one run and counts the other two.
Here collapse_threshold=10 also opens the sections with up to 10 items, so the diagram shows open:
from IPython.display import display
from nominal.core import set_display_options
with set_display_options(graph_max_nodes=5, collapse_threshold=10):
display(rig)
show_graph=False leaves diagrams out of the cards.
Configuring the display#
set_display_options changes how every card looks,
from that cell on, and get_display_options returns the current settings as DisplayOptions:
from nominal.core import get_display_options, set_display_options
get_display_options()
Timestamps show to the second by default. Hover over one to see it to the nanosecond. For example, show timestamps in the test site’s time zone, to the millisecond, in a more readable format:
set_display_options(
timezone="America/Denver", time_precision="ms", time_format="readable"
)
rig
Called on its own like this, a change lasts until the kernel restarts.
To use the same options in every notebook, put the call in an
IPython startup file,
such as ~/.ipython/profile_default/startup/nominal.py.
Each card loads its related resources from Nominal, with a few requests, and waits at most
fetch_timeout seconds, 5 by default, for them. A section that hasn’t loaded by then says so.
To display cards faster, or offline, fetch_details=False shows only the fields
the resource already holds.
Used in a with block, the change lasts only until the block ends:
from IPython.display import display
with set_display_options(fetch_details=False):
display(rig)
style="text" shows the plain text form instead of cards:
with set_display_options(style="text"):
display(rig)
A dataset#
A Dataset card shows the time span of its data and lists its files and channels:
telemetry = rig.get_dataset("telemetry")
telemetry
A channel#
A numeric Channel card summarizes its data: the number of samples, the minimum,
maximum and mean, the first and last timestamps, and a chart of its range and mean over time:
telemetry.get_channel("gearbox_temp")
A run#
A Run card shows its number, time span and duration, and lists its assets, datasets and links:
hold = next(
run
for run in rig.list_runs()
if run.name == "RTR-02 Hold at 300 rpm" and not run.is_archived
)
hold
Files and events#
Other resources have cards too, such as a dataset’s files (DatasetFile)
and an asset’s events (Event):
rig.search_events()[0]