00001
00002 from slimpy_base.Core.User.linop.rclinOp import linearop_r as LinearOperatorStruct
00003 from numpy import ceil
00004 from slimpy_base.api.Plugins.slim2rsf.sfCommandFactory import rsfCommandFactory
00005 from slimpy_base.api.Plugins.slim2rsf.sfcommands.sfConverter import sfConverter
00006
00007
00008
00009
00010
00011
00012 class fftX_Converter( sfConverter ):
00013 """
00014 This is a mapping instance that maps a SLIMpy command into an object that
00015 can be run
00016 This also maps the agruments and keyword arguments to be pugin specific
00017 """
00018
00019 @classmethod
00020 def map( cls, source, command ):
00021 """
00022 map a SLIMpy command to a rsf command
00023 """
00024
00025 command = cls.default_function( command, "fft1" )
00026
00027 command = cls.truefalseHelper( command )
00028
00029 command = cls.keywordmap( command, {'adj':'inv'} )
00030
00031 return cls.pack( command )
00032
00033
00034 @classmethod
00035 def trans( cls, command, space, *spaces ):
00036 'define how this operator affect the space'
00037 n1 = spaces[0]['n1']
00038 space['n1_fft']= n1
00039 space["n1"] = int( ceil( n1/2. )+1 )
00040 space['data_type']='float'
00041 return space
00042
00043 @classmethod
00044 def trans_adj( cls, command, space, *spaces ):
00045 """
00046 trans_adj will automatically be called in the case
00047 where the command has an adj keyword that is true
00048 """
00049 n1 = spaces[0]['n1_fft']
00050 space['data_type']='complex'
00051 space['n1']= n1
00052 return space
00053
00054 @classmethod
00055 def constr( cls, command, space ):
00056 'make sure the data on the forward command is float'
00057 cls.match( space, data_type='float' )
00058 @classmethod
00059 def constr_adj( cls, command, space ):
00060 'make sure the data on the adjoint command is complex'
00061 cls.match( space, data_type='complex' )
00062
00063
00064
00065
00066
00067 class fft1X( LinearOperatorStruct ):
00068 """
00069 Fourier transfrorm on the first axis
00070 """
00071 name = "fftX"
00072
00073 def __init__( self, inSpace, sym=True, opt=False ):
00074
00075 kparams = dict( sym=sym, opt=opt, adj=False )
00076
00077 LinearOperatorStruct.__init__( self, inSpace, **kparams )
00078
00079
00080
00081
00082
00083 factory = rsfCommandFactory()
00084
00085
00086
00087
00088 factory['fftX'] = fftX_Converter
00089