Beispiel #1
0
def interactive_responseFct():
	app = interactive(plot_ResponseFct,h_boom = FloatSlider(min=h_boom, max = h_boom_max, step = 0.1, value = h_boom),
                  h_1 = FloatSlider(min=0., max=zmax,value=0.1, step = 0.1),
                  sigma_1 = FloatSlider(min=sigmin, max = sigmax,value=sigmin, step = sigmin),
                  sigma_2 = FloatSlider(min=sigmin, max = sigmax,value=sigmin, step = sigmin),
                  orientation=ToggleButtons(options=['vertical','horizontal']))
	return app
Beispiel #2
0
 def interact_plot_inversion(self, maxIter=30):
     interact(
         self.plot_inversion,
         mode=RadioButtons(
             description="mode", options=["Run", "Explore"], value="Run"
         ),
         maxIter=IntText(value=maxIter),
         m0=FloatSlider(
             min=-2, max=2, step=0.05, value=0.0, continuous_update=False
         ),
         mref=FloatSlider(
             min=-2, max=2, step=0.05, value=0.0, continuous_update=False
         ),
         percentage=FloatText(value=self.percentage),
         floor=FloatText(value=self.floor),
         chifact=FloatText(value=1.0),
         beta0_ratio=FloatText(value=100),
         coolingFactor=FloatSlider(
             min=0.1, max=10, step=1, value=2, continuous_update=False
         ),
         coolingRate=IntSlider(
             min=1, max=10, step=1, value=1, continuous_update=False
         ),
         alpha_s=FloatText(value=1e-10),
         alpha_x=FloatText(value=0),
         target=False,
         option=ToggleButtons(options=["misfit", "tikhonov"], value="misfit"),
         i_iteration=IntSlider(
             min=0, max=maxIter, step=1, value=0, continuous_update=False
         ),
     )
def interact_setup(transforms, THRESHOLD, THRESHOLD_MIN, THRESHOLD_MAX,
                   THRESHOLD_STEP):
    from ipywidgets import Dropdown, FloatSlider

    transformDropdown = Dropdown(options=list(transforms.keys()),
                                 description='Transform: ',
                                 value='None')
    paramSlider = FloatSlider(value=0,
                              min=transforms['None'][0],
                              max=transforms['None'][1],
                              step=transforms['None'][2],
                              description='Param: ')
    thresholdSlider = FloatSlider(value=THRESHOLD,
                                  min=THRESHOLD_MIN,
                                  max=THRESHOLD_MAX,
                                  step=THRESHOLD_STEP,
                                  description='Threshold: ')

    def on_update_transform_widget(*args):
        # resetting range for incompatible ranges
        paramSlider.min = 0
        paramSlider.max = 100
        # actually setting range
        paramSlider.min = transforms[transformDropdown.value][0]
        paramSlider.max = transforms[transformDropdown.value][1]
        paramSlider.step = transforms[transformDropdown.value][2]

    transformDropdown.observe(on_update_transform_widget, 'value')

    return transformDropdown, paramSlider, thresholdSlider
Beispiel #4
0
def sgd_simple_lr_dataset_demo():
    random_state = check_random_state(10)

    x, y = make_regression(n_features=1,
                           n_samples=100,
                           noise=30.5,
                           random_state=random_state,
                           bias=200)
    x = pd.Series(x[:, 0])
    y /= 100
    y *= 2.0
    y = pd.Series(y)

    params = {'b0': -1, 'b1': -5, 'path': []}

    interact_manual(run_multiple_sgd_iter_for_simple_lr,
                    x=fixed(x),
                    y=fixed(y),
                    random_state=fixed(random_state),
                    params=fixed(params),
                    n_iter=FloatSlider(min=1, max=100, step=1, value=1),
                    learning_rate=FloatSlider(min=0.01,
                                              max=2.0,
                                              step=0.01,
                                              value=0.01))
