예제 #1
0
    def swi_rawdata(self, dir, name, measure, **keys):
        s = ccm.stats.Stats('%s/%s' % (dir, name))
        data = s.get_raw(measure)

        c = ArrayPlotConfig(keys)

        page = T.div()
        config = T.form(
            action="/rawdata/%s/%s/%s" % (dir, name, measure), method="get")[
                c.index_bar("/rawdata/%s/%s/%s" %
                            (dir, name, measure), 'index', len(data)),
                c.index_config(), T.br,
                c.plot_axis_config(),
                T.input(type='submit', value='Update'), ]

        params, settings, options, defaults = make_settings_table(dir)
        setting = parse_setting_name(name)
        params = T.table(border=1)
        row1 = T.tr()
        row2 = T.tr()
        for k, vv in sorted(options.items()):
            if len(vv) > 1:
                row1[T.th[k]]
                values = T.td()
                vvlist = list(
                    sorted(vv, key=lambda x: convert_string_to_value(x)))
                for i in range(len(vvlist)):
                    vvv = vvlist[i]
                    sval = setting.get(k, defaults[k])
                    if vvv == sval:
                        values[T.b[vvv], T.br]
                    else:
                        setting2 = dict(setting)
                        setting2[k] = vvv
                        name2 = make_setting_name(dir, setting2)
                        values[T.a(href="/rawdata/%s/%s/%s?%s" %
                                   (dir, name2, measure, c.url_args()))[vvv],
                               T.br]
                row2[values]
        params[row1, row2]

        if type(data[0]) is float or type(data[0]) is int:
            table = T.table()
            for d in data:
                table[T.tr[T.td[d]]]

            page[table,
                 T.img(src='/histogram/%s/%s/%s' % (dir, name, measure))]

            return str(page)
        elif type(data[0]) is list and type(data[0][0]) is float:
            page[T.a(href='/arrayplot/%s/%s/%s?%s' %
                     (dir, name, measure, c.url_args(
                         dpi=300)))[T.img(style='float:right',
                                          src='/arrayplot/%s/%s/%s?%s' %
                                          (dir, name, measure, c.url_args()))],
                 params, config]

        return str(page)
예제 #2
0
    def swi_rawdata(self,dir,name,measure,**keys):
        s=ccm.stats.Stats('%s/%s'%(dir,name))
        data=s.get_raw(measure)
        
        c=ArrayPlotConfig(keys)

        page=T.div()
        config=T.form(action="/rawdata/%s/%s/%s"%(dir,name,measure),method="get")[
            c.index_bar("/rawdata/%s/%s/%s"%(dir,name,measure),'index',len(data)),
            c.index_config(),
            T.br,
            c.plot_axis_config(),
            T.input(type='submit',value='Update'),          
            ]            
            
        params,settings,options,defaults=make_settings_table(dir)
        setting=parse_setting_name(name)
        params=T.table(border=1)    
        row1=T.tr()
        row2=T.tr()
        for k,vv in sorted(options.items()):
            if len(vv)>1:
                row1[T.th[k]]
                values=T.td()
                vvlist=list(sorted(vv,key=lambda x: convert_string_to_value(x)))
                for i in range(len(vvlist)):
                    vvv=vvlist[i]
                    sval=setting.get(k,defaults[k])
                    if vvv==sval:
                        values[T.b[vvv],T.br]                    
                    else:
                        setting2=dict(setting)
                        setting2[k]=vvv
                        name2=make_setting_name(dir,setting2)
                        values[T.a(href="/rawdata/%s/%s/%s?%s"%(dir,name2,measure,c.url_args()))[vvv],T.br]
                row2[values]
        params[row1,row2]
            
                
        if type(data[0]) is float or type(data[0]) is int:
            table=T.table()
            for d in data:
                table[T.tr[T.td[d]]]
            
            page[table,T.img(src='/histogram/%s/%s/%s'%(dir,name,measure))]
            
            return str(page)
        elif type(data[0]) is list and type(data[0][0]) is float:                        
            page[T.a(href='/arrayplot/%s/%s/%s?%s'%(dir,name,measure,c.url_args(dpi=300)))[T.img(style='float:right',src='/arrayplot/%s/%s/%s?%s'%(dir,name,measure,c.url_args()))],params,config]
                
                
        return str(page)
