Mercurial > hg > absrec
diff test_approx.py @ 21:d395461b92ae tip
Lots and lots of modifications. Approximate recovery script working.
author | Nic Cleju <nikcleju@gmail.com> |
---|---|
date | Mon, 23 Apr 2012 10:54:57 +0300 |
parents | 2837cfeaf353 |
children |
line wrap: on
line diff
--- a/test_approx.py Thu Apr 05 14:00:13 2012 +0300 +++ b/test_approx.py Mon Apr 23 10:54:57 2012 +0300 @@ -48,6 +48,7 @@ import pyCSalgos.BP.l1qec import pyCSalgos.BP.l1qc import pyCSalgos.NESTA.NESTA +import pyCSalgos.SL0.EllipseProj # For plotting with right axes import utils @@ -64,7 +65,7 @@ currmodule = sys.modules[__name__] currmodule.proccount = share currmodule.ntasks = ntasks - currmodule._printLock = printLock + currmodule.printLock = printLock def generateTaskParams(globalparams): """ @@ -82,7 +83,8 @@ lambdas = globalparams['lambdas'] # Process parameters - noiselevel = 1.0 / (10.0**(SNRdb/10.0)); + # noiselevel = norm(noise)/norm(signal) = SNR**(-1/2) = 10**-(SNRdb/20) + noiselevel = 1.0 / (10.0**(SNRdb/20.0)); for delta in deltas: for rho in rhos: @@ -368,6 +370,8 @@ currmodule.printLock = multiprocessing.Lock() pool = multiprocessing.Pool(ncpus,initializer=initProcess,initargs=(currmodule.proccount,currmodule.ntasks,currmodule.printLock)) taskresults = pool.map(run_once_tuple, taskparams) + pool.close() + pool.join() else: for taskparam in taskparams: taskresults.append(run_once_tuple(taskparam)) @@ -434,6 +438,8 @@ print "Caught exception when running algorithm",strname," :",e.message except pyCSalgos.NESTA.NESTA.NestaError as e: print "Caught exception when running algorithm",strname," :",e.message + except pyCSalgos.SL0.EllipseProj.EllipseProjDaiError as e: + print "Caught exception when running algorithm",strname," :",e.message # Run algorithms with Lambda for ilbd,lbd in zip(numpy.arange(lambdas.size),lambdas): @@ -449,6 +455,9 @@ elapsed[strname][ilbd] = elapsed[strname][ilbd] + (time.time() - timestart) except pyCSalgos.BP.l1qc.l1qcInputValueError as e: print "Caught exception when running algorithm",strname," :",e.message + except pyCSalgos.SL0.EllipseProj.EllipseProjDaiError as e: + print "Caught exception when running algorithm",strname," :",e.message + return xrec, elapsed @@ -459,17 +468,55 @@ """ #paramsl1prove['reference_signal'] = nesta[1] # 'NESTA' run(stdparams_approx.paramsl1prove) - plotProveEll1(stdparams_approx.paramsl1prove['savedataname']) - + #plotProveEll1(stdparams_approx.paramsl1prove['savedataname']) + utils.replot_ProveEll1(stdparams_approx.paramsl1prove['savedataname'], + algonames = None, # will read them from mat file + doshow=False, + dosave=True, + saveplotbase=stdparams_approx.paramsl1prove['saveplotbase'], + saveplotexts=stdparams_approx.paramsl1prove['saveplotexts']) def generateFig(): """ Generates figures. Figures are saved in the current folder. """ - run(stdparams_exact.std1) - plot(stdparams_exact.std1['savedataname']) - + #stdparams_approx.params1['ncpus'] = 1 + run(stdparams_approx.params1) + utils.replot_approx(stdparams_approx.params1['savedataname'], + algonames = None, # will read them from mat file + doshow=False, + dosave=True, + saveplotbase=stdparams_approx.params1['saveplotbase'], + saveplotexts=stdparams_approx.params1['saveplotexts']) + + #stdparams_approx.params2['ncpus'] = 1 + run(stdparams_approx.params2) + utils.replot_approx(stdparams_approx.params2['savedataname'], + algonames = None, # will read them from mat file + doshow=False, + dosave=True, + saveplotbase=stdparams_approx.params2['saveplotbase'], + saveplotexts=stdparams_approx.params2['saveplotexts']) + + #stdparams_approx.params3['ncpus'] = 1 + run(stdparams_approx.params3) + utils.replot_approx(stdparams_approx.params3['savedataname'], + algonames = None, # will read them from mat file + doshow=False, + dosave=True, + saveplotbase=stdparams_approx.params3['saveplotbase'], + saveplotexts=stdparams_approx.params3['saveplotexts']) + + #stdparams_approx.params4['ncpus'] = 1 + run(stdparams_approx.params4) + utils.replot_approx(stdparams_approx.params4['savedataname'], + algonames = None, # will read them from mat file + doshow=False, + dosave=True, + saveplotbase=stdparams_approx.params4['saveplotbase'], + saveplotexts=stdparams_approx.params4['saveplotexts']) + # Script main if __name__ == "__main__": @@ -482,9 +529,40 @@ #stdparams_approx.paramstest['ncpus'] = 1 #run(stdparams_approx.paramstest) #plot(stdparams_approx.paramstest['savedataname']) - utils.replot_approx(stdparams_approx.paramstest['savedataname'], + #utils.replot_approx(stdparams_approx.paramstest['savedataname'], algonames = None,doshow=False,dosave=True,saveplotbase=stdparams_approx.paramstest['saveplotbase'],saveplotexts=stdparams_approx.paramstest['saveplotexts']) + + #stdparams_approx.params5['ncpus'] = 3 + #run(stdparams_approx.params5) + #utils.replot_approx(stdparams_approx.params5['savedataname'], + # algonames = None, # will read them from mat file + # doshow=False, + # dosave=True, + # saveplotbase=stdparams_approx.params5['saveplotbase'], + # saveplotexts=stdparams_approx.params5['saveplotexts']) + +# stdparams_approx.params3sl0['ncpus'] = 1 +# run(stdparams_approx.params3sl0) +# utils.replot_approx(stdparams_approx.params3sl0['savedataname'], +# algonames = None, # will read them from mat file +# doshow=False, +# dosave=True, +# saveplotbase=stdparams_approx.params3sl0['saveplotbase'], +# saveplotexts=stdparams_approx.params3sl0['saveplotexts']) + + #stdparams_approx.params3['ncpus'] = 1 + run(stdparams_approx.params3) + utils.replot_approx(stdparams_approx.params3['savedataname'], algonames = None, # will read them from mat file doshow=False, dosave=True, - saveplotbase=stdparams_approx.paramstest['saveplotbase'], - saveplotexts=stdparams_approx.paramstest['saveplotexts']) + saveplotbase=stdparams_approx.params3['saveplotbase'], + saveplotexts=stdparams_approx.params3['saveplotexts']) + + #stdparams_approx.params4['ncpus'] = 1 + run(stdparams_approx.params4) + utils.replot_approx(stdparams_approx.params4['savedataname'], + algonames = None, # will read them from mat file + doshow=False, + dosave=True, + saveplotbase=stdparams_approx.params4['saveplotbase'], + saveplotexts=stdparams_approx.params4['saveplotexts'])