def sdof_interact():
    """Create interactive plots of characteristics of SDOF system."""
    m_slide = widgets.FloatSlider(min=1e-5, max=20, step=.1, value=5,
                                  continuous_update=False)
    k_slide = FloatSlider(min=1e-5, max=1000, step=1., value=100,
                          continuous_update=False)
    c_slide = FloatSlider(min=-1, max=200, step=.1, value=2,
                          continuous_update=False)

    m_label = widgets.Label('Mass')
    c_label = Label('Damping')
    k_label = Label('Stiffness')

    m_slider = widgets.VBox([m_label, m_slide])
    c_slider = widgets.VBox([c_label, c_slide])
    k_slider = widgets.VBox([k_label, k_slide])

    ui = widgets.HBox([m_slider, c_slider, k_slider])

    out = widgets.interactive_output(plot_sdof_resp,
                                     {'m': m_slide,
                                      'c': c_slide, 'k': k_slide})

    sdof_responses = widgets.VBox([ui, out])
    return sdof_responses
Beispiel #6
0
def search_xgb_hyper():
    n_estimators_slider = IntSlider(min=1, max=1000, step=10, value=30)
    max_depth_slider = IntSlider(min=1, max=15, step=1, value=3)
    learning_rate_slider = FloatSlider(min=0.01, max=0.3, step=0.01, value=0.1)
    subsample_slider = FloatSlider(min=0.1, max=1, step=0.1, value=1.0)
    gamma_slider = FloatSlider(min=0.1, max=1, step=0.1, value=0)
    reg_alpha_slider = FloatSlider(min=0.1, max=1, step=0.1, value=0)
    reg_lambda_slider = FloatSlider(min=0.1, max=1, step=0.1, value=1.0)

    @interact(n_estimators=n_estimators_slider,
              max_depth=max_depth_slider,
              learning_rate=learning_rate_slider,
              subsample=subsample_slider,
              gamma=gamma_slider,
              reg_alpha=reg_alpha_slider,
              reg_lambda=reg_lambda_slider)
    def plot(n_estimators, max_depth, learning_rate, subsample, gamma,
             reg_alpha, reg_lambda):
        model = xgb.XGBRegressor(n_estimators=n_estimators,
                                 max_depth=max_depth,
                                 learning_rate=learning_rate,
                                 subsample=subsample,
                                 gamma=gamma,
                                 reg_alpha=reg_alpha,
                                 reg_lambda=reg_lambda)
        model.fit(X_train, Y_train)
        predict = model.predict(X_test)
        plt.plot(x_plot, predict[:, np.newaxis],
                 label='XGB n_estimators={0}, max_depth={1}, learning_rate={2}, subsample={3}, gamma={4}, reg_alpha={5}, reg_lambda={6}'.format(
                     n_estimators, max_depth, learning_rate, subsample, gamma, reg_alpha, reg_lambda), \
                 color='g', alpha=0.9, linewidth=2)

    plt.legend(loc='upper left')
    plt.show()
Beispiel #7
0
def gui_field_widgets(uni=False, test=False):
    """Return new widgets for field GUI functionality."""
    flims = {
        'min': 30,
        'max': 60,
        'value': 30,
        'step': 1,
        'continuous_update': False
    }
    iso_lims = {'description': 'Iso.', 'continuous_update': False}
    if uni:
        iso_lims.update({
            'min': 0.0001,
            'max': 0.1,
            'value': 0.0005,
            'step': 0.0005,
            'readout_format': '.4f'
        })
    else:
        iso_lims.update({'min': 3.0, 'max': 10.0, 'value': 2.0})
    if uni and not test:
        iso_lims['value'] = 0.03
    alims = {'min': 0.01, 'max': 1.0, 'value': 1.0, 'step': 0.01}
    return _ListDict([('alpha', FloatSlider(description='Opacity', **alims)),
                      ('iso', FloatSlider(**iso_lims)),
                      ('nx', IntSlider(description='Nx', **flims)),
                      ('ny', IntSlider(description='Ny', **flims)),
                      ('nz', IntSlider(description='Nz', **flims))])
Beispiel #8
0
    def __init__(self, runtime):
        """Initialise the game
        
        :param runtime: runtime in seconds
        """
        self.runtime = runtime

        self.startbutton = Button(description='Run')
        self.startbutton.on_click(self.run)

        self.timeprogress = FloatProgress(value=0,
                                          min=0,
                                          max=self.runtime,
                                          description='Time')
        self.setpoint = FloatSlider(value=0,
                                    min=-LIMIT,
                                    max=LIMIT,
                                    description='Setpoint')
        self.controlled = FloatSlider(value=0,
                                      min=-LIMIT,
                                      max=LIMIT,
                                      description='Controlled')
        self.controlled.disabled = True
        self.manipulated = FloatSlider(value=0,
                                       min=-LIMIT,
                                       max=LIMIT,
                                       description='MV')
        self.scoretext = Text(value='0', description='Score')
        self.score = 0

        self.timer = tornado.ioloop.PeriodicCallback(self.update, SLEEP)

        self.running = False
        self.reset()
