Example #1
0
def mypltshow(fnfig, disp='1'):
    #  import pdb;pdb.set_trace(); #for debug
    print('fnfig={}'.format(fnfig))
    #  if fnfig not in ['../../result-chaospred/lorenz1e-8T0.025n10000p256m1_gmp/t0-2000:4300-4800k10N40ns50m2b1a1.0/hh_L1c1.eps',
    #                   '../../result-chaospred/lorenz1e-8T0.025n10000p256m1_gmp/t0-2000:4300-4800k10N40ns50m2b1a1.0/hh_L2c2.eps']:
    plt.savefig(fnfig)
    if disp == '1':
        mylib.myshell("sleep 1;gv " + fnfig + "&")
    plt.close()  #plt.show()
Example #2
0
  else:#args.sql == '0':
#    import pdb;pdb.set_trace(); #for debug
  #  fnq='{}/*'.format(dm)
  #  Fq=[r.split('/')[-1][:-6] for r in glob.glob(fnq)] #file list
#    GK=gaussian_kernel(21)
    it=0
    for r in Ra:
      fnq='{}/*R{}*'.format(dq,r)
      Fq=[(f.split('/')[-1])[:-6] for f in glob.glob(fnq)] #file list
      for i_s,s in enumerate(Sa):
        for d in Da:
          for l in La:
            fn='{}-{}{}'.format(s,d,l) # fn=s +'-'+ d + l
            if not fn in fnerr:
              mylib.myshell('make data-clean')
              if r == '1':
                sm='{}-{}{}-R{}'.format(s,d,l,r) #sm=s +'-'+ d + l + '-R'+ r
                cmd='cp {}/{}-{}{}.dat {}/{}.dat'.format(dn,s,d,l,dr,sm)
              else:
                errflag=1
                while errflag == 1:
                  s2=S[np.random.randint(nS)]
                  d2=D[np.random.randint(nD)]
                  l2=L[np.random.randint(nL)]
                  fn2='{}-{}{}'.format(s2,d2,l2) 
#                  sm='{}-{}{}-{}-{}{}-R{}'.format(s,d,l,s2,d2,l2,r)
                  sm='{}-{}{}-R{}-{}-{}{}'.format(s,d,l,r,s2,d2,l2)
                  if (not fn2 in fnerr) and (not sm in Fq) and (s != s2):
                    errflag=0
#                import pdb;pdb.set_trace(); #for debug
Example #3
0
  print('#start time:{}'.format(datetime.datetime.now()))

#  import pdb;pdb.set_trace(); #for debug
  if args.AF != '_' and args.AF != 'q':
    fbtrain='train_xy'
    AF=map(os.path.expanduser,(args.AF).split(':'))
#    import pdb;pdb.set_trace(); #for debug
    FtrainAF=np.array(pd.read_csv('{}'.format(AF[0]),delim_whitespace=True,dtype=np.float64,header=None))[:,:-1]
    for i in range(1,len(AF)):
      FtrainAF1=np.array(pd.read_csv('{}'.format(AF[i]),delim_whitespace=True,dtype=np.float64,header=None))[:,:-1]
#      import pdb;pdb.set_trace(); #for debug
      FtrainAF=np.concatenate([FtrainAF,FtrainAF1],axis=1)
  #
  for i_m,m in enumerate(M):#machine
    if args.ow == 1:
      mylib.myshell('make data-clean;mkdir -p tmp')
    else:
      print('#No data-cleaned because -ow 0')
    fbtrain='train_xy'
    fbtest='test_xy'
    fntrain='{}.dat'.format(fbtrain)
    fntest='{}.dat'.format(fbtest)
    fptrain=open(fntrain,'w')
    fptest=open(fntest,'w')
    Fall=[]
    Ftrain={}
    Ftest={}
    ytrain=[]
#    import pdb;pdb.set_trace(); #for debug

    if method[0]=='none':#all oob
