Esempio n. 1
0
def interactA():
    widH = widgets.IntSliderWidget(min=0, max=1000, step=1, value=100)
    widZ = widgets.IntSliderWidget(min=0, max=1000, step=1, value=1)
    wida = widgets.FloatSliderWidget(min=0.01, max=1, step=0.01, value=0.05)
    widb = widgets.FloatSliderWidget(min=0.1, max=1, step=0.05, value=0.3)
    widz = widgets.FloatSliderWidget(min=0.01, max=0.5, step=0.01, value=0.2)
    interact(graficaSolucionA,
             humanos=widH,
             zombies=widZ,
             muertos=fixed(0),
             a=wida,
             b=(0.1, 1, 0.05),
             z=(0.01, 0.5, 0.01))
Esempio n. 2
0
    def __init__(self):
        self.stormStuff = StormNameData().splitStormInfo()
        years = sorted(self.stormStuff.groupby(["Year"]).groups.keys())

        # Slider to select year for file
        self.menuYears = widgets.IntSliderWidget(min=1851,
                                                 max=2014,
                                                 step=1,
                                                 value=2014,
                                                 description="Year")
        self.menuNames = widgets.DropdownWidget()
        self.menuNames.on_trait_change(self._createUrl, 'value')

        # Button to create dropdown menu of storms for the selected year
        self.buttonName = widgets.ButtonWidget(
            description="Get Storm Names")  #, value = menuYears.value)
        self.buttonName.on_click(self._updateNames)

        # Button to call the plotting class and other necessary classes
        self.plottingButton = widgets.ButtonWidget(
            description="Plot Selected Storm", disabled=True)

        # Container widget to hold storm selection widgets
        self.stormSelector = widgets.ContainerWidget(children=[
            self.menuYears, self.buttonName, self.menuNames,
            self.plottingButton
        ],
                                                     visible=True)

        # Container widget to hold both storm selectign widgets and plotting button
        self.form = widgets.ContainerWidget()
        self.form.children = [self.stormSelector]
        display(self.form)
Esempio n. 3
0
def factorizer():
    box = widgets.ContainerWidget()
    header = widgets.HTMLWidget(value="<h1>Integer Factorizer</h1><br>")
    number = widgets.IntSliderWidget(description="Number:", value=100)
    speed = widgets.FloatSliderWidget(description="Delay:",
                                      min=0.0,
                                      max=0.2,
                                      value=0.1,
                                      step=0.01)

    subbox = widgets.ContainerWidget()
    button = widgets.ButtonWidget(description="Calculate")
    subbox.children = [button]

    box.children = [header, number, speed, subbox]
    display(box)

    box.add_class('align-center')
    box.add_class('center')
    box.add_class('well well-small')
    box.set_css('width', 'auto')

    subbox.remove_class('vbox')
    subbox.add_class('hbox')

    # subbox.add_class('end')

    def handle_caclulate(sender):
        plot_primes(number.value, delay=speed.value)

    button.on_click(handle_caclulate)
Esempio n. 4
0
def interactB():
    widH = widgets.IntSliderWidget(min=0, max=1000, step=1, value=100)
    widZ = widgets.IntSliderWidget(min=0, max=1000, step=1, value=1)
    widI = widgets.IntSliderWidget(min=0, max=10, step=1, value=0)
    wida = widgets.FloatSliderWidget(min=0.01, max=1, step=0.01, value=0.05)
    widb = widgets.FloatSliderWidget(min=0.1, max=1, step=0.05, value=0.6)
    widz = widgets.FloatSliderWidget(min=0.01, max=0.5, step=0.01, value=0.2)
    widr = widgets.FloatSliderWidget(min=0.1, max=1, step=0.05, value=0.9)
    interact(solucionB,
             humanos=widH,
             infectados=widI,
             zombies=widZ,
             muertos=fixed(0),
             a=wida,
             b=widb,
             z=widz,
             r=widr)
Esempio n. 5
0
 def pick_soft_threshold(self):
     w = interactive(self._soft_threshold,
                     method=('spearman', 'pearson', 'kendall'),
                     power=widgets.IntSliderWidget(min=0,
                                                   max=100,
                                                   step=2,
                                                   value=10),
                     signed=True)
     display(w)
