当前位置: 首页>>代码示例>>Python>>正文


Python Matlab.run_func方法代码示例

本文整理汇总了Python中pymatbridge.Matlab.run_func方法的典型用法代码示例。如果您正苦于以下问题:Python Matlab.run_func方法的具体用法?Python Matlab.run_func怎么用?Python Matlab.run_func使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymatbridge.Matlab的用法示例。


在下文中一共展示了Matlab.run_func方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: start_mlab

# 需要导入模块: from pymatbridge import Matlab [as 别名]
# 或者: from pymatbridge.Matlab import run_func [as 别名]
def start_mlab():
    dir_path = os.path.dirname(os.path.realpath(__file__))
    dir_list = ['/HHT_MATLAB_package', '/HHT_MATLAB_package/EEMD',
                '/HHT_MATLAB_package/checkIMFs', '/HHT_MATLAB_package/HSA']
    mlab = Matlab()
    mlab.start()
    for d in dir_list:
        res = mlab.run_func('addpath', dir_path + d)
    return mlab
开发者ID:HHTpy,项目名称:HHTpywrapper,代码行数:11,代码来源:matlab.py

示例2: network_hill

# 需要导入模块: from pymatbridge import Matlab [as 别名]
# 或者: from pymatbridge.Matlab import run_func [as 别名]
def network_hill(panel, prior_graph=[], lambdas=[], max_indegree=3, reg_mode='full', stdise=1, silent=0, maxtime=120):
    '''
    run_hill(panel)

    input: dataframe
    should be a T x N dataframe with T time points and N samples.

    output: dict containing key 'e' and key 'i' from Hill's code
    '''
    from scipy.io import savemat
    from scipy.io import loadmat

    # start matlab
    mlab = Matlab(maxtime=maxtime)
    mlab.start()

    # .mat shuttle files
    # add path check
    inPath = os.path.join('..', 'cache', 'dbn_wrapper_in.mat')
    outPath = os.path.join('..', 'cache', 'dbn_wrapper_out.mat')
    
    D = np.transpose(panel.values)
    num_rows = np.shape(D)[0]
    num_cols = np.shape(D)[1]
    D = np.reshape(D, (num_rows, num_cols, 1))
    
    #D = np.transpose(panel, (2,1,0))
    

    # save the matlab object that the DBN wrapper will load
    # contains all the required parameters for the DBN code
    savemat(inPath, {"D" : D,
                     "max_indegree" : max_indegree,
                     "prior_graph" : prior_graph,
                     "lambdas" : lambdas,
                     "reg_mode" : reg_mode,
                     "stdise" : stdise,
                     "silent" : silent})

    # DBN wrapper just needs an input and output path
    args = {"inPath" : inPath, "outPath" : outPath}

    # call DBN code
    res = mlab.run_func('dbn_wrapper.m', args, maxtime=maxtime)

    mlab.stop()

    out = loadmat(outPath)
    
    edge_prob = pd.DataFrame(out['e'], index=panel.columns, columns=panel.columns)
    edge_sign = pd.DataFrame(out['i'], index=panel.columns, columns=panel.columns)
    
    #edge_prob = out['e']
    #edge_sign = out['i']

    return (edge_prob, edge_sign)
开发者ID:szairis,项目名称:DREAM8,代码行数:58,代码来源:models.py

示例3: fix_model

# 需要导入模块: from pymatbridge import Matlab [as 别名]
# 或者: from pymatbridge.Matlab import run_func [as 别名]
 def fix_model(self, W, intMat, drugMat, targetMat, seed=None):
     R = W*intMat
     drugMat = (drugMat+drugMat.T)/2
     targetMat = (targetMat+targetMat.T)/2
     mlab = Matlab()
     mlab.start()
     # print os.getcwd()
     # self.predictR = mlab.run_func(os.sep.join([os.getcwd(), "kbmf2k", "kbmf.m"]), {'Kx': drugMat, 'Kz': targetMat, 'Y': R, 'R': self.num_factors})['result']
     self.predictR = mlab.run_func(os.path.realpath(os.sep.join(['../kbmf2k', "kbmf.m"])), {'Kx': drugMat, 'Kz': targetMat, 'Y': R, 'R': self.num_factors})['result']
     # print os.path.realpath(os.sep.join(['../kbmf2k', "kbmf.m"]))
     mlab.stop()
