00001 """
00002 @package new_fft_rsf_integration
00003 This is the second step in createing a linear opertor. There are two substeps to this module.
00004 - create a \ref slimpy_base.api.Plugins.slim2rsf.sfcommands.sfConverter "sfConverter"
00005 subclass that defines how to use a SLIMpy operator with rsf commands.
00006 - register the converter with the rsf plugin.
00007 """
00008
00009 from numpy import ceil
00010 from slimpy_base.api.Plugins.slim2rsf.sfCommandFactory import rsfCommandFactory
00011 from slimpy_base.api.Plugins.slim2rsf.sfcommands.sfConverter import sfConverter
00012
00013
00014
00015
00016
00017
00018 class fftX_Converter( sfConverter ):
00019 """
00020 This is a mapping instance that maps a SLIMpy command into an object that
00021 can be run.
00022 There are three types of function this class should have.
00023 - map
00024 - trans
00025 - constr
00026 Each of these functions can have an optional '_adj' at the end of the name
00027 if the operator's adjoint is different than the forward.
00028
00029 \par map should change the arguments of the operator such that it can run as
00030 an rsf command line.
00031 \par trans defines how this operator affects the domain of the input.
00032 this is also to calculate the range of the operator at initialization.
00033 \par constr defines any run time error messages if the vector is not in the domain of
00034 the operator.
00035
00036
00037 """
00038
00039 @classmethod
00040 def map( cls, source, command ):
00041 """
00042 map a SLIMpy command to a rsf command
00043 """
00044
00045 command = cls.default_function( command, "fft1" )
00046
00047 command = cls.truefalseHelper( command )
00048
00049 command = cls.keywordmap( command, {'adj':'inv'} )
00050
00051 return cls.pack( command )
00052
00053
00054 @classmethod
00055 def trans( cls, command, space, *spaces ):
00056 'define how this operator affect the space'
00057 n1 = spaces[0]['n1']
00058 space['n1_fft']= n1
00059 space["n1"] = int( ceil( n1/2. )+1 )
00060 space['data_type']='complex'
00061 return space
00062
00063 @classmethod
00064 def trans_adj( cls, command, space, *spaces ):
00065 """
00066 trans_adj will automatically be called in the case
00067 where the command has an adj keyword that is true
00068 """
00069 n1 = spaces[0]['n1_fft']
00070 space['data_type']='float'
00071 space['n1']= n1
00072 return space
00073
00074 @classmethod
00075 def constr( cls, command, space ):
00076 'make sure the data on the forward command is float'
00077 cls.match( space, data_type='float' )
00078
00079
00080 @classmethod
00081 def constr_adj( cls, command, space ):
00082 'make sure the data on the adjoint command is complex'
00083 cls.match( space, data_type='complex' )
00084
00085
00086
00087
00088
00089
00090
00091
00092 factory = rsfCommandFactory()
00093
00094
00095
00096
00097 factory['fftX'] = fftX_Converter
00098