from SimPEG import Survey, Utils, np, sp class RxFDEM(Survey.BaseRx): knownRxTypes = { 'exr':['e', 'Ex', 'real'], 'eyr':['e', 'Ey', 'real'], 'ezr':['e', 'Ez', 'real'], 'exi':['e', 'Ex', 'imag'], 'eyi':['e', 'Ey', 'imag'], 'ezi':['e', 'Ez', 'imag'], 'bxr':['b', 'Fx', 'real'], 'byr':['b', 'Fy', 'real'], 'bzr':['b', 'Fz', 'real'], 'bxi':['b', 'Fx', 'imag'], 'byi':['b', 'Fy', 'imag'], 'bzi':['b', 'Fz', 'imag'], } def __init__(self, locs, rxType): Survey.BaseRx.__init__(self, locs, rxType) @property def projField(self): """Field Type projection (e.g. e b ...)""" return self.knownRxTypes[self.rxType][0] @property def projGLoc(self): """Grid Location projection (e.g. Ex Fy ...)""" return self.knownRxTypes[self.rxType][1] @property def projComp(self): """Component projection (real/imag)""" return self.knownRxTypes[self.rxType][2] def projectFields(self, tx, mesh, u): P = self.getP(mesh) u_part_complex = u[tx, self.projField] # get the real or imag component real_or_imag = self.projComp u_part = getattr(u_part_complex, real_or_imag) return P*u_part def projectFieldsDeriv(self, tx, mesh, u, v, adjoint=False): P = self.getP(mesh) if not adjoint: Pv_complex = P * v real_or_imag = self.projComp Pv = getattr(Pv_complex, real_or_imag) elif adjoint: Pv_real = P.T * v real_or_imag = self.projComp if real_or_imag == 'imag': Pv = 1j*Pv_real elif real_or_imag == 'real': Pv = Pv_real.astype(complex) else: raise NotImplementedError('must be real or imag') return Pv class TxFDEM(Survey.BaseTx): freq = None #: Frequency (float) rxPair = RxFDEM knownTxTypes = ['VMD'] def __init__(self, loc, txType, freq, rxList): self.freq = float(freq) Survey.BaseTx.__init__(self, loc, txType, rxList) class FieldsFDEM(Survey.Fields): """Fancy Field Storage for a FDEM survey.""" knownFields = {'b': 'F', 'e': 'E'} dtype = complex class SurveyFDEM(Survey.BaseSurvey): """ docstring for SurveyFDEM """ txPair = TxFDEM def __init__(self, txList, **kwargs): # Sort these by frequency self.txList = txList Survey.BaseSurvey.__init__(self, **kwargs) _freqDict = {} for tx in txList: if tx.freq not in _freqDict: _freqDict[tx.freq] = [] _freqDict[tx.freq] += [tx] self._freqDict = _freqDict self._freqs = sorted([f for f in self._freqDict]) @property def freqs(self): """Frequencies""" return self._freqs @property def nFreq(self): """Number of frequencies""" return len(self._freqDict) @property def nTxByFreq(self): if getattr(self, '_nTxByFreq', None) is None: self._nTxByFreq = {} for freq in self.freqs: self._nTxByFreq[freq] = len(self.getTransmitters(freq)) return self._nTxByFreq def getTransmitters(self, freq): """Returns the transmitters associated with a specific frequency.""" assert freq in self._freqDict, "The requested frequency is not in this survey." return self._freqDict[freq] def projectFields(self, u): data = Survey.Data(self) for tx in self.txList: for rx in tx.rxList: data[tx, rx] = rx.projectFields(tx, self.mesh, u) return data def projectFieldsDeriv(self, u): raise Exception('Use Transmitters to project fields deriv.')