00001 """/*!
00002 @page es1step5 Step 5
00003 Solve the full problem
00004 \f[
00005 \tilde{\textbf{x}} = \arg\min \|\textbf{x}\|_1\quad\mbox{s.t.}\quad\left[
00006 \begin{array}{ccc}
00007 \textbf{PC} & \vline & \textbf{W}
00008 \end{array}\right]\textbf{x}=\textbf{y}
00009
00010 \f]
00011
00012 \par Objectives:
00013 - Create an Augmented system of equations
00014 - Change verbosity of the output
00015
00016 @par Additional inputs:
00017 - 'lowfweight.rsf'
00018
00019 @par Additional outputs:
00020 - 'residual.rsf'
00021
00022 @section Walkthrough
00023 The augmented operator created here represents the operator
00024 in the above equation.
00025
00026 @code
00027 AH = AugOperator( [[PC],
00028 [W]] )
00029 @endcode
00030
00031 @subsection voo Verbosity Output Options
00032 Also note that the options passed into the SwellSeparation builder have changed.
00033 @code
00034 debug=['stat'] , logfile='sep.log'
00035 @endcode
00036 the debug=['stat'] tells SLIMpy to only print the current status to the screen.
00037 The logfile options save all of the printed and unprinted output to the file sep.log.
00038 since there is so much information sep.log is not an ascii file and it must be viewd with the
00039 slimpy record_viewer.py executable.
00040 \par Example usage:
00041 To view the output the same as the provious example do:
00042 @code
00043 record_viewer.py -a cmd -a err sep.log
00044 @endcode
00045 */"""
00046
00047
00048 from slimproj import *
00049
00050 from SLIMpy.linear_operators import *
00051 from slimpy_contrib.ana.GenLandweber import GenThreshLandweber
00052 from slimpy_contrib.ana.utils.thresholds import LinearCooling
00053 from SLIMpy import DotTest, VectorSpace
00054
00055
00056 from rsfproj import *
00057 #===============================================================================
00058 # import local plotting function
00059 #===============================================================================
00060 from os.path import abspath
00061 sys.path.append( abspath('..') )
00062 from swellplot import plot_swell
00063
00064
00065 data = '../data.rsf'
00066 sig = '../sig.rsf'
00067 noise = '../swellnoise.rsf'
00068 weight = 'lowfweight.rsf'
00069 residual = 'residual'
00070
00071 @slim_builder_simple
00072 def SwellSeparation( vectors,nouter=2, ninner=2, lmax=0.01, lmin=0.02 ):
00073 """
00074 @param vectors a list of vectors created from SCons sources
00075 @param thr the value to threshold with
00076 """
00077
00078 y = vectors[0]
00079 weight = vectors[1]
00080
00081 C = Cosine( y.space )
00082 P = DiagonalWeight( y.space, weight )
00083
00084 thresh = LinearCooling( lmax, lmin, nouter )
00085
00086 solver = GenThreshLandweber( nouter, ninner, thresh )
00087
00088
00089 PC = CompoundOperator( [P,C] )
00090 W = dwt( y.space )
00091
00092
00093 AH = AugOperator( [[PC],
00094 [W]] )
00095
00096 D = DiagonalWeight( AH.domain(), .49 )
00097
00098 AD = CompoundOperator( [AH,D] )
00099
00100 A = AD.H
00101
00102 #solve for x s.t. y = C*x
00103 x = solver.solve( A, y )
00104
00105
00106 noise = .49 * ( PC.H * x.flat[0] )
00107 signal = .49 * ( W.H * x.flat[1] )
00108
00109 return noise,signal
00110
00111 #===============================================================================
00112 # Flows
00113 #===============================================================================
00114 Flow ( weight, None,
00115 'math n1=512 output="1-(1*x1*0.1/512.0)" '
00116 )
00117
00118 SwellSeparation( ['enoise','esig'], [data,weight],
00119 # SwellSeparation options
00120 nouter=10, ninner=10, lmax=0.001, lmin=0.99,
00121 # slimpy options
00122 debug=['stat'] , logfile='sep.log'
00123 )
00124
00125 Flow( residual, [ data, 'enoise','esig' ],
00126 ' math en=${SOURCES[1]} es=${SOURCES[2]} output="input-en-es" '
00127 )
00128
00129
00130 #===============================================================================
00131 # RSF plotting functions
00132 #===============================================================================
00133 plot_swell( data, noise, sig , 'enoise', 'esig', 'residual' )
00134
00135
00136
00137 #===============================================================================
00138 # Dot Test
00139 #===============================================================================
00140
00141 @slim_builder_simple
00142 def AugmentedDotTest( vectors):
00143
00144 y = vectors[0]
00145 weight = vectors[1]
00146
00147 C = Cosine( y.space )
00148 P = DiagonalWeight( y.space, weight )
00149
00150 PC = CompoundOperator( [P,C] )
00151 W = dwt( y.space )
00152
00153
00154 AH = AugOperator( [[PC],
00155 [W]] )
00156
00157 D = DiagonalWeight( AH.domain(), .49 )
00158
00159 AD = CompoundOperator( [AH,D] )
00160
00161 DotTest(AD,2,5)
00162
00163
00164 test = AugmentedDotTest( 'test', [data,weight],
00165 debug=[] , logfile='dottest' )
00166 Alias( 'dottest', test)
00167