예제 #3
0
    def swi_sim(self, dir):
        fn = '%s/code.py' % dir
        lines = file(fn).readlines()

        params, settings, options, defaults = make_settings_table(dir)

        header = T.tr()
        for p in params:
            header[T.th[p]]
        table = T.table[header]
        for row, name in settings:
            r = T.tr()
            for x in row:
                r[T.td[x]]
            r[T.td[T.a(href='/stats/%s/%s' % (dir, name))['data']]]
            r[T.td[T.a(href='/graph/%s/%s' % (dir, name))['graph']]]
            table[r]

        body = T.div[T.a(href='/code/%s.py' % dir)['source code'], T.br, table]

        return html('Simulation: %s' % dir, body)
예제 #4
0
 def swi_sim(self,dir):
     fn='%s/code.py'%dir
     lines=file(fn).readlines()
     
     params,settings,options,defaults=make_settings_table(dir)
     
     header=T.tr()
     for p in params: header[T.th[p]]
     table=T.table[header]
     for row,name in settings:
         r=T.tr()
         for x in row: 
             r[T.td[x]]
         r[T.td[T.a(href='/stats/%s/%s'%(dir,name))['data']]]    
         r[T.td[T.a(href='/graph/%s/%s'%(dir,name))['graph']]]    
         table[r]
     
     
     body=T.div[T.a(href='/code/%s.py'%dir)['source code'],T.br,
                 table]
     
     return html('Simulation: %s'%dir,body)
