00001 """/*! 00002 @page es1step6 Step 6 00003 00004 \par Objectives: 00005 - Make the script more portable and easy to use by using the built-in solve builder 00006 00007 @section Walkthrough 00008 I have replaced the builder with the Built in Solve builder 00009 @par Additional inputs: 00010 - 'lowfweight.rsf' 00011 00012 @par Additional outputs: 00013 - 'residual.rsf' 00014 00015 00016 */""" 00017 00018 00019 from slimproj import * 00020 from SLIMpy.linear_operators import * 00021 from SLIMpy import vector 00022 from SLIMpy import DotTest, VectorSpace 00023 from slimpy_contrib.ana.problems.l1_minimization_problem import l1_min 00024 00025 from rsfproj import * 00026 #=============================================================================== 00027 # import local plotting function 00028 #=============================================================================== 00029 from os.path import abspath 00030 sys.path.append( abspath('..') ) 00031 from swellplot import plot_swell 00032 00033 00034 data = '../data.rsf' 00035 sig = '../sig.rsf' 00036 noise = '../swellnoise.rsf' 00037 weight = 'lowfweight.rsf' 00038 residual = 'residual' 00039 00040 #Global Operators 00041 PC = None 00042 W = None 00043 00044 def transform_callback( target, source, env, space ): 00045 00046 global PC, W 00047 00048 weight = vector( source[1] ) 00049 00050 C = Cosine( space ) 00051 P = DiagonalWeight( space, weight ) 00052 00053 PC = CompoundOperator( [P,C] ) 00054 W = dwt( space ) 00055 00056 AH = AugOperator( [[PC], 00057 [W]] ) 00058 00059 D = DiagonalWeight( AH.domain(), .49 ) 00060 00061 AD = CompoundOperator( [AH,D] ) 00062 00063 A = AD.H 00064 return A 00065 00066 def recovery_callback( target, source, env, space ): 00067 00068 AH = AugOperator( [[PC.H, 0 ], 00069 [ 0, W.H ]] ) 00070 00071 D = DiagonalWeight( AH.range(), .49 ) 00072 DA = CompoundOperator( [D,AH] ) 00073 return DA 00074 00075 def result_callback( target, source, env, result ): 00076 result.flat[0].setName( str(target[0] ) ) 00077 result.flat[1].setName( str(target[1] ) ) 00078 00079 00080 #=============================================================================== 00081 # Flows 00082 #=============================================================================== 00083 00084 Flow ( weight, None, 00085 'math n1=512 output="1-(1*x1*0.1/512.0)" ' 00086 ) 00087 00088 Solve( ['enoise','esig'], [data,weight], 00089 problem=l1_min, 00090 transform_callback=transform_callback, 00091 inv_callback = recovery_callback, 00092 result_callback=result_callback, 00093 # l1_min problem options 00094 nouter=10, ninner=10, lmax=0.001, lmin=0.99, 00095 # slimpy options 00096 debug=['stat'] , logfile='sep.log' 00097 ) 00098 00099 00100 Flow( residual, [ data, 'enoise','esig' ], 00101 ' math en=${SOURCES[1]} es=${SOURCES[2]} output="input-en-es" ' 00102 ) 00103 00104 00105 #=============================================================================== 00106 # RSF plotting functions 00107 #=============================================================================== 00108 plot_swell( data, noise, sig , 'enoise', 'esig', 'residual' ) 00109 00110 #=============================================================================== 00111 # Dot Test 00112 #=============================================================================== 00113 00114 @slim_builder 00115 def AugmentedDotTest( target, source, env ): 00116 00117 y = vector(source[0]) 00118 AD = transfrom_callback( target, source, env , y.space ) 00119 DotTest(AD,2,5) 00120 00121 test = AugmentedDotTest( 'test', [data,weight], 00122 debug=[] , logfile='dottest' ) 00123 Alias( 'dottest', test) 00124