Example #4
0
 fny = '{}/{}.txt'.format(ddc, fbc)
 Ey = args.Ey
 Sth = args.Sth
 fnlog = 'chaospred2019.log'
 TP0 = map(int, (args.TP0).split(' '))
 N_A = (args.N).split(' ')
 n_seed_A = map(int, (args.n_seed).split(' '))
 phase = args.phase
 ID = args.ID
 ###############
 #####phase 1
 ###############
 k = 10
 if phase == '' or phase == '1':
     mylib.myshell(
         'make data-clean;cat /dev/null>{}/{};cat /dev/null >{}/cmd.sh'.
         format(d0, fnlog, d0))
     for tp0 in TP0:
         mylib.myshell('rm --force lossall.dat tspall.dat tspall_id.dat')
         tp1 = tp0 + 500
         t = '0-{}:{}-{}'.format(tr1, tp0, tp1)
         for iN, N in enumerate(N_A):
             d1 = '{}/t{}k{}{}ID{}'.format(d0, t, k, N, ID)
             mylib.myshell('mkdir -p {}'.format(d1))
             #        import pdb;pdb.set_trace(); #for debug
             for iseed in range(n_seed_A[iN]):
                 cmd = './tspredv3 {} {} mp:1:1:1 DiffMode:0 Hosei:0 {} M:1-1:1 ib:0:0:0:0 rsa:-1:1:1 k:{} y:-18.5:18.5:0:1 g:1.4e-3 w:0.2 T:100 vt:0.5 vr:10 lossall:1 DISP:0 e4t:0 e4p:0 nop:1 seed:{}'.format(
                     fny, t, N_A[iN], k, iseed)
                 print('#Exec {}'.format(cmd))
                 #          import pdb;pdb.set_trace(); #for debug
                 mylib.myshell(cmd)
Example #5
0
            pd.read_csv('{}{}.dat'.format(AF[0], fbtrain),
                        delim_whitespace=True,
                        dtype=np.float64,
                        header=None))[:, :-1]
        for i in range(1, len(AF)):
            FtrainAF1 = np.array(
                pd.read_csv('{}{}.dat'.format(AF[i], fbtrain),
                            delim_whitespace=True,
                            dtype=np.float64,
                            header=None))[:, :-1]
            #      import pdb;pdb.set_trace(); #for debug
            FtrainAF = np.concatenate([FtrainAF, FtrainAF1], axis=1)
    #
    for i_m, m in enumerate(M):  #machine
        if args.ow == 1:
            mylib.myshell('make data-clean;mkdir -p tmp')
        else:
            print('#No data-cleaned because -ow 0')
        fbtrain = 'train_xy'
        fbtest = 'test_xy'
        fntrain = '{}.dat'.format(fbtrain)
        fntest = '{}.dat'.format(fbtest)
        fptrain = open(fntrain, 'w')
        fptest = open(fntest, 'w')
        Fall = []
        Ftrain = {}
        Ftest = {}
        ytrain = []
        #    import pdb;pdb.set_trace(); #for debug

        if method[0] == 'none':  #all oob
Example #6
0
            fnB0='{}-{}{}-R{}'.format(s,d,l,r)
            fnB=''
            for fnq in Fq:
              if fnB0 in fnq:
                fnB=fnq 
#              if fnB0=='fhs-roku7-R0.8-fms-si6-zero2-R0.8':
#                import pdb;pdb.set_trace(); #for debug

            if fnB == '':
              print('#{}*-M.dat does not exist'.format(fnB0))
              continue
            fnout='{}/{}-xyC.dat'.format(dr,fnB)#
            if os.path.exists(fnout) and args.ow == 0:
              print('#{} exists: Omit calc becaus -ow 0'.format(fnout))
              continue
#              cmd0='fnB:"{}/{}";load("M2xyC.mac");'.format(dr,fnB);
#              import pdb;pdb.set_trace(); #for debug
            cmd='echo {}fnB:"{}/{}";batchload("M2PC.mac");{}|maxima'.format("'",dr,fnB,"'")