예제 #5
0
    def swi_graph(self,dir,name,bcount=100,conf=0.95,x=None,y=None,multi=None,m=None,compare='',sortby='',width=8,height=6,dpi=80,
                  xvals='',yvals='',multivals='',contour_n=100,contour_min='',contour_max='',contour_lines=10,contour_fmt='',xlabel='',ylabel='',
                  xtickrotation='0',b_left='0.1',b_bot='0.1',b_top='0.1',b_right='0.1'):
        measures=m
        params,settings,options,defaults=make_settings_table(dir)
        setting=parse_setting_name(name)

        s=ccm.stats.Stats('%s/%s'%(dir,name))
        
        if x not in options or len(options[x])<=1: x=None
        if y not in options or len(options[y])<=1: y=None
        if multi not in options or len(options[multi])<=1: multi=None
        if xvals is '' and x is not None:
            xvals=';'.join(['%s'%xx for xx in sorted(options[x])])
        if yvals is '' and y is not None:
            yvals=';'.join(['%s'%yy for yy in sorted(options[y])])
        if multivals is '' and multi is not None:
            multivals=';'.join(['%s'%yy for yy in sorted(options[multi])])
        if x is None: xvals=''
        if y is None: yvals=''    
        if multi is None: multivals=''
        
        if measures is None: 
            measures=list(sorted(s.measures()))
            if len(measures)>10: measures=measures[:10]
        if type(measures) is str: measures=[measures]

        imgargs=combine_args(dict(bcount=bcount,conf=conf,x=x,y=y,multi=multi,m=measures,compare=compare,width=width,height=height,dpi=dpi,
                              sortby=sortby,xvals=xvals,yvals=yvals,multivals=multivals,contour_n=contour_n,contour_max=contour_max,contour_min=contour_min,contour_lines=contour_lines,contour_fmt=contour_fmt,
                              xlabel=xlabel,ylabel=ylabel,xtickrotation=xtickrotation,b_top=b_top,b_bot=b_bot,b_left=b_left,b_right=b_right))
        
        f_sort=T.div[
            T.label['Sort by:'],T.input(type='text',name='sortby',value=sortby),
            ]
            
        
        f_ci=T.div[
            T.label['Confidence Interval:'],T.input(type='text',name='conf',value=conf),
            T.label['Bootstrap Samples:'],T.input(type='text',name='bcount',value=bcount),
            ]
        f_compare=T.div[
            T.label['Compare to:'],T.input(type='text',name='compare',value=compare)[''],
            ]
        f_size=T.div[
            T.label['Width:'],T.input(type='text',name='width',value=width),
            T.label['Height:'],T.input(type='text',name='height',value=height),
            T.label['DPI:'],T.input(type='text',name='dpi',value=dpi),
            ]
            
        f_axes=T.div[
            T.label['X-Axis:'],T.select(name='x',onchange='this.form.submit();')[[T.option(**[{},dict(selected='y')][x==None])['---']]+[T.option(**[{},dict(selected='y')][x==k])[k] for k,v in sorted(options.items()) if len(v)>1]],
            T.label['values:'],T.input(type='text',name='xvals',value=[xvals,''][xvals==None]),
            T.br,
            T.label['Y-Axis:'],T.select(name='y',onchange='this.form.submit();')[[T.option(**[{},dict(selected='y')][y==None])['---']]+[T.option(**[{},dict(selected='y')][y==k])[k] for k,v in sorted(options.items()) if len(v)>1]],
            T.label['values:'],T.input(type='text',name='yvals',value=[yvals,''][yvals==None]),
            T.br,
            T.label['Multiline:'],T.select(name='multi',onchange='this.form.submit();')[[T.option(**[{},dict(selected='y')][multi==None])['---']]+[T.option(**[{},dict(selected='y')][multi==k])[k] for k,v in sorted(options.items()) if len(v)>1]],
            T.label['values:'],T.input(type='text',name='multivals',value=[multivals,''][multivals==None]),
            ]    
            
        f_labels=T.div[
            T.label['Label X:'],T.input(type='text',name='xlabel',value=xlabel),
            T.label['Label Y:'],T.input(type='text',name='ylabel',value=ylabel),
            T.label['X-tick rotation:'],T.input(type='text',name='xtickrotation',value=xtickrotation),
            ]
        f_border=T.div[
            T.label['Left:'],T.input(type='text',name='b_left',value=b_left),
            T.label['Right:'],T.input(type='text',name='b_right',value=b_right),
            T.label['Top:'],T.input(type='text',name='b_top',value=b_top),
            T.label['Bottom:'],T.input(type='text',name='b_bot',value=b_bot),
            ]
            
            
        f_contour=T.div()
        if x is not None and y is not None:
            f_contour[T.label['Contour Shading:'],T.input(type='text',name='contour_n',size=5,value=contour_n)]
            f_contour[T.label['Lines:'],T.input(type='text',name='contour_lines',size=5,value=contour_lines)]
            f_contour[T.br]
            f_contour[T.label['Contour Min:'],T.input(type='text',name='contour_min',size=5,value=contour_min)]
            f_contour[T.label['Max:'],T.input(type='text',name='contour_max',size=5,value=contour_max)]
            f_contour[T.label['Format:'],T.input(type='text',name='contour_fmt',size=6,value=contour_fmt)]
                
            
        params=T.table(border=1)    
        row1=T.tr()
        row2=T.tr()
        for k,vv in sorted(options.items()):
            if len(vv)>1:
                row1[T.th[k]]
                values=T.td()
                vvlist=list(sorted([convert_string_to_value(vvv) for vvv in vv]))
                #vvlist=list(sorted(vv))
                for i in range(len(vvlist)):
                    vvv=vvlist[i]
                    sval=setting.get(k,defaults[k])
                    if vvv==convert_string_to_value(sval) or vvv==sval:
                        values[T.b[vvv],T.br]                    
                    else:
                        setting2=dict(setting)
                        setting2[k]=vvv
                        name2=make_setting_name(dir,setting2)
                        values[T.a(href="/graph/%s/%s?%s"%(dir,name2,imgargs))[vvv],T.br]
                row2[values]
        params[row1,row2]
        
        
        
        
        f_measures=T.select(multiple='y',size=20,name='m')
        for m in sorted(s.measures()):
            if m in measures:
                opt=T.option(value=m,selected='y')[m]
            else:
                opt=T.option(value=m)[m]
            f_measures[opt]
        
        src='/graphpng/%s/%s?%s'%(dir,name,imgargs)
        img=T.a(href=src+'&dpi=300')[T.img(src=src,style='float:right')]
        
    
        form=T.form(action="/graph/%s/%s"%(dir,name),method="get")[
            img,
            T.a(href='/stats/%s/%s'%(dir,name))['data'],
            params,
            f_axes,
            f_contour,
            f_measures,T.input(type='submit',value='Recalculate'),
            f_sort,T.br,
            f_ci,T.br,#'N=%d'%s.N,T.br,
            f_compare,T.br,
            f_size,T.br,
            f_labels,T.br,
            f_border,T.br,
            T.input(type='submit',value='Recalculate')            
            ]
    

        return html('%s <small>%s</small>'%(T.a(href='/sim/%s'%dir)[dir],name),form)
