00001 """
00002 This is the very first example you should look at when learning SLIMpy
00003 @page es1step1 Step 1
00004 \par Objectives:
00005 - get SLIMpy ready to use
00006 - become familiar with the python syntax
00007 - do a simple non-iterative de-noise with surfacelets
00008 @section setup Setup
00009 Now that you have acquired SLIMpy
00010 you should
00011 \ref configure_slimpy "configure"
00012 it using the configure_slimpy.py script this creates a .slimpy_rc file in your home directory
00013 @section walkthrough Walkthrough
00014
00015 @par Preamble
00016
00017 @code
00018 >>> from SLIMpy import *
00019 @endcode
00020 Include the SLIMpy package into the current python module.
00021
00022 @code
00023
00024 >>> options = parse_args( )
00025
00026 @endcode
00027
00028 \ref SLIMpy.setup.parse_args "parse_args"
00029 tells SLIMpy that it is working as a command line program and to
00030 enable the SLIMpy command line arguments.
00031
00032 parse_args initializes SLIMpy. This produces the following output
00033 @code
00034
00035 SLIMpy: Building AST ...
00036
00037 @endcode
00038
00039 @code
00040
00041 >>> sig = vector( '../sig.rsf' )
00042 >>> noise = vector( '../swellnoise.rsf' )
00043 >>> data = sig + noise
00044
00045 @endcode
00046
00047 Here we tell SLIMpy to look at the files `sig.rsf' and 'swellnoise.rsf' as vectors.
00048 \ref slimpy_base.User.adiFactories.VectorFactory "vector" is acutaly a forctory function that creates a
00049 \ref slimpy_base.Core.User.Structures.serial_vector.Vector "Vector Class" instance.
00050
00051 @code
00052 >>> A = Cosine( sig.space )
00053 @endcode
00054 This creates an implicit linear operator representing the
00055 \ref slimpy_base.api.linearops.contourlets.surf "Surfacelet Transform".
00056
00057 @par Body
00058
00059 @code
00060 >>> tmp1 = A * data
00061 >>> tmp2 = tmp1.thr( 0.0001 )
00062 >>> res = A.H * tmp2
00063 @endcode
00064
00065 These line represents the body of the code. this is where slimpy makes it easy
00066 for the user to create a flow.
00067
00068 @par Finalize
00069
00070 @code
00071 >>> data.setName('data')
00072 >>> res.setName( "res" )
00073 @endcode
00074
00075 The command
00076 \ref slimpy_base.Core.User.Structures.serial_vector.Vector.setName "setName"
00077 tells SLIMpy that the vector res is a
00078 target to be built and kept.
00079
00080 \note that the previous lines two produce NO output because there is no actual work
00081 done here since SLIMpy is still in the ``Build AST'' mode.
00082
00083 @code
00084 >>> Execute( )
00085 @endcode
00086
00087 \ref slimpy_base.Environment.InstanceManager.InstanceManager.Execute "Execute"
00088 is where the work is done, it produces the following lines of output:
00089
00090 @code
00091 SLIMpy: Done building AST
00092 SLIMpy: Executing commands ...
00093 true | sfmath type="float" n2="256" n1="256" output="0" |
00094 sfput label1="Time" label2="Lateral" var="0.0002" unit2="km" unit1="s" d1="0.004" d2="0.032" o2="0" o1="0" |
00095 DATAPATH=./ sfnoise mean="0" > ./slim.18526.env1.exampl.creat.00001.rsf
00096 < ./sig.rsf DATAPATH=./ sfmath output="vec+input" vec="./slim.18526.env1.exampl.creat.00001.rsf" > ./data.rsf
00097 < ./data.rsf sfsurf adj="n" Pyr_Level="2" | sfthr mode="soft" thr="0.0001" |
00098 DATAPATH=./ sfsurf adj="y" Pyr_Level="2" > ./res.rsf
00099 sync
00100 sfrm ./slim.18526.env1.exampl.creat.00001.rsf
00101 SLIMpy: Done executing commands
00102 @endcode
00103
00104 """
00105
00106
00107 from SLIMpy import *
00108
00109
00110
00111 options = parse_args( )
00112
00113
00114 sig = vector( '../sig.rsf' )
00115 noise = vector( '../swellnoise.rsf' )
00116 data = sig + noise
00117
00118
00119 A = Cosine( sig.space )
00120
00121 tmp1 = A * data
00122 tmp2 = tmp1.thr( 0.0001 )
00123 res = A.H * tmp2
00124
00125
00126 data.setName('data')
00127 res.setName( "res" )
00128
00129
00130 Execute( )
00131
00132