#            cmd='echo {}fnB:"{}/{}";batchload("M2pc.mac");{}|maxima'.format("'",dr,fnB,"'")
#            cmd='echo {}fnB:"{}/{}";batchload("M2xyC.mac");{}|maxima >tmp/tmp.log'.format("'",dr,fnB,"'")
#            cmd='echo {}fnB:"{}/{}";batch("M2xyC.mac");{}|maxima -b >/dev/null'.format("'",dr,fnB,"'")
            #cmd='maxima < M2xyC.mac' #read tmp/M.dat produce tmp/xyC.dat
            print('#{}'.format(cmd))
            mylib.myshell(cmd);
            import pdb;pdb.set_trace(); #for debug 20191105
          it += 1
          if args.stopi>0 and it==args.stopi:
            import pdb;pdb.set_trace(); #for debug 20191105
#              import pdb;pdb.set_trace(); #for debug
#                import pdb;pdb.set_trace(); #for debug
Example #7
0
def mypltshow(fnfig, disp=1):
    plt.savefig(fnfig)
    if disp == 1:
        mylib.myshell("sleep 1;gv " + fnfig + "&")
    plt.close()  #plt.show()
Example #8
0
                                            not sm in Fq) and (s != s2):
                                        errflag = 0
#                import pdb;pdb.set_trace(); #for debug
                                dmsm = '{}/{}.dat'.format(dm, sm)
                                cmd = 'python speechmix.py -y0 {}/{}-{}{}.dat -y1 {}/{}-{}{}.dat -r {} > {}'.format(
                                    dn, s, d, l, dn, s2, d2, l2, r, dmsm)
#              dmsm='{}/{}.dat'.format(dm,sm)
#              if os.path.exists(fnout) and args.ow == 0:
#              import pdb;pdb.set_trace(); #for debug
                            if not os.path.exists(
                                    os.path.expanduser(dmsm)) or (
                                        os.path.exists(
                                            os.path.expanduser(dmsm))
                                        and args.ow[0] == '1'):
                                print('#mixR_y.py:L142 {}'.format(cmd))
                                mylib.myshell(cmd)  #speechmix.py
                            else:
                                print('#{} exists: Omit calc because ow=="1?"'.
                                      format(dmsm, args.ow))
