00001 """
00002 Generic Single Linear operator functions
00003 """
00004
00005 __copyright__ = """
00006 Copyright 2008 Sean Ross-Ross
00007 """
00008 __license__ = """
00009 This file is part of SLIMpy .
00010
00011 SLIMpy is free software: you can redistribute it and/or modify
00012 it under the terms of the GNU Lesser General Public License as published by
00013 the Free Software Foundation, either version 3 of the License, or
00014 (at your option) any later version.
00015
00016 SLIMpy is distributed in the hope that it will be useful,
00017 but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00019 GNU Lesser General Public License for more details.
00020
00021 You should have received a copy of the GNU Lesser General Public License
00022 along with SLIMpy . If not, see <http://www.gnu.org/licenses/>.
00023 """
00024
00025
00026 from slimpy_base.Core.User.linop.rclinOp import linearop_r as LinearOperatorStruct
00027 from slimpy_base.Core.User.linop.linear_operator import Identity
00028 from slimpy_base.Core.Interface.node import Source
00029 import re
00030
00031
00032
00033 class pad( LinearOperatorStruct ):
00034 """
00035 P = pad( space, beg#, end# n# , n#out,adj, )
00036 Pad a dataset with zeros
00037 """
00038
00039 def __new__(cls, *inSpace, **kparams):
00040
00041 if inSpace or kparams:
00042 all_zeros = True
00043 for nN, val in kparams.iteritems():
00044 if nN.startswith('end') or nN.startswith('beg'):
00045 if val != 0:
00046 all_zeros = False
00047 break
00048
00049 if all_zeros:
00050 return Identity(inSpace[0])
00051
00052 return LinearOperatorStruct.__new__( cls, *inSpace, **kparams )
00053
00054 name = "pad"
00055
00056 def __init__(self,inSpace,adj=False,**kparams):
00057 """
00058 nN is the number of N's that are given to the functions.
00059 Note: n1,n2 and n1out,n2out are the same. beg1.end1 - beg2,end2 adds padding to the dataset.
00060 """
00061
00062 for nN in kparams:
00063 if not re.match('(^beg\d+$|^end\d+$|^n\d+$|^adj$|^n\d+out$)',nN):
00064 raise TypeError,"Invalid Parameter, must be n# or n#out, beg# or end#."
00065
00066
00067 LinearOperatorStruct.__init__(self,inSpace,adj=adj,**kparams)
00068
00069
00070
00071 class Taper( LinearOperatorStruct ):
00072 """
00073 Cos Taper image on all sides with 2*eps
00074 """
00075 name = 'taper'
00076 def __init__(self,domain,eps,adj=False):
00077 """
00078 Initialize the operator.
00079 """
00080 LinearOperatorStruct.__init__(self,domain,adj=False,eps=eps)
00081
00082
00083
00084 class costaper( LinearOperatorStruct ):
00085 """
00086 Cos Tapering
00087 """
00088 name = "costaper"
00089 def __init__(self,inSpace,**kparams):
00090 """
00091 Initialize the operator.
00092 """
00093 LinearOperatorStruct.__init__(self,inSpace,adj=False,**kparams)
00094
00095
00096
00097 class dipfilter( LinearOperatorStruct ):
00098 """
00099 Dip Filter operation, assume the data is in the Fourier Domain.
00100 """
00101 name = "dipfilter"
00102 def __init__( self, inSpace, ang1=None, ang2=None, ang3=None, ang4=None, ang=None, angle='n', dim=2, adj=False, **kparams ):
00103 """
00104 Takes parameters dim=[2/3], pass=[y/n], ang[1-4]=
00105 """
00106 for nN in kparams:
00107 if not re.match( '(^v\d*$|^pass$)', nN ):
00108 raise TypeError, "Invalid Parameter, must be v# or pass."
00109
00110 if ang != None:
00111 ang = 90-ang
00112 kparams = dict( kparams,
00113 adj=adj,
00114 angle=angle,
00115 dim=dim,
00116 ang1=-ang,
00117 ang2=-0.9*ang,
00118 ang3=0.9*ang,
00119 ang4=ang )
00120 else:
00121 kparams = dict( kparams,
00122 adj=adj,
00123 angle=angle,
00124 dim=dim,
00125 ang1=ang1,
00126 ang2=ang2,
00127 ang3=ang3,
00128 ang4=ang4 )
00129
00130 LinearOperatorStruct.__init__( self, inSpace, **kparams )
00131
00132
00133
00134
00135 class mig( LinearOperatorStruct ):
00136 """
00137 R/T Migration-Demigration
00138 Perform a simulation and migration of the RSF mig operator.
00139 """
00140 name = "mig"
00141 def __init__( self, inSpace, dataSpace, que='y', adj=False, **kparams ):
00142 """
00143 inp and out are the input and output's of the file.
00144 The que='n' param sets the default mig script to force run in environment.
00145 """
00146
00147
00148 kparams.update( modelSpace=inSpace, dataSpace=dataSpace, adj=adj, que=que )
00149
00150 LinearOperatorStruct.__init__( self, inSpace, **kparams )
00151
00152
00153
00154 class multpred( LinearOperatorStruct ):
00155 """
00156 M = multpred( inSpace, filt=1, input=None, adj=False )
00157 Multiple Prediction Program of Deli's
00158 """
00159 name = "multpred"
00160
00161 __block_diagonal__ = True
00162
00163 def __init__( self, inSpace, filt=1, input=None, adj=0, **kparams ):
00164 """
00165 Takes filt and input as paramaters. Input as source so it creates it.
00166 """
00167 kparams.update( filt=filt, adj=adj )
00168
00169 if filt==1:
00170 assert input is not None
00171 kparams.update( input=Source(input.getContainer()) )
00172
00173 LinearOperatorStruct.__init__( self, inSpace, **kparams )
00174
00175