예제 #6
0
    def swi_graph(self,
                  dir,
                  name,
                  bcount=100,
                  conf=0.95,
                  x=None,
                  y=None,
                  multi=None,
                  m=None,
                  compare='',
                  sortby='',
                  width=8,
                  height=6,
                  dpi=80,
                  xvals='',
                  yvals='',
                  multivals='',
                  contour_n=100,
                  contour_min='',
                  contour_max='',
                  contour_lines=10,
                  contour_fmt='',
                  xlabel='',
                  ylabel='',
                  xtickrotation='0',
                  b_left='0.1',
                  b_bot='0.1',
                  b_top='0.1',
                  b_right='0.1'):
        measures = m
        params, settings, options, defaults = make_settings_table(dir)
        setting = parse_setting_name(name)

        s = ccm.stats.Stats('%s/%s' % (dir, name))

        if x not in options or len(options[x]) <= 1: x = None
        if y not in options or len(options[y]) <= 1: y = None
        if multi not in options or len(options[multi]) <= 1: multi = None
        if xvals is '' and x is not None:
            xvals = ';'.join(['%s' % xx for xx in sorted(options[x])])
        if yvals is '' and y is not None:
            yvals = ';'.join(['%s' % yy for yy in sorted(options[y])])
        if multivals is '' and multi is not None:
            multivals = ';'.join(['%s' % yy for yy in sorted(options[multi])])
        if x is None: xvals = ''
        if y is None: yvals = ''
        if multi is None: multivals = ''

        if measures is None:
            measures = list(sorted(s.measures()))
            if len(measures) > 10: measures = measures[:10]
        if type(measures) is str: measures = [measures]

        imgargs = combine_args(
            dict(bcount=bcount,
                 conf=conf,
                 x=x,
                 y=y,
                 multi=multi,
                 m=measures,
                 compare=compare,
                 width=width,
                 height=height,
                 dpi=dpi,
                 sortby=sortby,
                 xvals=xvals,
                 yvals=yvals,
                 multivals=multivals,
                 contour_n=contour_n,
                 contour_max=contour_max,
                 contour_min=contour_min,
                 contour_lines=contour_lines,
                 contour_fmt=contour_fmt,
                 xlabel=xlabel,
                 ylabel=ylabel,
                 xtickrotation=xtickrotation,
                 b_top=b_top,
                 b_bot=b_bot,
                 b_left=b_left,
                 b_right=b_right))

        f_sort = T.div[T.label['Sort by:'],
                       T.input(type='text', name='sortby', value=sortby), ]

        f_ci = T.div[T.label['Confidence Interval:'],
                     T.input(type='text', name='conf', value=conf),
                     T.label['Bootstrap Samples:'],
                     T.input(type='text', name='bcount', value=bcount), ]
        f_compare = T.div[
            T.label['Compare to:'],
            T.input(type='text', name='compare', value=compare)[''], ]
        f_size = T.div[T.label['Width:'],
                       T.input(type='text', name='width', value=width),
                       T.label['Height:'],
                       T.input(type='text', name='height', value=height),
                       T.label['DPI:'],
                       T.input(type='text', name='dpi', value=dpi), ]

        f_axes = T.div[
            T.label['X-Axis:'],
            T.select(name='x', onchange='this.form.submit();')[
                [T.option(**[{}, dict(selected='y')][x == None])['---']] + [
                    T.option(**[{}, dict(selected='y')][x == k])[k]
                    for k, v in sorted(options.items()) if len(v) > 1
                ]], T.label['values:'],
            T.
            input(type='text', name='xvals', value=[xvals, ''][xvals == None]),
            T.br, T.label['Y-Axis:'],
            T.select(name='y', onchange='this.form.submit();')[
                [T.option(**[{}, dict(selected='y')][y == None])['---']] + [
                    T.option(**[{}, dict(selected='y')][y == k])[k]
                    for k, v in sorted(options.items()) if len(v) > 1
                ]], T.label['values:'],
            T.
            input(type='text', name='yvals', value=[yvals, ''][yvals == None]),
            T.br, T.label['Multiline:'],
            T.select(name='multi', onchange='this.form.submit();')
            [[T.option(**[{}, dict(selected='y')][multi == None])['---']] + [
                T.option(**[{}, dict(selected='y')][multi == k])[k]
                for k, v in sorted(options.items()) if len(v) > 1
            ]], T.label['values:'],
            T.input(type='text',
                    name='multivals',
                    value=[multivals, ''][multivals == None]), ]

        f_labels = T.div[
            T.label['Label X:'],
            T.input(type='text', name='xlabel', value=xlabel),
            T.label['Label Y:'],
            T.input(type='text', name='ylabel', value=ylabel),
            T.label['X-tick rotation:'],
            T.input(type='text', name='xtickrotation', value=xtickrotation), ]
        f_border = T.div[T.label['Left:'],
                         T.input(type='text', name='b_left', value=b_left),
                         T.label['Right:'],
                         T.input(type='text', name='b_right', value=b_right),
                         T.label['Top:'],
                         T.input(type='text', name='b_top', value=b_top),
                         T.label['Bottom:'],
                         T.input(type='text', name='b_bot', value=b_bot), ]

        f_contour = T.div()
        if x is not None and y is not None:
            f_contour[
                T.label['Contour Shading:'],
                T.input(type='text', name='contour_n', size=5, value=contour_n
                        )]
            f_contour[T.label['Lines:'],
                      T.input(type='text',
                              name='contour_lines',
                              size=5,
                              value=contour_lines)]
            f_contour[T.br]
            f_contour[
                T.label['Contour Min:'],
                T.input(
                    type='text', name='contour_min', size=5, value=contour_min
                )]
            f_contour[
                T.label['Max:'],
                T.input(
                    type='text', name='contour_max', size=5, value=contour_max
                )]
            f_contour[
                T.label['Format:'],
                T.input(
                    type='text', name='contour_fmt', size=6, value=contour_fmt
                )]

        params = T.table(border=1)
        row1 = T.tr()
        row2 = T.tr()
        for k, vv in sorted(options.items()):
            if len(vv) > 1:
                row1[T.th[k]]
                values = T.td()
                vvlist = list(
                    sorted([convert_string_to_value(vvv) for vvv in vv]))
                #vvlist=list(sorted(vv))
                for i in range(len(vvlist)):
                    vvv = vvlist[i]
                    sval = setting.get(k, defaults[k])
                    if vvv == convert_string_to_value(sval) or vvv == sval:
                        values[T.b[vvv], T.br]
                    else:
                        setting2 = dict(setting)
                        setting2[k] = vvv
                        name2 = make_setting_name(dir, setting2)
                        values[T.a(href="/graph/%s/%s?%s" %
                                   (dir, name2, imgargs))[vvv], T.br]
                row2[values]
        params[row1, row2]

        f_measures = T.select(multiple='y', size=20, name='m')
        for m in sorted(s.measures()):
            if m in measures:
                opt = T.option(value=m, selected='y')[m]
            else:
                opt = T.option(value=m)[m]
            f_measures[opt]

        src = '/graphpng/%s/%s?%s' % (dir, name, imgargs)
        img = T.a(href=src + '&dpi=300')[T.img(src=src, style='float:right')]

        form = T.form(
            action="/graph/%s/%s" % (dir, name),
            method="get")[img,
                          T.a(href='/stats/%s/%s' % (dir, name))['data'],
                          params, f_axes, f_contour, f_measures,
                          T.input(type='submit', value='Recalculate'), f_sort,
                          T.br, f_ci, T.br,  #'N=%d'%s.N,T.br,
                          f_compare, T.br, f_size, T.br, f_labels, T.br,
                          f_border, T.br,
                          T.input(type='submit', value='Recalculate')]

        return html(
            '%s <small>%s</small>' % (T.a(href='/sim/%s' % dir)[dir], name),
            form)