Beispiel #9
0
    def __init__(self):

        interact(self.solve_and_plot,
                 SL=FloatSlider(value=1.85, min=1.4, max=2.4, step=0.05),
                 Fmax=FloatSlider(value=0.17, min=0.17, max=0.92, step=0.05),
                 Ca50=FloatSlider(value=3.0, min=0.87, max=3.0, step=0.05),
                 n=FloatSlider(value=7.6, min=3, max=10, step=0.5))
Beispiel #10
0
def manipulation_LJ(func):
    def f(r_m, epsilon):
        fig, ax = plt.subplots(figsize=(5, 5))
        circle1 = plt.Circle((0, 2), 0.2, color='b')
        circle2 = plt.Circle((r_m, 2), 0.2, color='r')
        ax.add_artist(circle1)
        ax.add_artist(circle2)
        r = np.linspace(0.01, 6, num=1000)
        plt.plot(r, func(r, r_m, epsilon))

        plt.xlim(-0.5, 5)
        plt.ylim(-2.5, 3)
        plt.show()

    return interactive(f,
                       r_m=FloatSlider(min=0.1,
                                       max=5,
                                       step=0.2,
                                       description=r'\(r_m\)',
                                       value=2),
                       epsilon=FloatSlider(min=0.1,
                                           max=2.,
                                           step=0.2,
                                           description=r'\(\epsilon\)',
                                           value=2))
Beispiel #11
0
 def interact_plot_G(self):
     Q = interact(
         self.plot_G,
         N=IntSlider(min=1,
                     max=100,
                     step=1,
                     value=20,
                     continuous_update=False),
         M=IntSlider(min=1,
                     max=100,
                     step=1,
                     value=100,
                     continuous_update=False),
         p=FloatSlider(min=-1,
                       max=0,
                       step=0.05,
                       value=-0.15,
                       continuous_update=False),
         q=FloatSlider(min=0,
                       max=1,
                       step=0.05,
                       value=0.25,
                       continuous_update=False),
         j1=FloatText(value=1.0),
         jn=FloatText(value=19.0),
         scale=ToggleButtons(options=["linear", "log"], value="log"),
         fixed=False,
         ymin=FloatText(value=-0.005),
         ymax=FloatText(value=0.011),
     )
     return Q
 def display(self):
     widget = interact(self.solve_and_plot,
                       k_on=FloatSlider(value=400, min=100, max=500,
                                        step=2),
                       f=FloatSlider(value=50, min=0, max=500, step=5),
                       h=FloatSlider(value=8, min=0, max=15, step=0.1),
                       g=FloatSlider(value=4, min=0, max=10, step=0.1))
Beispiel #13
0
    def interact(self):
        """ Start interactive reweighting in ipython.
        """
        from ipywidgets import interact, FloatSlider

        if self.ensemble == "grand_canonical":
            def f(temperature, mu):
                self.rew_temperature = temperature
                self.rew_obs = mu
                w = self.reweighting
                return self.critical_observable.hist(bins=100,
                                                     weights=w)
            temp = self.temperature
            mu = self.observable
            interact(f, temperature=FloatSlider(min=0.95*temp, max=1.05*temp,
                                                step=0.001, value=temp,
                                                continuous_update=False),
                     mu=FloatSlider(min=1.05*mu, max=0.95*mu,
                                    step=0.001, value=mu,
                                    continuous_update=False))
        else:
            def f(temperature, pressure):
                self.rew_temperature = temperature
                self.rew_obs = pressure
                w = self.reweighting
                return self.critical_observable.hist(bins=100,
                                                     weights=w)
            temp = self.temperature
            press = self.observable
            interact(f, temperature=FloatSlider(min=temp-10.0, max=temp+10.0,
                                                step=0.05, value=temp,
                                                continuous_update=False),
                     pressure=FloatSlider(min=press-10.0, max=press+10.0,
                                          step=0.05, value=press,
                                          continuous_update=False))