Esempio n. 6
0
    def userControls(self):
        # Button to select new storm from StormSelector
        self.selectStorm = widgets.ButtonWidget(description="Select New Storm",
                                                visible=True)
        self.selectStorm.on_click(selectNewStorm)

        # Model selection widgets and controls to change model
        self.modelSelection = widgets.DropdownWidget(
            values=self.forecast.groupby(["Group"]).groups.keys(), value="NHC")
        self.modelSelection.on_trait_change(self.onChangeModel, 'value')
        # Slider widget to move plots through time
        self.frameNumber = widgets.IntSliderWidget(min=0,
                                                   max=1,
                                                   value=0,
                                                   step=1,
                                                   description="Time")

        # Button widgets to advance and retract time frames
        add = widgets.ButtonWidget(description="+")
        subtract = widgets.ButtonWidget(description="-")
        add.on_click(self.advanceFrame)
        subtract.on_click(self.subtractFrame)

        # Checkbox to add multiple tracks to plot
        clearAll = widgets.ButtonWidget(description="Clear Plot")
        clearAll.on_click(self.clearPlot)
        self.check = widgets.CheckboxWidget(description="Add multiple tracks:",
                                            value=False)
        # Widgets to tracks to plot
        self.newTrackMenu = widgets.DropdownWidget(
            values=self.forecast.groupby(["Group"]).groups.keys())
        self.addTrackButton = widgets.ButtonWidget(description="Add New Track")
        self.plotMultiTrackButton = widgets.ButtonWidget(
            description="Plot New Tracks")
        # Container that holds multiple track widgets
        self.addNewTrack = widgets.ContainerWidget(
            visible=False,
            children=[
                self.newTrackMenu, self.addTrackButton,
                self.plotMultiTrackButton, clearAll
            ])
        # Adding actions to control frameNumber slider widget
        self.addTrackButton.on_click(self.addingNewTrack)
        self.plotMultiTrackButton.on_click(self.plottingTracks)
        self.check.on_trait_change(self.addTracks, 'value')

        if self.container is None:
            # Container that holds all widgets
            self.container = widgets.ContainerWidget(children=[
                self.selectStorm, self.frameNumber, add, subtract,
                self.modelSelection, self.check, self.addNewTrack
            ])
            display(self.container)

        self.container.visible = True
Esempio n. 7
0
def integratemeasurement(t = widgets.IntSliderWidget(min=1, max=5000, step=1, value=40, description="")):
    #print t
    f = (data['<Ebene>']==3) & (data['<Winkel>']>-0.015) & (data['<Winkel>']<0.015)
    angle = data['<Winkel>'][f].iloc[:t]
    distance = data['<Radius>'][f].iloc[:t] /100.0
    layer = data['<Ebene>'][f].iloc[:t]

    plt.scatter(distance,angle, s=50, alpha=0.1)
    
    plt.axis('equal')
    plt.xlabel('z [$m$]')
    plt.ylabel('$\phi$ [$rad$]')
Esempio n. 8
0
def interactC():
    widH = widgets.IntSliderWidget(min=0, max=1000, step=1, value=100)
    widZ = widgets.IntSliderWidget(min=0, max=1000, step=1, value=1)
    widI = widgets.IntSliderWidget(min=0, max=10, step=1, value=0)
    wida = widgets.FloatSliderWidget(min=0.01, max=1, step=0.01, value=0.05)
    widb = widgets.FloatSliderWidget(min=0.1, max=1, step=0.05, value=0.85)
    widz = widgets.FloatSliderWidget(min=0.01, max=0.5, step=0.01, value=0.09)
    widr = widgets.FloatSliderWidget(min=0.1, max=1, step=0.05, value=0.8)
    widk = widgets.FloatSliderWidget(min=0.1, max=1, step=0.1, value=0.3)
    wids = widgets.FloatSliderWidget(min=0.01, max=0.5, step=0.01, value=0.01)
    widg = widgets.FloatSliderWidget(min=0.1, max=1, step=0.1, value=0.6)
    interact(solucionC,
             humanos=widH,
             infectados=widI,
             zombies=widZ,
             muertos=fixed(0),
             cuarentena=fixed(0),
             a=wida,
             b=widb,
             z=widz,
             r=widr,
             k=widk,
             s=wids,
             g=widg)
# <codecell>

%%javascript
require(["leaflet"], function(leaflet) {

var map = window._my_maps['i3c9fe247-096f-4df2-b6d7-291bb6d3b0e1']
console.log(map.getCenter());
    
});

# <codecell>

from IPython.html import widgets
from IPython.html.widgets import interact, fixed