开发者ID:hansaimlim,项目名称:PyDTI,代码行数:13,代码来源:kbmf.py

示例4: plot_deltahist

# 需要导入模块: from pymatbridge import Matlab [as 别名]
# 或者: from pymatbridge.Matlab import run_func [as 别名]
def plot_deltahist(fileName1, fileName2):

    prog = find_executable('matlab')
    if not prog:
        sys.exit("Could not find MATLAB on the PATH. Exiting...")
    else:
        print("Found MATLAB in "+prog) 

    mlab = Matlab(executable=prog)
    mlab.start()
    results = mlab.run_func('./plot_deltahist.m', {'arg1': fileName1, 'arg2': fileName2})
    mlab.stop()
开发者ID:asarhegyi,项目名称:adcpp,代码行数:14,代码来源:testbench.py

示例5: objective_function

# 需要导入模块: from pymatbridge import Matlab [as 别名]
# 或者: from pymatbridge.Matlab import run_func [as 别名]
    def objective_function(self, x):
        '''
        matlabpath: we need the path to matlab since we need to run it.
        
        IMPORTANT: walker_simulation.m must be included in the 
        WGCCM_three_link_walker_example file in order to work. 
        So simply modify the path below.
        '''
		mlab = Matlab(executable= matlabpath)
		mlab.start()
		output = mlab.run_func(os.path.join(self.matlab_code_directory, 'walker_simulation.m'), 
						   {'arg1': x[:, 0],'arg2': x[:, 1],'arg3': x[:, 2],
						   'arg4': x[:, 3],'arg5':x[:, 4],'arg6': x[:, 5],
						   'arg7': x[:, 6],'arg8': x[:, 7],'arg9': self.num_steps})
						   

		answer = output['result']
		simul_output = answer['speed']
		mlab.stop()
开发者ID:aaronkl,项目名称:RoBO,代码行数:21,代码来源:walker.py

示例6: Matlab

# 需要导入模块: from pymatbridge import Matlab [as 别名]
# 或者: from pymatbridge.Matlab import run_func [as 别名]
randType = 2
checksignal = 1

##
data = np.loadtxt(filename)
time = data[:, 0]
amp = data[:, 1]
dt = time[1] - time[0]

##
mlab = Matlab()
mlab.start()
mlab.run_code('addpaths')

# Fast EEMD
res = mlab.run_func('feemd_post_pro', amp, Nstd, NE, numImf, runCEEMD, maxSift,
                    typeSpline, toModifyBC, randType, seedNo, checksignal)
imfs = res['result']


# Orthogonality Checking
oi = mlab.run_func('ratio1', imfs)
oi_pair = mlab.run_func('ratioa', imfs)
print('Non-orthogonal leakage of components:')
print(oi['result'])
print('Non-orthogonal leakage for pair of adjoining components:')
print(oi_pair['result'])

# Hilbert Transform
fa_res = mlab.run_func('fa', imfs[:, 3], dt, 'hilbtm', 'pchip', 0, nargout=2)
fa = fa_res['result']
ifreq = np.transpose(fa[0])
开发者ID:YihaoSu,项目名称:HHTpywrapper,代码行数:34,代码来源:main1d.py

示例7: Matlab

# 需要导入模块: from pymatbridge import Matlab [as 别名]
# 或者: from pymatbridge.Matlab import run_func [as 别名]
#  Parameters Setting
filename = "./Input_data/example_lena.png"
npixs = 512
Nstd = 0.4
NE = 20
seedNo = 1
numImf = 6
runCEEMD = 1
maxSift = 10
typeSpline = 2
toModifyBC = 1
randType = 2
checksignal = 1

##
mlab = Matlab()
mlab.start()
mlab.run_code("addpaths")

# Fast 2dEEMD
res = mlab.run_func(
    "meemd", filename, npixs, Nstd, NE, numImf, runCEEMD, maxSift, typeSpline, toModifyBC, randType, seedNo, checksignal
)
imfs = res["result"]

