示例#1
0
def main():
    all_traits = []
    dirs = ['SUBJECTS_LEFT', 'SUBJECTS_RIGHT', 'SUBJECTS_MERGED']
    for d in dirs:
        f = [f for f in os.listdir(d) if st(f)[1] == '.dat'][0]
        df = pd.read_table(pj(d, f), sep=' ', na_values=',,,')
        traits = ['%s__%s' % (t, m) for m in df.columns[1:] for t in df.ix[:, 0]]
        all_traits += traits
    df = pd.read_csv('overall_traits.csv')
    df['idx'] = df.trait.apply(lambda x: x.replace('_dot_', '.').replace('_dash_', '-').lstrip('n_'))
    df = df.drop('trait', axis=1).drop_duplicates(subset='idx').set_index('idx')
    df.to_csv('results.csv')
    print '---'
    j = 0
    for i in all_traits:
        if i not in df.index.tolist():
            print 'n_' + i.replace('.', '_dot_').replace('-', '_dash_')
            j += 1
    print j
import cmd, subprocess, sys, logging
from sympy import *
from os.path import splitext as st

logging.basicConfig(filename=st(__file__)[0] + '.log', level=logging.DEBUG)

class PyWayShell(cmd.Cmd):
    intro = "Benvenuto :) Digita help o ? per vedere l'elenco dei comandi.\n"
    prompt = '>> '

    def __init__(self):
        cmd.Cmd.__init__(self)
        self.namespace = {}

    def do_quit(self, line):
        """Esce dal programma."""
        print("\nGrazie per aver usato pyWayShell :)")
        sys.exit(1)

    def do_shell(self, line):
        """Esegue il comando nella shell di sistema."""
        try:
            subprocess.call(line, timeout=5, shell=True)
        except subprocess.TimeoutExpired:
            print('Il processo non è terminato nel timeout stabilito')

    def emptyline(self):    
        """Non fare nulla se la linea e' vuota"""
        pass

    def do_EOF(self, line):
示例#3
0
import cmd, subprocess, sys, logging
from sympy import *
from os.path import splitext as st

logging.basicConfig(filename=st(__file__)[0] + '.log', level=logging.DEBUG)


class PyWayShell(cmd.Cmd):
    intro = "Benvenuto :) Digita help o ? per vedere l'elenco dei comandi.\n"
    prompt = '>> '

    def __init__(self):
        cmd.Cmd.__init__(self)
        self.namespace = {}

    def do_quit(self, line):
        """Esce dal programma."""
        print("\nGrazie per aver usato pyWayShell :)")
        sys.exit(1)

    def do_shell(self, line):
        """Esegue il comando nella shell di sistema."""
        try:
            subprocess.call(line, timeout=5, shell=True)
        except subprocess.TimeoutExpired:
            print('Il processo non è terminato nel timeout stabilito')

    def emptyline(self):
        """Non fare nulla se la linea e' vuota"""
        pass
示例#4
0
        plt.subplots_adjust(wspace=0.4)
        anim3 = amp.Animation([arrows, blocks, average_blocks], timeline2)
        anim3.timeline_slider(text='ICYCLE', valfmt='%d')

        anim3.save_gif(output_filename)


if __name__ == '__main__':
    import argparse
    from os.path import splitext as st
    parser = argparse.ArgumentParser(description='DAT files -> gif')
    parser.add_argument('query', help='DAT files query')
    parser.add_argument('-o', help='output_filename', default='sample.gif')
    parser.add_argument('-mt', '--make_average_temp', action='store_true')
    parser.add_argument('-mto',
                        help='mt_output_filename',
                        default='average_temp.gif')
    parser.add_argument('-f', '--fps', type=int, default=10)
    args = parser.parse_args()

    converter = dat(args.query)
    converter.save_gif(output_filename=st(args.o)[0],
                       vmin=-0.5,
                       vmax=0.5,
                       dpi=150,
                       fps=args.fps)
    if args.make_average_temp:
        converter.make_average_temp(dpi=150,
                                    fps=args.fps,
                                    output_filename=st(args.mto)[0])