zoom_widget = widgets.IntSliderWidget(min=1, max=18, step=1)
zoom_widget.value = 12

interact (leaflet, leaflet_api_key=fixed(LEAFLET_KEY), lat=fixed(37.8717), 
                  long=fixed(-122.2728),height=fixed(500), zoom=zoom_widget)

# <headingcell level=1>

# Doing more with a map

# <codecell>

%%javascript
console.log(IPython.notebook.get_cells());

# <codecell>
Esempio n. 10
0
def mean_filter_interactive_demo(image):
    from IPython.html import widgets
    mean_filter_step = mean_filter_demo(image)
    step_slider = widgets.IntSliderWidget(min=0, max=image.size - 1, value=0)
    widgets.interact(mean_filter_step, i_step=step_slider)
Esempio n. 11
0
               topojson='objects.us_counties_20m')

embed_map(map)

# <headingcell level=1>

# Blending folium with interact

# <codecell>

from IPython.html import widgets
from IPython.display import display, Image, HTML, clear_output

# <codecell>

# not the most interesting demo --> but a proof of concept on how we can control map using interact

def plot_map(lat, long, zoom):
    map = folium.Map(location=[lat, long], zoom_start=zoom)
    map.simple_marker([lat, long], popup='lat:{lat} long:{long}'.format(lat=lat,long=long))
    display(inline_map(map))
    
widgets.interact(plot_map, 
                 lat=widgets.FloatSliderWidget(min=-90,max=90,step=0.1,value=0),
                 long=widgets.FloatSliderWidget(min=-180,max=180,step=0.1,value=0),
                 zoom=widgets.IntSliderWidget(min=0,max=20,step=1,value=2))

# <codecell>


