Exemplo n.º 1
0
def collapsable_card_ui(item, prefix, outer_collapse=False):
    eta_ui = custom_input_group(
        prepend_label="Asymmetry (η)",
        append_label="",
        id=f"{prefix}-eta",
        debounce=True,
        min=0.0,
        max=1.0,
    )

    labels = ["alpha (α)", "beta (β)", "gamma (γ)"]
    keys = ["alpha", "beta", "gamma"]
    euler_angles_ui = [
        custom_input_group(
            prepend_label=label_,
            append_label="deg",
            id=f"{prefix}-{key_}",
            debounce=True,
        ) for label_, key_ in zip(labels, keys)
    ]

    return collapsable_card(
        text=f"{prefix.replace('_',' ')}",
        id_=prefix,
        featured=[item, eta_ui],
        hidden=euler_angles_ui,
        message="Show/Hide Euler angles",
        outer=outer_collapse,
    )
Exemplo n.º 2
0
def global_environment():
    """Generate a list of widgets whose entries are the sample global environment
    parameter. The widgets includes flux density, rotor frequency, and rotor angle."""

    flux_density = custom_input_group(
        prepend_label="Magnetic flux density (B₀)",
        append_label="T",
        value=9.4,
        id="magnetic_flux_density",
        min=0.0,
        debounce=True,
    )

    # rotor frequency
    rotor_frequency = custom_input_group(
        prepend_label="Rotor frequency (𝜈ᵣ)",
        append_label="kHz",
        value=0.0,
        id="rotor_frequency",
        min=0.0,
        debounce=True,
    )

    # rotor angle
    magic_angle = custom_button(
        icon_classname="fas fa-magic",
        tooltip="Set value to the magic angle.",
        id="set-to-magic-angle",
        className="icon-button",
        module="html",
    )
    # dbc.Button(
    #     html.I(className="fas fa-magic"),
    #     color="light",
    #     id="set-to-magic-angle",
    #     size="sm",
    # )
    # datalist = html.Datalist([0, 54.7356103172, 90], id="datalist-magic-angle")
    rotor_angle = custom_input_group(
        prepend_label=html.Div(["Rotor angle (θᵣ)", magic_angle]),
        append_label="deg",
        value=54.7356103172,
        id="rotor_angle",
        max=90,
        min=0,
        debounce=True,
        # list="datalist-magic-angle",
    )

    app.clientside_callback(
        """function(n) { return 54.7356103172; }""",
        Output("rotor_angle", "value"),
        Input("set-to-magic-angle", "n_clicks"),
    )

    return container(
        text="Global Environment Parameters",
        featured=[flux_density, rotor_frequency, rotor_angle],
    )
Exemplo n.º 3
0
def isotope_and_shift_ui():
    def isotope_ui():
        """Isotope"""
        label = dbc.InputGroupAddon("Isotope", addon_type="prepend")
        select = dbc.Select(options=isotope_options_list,
                            value="1H",
                            id="isotope")

        # callback to hide the quadrupolar fields when isotope is I=1/2
        app.clientside_callback(
            """
            function (isotope) {
                hideQuad();
                throw window.dash_clientside.PreventUpdate;
            }
            """,
            Output("isotope", "value"),
            [Input("isotope", "value")],
        )

        return dbc.InputGroup([label, select], className="input-form")

    # isotropic chemical shift
    isotropic_chemical_shift_ui = custom_input_group(
        prepend_label="Isotropic chemical shift (δ)",
        append_label="ppm",
        id="isotropic_chemical_shift",
        debounce=True,
    )

    return html.Div(
        [isotope_ui(), isotropic_chemical_shift_ui],
        className="container scroll-cards",
    )
Exemplo n.º 4
0
def ui(index, data=None, **kwargs):
    scale = custom_input_group(
        prepend_label="Factor",
        value=1 if data is None else data["factor"],
        min=0,
        id={
            "function": "scale",
            "args": "factor",
            "index": index
        },
        debounce=True,
    )

    return container(
        text=[
            "Scale",
            custom_button(
                icon_classname="fas fa-times",
                id={
                    "type": "remove-post_sim-functions",
                    "index": index
                },
                className="icon-button",
                module="html",
                tooltip="Remove scaling module.",
            ),
        ],
        featured=scale,
    )
Exemplo n.º 5
0
def experiment_ui():

    # upload experiment dataset
    tooltip = (
        "Click to attach a measurement file to the selected method. "
        "Alternatively, drag and drop the file onto the Simulation area.")
    icon = html.I(className="fas fa-paperclip fa-lg", title=tooltip)
    clip_btn = html.Button(icon, className="icon-button")
    upload = dcc.Upload(clip_btn, id="import-measurement-for-method")

    # label = dbc.InputGroupAddon("Measurement data", addon_type="prepend")
    # upload_ui = dbc.InputGroup([label, upload], className="input-form")

    # standard deviation
    calc_tooltip = (
        "Click to calculate the noise standard deviation from the selected region of ∂"
        "the experiment spectrum.")
    calc_icon = html.I(className="fas fa-calculator", title=calc_tooltip)
    calc_btn = html.Button(calc_icon,
                           id="calc-sigma-button",
                           className="icon-button")
    sigma = custom_input_group(
        prepend_label=
        "Noise standard deviation (σ)",  # Text overwraps the input field
        append_label=calc_btn,
        value=1.0,
        min=1e-6,
        id="measurement-sigma",
        debounce=True,
    )

    return container(
        text=["Experiment", upload],
        featured=[sigma],
    )