Beispiel #14
0
def R_C_interactive():
    w1 = interact(R_C_plot, 
                  R=FloatSlider(description='$R$', min=0, max=60, step=1, value=10, orientation='horizontal', 
                                readout=True, readout_format='.1f', continuous_update=True),
                  C=FloatSlider(description='$C$', min=1e-6, max=1e-3, step=1e-6, value=1e-5,orientation='horizontal',
                                readout=True, readout_format='.2e', continuous_update=False))
    display(w1)
def choose_slope_with_bias(X, y):
    k_slider = FloatSlider(min=0, max=40, step=2, value=2)
    b_slider = FloatSlider(min=0, max=10, step=1, value=0)

    @interact(k=k_slider, b=b_slider)
    def interact_plot_data_and_hyp(k, b):
        plot_data_and_hyp_with_bias(X, y, k, b)
Beispiel #16
0
    def create_sliders(self, R_i, V_i):
        # Records the initial position and velocity
        self.R_i = R_i
        self.V_i = V_i

        self.run_button = widgets.Button(description="Run (with new values)")
        display(self.run_button)
        self.run_button.on_click(self.mainloop)

        self.trace_button = widgets.Button(description="Tracer On/Off")
        display(self.trace_button)
        self.trace_button.on_click(self.t_onoff)

        widgets.interact(self.q_update,
                         val=FloatSlider(min=1000.,
                                         max=10000.,
                                         step=0.1,
                                         value=self.q,
                                         description='Charge Factor'))
        widgets.interact(self.r_update,
                         val=FloatSlider(min=0.01,
                                         max=1.,
                                         step=0.001,
                                         value=self.R_i[2],
                                         description='Particle Height'))
Beispiel #17
0
 def display(self):
   widget = interact(self.solve_and_plot,
           gamma = FloatSlider(value = 4.17, min = 0, max = 10, step= 0.5),
           k_1 = FloatSlider(value = 2*10**(-5), min = 0, max = 2*10**(-5) * 2, step= 10**(-5)),
           k_2 = FloatSlider(value = 0.13, min = 0.05, max = 0.13*2, step= 0.02),
           k_4 = FloatSlider(value = 0.9, min = 0, max = 0.9*2, step= 0.2),
           k_31 = FloatSlider(value = 1, min = 0, max = 2, step= 0.2))
Beispiel #18
0
def DC2DfwdWidget():
    return widgetify(DC2DfwdWrapper,
                     manual=True,
                     rhohalf=FloatText(min=10,
                                       max=1000,
                                       value=1000,
                                       continuous_update=False,
                                       description='$\\rho_1$'),
                     rhosph=FloatText(min=10,
                                      max=1000,
                                      value=50,
                                      continuous_update=False,
                                      description='$\\rho_2$'),
                     xc=FloatSlider(min=-40,
                                    max=40,
                                    step=1,
                                    value=0,
                                    continuous_update=False),
                     zc=FloatSlider(min=-20,
                                    max=0,
                                    step=1,
                                    value=-10,
                                    continuous_update=False),
                     r=FloatSlider(min=0,
                                   max=15,
                                   step=0.5,
                                   value=5,
                                   continuous_update=False),
                     predmis=ToggleButtons(options=['pred', 'mis']),
                     surveyType=ToggleButtons(
                         options=['DipoleDipole', 'PoleDipole', 'DipolePole']))
def posterior(Nm, Nc):
    mtrue, ctrue = [2, 3]
    cmin, c0, cmax = [2.55, 3.05, 3.55]
    mmin, m0, mmax = [1.3, 2.1, 2.9]
    m = FloatSlider(value=m0,
                    description=r'$m$',
                    min=mmin,
                    max=mmax,
                    step=(mmax - mmin) / Nm,
                    continuous_update=False)
    c = FloatSlider(value=c0,
                    description=r'$c$',
                    min=cmin,
                    max=cmax,
                    step=(cmax - cmin) / Nc,
                    continuous_update=False)
    p = Posterior(cmin=cmin,
                  cmax=cmax,
                  Nc=Nc,
                  mmin=mmin,
                  mmax=mmax,
                  Nm=Nm,
                  ctrue=ctrue,
                  mtrue=mtrue,
                  var=0.1)
    io = interactive_output(plot_posterior, {'m': m, 'c': c, 'p': fixed(p)})
    return VBox([HBox([m, c]), io])