Esempio n. 12
0
def modeAnalyzerGrowth(myDMD_Uy,
                       k=(0, 100),
                       m=(0, 500),
                       vmin=-0.1,
                       vmax=0.1,
                       xscale='log',
                       min_norm=3.0,
                       min_abs=0.0003,
                       component=0,
                       extent=None):
    def plotTime(k, m, sorting, vmin=vmin, vmax=vmax, plotSpectrum=True):
        idx_pos, idx_neg, f = myDMD_Uy.getFrqSortedIdx()

        normList = myDMD_Uy.result['mode_norms']
        stabList = np.absolute(myDMD_Uy.result['ritz_vals'])

        fig = plt.figure(figsize=(15, 5))
        gs = gridspec.GridSpec(1, 5)
        ax1 = plt.subplot(gs[0, 0])
        ax2 = plt.subplot(gs[0, 1])
        ax3 = plt.subplot(gs[0, 2])
        ax4 = plt.subplot(gs[0, 3:5])

        #idx=[myDMD_Uy.getIdxforFrq(65.0)]

        if sorting == 0:
            idx_sel = myDMD_Uy.getFilteredIndex(min_norm=min_norm,
                                                min_abs=min_abs)[::-1]
            idx_sel = [idx for idx in idx_pos if idx in idx_sel]
            idx = [idx_sel[m]]

        elif sorting == 1:
            #idx=[myDMD_Uy.getGrowthSortedIdx()[::-1][m]]
            idx_norm = np.argsort(normList)[::-1]
            idx_sel = idx_norm

            #idx=[idx_stab[m]]
            idx = [idx_norm[m]]
        elif sorting == 2:
            idx_stab = np.argsort(np.abs(np.log(stabList)))
            idx_sel = idx_stab
            idx = [idx_stab[m]]
        elif sorting == 3:
            idx_none = np.linspace(0, len(normList), len(normList) + 1)
            idx_sel = idx_none
            print idx_sel
            idx = [idx_none[m]]
        elif sorting == 4:
            idx_sel = myDMD_Uy.getFilteredIndex(min_norm=min_norm,
                                                min_abs=min_abs)[::-1]
            idx = [idx_sel[m]]

        #idx=[idx_pos[m]]
        out = myDMD_Uy.reconstructDMD(k=k, idx=idx)
        if len(out.shape) > 2:
            out = out[component]
        ax1.imshow(np.real(out), vmin=vmin, vmax=vmax, extent=extent)
        ax1.set_title(str(idx[0]))
        #md=myDMD_Uy.getMode(idx[0],component=component)
        md = myDMD_Uy.getMode(idx[0], component=component)
        print md.shape
        if len(md.shape) > 2:
            md = md[component]

        ax2.imshow(np.real(md) / np.linalg.norm(md),
                   vmin=vmin,
                   vmax=vmax,
                   extent=extent)
        ax2.grid()
        ax3.imshow(np.imag(md) / np.linalg.norm(md),
                   vmin=vmin,
                   vmax=vmax,
                   extent=extent)
        ax3.grid()

        if (plotSpectrum):
            f1 = np.abs(myDMD_Uy.getFrq(idx[0]))
            #ax4.plot(f,normList)
            flist = myDMD_Uy.getFrqList()
            if sorting == 4 or sorting == 0:
                DecompositionPlotting.plotGrowth(myDMD_Uy,
                                                 ax4,
                                                 k,
                                                 idx=idx_sel[::-1],
                                                 dt=myDMD_Uy.result['dt'])
            else:
                #DecompositionPlotting.plotGrowth(myDMD_Uy,ax4,k,idx=idx_sel[::-1])
                DecompositionPlotting.plotGrowth(myDMD_Uy,
                                                 ax4,
                                                 k,
                                                 dt=myDMD_Uy.result['dt'])
            ritz_sel = np.log(myDMD_Uy.result['ritz_vals'][idx[0]]**
                              k) / myDMD_Uy.result['dt']
            ax4.plot(
                np.imag(ritz_sel) / (2.0 * np.pi), np.real(ritz_sel), 'rx')
            #ax4.plot(flist[idx_pos],10*np.log10(stabList[idx_pos]))
            #ax4.plot(flist[idx_pos[m]],10*np.log10(stabList[idx_pos[m]]),'ro')

            #ax4.plot(f1,myDMD_Uy.result['mode_norms'][idx[0]],'ro')
            #print f1,myDMD_Uy.result['mode_norms'][idx[0]]
            #ax4.set_xscale(xscale)
            #ax4.set_yscale('log')
            ax4.grid()
            ax4.set_title(
                str(np.round(f1, 5)) + r' Hz |$\lambda$|=' +
                str(np.round(myDMD_Uy.getEigAbs()[idx[0]], 6)) +
                r' |$\phi$| ' + str(np.round(normList[idx[0]], 2)))
        plt.show()

    kw = widgets.IntSliderWidget()
    kw.min = k[0]
    kw.max = k[1]
    kw.value = 1

    mw = widgets.IntSliderWidget()
    mw.min = m[0]
    mw.max = m[1]
    mw.value = 0
    sw = widgets.Dropdown(options={
        'Frequency': 0,
        'Norm': 1,
        'Growth': 2,
        'None': 3,
        'Importance': 4
    })
    #sw.values={'Frequency':0,'Norm':1,'Growth':2,'None':3,'Importance':4}
    ws = widgets.interaction.interactive(
        plotTime,
        k=kw,
        m=mw,
        vmin=widgets.FloatTextWidget(value=vmin),
        vmax=widgets.FloatTextWidget(value=vmax),
        plotSpectrum=True,
        sorting=sw)

    return ws
