Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds TiledBrowserWidget.py #56

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions AFL/automation/shared/DataLabelerWidget.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List
from typing import List, Optional

import ipywidgets # type: ignore
import numpy as np
Expand All @@ -16,6 +16,7 @@ def __init__(
sas_variable: str,
composition_variable: str | List[str],
sample_dim: str = "sample",
fit_variable: Optional[str] = None,
):
"""

Expand All @@ -34,6 +35,10 @@ def __init__(
sample_dim: str
The name of the `xarray` dimension corresponding to each sample or measurement. This is typically named
'sample' in much of the AFL agent codebase.

fit_variable: Optional[str]
If not none, this data will be plotted along with the sas_variable data. This data variable should have the
same shape as sas_variable.
"""

# preprocess the dataset before sending to the data model
Expand All @@ -50,6 +55,9 @@ def __init__(
sample_dim, ...
)

if fit_variable is not None:
dataset['fit'] = input_dataset[fit_variable].transpose(sample_dim,...)

self.data_view = DataLabelerView()
self.data_model = DataLabelerModel(dataset)
self.data_index = 0
Expand Down Expand Up @@ -525,7 +533,7 @@ def update_composition_colors(self, colors):

def run(self, x, y, all_compositions, composition, models, ternary, components):
self.ternary = ternary
self.fig1 = go.FigureWidget(go.Scatter(x=x, y=y, mode='markers'))
self.fig1 = go.FigureWidget(go.Scatter(x=x, y=y, mode="markers"))
self.intensity = self.fig1.data[0]
self.fig1.update_yaxes(type="log")
self.fig1.update_xaxes(type="log")
Expand Down Expand Up @@ -616,7 +624,9 @@ def run(self, x, y, all_compositions, composition, models, ternary, components):
self.bprev = ipywidgets.Button(description="Prev")
self.bnext = ipywidgets.Button(description="Next")
self.bgoto = ipywidgets.Button(description="GoTo")
self.current_index = ipywidgets.IntText(description="Data Index:", value=0, min=0)
self.current_index = ipywidgets.IntText(
description="Data Index:", value=0, min=0
)

self.n_orders = ipywidgets.BoundedIntText(
description="n_orders", min=1, max=8, value=4
Expand Down
Loading