Beispiel #20
0
def manipulation_Harmonique(func):
    def f(r_m, k):
        fig, ax = plt.subplots(figsize=(5, 5))
        circle1 = plt.Circle((0, 2), 0.2, color='b')
        circle2 = plt.Circle((r_m, 2), 0.2, color='r')
        ax.add_artist(circle1)
        ax.add_artist(circle2)
        r = np.linspace(-2, 6, num=100)
        plt.plot(r, func(r, r_m, k))

        plt.xlim(-0.5, 4)
        plt.ylim(-0.5, 4)
        plt.show()

    return interactive(f,
                       r_m=FloatSlider(min=0.5,
                                       max=5,
                                       step=0.2,
                                       description=r'\(r_m\)',
                                       value=2),
                       k=FloatSlider(min=0.5,
                                     max=5.,
                                     step=0.2,
                                     description=r'\(k\)',
                                     value=2))
Beispiel #21
0
def recharge_source():
    Q = FloatSlider(value=1000,
                    description=r'$Q$ [m$^3$/day]',
                    min=500,
                    max=1500,
                    step=500,
                    continuous_update=False)
    t = FloatLogSlider(value=1.0,
                       description=r'$t$ [day]',
                       base=10,
                       min=-1,
                       max=2,
                       step=0.2,
                       continuous_update=False)
    r = FloatSlider(value=200,
                    description=r'$r$ [m]',
                    min=100,
                    max=500,
                    step=100,
                    continuous_update=False)
    T = FloatSlider(value=300,
                    description=r'$T$ [m$^2$/day]',
                    min=100,
                    max=500,
                    step=100,
                    continuous_update=False)
    image = Checkbox(value=False, description='image well')
    io = interactive_output(show_theis_image2, {
        'Q': Q,
        't': t,
        'r': r,
        'T': T,
        'image': image
    })
    return VBox([HBox([Q, t, image]), HBox([T, r]), io])
Beispiel #22
0
def exercise_referencePoint():
    x_lim, y_lim = [-16, 16], [-2, 18]

    style = {'description_width': 'initial'}
    # Interactive Widgets
    x1_widget = FloatSlider(description='Obstacle center \( x_1\)',
                            min=x_lim[0],
                            max=x_lim[1],
                            step=0.1,
                            value=6,
                            style=style)
    x2_widget = FloatSlider(description='Obstacle center \( x_2\)',
                            min=y_lim[0],
                            max=y_lim[1],
                            step=0.1,
                            value=5,
                            style=style)
    angle_widget = FloatSlider(description='Obstacle orientation \( \Theta \)',
                               min=-180,
                               max=180,
                               step=1,
                               value=30,
                               style=style)
    referencePoint_direction = FloatSlider(
        description='Reference point: Direction',
        min=-180,
        max=180,
        step=1,
        value=0,
        style=style)
    referencePoint_excentricity = FloatSlider(
        description='Reference point: Excentricity',
        min=0,
        max=0.999,
        step=0.01,
        value=0.0,
        style=style)

    draw_style = widgets.Dropdown(
        options=["None", "Vectorfield", "Simulated streamline"],
        value="Simulated streamline",
        description='Visualization',
        disabled=False,
    )

    # Main function
    interact_manual(widgetFunction_referencePoint,
                    x1=x1_widget,
                    x2=x2_widget,
                    th_r=angle_widget,
                    draw_style=draw_style,
                    refPoint_dir=referencePoint_direction,
                    refPoint_rat=referencePoint_excentricity,
                    x_low=fixed(x_lim[0]),
                    x_high=fixed(x_lim[1]),
                    y_low=fixed(y_lim[0]),
                    y_high=fixed(y_lim[1]))

    print("")