# Plot Results
HHTplots.example_lena(filename, imfs)

mlab.stop()
开发者ID:YihaoSu,项目名称:HHTpywrapper,代码行数:31,代码来源:main2d.py

示例8: Matlab

# 需要导入模块: from pymatbridge import Matlab [as 别名]
# 或者: from pymatbridge.Matlab import run_func [as 别名]
import pymatbridge
from pymatbridge import Matlab

# Initialise MATLAB
mlab = Matlab()

# Start the server
mlab.start()
# Run a test function: just adds 1 to the argument a
res = []
for i in range(5):
     res.append(mlab.run_func('demo_func.m', {'a': i})['result'])
     print res[-1]

# test the JSON parsing.
# quotes, and \n
res.append(mlab.run_code('fprintf(1,char([34,104,105,34,10]));'))
print res[-1]
# \b, \n
res.append(mlab.run_code('fprintf(1,char([8,10]));'))
print res[-1]
# \f, \n
res.append(mlab.run_code('fprintf(1,char([12,10]));'))
print res[-1]
# \r, \n
res.append(mlab.run_code('fprintf(1,char([13,10]));'))
print res[-1]
# \t, \n
res.append(mlab.run_code('fprintf(1,char([9,10]));'))
print res[-1]
# \\, \n
开发者ID:bambooeater,项目名称:python-matlab-bridge,代码行数:33,代码来源:test.py

示例9: len

# 需要导入模块: from pymatbridge import Matlab [as 别名]
# 或者: from pymatbridge.Matlab import run_func [as 别名]
mlab.start()
N = len(samples)
involved = [[] for _ in range(N)]
row = 0
for i in range(N):
    for j in range(i+1, N):
        involved[i].append(row)
        involved[j].append(row)
        row += 1
rows = set(range(row))
notinvolved = [list(rows.difference(_)) for _ in involved]
dsts = np.zeros((len(samples), 2))
thetas = np.zeros((len(samples), 31))
i = 0
for train_row, test_row in zip(notinvolved, involved):
    res = mlab.run_func('optimize_weights.m', {'A': A[train_row, :].tolist()})
    x = np.array(res['result'])
    dsts[i, :] = [np.linalg.norm(np.dot(A[test_row, :], x)),
                  np.linalg.norm(np.dot(A[test_row, :], theta))]
    thetas[i, :] = x.ravel()
    i += 1

s = clock()
res = mlab.run_func('optimize_weights.m',
                    {'A': A.tolist(), 'involved': involved,
                     'notinvolved': notinvolved})
clock() - s

mlab.stop()
dsts = np.array(res['result']['distances'])
thetas = np.array(res['result']['thetas'])
开发者ID:daureg,项目名称:illalla,代码行数:33,代码来源:learn_weights.py

示例10: backtest

