def download_btn_pack():
    """Button group for selecting type of download"""
    kwargs = {"outline": True, "color": "dark", "size": "lg"}
    img_btn = custom_button(
        text="image",
        icon_classname="far fa-file-image fa-lg",
        tooltip="Download csdf of all spectra lines",
        id="download-img",
        active=True,
        **kwargs,
    )
    csdf_btn = custom_button(
        text="csdf",
        icon_classname="far fa-file-archive fa-lg",
        tooltip="Download csdf of all spectra lines",
        id="download-csdf",
        **kwargs,
    )
    html_btn = custom_button(
        text="html",
        icon_classname="far fa-file-code fa-lg",
        tooltip="Download plot as interactive html file",
        id="download-html",
        **kwargs,
    )

    return html.Div(dbc.ButtonGroup([img_btn, csdf_btn, html_btn]),
                    className="center")
Exemple #2
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,
    )
Exemple #3
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],
    )
Exemple #4
0
def edit_sample_info_button_ui():
    return custom_button(
        icon_classname="fas fa-pencil-alt",
        tooltip="Click to edit title and description.",
        id="title-home-button",
        className="icon-button",
        module="html",
    )
Exemple #5
0
def buttons():
    """Static user interface buttons"""
    kwargs = {"outline": True, "color": "dark", "size": "md"}
    sim = custom_button(
        text="Sim",
        icon_classname="fac fa-spectrum fa-lg",
        id="sim-button",
        tooltip="Simulate spectrum with current parameters",
        **kwargs
    )
    fit = custom_button(
        text="Fit",
        icon_classname="fac fa-chi-squared fa-lg",
        id="fit-button",
        tooltip="Run a least-squared fitting analysis",
        **kwargs
    )
    return dbc.ButtonGroup([sim, fit])
Exemple #6
0
def header():
    """Report title"""
    kwargs = {"outline": True, "color": "dark", "size": "md"}
    report_btn = custom_button(
        text="Full Report",
        icon_classname="fas fa-file-pdf fa-lg",
        id="download-fit-report-btn",
        tooltip="Download the full fit report as a pdf",
        **kwargs,
    )
    values_btn = custom_button(
        text="Values",
        icon_classname="fas fa-file-download  fa-lg",
        id="download-fit-values-btn",
        tooltip="Download the full fit report as a pdf",
        **kwargs,
    )
    return html.Div(
        children=dbc.ButtonGroup([report_btn, values_btn]),
        className="card-header",
    )
Exemple #7
0
def layout():
    label = html.Label(id="method-title")
    title = html.Div(label, className="ui_title")

    # submit method button
    submit = custom_button(text="Submit Method",
                           id="apply-method-changes",
                           tooltip="Submit Method")
    submit = html.Div(
        submit,
        id="apply-method-div",
        style={"display": "block"},
        className="submit-button",
    )

    # submit processing button
    submit_pro = custom_button(
        text="Submit Processor",
        id="submit-signal-processor-button",
        tooltip="Submit Processor",
    )
    submit_pro = html.Div(
        submit_pro,
        id="signal-processor-div",
        style={"display": "none"},
        className="submit-button",
    )

    # tabs
    tabs = dbc.Tabs([method_property_tab_ui(),
                     signal_processing_tab_ui()],
                    id="method-tabs")

    # method layout
    return html.Div(
        [html.Div([title, tabs]), submit, submit_pro],
        id="method-editor-content",
        className="slider2",
    )
Exemple #8
0
def ui():
    """Modal body with form  and close button"""
    close_button = custom_button(
        icon_classname="fas fa-times 2x",
        tooltip="Close",
        id="close-info-modal",
        className="icon-button",
        module="html",
    )

    content = dbc.ModalBody([close_button, body()])
    return dbc.Modal(
        [content, footer()],
        id="info-modal-editor",
        is_open=False,
        role="document",
        className="modal-dialogue",
        backdrop="static",
    )
Exemple #9
0
    def download_spectra():
        """Button for opening spectra downloads modal"""
        kwargs = {"outline": True, "color": "dark", "size": "md"}
        download_btn = custom_button(
            icon_classname="fas fa-download fa-lg",
            tooltip="Download Simulation from selected method.",
            id="open-download-spectra-modal",
            **kwargs,
        )

        app.clientside_callback(
            """function (n1, n2, is_open) { return !is_open; }""",
            Output("download-spectra-modal", "is_open"),
            Input("open-download-spectra-modal", "n_clicks"),
            Input("close-download-spectra-modal", "n_clicks"),
            State("download-spectra-modal", "is_open"),
            prevent_initial_call=True,
        )

        return download_btn
Exemple #10
0
def download_session_ui():
    """Download session"""
    session_link = html.A(id="download-session-link",
                          style={"display": "none"})
    session_button = custom_button(
        icon_classname="fas fa-file-download fa-lg",
        tooltip="Click to download the session",
        id="download-session-button",
        className="icon-button",
        module="html",
    )

    # callback for downloading session
    app.clientside_callback(
        ClientsideFunction(namespace="clientside",
                           function_name="downloadSession"),
        Output("download-session-link", "href"),
        Input("download-session-button", "n_clicks"),
        State("local-simulator-data", "data"),
        prevent_initial_call=True,
    )
    return html.Div([session_link, session_button])
def ui(index, data=None, n_dim=1, n_dv=1, **kwargs):
    def function_type(index):
        type_label = dbc.InputGroupAddon("Type", addon_type="prepend")
        val = "Exponential" if data is None else data["type"]
        type_select = dbc.Select(
            options=[
                {"label": "Gaussian", "value": "Gaussian"},
                {"label": "Lorentzian", "value": "Exponential"},
            ],
            value=val,
            id={"function": "apodization", "args": "type", "index": index},
        )
        return dbc.InputGroup([type_label, type_select], className="input-form")

    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]*",
        )

    def dimension_index(index):
        input_ = dbc.InputGroupAddon("Spectral dimension indexes", addon_type="prepend")

        value = [0]
        if data is not None:
            value = [0] if "dim_index" not in data else data["dim_index"]

        dim_index = dcc.Dropdown(
            options=[{"label": f"{i}", "value": i} for i in range(n_dim)],
            value=value,
            multi=True,
            id={"function": "apodization", "args": "dim_index", "index": index},
        )
        return dbc.InputGroup([input_, dim_index], className="input-form")

    def dependent_variable_index(index):
        input_ = dbc.InputGroupAddon("Spin System indexes", addon_type="prepend")
        options = [{"label": f"{i}", "value": i} for i in range(n_dv)]
        options += [{"label": "ALL", "value": "None"}]

        value = ["None"]
        if data is not None:
            value = ["None"] if "dv_index" not in data else data["dv_index"]

        dv_index = dcc.Dropdown(
            options=options,
            value=value,
            searchable=True,
            multi=True,
            id={"function": "apodization", "args": "dv_index", "index": index},
        )
        return dbc.InputGroup([input_, dv_index], className="input-form")

    featured = [function_type(index), arguments(index)]
    hidden = [dimension_index(index), dependent_variable_index(index)]
    return container(
        text=[
            "Convolution",
            custom_button(
                icon_classname="fas fa-times",
                id={"type": "remove-post_sim-functions", "index": index},
                className="icon-button",
                module="html",
                tooltip="Remove convolution module.",
            ),
        ],
        featured=[*featured, *hidden],
    )