00001 """/*! 00002 @page es1step4 Step 4 00003 The next step is to create a compound operator @b PC where @b P is the diagonal 00004 weighting on the range of @b C. 00005 \f[ 00006 \tilde{\textbf{x}} = \arg\min \|\textbf{x}\|_1\quad\mbox{s.t.}\quad 00007 \textbf{PC} 00008 \textbf{x}+\epsilon=\textbf{y} 00009 \f] 00010 00011 \par Objectives: 00012 - Create a compound operator 00013 - Learn more of the builtin SLIMpy Options 00014 00015 @section Walkthrough 00016 00017 The code in extremely similar to the previous example, except this time we pass the 00018 operator @a A into the solver. 00019 @code 00020 >>> C = Cosine( y.space ) 00021 >>> P = DiagonalWeight( C.range(), weight ) 00022 00023 >>> A = CompoundOperator( [P,C] ).H 00024 00025 @endcode 00026 */""" 00027 00028 00029 from slimproj import * 00030 00031 from SLIMpy.linear_operators import * 00032 from slimpy_contrib.ana.GenLandweber import GenThreshLandweber 00033 from slimpy_contrib.ana.utils.thresholds import LinearCooling 00034 from SLIMpy import DotTest 00035 00036 from rsfproj import * 00037 #=============================================================================== 00038 # import local plotting function 00039 #=============================================================================== 00040 from os.path import abspath 00041 sys.path.append( abspath('..') ) 00042 from swellplot import plot_swell 00043 00044 00045 00046 data = '../data.rsf' 00047 sig = '../sig.rsf' 00048 noise = '../swellnoise.rsf' 00049 00050 weight = 'lowfweight.rsf' 00051 00052 @slim_builder_simple 00053 def SwellSeparation( vectors, nouter=2, ninner=2, lmax=0.01, lmin=0.02 ): 00054 """ 00055 @param vectors a list of vectors created from SCons sources 00056 @param thr the value to threshold with 00057 """ 00058 00059 y = vectors[0] 00060 weight = vectors[1] 00061 00062 C = Cosine( y.space ) 00063 P = DiagonalWeight( C.range(), weight ) 00064 00065 A = CompoundOperator( [P,C] ).H 00066 00067 thresh = LinearCooling( .01, .02, nouter ) 00068 solver = GenThreshLandweber( nouter, 5, thresh ) 00069 00070 #solve for x s.t. y = C*x 00071 x = solver.solve( A, y ) 00072 00073 res = C * x 00074 00075 return res 00076 00077 00078 Flow ( weight, None, 00079 'math n1=512 output="1-(1*x1*0.1/512.0)" ' 00080 ) 00081 00082 SwellSeparation( ['enoise'], [data,weight] , nouter=5, ninner=5, lmax=0.001, lmin=0.1 ) 00083 00084 Flow( 'esig', ['enoise', data] , 'math x=${SOURCES[1]} output="x-input"' ) 00085 00086 #=============================================================================== 00087 # RSF plotting functions 00088 #=============================================================================== 00089 plot_swell( data, noise, sig , 'enoise', 'esig' ) 00090 00091 #=============================================================================== 00092 # Dot Test 00093 #=============================================================================== 00094 00095 @slim_builder_simple 00096 def WeightedCosineDotTest( vectors): 00097 00098 y = vectors[0] 00099 weight = vectors[1] 00100 00101 C = Cosine( y.space ) 00102 P = DiagonalWeight( y.space, weight ) 00103 00104 A = CompoundOperator( [P,C] ) 00105 DotTest(A,3,5) 00106 00107 00108 test = WeightedCosineDotTest( 'test', [data,weight], 00109 debug=[] ) 00110 Alias( 'dottest', test) 00111