00001 """/*!
00002 @page es1step2 Step 2
00003 \par Objectives:
00004 - Integrate the previous example with SCons and Madagascar reproducibility
00005 - Perform a dot-test on a linear operator
00006 \section walkthrough Walkthrough
00007
00008 @par Usage:
00009 @code
00010 scons view
00011 scons dottest
00012 @endcode
00013 @par Preamble
00014
00015 @code
00016 from slimproj import *
00017 @endcode
00018
00019 slimproj is the SLIMpy SCons integration package.
00020 Hopefully you are familiar with the Madagascar pacage
00021
00022 @code
00023 from rsfproj import *
00024
00025 Flow( 'sig', None , "sigmoid n1=256 n2=256" )
00026 Flow( 'data', 'sig' , "noise var=0.0002" )
00027 @endcode
00028
00029 This code does the same as in the previous example and creates the sigmoid synthetic model and data.
00030
00031 @code
00032 @slim_builder_simple
00033 def SwellSeparation( vectors, thr=0.001 ):
00034 @endcode
00035
00036 Here I define the body of the code in the function SurfaceletDeNoise.
00037 SurfaceletDeNoise is a special function because it has the
00038 \ref slimproj_core.builders.funtion_decorators.slim_builder_simple "slim_builder_simple"
00039 decorator above it.
00040 This turns the function into a SCons Builder object.
00041 The body of the code is defined the same as the previous example.
00042 @code
00043 res = SwellSeparation( 'enoise', data , thr=0.001 )
00044 @endcode
00045 Here we call the SCons Builder to build the target @a res.rsf from the soucre @a data.rsf.
00046 The reason that I do it this way - by putting the body of the code inside a builder - instead
00047 of just calling the code inline inside of the SConstruct, is becuase at the time scons is evaulating
00048 this code nothing has been built yet. This means that we have to give scons
00049 somthing to run after this script exits
00050 so that scons can track the dependancies and build everything in order.
00051
00052 @par Dot-Testing functionality
00053
00054 Dot-testing in SLIMpy is very simple. SLIMpy can create random noise realizations from a linear operator's domain and range
00055 which are
00056 @ref slimpy_base.Core.User.Structures.VectorSpace.VectorSpace "VectorSpace"
00057 objects. From these the
00058 @ref slimpy_base.utils.DotTest.DotTest "DotTest"
00059 can compute @f$ \langle Ay,x \rangle \approx \langle A^{H}x, y \rangle @f$.
00060
00061 @code
00062 DotTest(A,5,5)
00063 @endcode
00064
00065 In this case the first parameter @b A is the cosine transform and the second two parameters are
00066 the precision of a pass or fail and the number of noise realizations to test.
00067
00068 */"""
00069
00070 import sys
00071
00072 #===============================================================================
00073 # import local plotting function
00074 #===============================================================================
00075 from os.path import abspath
00076 sys.path.append( abspath('..') )
00077 from swellplot import plot_swell
00078
00079 from slimproj import *
00080
00081 from SLIMpy.linear_operators import Cosine
00082 from SLIMpy import DotTest
00083
00084 #===============================================================================
00085 # Madagascar
00086 #===============================================================================
00087
00088 from rsfproj import *
00089
00090 data = '../data.rsf'
00091 sig = '../sig.rsf'
00092 noise = '../swellnoise.rsf'
00093 #SConscript( '../SConstruct' )
00094
00095 #===============================================================================
00096 # SLIMpy Bulider
00097 #===============================================================================
00098
00099 @slim_builder_simple
00100 def SwellSeparation( vectors, thr=0.001 ):
00101 """
00102 @param vectors a list of vectors created from SCons sources
00103 @param thr the value to threshold with
00104 """
00105
00106 data = vectors[0]
00107 A = Cosine( data.space )
00108
00109 tmp1 = A * data
00110 tmp2 = tmp1.thr( thr )
00111 res = A.H * tmp2
00112
00113 return res
00114
00115 e_noise = SwellSeparation( 'enoise', data , thr=5 )
00116
00117
00118
00119
00120
00121 #===============================================================================
00122 # RSF plotting functions
00123 #===============================================================================
00124 plot_swell( data, noise, sig , 'enoise', 'esig' )
00125
00126 #===============================================================================
00127 # Dot Test
00128 #===============================================================================
00129
00130 @slim_builder_simple
00131 def CosineDotTest( vectors):
00132
00133 A = Cosine( vectors[0].space )
00134 DotTest(A,5,5)
00135
00136
00137 test = CosineDotTest( 'test', data ,
00138 debug=[], logfile='dottest' )
00139 Alias( 'dottest', test)