Ejemplo n.º 1
0
    def index_bar(self,url,key,max):
        value=int(getattr(self,key))
        indexbar=T.div()
        d=dict()        
        if value>0:
            d[key]=value-1
            indexbar[T.a(href='%s?%s'%(url,self.url_args(**d)))['<<'],' ']
        else:
            indexbar['<<',' ']
            
        
        for i in range(max):
            if i!=value:
                d[key]=i
                indexbar[T.a(href='%s?%s'%(url,self.url_args(**d)))[i],' ']
            else:
                indexbar[i,' ']

        if value<max-1:
            d[key]=value+1
            indexbar[T.a(href='%s?%s'%(url,self.url_args(**d)))['>>']]
        else:
            indexbar['>>']

        return indexbar
Ejemplo n.º 2
0
def html(title,text):
    return T.html[
              T.head[T.title["Model Explorer: %s"%title]],
              T.body[
                T.h1[title],
                T.hr,
                text,
                T.hr,
                T.a(href='/')['home']]]
Ejemplo n.º 3
0
def html(title,text):
    return T.html[
              T.head[T.title["CCMSuite: %s"%title]],
              T.body[
                T.h1[title],
                T.hr,
                text,
                T.hr,
                T.a(href='/')['home']]]
Ejemplo n.º 4
0
 def index_config(self):
     return T.div[
         T.input(type='hidden',name='index',value=self.index),
         T.div[
             T.label['X-axis scale:'],T.input(type='text',name='dt',value=self.dt),
             ],
         T.div[
             T.label['Plot Color:'],T.input(type='text',name='line_color',value=self.line_color),
             T.label['Thickness:'],T.input(type='text',name='line_thickness',value=self.line_thickness),
             ],
         T.div[
             T.label['Other Run Color:'],T.input(type='text',name='other_color',value=self.other_color),
             T.label['Thickness:'],T.input(type='text',name='other_thickness',value=self.other_thickness),
             ],
         T.div[
             T.label['Overlay:'],T.input(type='text',name='overlay',value=self.overlay),
             T.label['Scale:'],T.input(type='text',name='overlay_scale',value=self.overlay_scale),
             T.label['Color:'],T.input(type='text',name='overlay_color',value=self.overlay_color),
             T.label['Thickness:'],T.input(type='text',name='overlay_thickness',value=self.overlay_thickness),
             ],
         ]
Ejemplo n.º 5
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)
Ejemplo n.º 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=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)
Ejemplo n.º 7
0
    def swi_rawdata(self,dir,name,measure,**keys):
        s=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)
Ejemplo n.º 8
0
 def swi_stats(self,dir,name,bcount=100,conf=0.95):
 
     form=T.form(action="/stats/%s/%s"%(dir,name),method="get")[
         T.label['Confidence Interval:'],T.input(type='text',name='conf',value=conf),
         T.label['Bootstrap Samples:'],T.input(type='text',name='bcount',value=bcount),
         T.input(type='submit',value='Recalculate')
         ]
         
     s=stats.Stats('%s/%s'%(dir,name))
     
     statistics=['mean','median','sd']
     
     table=T.table()
     row=T.tr[T.th['']]
     for stat in statistics:
         row[T.th(colspan='3')[stat]]
     row[T.th]    
     table[row]    
     row=T.tr[T.th['measure']]
     for stat in statistics:
         row[T.th['low'],T.th['sample'],T.th['high']]
     row[T.th]    
     table[row]    
     for m in sorted(s.measures()):
         sm=s.measure(m)
         row=T.tr[T.td[m]]
         for stat in statistics:
             data=sm.get_stat(stat,int(bcount),float(conf))
             
             if data is None:
                 row[T.td(),T.td(),T.td()]
             else:
                 if data[1][0] is None: row[T.td()]
                 else: row[T.td(bgcolor='#EEEEEE')['%f'%data[1][0]]]
                 if data[0] is None: row[T.td()]
                 else: row[T.td(bgcolor='#CCCCCC')['%f'%data[0]]]
                 if data[1][1] is None: row[T.td()]
                 else:row[T.td(bgcolor='#AAAAAA')['%f'%data[1][1]]]                    
         row[T.td[T.a(href='/rawdata/%s/%s/%s'%(dir,name,m))['raw data']]]        
         table[row]    
     
     return html('%s <small>%s</small>'%(T.a(href='/sim/%s'%dir)[dir],name),T.div[T.a(href='/graph/%s/%s'%(dir,name))['graph'],T.br,form,'N=%d'%s.N,table])#,iframe])
Ejemplo n.º 9
0
 def swi(self):
     dirs=T.ul()
     for d in find_directories():
         dirs[T.li[T.a(href='sim/%s'%d)[d]]]
     return html('Simulations',dirs)
Ejemplo n.º 10
0
 def plot_axis_config(self):
     return T.div[
         T.div[
             T.label['Width:'],T.input(type='text',name='width',value=self.width),
             T.label['Height:'],T.input(type='text',name='height',value=self.height),
             T.label['DPI:'],T.input(type='text',name='dpi',value=self.dpi),
             ],
         T.div[
             T.label['Label X:'],T.input(type='text',name='xlabel',value=self.xlabel),
             T.label['Label Y:'],T.input(type='text',name='ylabel',value=self.ylabel),
             T.label['X-tick rotation:'],T.input(type='text',name='xtickrotation',value=self.xtickrotation),
             ],
         T.div[
             T.label['X Limits:'],T.input(type='text',name='xlim',value=self.xlim),
             T.label['Y Limits:'],T.input(type='text',name='ylim',value=self.ylim),
             ],
         T.div[
             T.label['Left:'],T.input(type='text',name='b_left',value=self.b_left),
             T.label['Right:'],T.input(type='text',name='b_right',value=self.b_right),
             T.label['Top:'],T.input(type='text',name='b_top',value=self.b_top),
             T.label['Bottom:'],T.input(type='text',name='b_bot',value=self.b_bot),
             ],
         ]