Esempio n. 13
0
def wavelengthAnalyzer(myDMD_Uy,
                       dx,
                       L,
                       iRow,
                       vmin=-0.1,
                       vmax=0.1,
                       maxOnly=False):
    def on_change2(pt):
        #maxi=sp.argrelmax(normList)[0]
        #pt=maxi[pt]

        fig = plt.figure(figsize=(20, 10))

        gs = gridspec.GridSpec(2, 2)
        ax1 = plt.subplot(gs[:, 0])
        ax2 = plt.subplot(gs[0, 1])
        ax3 = plt.subplot(gs[1, 1])

        #ax=plt.subplot(1,2,1)
        ax1.plot(f, normList)

        ax1.plot(f[pt], normList[pt], 'ko')
        #ax1.text(f[pt],normList[pt],str(f[pt])+ 'Hz')
        string = 'f={:.3f} Hz\nMode={:.0f}'.format(f[pt], pt)
        ax1.text(0.05,
                 0.95,
                 string,
                 transform=ax1.transAxes,
                 fontsize=14,
                 verticalalignment='top')

        ax1.set_xscale('log')
        ax1.set_yscale('log')

        #ax=plt.subplot(1,2,2)
        idxMode = myDMD_Uy.getIdxforFrq(f[pt])
        mode = myDMD_Uy.getMode(idxMode)
        ax2.imshow(np.real(mode),
                   vmin=vmin,
                   vmax=vmax,
                   interpolation='nearest')

        uy = np.array(np.real(mode)[iRow, :])
        uy_imag = np.array(np.imag(mode)[iRow, :])
        ax3.plot(uy)
        ax3.plot(uy_imag, 'r')
        maxi = sp.argrelmax(uy)[0]
        mini = sp.argrelmin(uy)[0]
        exti = np.sort(np.r_[maxi, mini])

        maxi_imag = sp.argrelmax(uy_imag)[0]
        mini_imag = sp.argrelmin(uy_imag)[0]
        exti_imag = np.sort(np.r_[maxi_imag, mini_imag])

        print np.diff(exti)
        ax3.scatter(maxi, uy[maxi], marker=2)
        ax3.scatter(mini, uy[mini], marker=3)
        ax3.scatter(maxi_imag, uy_imag[maxi_imag], marker=2)
        ax3.scatter(mini_imag, uy_imag[mini_imag], marker=3)

        ax3.set_xlim([0, np.real(mode).shape[1]])
        gamma = 0
        print 'n=', L / (np.diff(maxi) * dx) + gamma
        print 'n=', L / (np.diff(mini) * dx) + gamma
        print 'n=', L / (np.diff(exti) * dx * 2.0) + gamma

        print 'n=', L / (np.diff(maxi_imag) * dx) + gamma
        print 'n=', L / (np.diff(mini_imag) * dx) + gamma
        print 'n=', L / (np.diff(exti_imag) * dx * 2.0) + gamma

    idx_pos, idx_neg, f = myDMD_Uy.getFrqSortedIdx()
    normList = myDMD_Uy.result['mode_norms'][idx_pos]
    ws = widgets.IntSliderWidget()
    ws.min = 0
    if maxOnly == True:
        ws.max = len(sp.argrelmax(normList)[0])
    else:
        ws.max = len(normList)
    ws.value = 1

    ws = widgets.interaction.interactive(on_change2, pt=ws)
    return ws
Esempio n. 14
0
def modeAnalyzer2(myDMD_Uy,
                  k=(0, 100),
                  m=(0, 500),
                  vmin=-0.1,
                  vmax=0.1,
                  xscale='linear'):
    def plotTime(k, m, plotSpectrum=True, magSort=True):
        #idx_pos,idx_neg,f=myDMD_Uy.getFrqSortedIdx()
        normList = myDMD_Uy.result['mode_norms']
        growthList = np.absolute(myDMD_Uy.result['ritz_vals'])
        f = myDMD_Uy.getFrqList()

        fig = plt.figure(figsize=(15, 5))
        gs = gridspec.GridSpec(1, 5)
        ax1 = plt.subplot(gs[0, 0])
        ax2 = plt.subplot(gs[0, 1])
        ax3 = plt.subplot(gs[0, 2])
        ax4 = plt.subplot(gs[0, 3:5])

        #idx=[myDMD_Uy.getIdxforFrq(65.0)]
        if magSort:
            idx = [myDMD_Uy.getGrowthSortedIdx()[::-1][m]]
            #idx=[myDMD_Uy.getNormSortedIdx()[::-1][m]]
        else:
            #idx_pos,idx_neg,fc=myDMD_Uy.getFrqSortedIdx()
            #idx=[idx_pos[m]]
            idx = [range(len(myDMD_Uy.result['ritz_vals']))[m]]

        out = myDMD_Uy.reconstructDMD(k=k, idx=idx)

        ax1.imshow(np.real(out), vmin=vmin, vmax=vmax)
        ax1.set_title(str(idx[0]))
        md = myDMD_Uy.getMode(idx[0])

        ax2.imshow(np.real(md), vmin=vmin, vmax=vmax)

        ax3.imshow(np.imag(md), vmin=vmin, vmax=vmax)

        print idx, myDMD_Uy.getFrq(idx[0]), myDMD_Uy.result['ritz_vals'][
            idx[0]], myDMD_Uy.result['mode_norms'][idx[0]]
        if (plotSpectrum):
            f1 = np.abs(myDMD_Uy.getFrq(idx[0]))
            ax4.plot(f1, np.absolute(myDMD_Uy.result['ritz_vals'][idx[0]]),
                     'x')
            ax4.scatter(f,
                        growthList,
                        marker='d',
                        c=normList,
                        edgecolor='none')

            ax4.set_xscale(xscale)
            ax4.set_yscale('log')
            ax4.set_title(str(f1) + ' Hz')
        plt.show()

    kw = widgets.IntSliderWidget()
    kw.min = k[0]
    kw.max = k[1]
    kw.value = 0

    mw = widgets.IntSliderWidget()
    mw.min = m[0]
    mw.max = m[1]
    mw.value = 0

    ws = widgets.interaction.interactive(plotTime,
                                         k=kw,
                                         m=mw,
                                         plotSpectrum=True,
                                         magSort=True)
    return ws