# 需要导入模块: from pymatbridge import Matlab [as 别名]
# 或者: from pymatbridge.Matlab import run_func [as 别名]
def backtest(filename, data, schedule_data):
  f = open(filename)
  f.readline()
  player_data = {}
  time_data = []
  for i in xrange(50):
    line = f.readline()
    if line is None or len(line) == 0:
      break
    date = int(line[:3])
    print date
    jsonvalue = "{"+f.readline()+"}"
    value = json.loads(jsonvalue)
    time_data.insert(0,(date,value))
    for p in value:
      if not p in player_data:
        player_data[p] = [0]
      player_data[p].insert(0,value[p])

  time_data2 = convertToPlayersTimeData(time_data, data)

  teams = set([i.team for i in data])

  for i in xrange(len(time_data2)):
    stamp_data = time_data2[i][1]
  Tracer()()
  portfolio = ["rohit sharma", "ajinkya rahane", "david warner", "glenn maxwell", "robin uthappa", "shane watson", "sandeep sharma", "sunil narine", "pravin tambe", "yuzvendra chahal", "bhuvneshwar kumar"]
  # portfolio = ["yuzvendra chahal", "shakib al hasan", "shane watson", "rohit sharma", "sandeep sharma", "sunil narine", "ajinkya rahane", "jacques kallis", "robin uthappa", "jayant yadav","bhuvneshwar kumar"]
  # portfolio = ["manish pandey", "rohit sharma","jacques kallis","robin uthappa", "aditya tare", "ambati rayudu", "morne morkel","piyush chawla","sunil narine","lasith malinga","pragyan ojha"]
  power_player = "glenn maxwell"
  # power_player = "bhuvneshwar kumar"
  portfolio_p = set([getPlayer(data, p)[0] for p in portfolio])
  power_player_p = getPlayer(data, power_player)[0]
  points = 0
  subs = 75

  mlab = Matlab(matlab='/Applications/MATLAB_R2013a.app/bin/matlab')
  mlab.start()
  for i in xrange(4,len(time_data2)):
    # START = str(time_data2[i][0])
    # CURRENT_TEAM = set(portfolio)
    # SUBSTITUTIONS = subs
    # PAST_STATS = time_data[i][1]
    print "\n\n\n\n\n\n"
    print (subs, str(time_data2[i][0]))
    print set(portfolio_p)
    print points
    print "\n\n\n\n\n\n"
    # print time_data[i-1][1]
    # Tracer()()

    inp = (subs, str(time_data2[i][0]), set(portfolio), time_data[i-1][1])
    backtest_pickteam.pickTeam(data, schedule_data, inp)



    res = mlab.run_func('/Users/deedy/Dev/FantasyIPL-Moneyball/python2matlab.m', {}, maxtime = 500)
    changes = backtest_results.getResults(data, schedule_data, res['result'])
    subs -= changes[2]
    portfolio_p = changes[0]
    power_player_p = changes[1]
    # Tracer()()
    # update portfolio
    # update subs
    # update power player
    # Tracer()()

    teams = [(p,time_data2[i][1][p] - time_data2[i-1][1][p] ) for p in time_data2[i][1] if p in portfolio_p]
    print teams
    pthis = 0
    for i in teams:
      if power_player_p == i[0]:
        pthis += 2*i[1]
      else:
        pthis += i[1]
    points+= pthis
    print "{0}\t{1}\t{2}\n\n".format(points, pthis, subs)


    # print "{0}\t{1}".format(time_data2[i][0] , teams)

  mlab.stop()
  Tracer()()
  f.close()
开发者ID:deedy,项目名称:FantasyIPL-Moneyball,代码行数:86,代码来源:backtest.py

示例11: custom_filter

# 需要导入模块: from pymatbridge import Matlab [as 别名]
# 或者: from pymatbridge.Matlab import run_func [as 别名]
def custom_filter(source, destination):
	mlab = Matlab(matlab='/usr/local/MATLAB/R2013a/bin/matlab')
	mlab.start()
	res = mlab.run_func('./lineDect.m', {'arg1': source, 'arg2':destination})
开发者ID:GUTeamU,项目名称:TP3,代码行数:6,代码来源:lineDect.py

示例12: range

# 需要导入模块: from pymatbridge import Matlab [as 别名]
# 或者: from pymatbridge.Matlab import run_func [as 别名]
for i in range(0,len(second_level)):
        name = second_level[i].split("Database/",1)[1].rsplit(".",1)[0]
        address, name2 = os.path.split(name)
        if name2 != ".DS_Store" and name2 != '':
            if not os.path.exists('Database_5pt/'+address):
                os.makedirs('Database_5pt/'+address)
            pt = open("Database_5pt/"+address+'/'+name2+".5pt","w+")
            img=io.imread(second_level[i])
            dets = detector(img, 1)
            for k, d in enumerate(dets):
                shape = predictor(img, d)
                left_eye = shape.part(45)
                right_eye = shape.part(36)
                pt.write(str(left_eye.x)+' '+str(left_eye.y)+'\n')
                pt.write(str(right_eye.x)+' '+str(right_eye.y)+'\n')
                nose = shape.part(30)
                pt.write(str(nose.x)+' '+str(nose.y)+'\n')
                left_mouse = shape.part(54)
                right_mouse = shape.part(48)
                pt.write(str(left_mouse.x)+' '+str(left_mouse.y)+'\n')
                pt.write(str(right_mouse.x)+' '+str(right_mouse.y)+'\n')
                pt.close()
                ec_y = shape.part(36).y-shape.part(45).y
                ec_y= (ec_y,-ec_y)(ec_y<0)
                mc_y = shape.part(54).y-shape.part(48).y
                mc_y =(mc_y,-mc.y)[ec_y<0]
                ec_mc_y = mc_y-ec_y
                pt.close()
                #computations
                mlab.run_func('src/software/face_db_align.m', {'face_dir': 'Database', 'ffp_dir': 'Database_5pt', 'ec_mc_y': ec_mc_y, 'ec_y': ec_y, 'img_size': size, 'save_dir': 'Database_preprocessed'})
