Package qubx :: Module fitness
[hide private]
[frames] | no frames]

Source Code for Module qubx.fitness

  1  """Top level of the application QUB Express. 
  2   
  3  Copyright 2008-2012 Research Foundation State University of New York  
  4  This file is part of QUB Express.                                           
  5   
  6  QUB Express is free software; you can redistribute it and/or modify           
  7  it under the terms of the GNU General Public License as published by  
  8  the Free Software Foundation, either version 3 of the License, or     
  9  (at your option) any later version.                                   
 10   
 11  QUB Express is distributed in the hope that it will be useful,                
 12  but WITHOUT ANY WARRANTY; without even the implied warranty of        
 13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         
 14  GNU General Public License for more details.                          
 15   
 16  You should have received a copy of the GNU General Public License,    
 17  named LICENSE.txt, in the QUB Express program directory.  If not, see         
 18  <http://www.gnu.org/licenses/>.                                       
 19   
 20   
 21  """ 
 22   
 23  #!/usr/bin/env python 
 24   
 25  # before top-level imports: 
 26  import uuid # glibc bug, needs first in some linuxes 
 27  import gobject 
 28  import multiprocessing 
 29  import os 
 30  import sys 
 31   
 32  QUBX_HOME_PATH = os.path.expanduser('~/.fitness') 
 33  APPNAME = 'Fitness' 
 34   
35 -class StdNull(object):
36 - def write(*args, **kw):
37 pass
38 actual_stdout, actual_stderr = sys.stdout, sys.stderr 39 sys.stdout, sys.stderr = StdNull(), StdNull() 40 41 multiprocessing.freeze_support() 42 gobject.threads_init() 43 44 import qubx.splash_main 45 qubx.splash_main.show_splash('Loading %s...' % APPNAME) 46 47 import qubx.tree 48 qubx.tree.CHOOSE_FLAVOR('numpy') 49 50 # top-level utilities and global imports: 51 from qubx.cube import * 52 53 VERSION = "3.5.0" 54 QUBX_VERSION = qubx.global_namespace.QUBX_VERSION = VERSION 55
56 -class FitnessApp(App):
57 - def setup_about(self):
58 try: 59 readme = open(os.path.join(qubx.global_namespace.app_path, 'README_Fitness.txt'), 'r').read() 60 except: 61 readme = """ Fitness 62 63 """ 64 try: 65 changelog = open(os.path.join(qubx.global_namespace.app_path, 'Fitness_change_log.txt'), 'r').read() 66 except: 67 traceback.print_exc() 68 changelog = '\n(no change log found)\n' 69 try: 70 license = open(os.path.join(qubx.global_namespace.app_path, 'LICENSE.txt'), 'r').read() 71 except: 72 license = "" 73 self.cube.Tools.About.set_text(readme + changelog + license)
74 75 76 77 78 if __name__ == '__main__': 79 run_me_first() 80 81 parser = argparse.ArgumentParser() 82 parser.add_argument("-t", "--trace", dest="trace", 83 action="store_true", 84 default=False, 85 help="prints line-by-line trace for debug") 86 parser.add_argument("-s", "--startup-script", dest="startup_script", 87 action="store", default="", 88 help="on startup, executes a python file") 89 (args, extras) = parser.parse_known_args() 90 qubx.global_namespace.args = args 91 qubx.global_namespace.extras = extras 92 qubx.global_namespace.unknown_args = extras 93 qubx.global_namespace.DEBUG = DEBUG = False 94 95 if args.trace: 96 qubx.global_namespace.DEBUG = DEBUG = True 97 tracelog = open('/dev/shm/trace', 'w')
98 - def traceit(frame, event, arg):
99 if event == "line": 100 lineno = frame.f_lineno 101 filename = frame.f_globals["__file__"] 102 if filename == "<stdin>": 103 filename = "<stdin> " 104 if (filename.endswith(".pyc") or 105 filename.endswith(".pyo")): 106 filename = filename[:-1] 107 name = frame.f_globals["__name__"] 108 line = linecache.getline(filename, lineno) 109 tracelog.write("%s:%s: %s\n" % (name, lineno, line.rstrip())) 110 tracelog.flush() 111 return traceit
112 sys.settrace(traceit) 113 114 try:
115 - def adjust_layout(cube):
116 # move Charts to top-level, above Tables 117 Charts = cube.Figures.Charts 118 cube.Figures.remove_face(cube.Figures.index('Charts')) 119 Charts.face_name = ' Charts' 120 cube.Layout.insert_face(2, Charts) 121 cube.Charts = Charts 122 cube.Figures.Charts = Charts # so qub express style scriptable commands work 123 cube.show_charts = lambda: cube.Charts.request_show() 124 cube.Layout.show_face(' Data', False) 125 cube.Layout.show_face(' Other', False) 126 cube.Figures.Charts = cube.Charts = Charts 127 # hide sidebar unless data is showing 128 cube.tasks_info_log.hide() 129 def show_sidebar_with_data(layout, face, showing): 130 if face == cube.Data: 131 if showing: 132 cube.tasks_info_log.show() 133 else: 134 cube.tasks_info_log.hide()
135 cube.Layout.OnToggleFace += show_sidebar_with_data # no Reffer needed for toplevel fns 136 gobject.idle_add(cube.Tables.show_table, cube.Data.table) 137 138 app = FitnessApp(APPNAME, VERSION, '.fitness3', has_modeling=False, DEBUG=DEBUG, codename='fitness', adjust_layout=adjust_layout) 139 app.main(startup_script=args.startup_script or os.path.join(qubx.pyenv.env.folder, 'startup_script.py')) 140 except KeyboardInterrupt: 141 pass # quit like they want 142 except Exception, e: 143 dlg = gtk.MessageDialog(None, buttons=gtk.BUTTONS_OK, 144 flags=gtk.DIALOG_MODAL, 145 message_format = traceback.format_exc()) 146 dlg.run() 147 dlg.destroy() 148 149 run_me_last() 150 151 152 153 # readme 154 # web stuff 155 156 157 # future: 158 159 # CurveFit segments together: reset ODEs to t0 160 161 # bkg sub (kalman) 162 163 # user nominate "independent" columns? 164 # file list? 165 # graceful degradation without libqubfast (resample, draw data, lmmin)? 166 # histogram display mode? Open Histogram? sharing space in Charts (Select)? 167 # shortcuts to e.g. residuals? 168 # opt. to put Charts fit curve into table? 169 # interactive textfile reading (delimiter, decimal comma, x column, ...)? 170 # CurveFit segments together: capture separate ssr? 171 172 ## Notebook 173 # Targets: 174 # UNO 175 # xmeans web app? 176 # min/max image dim? 177 178 ## Plugin 179 # api guide and regularization 180 # samples and skeletons 181 182 183 ## Release 184 # update the welcome message 185 # update the wiki 186 # update the videos 187 # update the docstrings 188 # write out more math 189 190 191 ## ... 192