def plot_loss_and_der(X, y, same=True, der_value=False):

    if not der_value:
        k_slider = FloatSlider(min=0, max=40, step=2, value=2, description='k')
    else:
        k_slider = FloatSlider(min=0, max=40, step=2, value=2, description='k')

    @interact(k0=k_slider)
    def plot_data_and_hyp_with_error(k0):
        plt.rcParams.update({'font.size': 22})

        fig, axis = plt.subplots(1, 2, figsize=(18, 6), dpi=300)

        for ax in axis:
            ax.set_xlim(0, 40)
            ax.grid()

        length = 1000
        begin = 0
        end = 40
        ks = np.linspace(begin, end, length)

        errors = [J(X, y, k) for k in ks]
        axis[0].plot(ks, errors, color='black')
        axis[1].plot(ks, [der_J(X, y, k) for k in ks], color='black')

        axis[0].scatter(k0, J(X, y, k0), color='black')
        axis[1].scatter(k0, der_J(X, y, k0), color='black')

        axis[0].set_title("$\dfrac{1}{N} \sum_{i=1}^{N} (kX_i - y_i)^2$")

        if not der_value:
            axis[1].set_title("$\dfrac{2}{N} \sum_{i=1}^{N} (kX_i - y_i)X_i$")
        else:
            axis[1].set_title(
                "$\dfrac{2}{N} \sum_{i=1}^{N} (kX_i - y_i)X_i=$" +
                "{0:.2f}".format(der_J(X, y, k0)))

        axis[0].set_xlabel("Значение параметра $k$")
        axis[0].set_ylabel("Значение функции ошибки")

        axis[1].set_xlabel("Значение параметра $k$")
        axis[1].set_ylabel("Значение производной\nфункции ошибки")

        axis[0].set_ylim(min(errors), max(errors))

        if k0 != 0:
            axis[0].plot([begin, end], [
                der_J(X, y, k0) * (begin - k0) + J(X, y, k0),
                der_J(X, y, k0) * (end - k0) + J(X, y, k0)
            ],
                         color='black',
                         linestyle='dashed')
        else:
            axis[0].plot([begin, end], [J(X, y, k0), J(X, y, k0)],
                         color='black',
                         linestyle='dashed')
        plt.tight_layout()
        plt.show()
def ResCylLayer_app():
    app = widgetify(
        PLOT,
        survey_type=ToggleButtons(
            options=["Wenner", "Dipole-Dipole"],
            value="Wenner",
        ),
        a_spacing=FloatSlider(
            min=2,
            max=10.0,
            step=1.0,
            value=4.0,
            continuous_update=False,
            description="a",
        ),
        array_center=FloatSlider(
            min=-30.25,
            max=30.25,
            step=0.5,
            value=-10.25,
            continuous_update=False,
            description="array center",
        ),
        xc=FloatSlider(min=-30.0,
                       max=30.0,
                       step=1.0,
                       value=0.0,
                       continuous_update=False),
        zc=FloatSlider(min=-30.0,
                       max=-3.0,
                       step=0.5,
                       value=-10,
                       continuous_update=False),
        r=FloatSlider(min=1.0,
                      max=10.0,
                      step=0.5,
                      value=8.0,
                      continuous_update=False),
        rhohalf=FloatText(
            min=1e-8,
            max=1e8,
            value=500.0,
            continuous_update=False,
            description="$\\rho_{half}$",
        ),
        rhoTarget=FloatText(
            min=1e-8,
            max=1e8,
            value=50.0,
            continuous_update=False,
            description="$\\rho_{cyl}$",
        ),
        Field=ToggleButtons(
            options=["Model", "Potential", "E", "J"],
            value="Model",
        ),
        Scale=ToggleButtons(options=["Linear", "Log"], value="Log"),
    )
    return app
Beispiel #25
0
 def configure_controllers(self):
     from ipywidgets import (interactive, Label, VBox, FloatSlider,
                             IntSlider, Checkbox)
     # continuous update
     self.continuous_update_button = Checkbox(
         value=False,
         description='Continuous update',
         disabled=False,
         indent=False,
     )
     self.controllers["continuous_update"] = interactive(
         self.set_continuous_update, value=self.continuous_update_button)
     # subplot
     number_of_plots = len(self.plotter.renderers)
     if number_of_plots > 1:
         self.sliders["subplot"] = IntSlider(value=number_of_plots - 1,
                                             min=0,
                                             max=number_of_plots - 1,
                                             step=1,
                                             continuous_update=False)
         self.controllers["subplot"] = VBox([
             Label(value='Select the subplot'),
             interactive(
                 self.set_subplot,
                 index=self.sliders["subplot"],
             )
         ])
     # azimuth
     default_azimuth = self.plotter.renderer._azimuth
     self.sliders["azimuth"] = FloatSlider(value=default_azimuth,
                                           min=-180.,
                                           max=180.,
                                           step=10.,
                                           continuous_update=False)
     # elevation
     default_elevation = self.plotter.renderer._elevation
     self.sliders["elevation"] = FloatSlider(value=default_elevation,
                                             min=-180.,
                                             max=180.,
                                             step=10.,
                                             continuous_update=False)
     # distance
     eps = 1e-5
     default_distance = self.plotter.renderer._distance
     self.sliders["distance"] = FloatSlider(value=default_distance,
                                            min=eps,
                                            max=2. * default_distance - eps,
                                            step=default_distance / 10.,
                                            continuous_update=False)
     # camera
     self.controllers["camera"] = VBox([
         Label(value='Camera settings'),
         interactive(
             self.set_camera,
             azimuth=self.sliders["azimuth"],
             elevation=self.sliders["elevation"],
             distance=self.sliders["distance"],
         )
     ])