Esempio n. 15
0
def modeAnalyzer(myDMD_Uy,
                 k=(0, 100),
                 m=(0, 500),
                 vmin=-0.1,
                 vmax=0.1,
                 xscale='log'):
    def plotTime(k, m, vmin=vmin, vmax=vmax, plotSpectrum=True, magSort=True):
        idx_pos, idx_neg, f = myDMD_Uy.getFrqSortedIdx()
        normList = myDMD_Uy.result['mode_norms']
        stabList = np.absolute(myDMD_Uy.result['ritz_vals'])

        fig = plt.figure(figsize=(15, 5))
        gs = gridspec.GridSpec(1, 5)
        ax1 = plt.subplot(gs[0, 0])
        ax2 = plt.subplot(gs[0, 1])
        ax3 = plt.subplot(gs[0, 2])
        ax4 = plt.subplot(gs[0, 3:5])

        #idx=[myDMD_Uy.getIdxforFrq(65.0)]
        if magSort:
            #idx=[myDMD_Uy.getGrowthSortedIdx()[::-1][m]]
            idx_stab = np.argsort(stabList**k)[::-1]
            idx_norm = np.argsort(normList)[::-1]

            #idx=[idx_stab[m]]
            idx = [idx_norm[m]]
        else:
            #idx_pos,idx_neg,fc=myDMD_Uy.getFrqSortedIdx()
            idx = [idx_pos[m]]

        #idx=[idx_pos[m]]

        out = myDMD_Uy.reconstructDMD(k=k, idx=idx_stab[1:])

        ax1.imshow(np.real(out), vmin=vmin, vmax=vmax)
        ax1.set_title(str(idx[0]))
        md = myDMD_Uy.getMode(idx[0])

        ax2.imshow(np.real(md), vmin=vmin, vmax=vmax)

        ax3.imshow(np.imag(md), vmin=vmin, vmax=vmax)

        if (plotSpectrum):
            f1 = np.abs(myDMD_Uy.getFrq(idx[0]))
            #ax4.plot(f,normList)
            flist = myDMD_Uy.getFrqList()
            DecompositionPlotting.plotEigenvals(myDMD_Uy, ax4, k)
            ritz_sel = myDMD_Uy.result['ritz_vals'][idx[0]]**k
            ax4.plot(np.real(ritz_sel), np.imag(ritz_sel), 'rx')
            #ax4.plot(flist[idx_pos],10*np.log10(stabList[idx_pos]))
            #ax4.plot(flist[idx_pos[m]],10*np.log10(stabList[idx_pos[m]]),'ro')

            #ax4.plot(f1,myDMD_Uy.result['mode_norms'][idx[0]],'ro')
            #print f1,myDMD_Uy.result['mode_norms'][idx[0]]
            #ax4.set_xscale(xscale)
            #ax4.set_yscale('log')
            ax4.set_title(
                str(f1) + r' Hz |$\lambda$|=' +
                str(myDMD_Uy.getEigAbs()[idx[0]]))
        plt.show()

    kw = widgets.IntSliderWidget()
    kw.min = k[0]
    kw.max = k[1]
    kw.value = 1

    mw = widgets.IntSliderWidget()
    mw.min = m[0]
    mw.max = m[1]
    mw.value = 0

    ws = widgets.interaction.interactive(
        plotTime,
        k=kw,
        m=mw,
        vmin=widgets.FloatTextWidget(value=vmin),
        vmax=widgets.FloatTextWidget(value=vmax),
        plotSpectrum=True,
        magSort=True)

    return ws