开发者ID:Paul-Darius,项目名称:ait-research-study-finished,代码行数:32,代码来源:5pt_preprocess.py

示例13: find_executable

# 需要导入模块: from pymatbridge import Matlab [as 别名]
# 或者: from pymatbridge.Matlab import run_func [as 别名]
    times which emulates a counter. Once it is done with
    counting it shuts down the matlab server.   
'''

from pymatbridge import Matlab
from distutils.spawn import find_executable


mcruns = 800
res = {'result': 0}

# Search for matlab	
prog = find_executable('matlab')
if not prog:
    sys.exit("Could not find MATLAB on PATH. Exiting...")
else:
    print("Found MATLAB in "+prog) 

# Create matlab session
mlab = Matlab(executable=prog)
mlab.start()

# Call jk.m in a for loop to emulate a counter
for mcindex in range(mcruns):
    res = mlab.run_func('../matlab/adder.m', {'arg1': res['result'], 'arg2': 1})
    print(res['result'])

# Shut down the matlab server
mlab.stop()

开发者ID:asarhegyi,项目名称:adcpp,代码行数:31,代码来源:mypymatbridge.py

示例14: execfile

# 需要导入模块: from pymatbridge import Matlab [as 别名]
# 或者: from pymatbridge.Matlab import run_func [as 别名]
from pymatbridge import Matlab
import os
import scipy.io

if __name__ == "__main__":
    config = {}
    execfile("settings.conf", config)
    # python 3: exec(open("example.conf").read(), config)
    mlab = Matlab(matlab=config["MATLAB_LOCATION"])
    path = os.getcwd() + "/"
    mlab.start()
    filename = config["f1arg1"]
    start = int(config["f1arg2"])
    end = int(config["f1arg3"])
    res = mlab.run_func(path + config["f1"], {"arg1": filename, "arg2": start, "arg3": end})
    mlab.stop()
    print("done")
开发者ID:jeremyjs,项目名称:MachineLearningResearch,代码行数:19,代码来源:m1.py

示例15: Matlab

# 需要导入模块: from pymatbridge import Matlab [as 别名]
# 或者: from pymatbridge.Matlab import run_func [as 别名]
from pymatbridge import Matlab
import os

mlab = Matlab()
mlab.start()
dir_path = os.path.dirname(os.path.realpath(__file__))
dir_list = ['/Input_data', '/HHT_MATLAB_package', '/HHT_MATLAB_package/EMD',
          '/HHT_MATLAB_package/checkIMFs', '/HHT_MATLAB_package/HT']
for d in dir_list:
    res = mlab.run_func('addpath', dir_path + d)

class EMD():
    def __init__(self, signal, Nstd, NE, num_imf=10, run_CEEMD=1, max_sift=10,
                 type_spline=2, modify_BC=1, rand_type=2, seed_no=1,
                 check_signal=1):
        res = mlab.run_func('feemd_post_pro', signal, Nstd, NE, num_imf,
                            run_CEEMD, max_sift, type_spline, modify_BC,
                            rand_type, seed_no, check_signal)
        self.imfs = res['result']

    def get_oi(self):
        oi = mlab.run_func('ratio1', self.imfs)
        oi_pair = mlab.run_func('ratioa', self.imfs)
        oi_dic = {'Non-orthogonal leakage of components': oi['result'],
                  'Non-orthogonal leakage for pair of adjoining components': oi_pair['result']}
        return oi_dic
开发者ID:YihaoSu,项目名称:HHTpywrapper,代码行数:28,代码来源:emd.py


注:本文中的pymatbridge.Matlab.run_func方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。