##
                            fnout = '{}/{}-M.dat'.format(
                                dr, sm, args.k, args.l)
                            #              import pdb;pdb.set_trace(); #for debug
                            if os.path.exists(os.path.expanduser(
                                    fnout)) and args.ow[1] == '0':
                                print('#{} exists: Omit calc because ow=="?0"'.
                                      format(fnout))
                                continue
    elapsed_time = time.time() - start_time
    etime = 'ElapsedTime {:.3f}s({})'.format(
        elapsed_time,
Example #9
0
                            continue
                        fnout = '{}/{}-PC.dat'.format(dr, fnB)  #
                        if os.path.exists(fnout) and args.ow == 0:
                            print('#{} exists: Omit calc becaus -ow 0'.format(
                                fnout))
                            continue
#              cmd0='fnB:"{}/{}";load("M2xyC.mac");'.format(dr,fnB);
#              import pdb;pdb.set_trace(); #for debug
                        cmd = 'echo {}fnB:"{}/{}";batchload("M2PC.mac");{}|maxima'.format(
                            "'", dr, fnB, "'")
                        #            cmd='echo {}fnB:"{}/{}";batchload("M2pc.mac");{}|maxima'.format("'",dr,fnB,"'")
                        #            cmd='echo {}fnB:"{}/{}";batchload("M2xyC.mac");{}|maxima >tmp/tmp.log'.format("'",dr,fnB,"'")
                        #            cmd='echo {}fnB:"{}/{}";batch("M2xyC.mac");{}|maxima -b >/dev/null'.format("'",dr,fnB,"'")
                        #cmd='maxima < M2xyC.mac' #read tmp/M.dat produce tmp/xyC.dat
                        print('#{}'.format(cmd))
                        mylib.myshell(cmd)
                        print('#{}-PC.dat created'.format(fnB))
#            import pdb;pdb.set_trace(); #for debug 20191105
                    sys.stdout.flush()
                    it += 1
                    if args.dbgi > 0 and it == args.dbgi:
                        print('### Now in debug mode')
                        import pdb
                        pdb.set_trace()
                        #for debug 20191105
#              import pdb;pdb.set_trace(); #for debug
#                import pdb;pdb.set_trace(); #for debug
    elapsed_time = time.time() - start_time
    etime = 'ElapsedTime {:.3f}s({})'.format(
        elapsed_time,
        str(datetime.timedelta(seconds=elapsed_time))[:-3])
Example #10
0
    else:  #args.sql == '0':
        #    import pdb;pdb.set_trace(); #for debug
        #  fnq='{}/*'.format(dm)
        #  Fq=[r.split('/')[-1][:-6] for r in glob.glob(fnq)] #file list
        #    GK=gaussian_kernel(21)
        it = 0
        for r in Ra:
            fnq = '{}/*R{}*'.format(dq, r)
            Fq = [(f.split('/')[-1])[:-6] for f in glob.glob(fnq)]  #file list
            for i_s, s in enumerate(Sa):
                for d in Da:
                    for l in La:
                        fn = '{}-{}{}'.format(s, d, l)  # fn=s +'-'+ d + l
                        if not fn in fnerr:
                            mylib.myshell('make data-clean')
                            if r == '1':
                                sm = '{}-{}{}-R{}'.format(
                                    s, d, l, r)  #sm=s +'-'+ d + l + '-R'+ r
                                cmd = 'cp {}/{}-{}{}.dat {}/{}.dat'.format(
                                    dn, s, d, l, dm, sm)
                            else:
                                errflag = 1
                                while errflag == 1:
                                    s2 = S[np.random.randint(nS)]
                                    d2 = D[np.random.randint(nD)]
                                    l2 = L[np.random.randint(nL)]
                                    fn2 = '{}-{}{}'.format(s2, d2, l2)
                                    #                  sm='{}-{}{}-{}-{}{}-R{}'.format(s,d,l,s2,d2,l2,r)
                                    sm = '{}-{}{}-R{}-{}-{}{}'.format(
                                        s, d, l, r, s2, d2, l2)
Example #11
0
def mypltshow(fnfig,disp='1'):
  plt.savefig(fnfig);
  if disp=='1':
    mylib.myshell("sleep 1;gv "+fnfig+"&");
  plt.close() #plt.show()
Example #12
0
    nS = len(S)
    nL = len(L)
    nT = len(T)
    nRX = len(RX) if RX[0] != '0' else 0
    #  import pdb;pdb.set_trace(); #for debug
    argv = sys.argv
    cmd = ''
    for a in argv:  #  for i,a in enumerate(argv):
        cmd += a + ' '
    print('#start:python {}'.format(cmd))

    start_time = time.time()
    print('#start time:{}'.format(datetime.datetime.now()))
    for i_m, m in enumerate(M):  #machine
        if args.ow == 1:
            mylib.myshell('make data-clean;mkdir -p tmp')
        else:
            print('#No data-cleaned because -ow 0')
        fntrain = 'train_xy'
        fntest = 'test_xy'
        fptrain = open(fntrain + '.dat', 'w')
        fptest = open(fntest + '.dat', 'w')
        Fall = []
        Ftrain = {}
        Ftest = {}
        ytrain = []
        #    import pdb;pdb.set_trace(); #for debug
        if nRX == 0:  #all oob
            for i_r, r in enumerate(R):
                for i_v, v in enumerate(V):
                    fnq = '{}/*{}*-R{}*-{}.dat'.format(