Beispiel #26
0
def R_RC_interactive():
    interact(R_RC_plot, 
             R0=FloatSlider(description='$R_0$', min=0, max=30, step=1, value=10, orientation='horizontal', 
                            readout=True, readout_format='.1f', continuous_update=True),
             R1=FloatSlider(description='$R_1$', min=5, max=30, step=1, value=20, orientation='horizontal', 
                            readout=True, readout_format='.1f', continuous_update=True),
             C1=FloatSlider(description='$C_1$', min=1e-6, max=1e-3, step=1e-6, value=1e-5,orientation='horizontal', 
                            readout=True, readout_format='.2e', continuous_update=False))
Beispiel #27
0
def InteractNosiy(noisyDataFile, noisyTimeFile):
    noisy = interactive(
        NoisyNMOWidget,
        t0=FloatSlider(min=0.1, max=0.6, step=0.01, continuous_update=False),
        v=FloatSlider(min=800.0, max=2500.0, step=100.0, continuous_update=False),
        syndat=fixed(noisyDataFile),
        timdat=fixed(noisyTimeFile),
    )
    return noisy
Beispiel #28
0
def InteractClean(cleanDataFile, cleanTimeFile):
    clean = interactive(
        CleanNMOWidget,
        t0=FloatSlider(min=0.2, max=0.8, step=0.01, continuous_update=False),
        v=FloatSlider(min=1000.0, max=5000.0, step=100.0, continuous_update=False),
        syndat=fixed(cleanDataFile),
        timdat=fixed(cleanTimeFile),
    )
    return clean
def plot_layer_potentials_app():
    def plot_layer_potentials_interact(survey, A, B, M, N, rho1, rho2, h,
                                       Plot):
        return plot_layer_potentials(survey, rho1, rho2, h, A, B, M, N, Plot)

    app = widgetify(
        plot_layer_potentials_interact,
        survey=ToggleButtons(
            options=[
                "Dipole-Dipole", "Dipole-Pole", "Pole-Dipole", "Pole-Pole"
            ],
            value="Dipole-Dipole",
        ),
        A=FloatSlider(min=-40.0,
                      max=40.0,
                      step=1.0,
                      value=-30.0,
                      continuous_update=False),
        B=FloatSlider(min=-40.0,
                      max=40.0,
                      step=1.0,
                      value=30.0,
                      continuous_update=False),
        M=FloatSlider(min=-40.0,
                      max=40.0,
                      step=1.0,
                      value=-10.0,
                      continuous_update=False),
        N=FloatSlider(min=-40.0,
                      max=40.0,
                      step=1.0,
                      value=10.0,
                      continuous_update=False),
        rho1=FloatText(
            min=rhomin,
            max=rhomax,
            value=500.0,
            continuous_update=False,
            description="$\\rho_1$",
        ),
        rho2=FloatText(
            min=rhomin,
            max=rhomax,
            value=500.0,
            continuous_update=False,
            description="$\\rho_2$",
        ),
        h=FloatSlider(min=0.0,
                      max=40.0,
                      step=1.0,
                      value=5.0,
                      continuous_update=False),
        Plot=ToggleButtons(options=["Model", "Potential", "E", "J"],
                           value="Model"),
    )
    return app
Beispiel #30
0
 def interact_LD(self, L_dict, D_dict):
     # closure just capture self in function
     def update(L, D):
         self.update_plot(L, D)
     layout = Layout(width="50%")
     lw = FloatSlider(**L_dict, layout=layout, description="L")
     dw = FloatSlider(**D_dict, layout=layout, description="D")
     box = HBox([lw, dw])
     interactive_output(update, {'L': lw, 'D': dw})
     display(box)