00001 """/*!
00002 @page es1step3 Step 3
00003 In this step we will build a slimpy script to solve the problem:
00004 \f[
00005 \tilde{\textbf{x}} = \arg\min \|\textbf{x}\|_1\quad\mbox{s.t.}\quad
00006 \textbf{C}
00007 \textbf{x}+\epsilon=\textbf{y}
00008 \f]
00009 where @b C is the cosine transform and @b x is the swell noise and @f$\epsilon@f$ is the signal.
00010 I will use the existing thresholded landweber solver with a linear threshold cooling scheme.
00011
00012 \par Objectives:
00013 - Use an exsiting iterative solver
00014
00015 @section Walkthrough
00016
00017 Using the code from the previous example I have chenged the code in the body of the
00018 function @b SwellSeparation.
00019 @code
00020 >>> thresh = LinearCooling( lmax, lmin, nouter )
00021
00022 >>> solver = GenThreshLandweber( nouter, ninner, thresh )
00023
00024 >>> x = solver.solve( C.H, y )
00025
00026 >>> res = C.H * x
00027 @endcode
00028
00029 */"""
00030
00031
00032 from slimproj import *
00033
00034 from SLIMpy.linear_operators import Cosine
00035 from slimpy_contrib.ana.GenLandweber import GenThreshLandweber
00036 from slimpy_contrib.ana.utils.thresholds import LinearCooling
00037 from SLIMpy import DotTest
00038
00039
00040 from rsfproj import *
00041 #===============================================================================
00042 # import local plotting function
00043 #===============================================================================
00044 from os.path import abspath
00045 sys.path.append( abspath('..') )
00046 from swellplot import plot_swell
00047
00048
00049 data = '../data.rsf'
00050 sig = '../sig.rsf'
00051 noise = '../swellnoise.rsf'
00052
00053
00054
00055 @slim_builder_simple
00056 def SwellSeparation( vectors, nouter=2, ninner=2, lmax=0.01, lmin=0.02 ):
00057 """
00058 @param vectors a list of vectors created from SCons sources
00059 @param thr the value to threshold with
00060 """
00061
00062 y = vectors[0]
00063
00064 C = Cosine( y.space )
00065
00066 thresh = LinearCooling( lmax, lmin, nouter )
00067
00068 solver = GenThreshLandweber( nouter, ninner, thresh )
00069
00070 #solve for x s.t. y = C*x
00071 x = solver.solve( C.H, y )
00072
00073 res = C.H * x
00074
00075 return res
00076
00077 SwellSeparation( ['enoise'], data , nouter=5, ninner=5, lmax=0.001, lmin=0.1 )
00078
00079 Flow( 'esig', ['enoise', data] , 'math x=${SOURCES[1]} output="x-input"')
00080
00081 #===============================================================================
00082 # RSF plotting functions
00083 #===============================================================================
00084 plot_swell( data, noise, sig , 'enoise', 'esig' )
00085