Esempio n. 16
0
    def __init__(
        self, panels, lma_ctrl, scatter_ctrl, charge_lasso, d
    ):  #, station_number_selection, charge_lasso_widget, draw_lasso_widget, color_field_widget, animation_time_widget, animate_button, label, LMA_Controlsa, LMA_Controlsb, tools_popup, number_of_stations):
        self.panels = panels
        self.lma_ctrl = lma_ctrl
        self.d = d
        self.scatter_ctrl = scatter_ctrl
        self.charge_lasso = charge_lasso

        #Max Chi2 Value:
        chi2_selection = widgets.BoundedFloatTextWidget(
            description='Max Chi2:', min='0.0', max='1000.0', value='1')
        chi2_selection.set_css({
            'max-width': '30px',
        })
        chi2_selection.on_trait_change(self.max_chi2, 'value')

        #Station Number Selection:
        station_number_selection = widgets.DropdownWidget(
            description='Number of Stations:',
            values=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
            value=7)
        station_number_selection.set_css({
            'background-dropdown': '#888888',
            'color': 'white',
        })
        station_number_selection.on_trait_change(self.number_of_stations,
                                                 'value')

        #Charge Lasso and Draw Button:
        charge_lasso_widget = widgets.RadioButtonsWidget(
            description='Charge Selection:',
            values=["-1", "0", "1"],
            value="-1")
        charge_lasso_widget.on_trait_change(self.change_lasso_charge, 'value')

        draw_lasso_widget = widgets.ButtonWidget(description='Draw')
        draw_lasso_widget.set_css({
            'background': '#888888',
            'color': 'white',
        })
        draw_lasso_widget.on_click(self.lasso_button)

        #Color Field Selection:
        color_field_widget = widgets.RadioButtonsWidget(
            description='Color By:',
            values=["chi2", "time", "charge"],
            value="time")
        color_field_widget.on_trait_change(self.change_color_field, 'value')

        #Animate (Slider and Button) Optional Manual Numerical Input commented out:
        animation_time_widget = widgets.IntSliderWidget(
            description='Animation Time:', min='0', max='30')
        animation_time_widget.value = '5'
        # animation_time_widget = widgets.TextWidget(Description='Animation Time')
        # animation_time_widget.placeholder = "value"
        animate_button = widgets.ButtonWidget(description="Animate")
        animate_button.set_css({
            'display': 'flex',
            'align-content': 'flex-end',
            'background': '#888888',
            'color': 'white',
        })
        animate_button.on_click(self.run_animation_button)

        #FOR CONTAINERS AND POPUP
        label = widgets.LatexWidget(value='LMA Tools')
        label.set_css({
            'font-size': '20px',
            'font-weight': 'bold',
            'align-self': 'center',
            'padding': '15px',
            'background': 'd8d8d8',
        })

        LMA_Controlsa = widgets.ContainerWidget()
        LMA_Controlsa.children = [
            station_number_selection, charge_lasso_widget, draw_lasso_widget,
            chi2_selection
        ]
        LMA_Controlsa.set_css({
            'display': 'flex',
            'flex-direction': 'column',
            # 'max-width': '300px',
            'flex-flow': 'row wrap',
            'align-content': 'flex-start',
            'padding': '10px',
            'background': '#e8e8e8',
            'font-weight': 'bold',
        })
        LMA_Controlsa.remove_class('vbox')
        LMA_Controlsa.add_class('hbox')

        LMA_Controlsb = widgets.ContainerWidget()
        LMA_Controlsb.children = [
            color_field_widget, animation_time_widget, animate_button
        ]
        LMA_Controlsb.set_css({
            'display': 'flex',
            'flex-flow': 'wrap',
            'align-items': 'right',
            'columns': '1',
            'padding': '10px',
            'background': '#e8e8e8',
            'font-weight': 'bold',
        })
        LMA_Controlsb.remove_class('vbox')
        LMA_Controlsb.add_class('hbox')

        tools_popup = widgets.PopupWidget(description='LMA Control Hub')
        tools_popup.set_css({
            'font-size': '14px',
            'align-self': 'center',
            'padding': '15px',
            'border': '5px ridge #989898',
            'background': '#e8e8e8',
        })
        tools_popup.children = [label, LMA_Controlsa, LMA_Controlsb]

        self.chi2_selection = chi2_selection
        self.station_number_selection = station_number_selection
        self.charge_lasso_widget = charge_lasso_widget
        self.draw_lasso_widget = draw_lasso_widget
        self.color_field_widget = color_field_widget
        self.animation_time_widget = animation_time_widget
        self.animate_button = animate_button
        self.label = label
        self.LMA_Controlsa = LMA_Controlsa
        self.LMA_Controlsb = LMA_Controlsb
        self.tools_popup = tools_popup