Exemplo n.º 6
0
def supersampling():
    return custom_input_group(
        prepend_label="Supersampling",
        append_label="Hz",
        value=1,
        id="INV-supersampling",
        min=0,
        debounce=True,
    )
Exemplo n.º 7
0
def magnetic_flux_density():
    return custom_input_group(
        prepend_label="Magnetic flux density B₀)",
        append_label="T",
        value=9.4,
        id="INV-kernel-flux",
        min=0.0,
        debounce=True,
    )
Exemplo n.º 8
0
def dim_parameters(i, label):
    label = dbc.Label(label)
    count = custom_input_group(
        prepend_label="Count",
        append_label="",
        value=25,
        id=f"INV-dimension-{i}-count",
        min=0,
        debounce=True,
    )
    increment = custom_input_group(
        prepend_label="Increment",
        append_label="Hz",
        value=370,
        id=f"INV-dimension-{i}-increment",
        min=1e-9,
        debounce=True,
    )
    return dbc.Col([label, count, increment], md=6)
Exemplo n.º 9
0
def rotor_angle():
    return custom_input_group(
        prepend_label="Rotor angle (θᵣ)",
        append_label="deg",
        value=54.735,
        id="INV-kernel-rotor_angle",
        max=90,
        min=0,
        debounce=True,
    )
Exemplo n.º 10
0
 def arguments(index):
     return custom_input_group(
         prepend_label="FWHM",
         append_label="Hz",
         value=10 if data is None else data["FWHM"].split(" ")[0],
         min=0,
         id={"function": "apodization", "args": "FWHM", "index": index},
         debounce=True,
         pattern="[0-9]*",
     )
Exemplo n.º 11
0
def quadrupolar_ui():
    Cq_ui = custom_input_group(
        prepend_label="Coupling constant (Cq)",
        append_label="MHz",
        id="quadrupolar-Cq",
        debounce=True,
    )

    # asymmetry and Euler angles
    return collapsable_card_ui(Cq_ui, "quadrupolar", True)
Exemplo n.º 12
0
def shielding_symmetric_ui():
    zeta_ui = custom_input_group(
        prepend_label="Anisotropy (ζ)",
        append_label="ppm",
        id="shielding_symmetric-zeta",
        debounce=True,
    )

    # asymmetry and Euler angles
    return collapsable_card_ui(zeta_ui, "shielding_symmetric")
Exemplo n.º 13
0
def inversion():
    return dbc.Card([
        # dbc.CardHeader(html.H4("Parameters")),
        custom_input_group(
            prepend_label="l1 weight λ",
            append_label="",
            value=1e-7,
            id="INV-l1",
            min=0,
            debounce=True,
        ),
        custom_input_group(
            prepend_label="l2 weight α",
            append_label="",
            value=1e-6,
            id="INV-l2",
            min=0,
            debounce=True,
        ),
        dbc.Button("Invert", id="INV-solve"),
    ])
Exemplo n.º 14
0
def spectral_dimension_ui(i):
    """Return a list of widgets whose entries are used in evaluating the dimension
    coordinates along the i^th dimension. The widgets includes number of points (count),
    spectral width, and reference offset.

    Args:
        i: An integer with the dimension index.
    """
    # count
    count = custom_input_group(
        prepend_label="Number of points",
        value=512,
        min=2,
        id=f"count-{i}",
        debounce=True,
        pattern="[0-9]*",
    )

    # spectral width
    spectral_width = custom_input_group(
        prepend_label="Spectral width",
        append_label="kHz",
        value=25.0,
        min=1e-6,
        id=f"spectral_width-{i}",
        debounce=True,
    )

    # reference offset
    reference_offset = custom_input_group(
        prepend_label="Reference offset",
        append_label="kHz",
        value=0.0,
        id=f"reference_offset-{i}",
        debounce=True,
    )

    # origin offset
    # origin_offset = custom_input_group(
    #     prepend_label="Origin offset",
    #     append_label="MHz",
    #     value=0.0,
    #     id=f"origin_offset-{i}",
    #     debounce=True,
    # )

    # origin offset
    label = custom_input_group(
        prepend_label="Label",
        append_label="",
        input_type="text",
        value="frequency",
        id=f"label-{i}",
        debounce=True,
    )

    return collapsable_card(
        text=f"Spectral Dimension - {i}",
        id_=f"dim-{i}",
        featured=[count, spectral_width, reference_offset],
        hidden=[label],
        message="Show/Hide",
        outer=True,
    )