diff --git a/simpegMT/BaseMT.py b/simpegMT/BaseMT.py index bebd7cc3..9ec143ec 100644 --- a/simpegMT/BaseMT.py +++ b/simpegMT/BaseMT.py @@ -2,7 +2,7 @@ from simpegEM.FDEM import BaseFDEMProblem from SurveyMT import SurveyMT from DataMT import DataMT from FieldsMT import FieldsMT -from SimPEG import SolverLU as SimpegSolver, Utils, mkvc +from SimPEG import SolverLU as SimpegSolver, PropMaps, Utils, mkvc import numpy as np class BaseMTProblem(BaseFDEMProblem): @@ -15,6 +15,36 @@ class BaseMTProblem(BaseFDEMProblem): dataPair = DataMT fieldsPair = FieldsMT + # Pickleing support methods + def __getstate__(self): + ''' + Method that makes the dictionary of the object pickleble, removes non-pickleble elements of the object. + + Used when doing: + pickle.dump(pickleFile,object) + ''' + odict = self.__dict__.copy() + # Remove fields that are not needed + del odict['hook'] + del odict['setKwargs'] + del odict['PropMap'] + # Return the dict + return odict + + def __setstate__(self,odict): + ''' + Function that sets a pickle dictionary in to an object. + + Used when doing: + object = pickle.load(pickleFile) + ''' + # Update the dict + self.__dict__.update(odict) + # Re-hook the methods to the object + Utils.codeutils.hook(self,Utils.codeutils.hook) + Utils.codeutils.hook(self,Utils.codeutils.setKwargs) + self. + # Set the solver Solver = SimpegSolver solverOpts = {} diff --git a/simpegMT/DataMT.py b/simpegMT/DataMT.py index e8ff9bd9..144d79a3 100644 --- a/simpegMT/DataMT.py +++ b/simpegMT/DataMT.py @@ -57,7 +57,7 @@ class DataMT(Survey.Data): # Masked array mArrRec = np.ma.MaskedArray(rec2ndarr(tArrRec),mask=np.isnan(rec2ndarr(tArrRec))).view(dtype=tArrRec.dtype) # Unique freq and loc of the masked array - uniFLmarr = np.unique(mArrRec[['freq','x','y','z']]) + uniFLmarr = np.unique(mArrRec[['freq','x','y','z']]).copy() try: outTemp = recFunc.stack_arrays((outTemp,mArrRec)) @@ -103,7 +103,7 @@ class DataMT(Survey.Data): # Initiate rxList rxList = [] # Find that data for freq - dFreq = recArray[recArray['freq'] == freq] + dFreq = recArray[recArray['freq'] == freq].copy() # Find the impedance rxTypes in the recArray. rxTypes = [ comp for comp in recArray.dtype.names if len(comp)==4 and 'z' in comp and ('r' in comp or 'i' in comp)] for rxType in rxTypes: @@ -112,7 +112,7 @@ class DataMT(Survey.Data): if np.any(notNaNind): # Make sure that there is any data to add. locs = rec2ndarr(dFreq[['x','y','z']][notNaNind].copy()) rxList.append(simpegMT.SurveyMT.RxMT(locs,rxType)) - dataList.append(dFreq[rxType][notNaNind]) + dataList.append(dFreq[rxType][notNaNind].copy()) srcList.append(src(rxList,freq)) # Make a survey diff --git a/simpegMT/FieldsMT.py b/simpegMT/FieldsMT.py index bd6ec799..622460a3 100644 --- a/simpegMT/FieldsMT.py +++ b/simpegMT/FieldsMT.py @@ -132,4 +132,15 @@ class FieldsMT_3D(FieldsMT): # 'b_1d' : ['e_1dSolution','E','_b'], # 'b_1dPrimary' : ['e_1dSolution','E','_bPrimary'], # 'b_1dSecondary' : ['e_1dSolution','E','_bSecondary'] - # } \ No newline at end of file + # } + + + # knownFields = {'e_pxSolution':'E','e_pySoluiton':'E'} + # aliasFields = { + # 'e_px' : ['e_pxSolution','E','_epx'], + # 'e_pxPrimary' : ['e_pxSolution','E','_epxPrimary'], + # 'e_pxSecondary' : ['e_pxSolution','E','_epxSecondary'], + # 'b_px' : ['e_pxSolution','F','_bpx'], + # 'b_pxPrimary' : ['e_pxSolution','F','_bpxPrimary'], + # 'b_pxSecondary' : ['e_pxSolution','F','_bpxSecondary'] + # } \ No newline at end of file diff --git a/simpegMT/SurveyMT.py b/simpegMT/SurveyMT.py index e727d7ca..5a0f7abb 100644 --- a/simpegMT/SurveyMT.py +++ b/simpegMT/SurveyMT.py @@ -28,16 +28,11 @@ class RxMT(Survey.BaseRx): 'z1dr':['Z1D', 'real'], 'z1di':['Z1D', 'imag'] #TODO: Add tipper fractions as well. Bz/B(x|y) - # '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'], + # Tipper + 'tzxr':['T3D','real'], + 'tzxi':['T3D','imag'], + 'tzyr':['T3D','real'], + 'tzyi':['T3D','imag'] } # TODO: Have locs as single or double coordinates for both or numerator and denominator separately, respectively. def __init__(self, locs, rxType): @@ -122,6 +117,21 @@ class RxMT(Survey.BaseRx): f_part_complex = (ey_px*hy_py - ey_py*hy_px)/(hx_px*hy_py - hx_py*hy_px) elif 'zyy' in self.rxType: f_part_complex = (-ey_px*hx_py + ey_py*hx_px)/(hx_px*hy_py - hx_py*hy_px) + elif self.projType is 'T3D': + Pbx = mesh.getInterpolationMat(self.locs,'Fx') + Pby = mesh.getInterpolationMat(self.locs,'Fy') + Pbz = mesh.getInterpolationMat(self.locs,'Fz') + bx_px = Pbx*f[src,'b_px'] + by_px = Pby*f[src,'b_px'] + bz_px = Pbz*f[src,'b_px'] + bx_py = Pbx*f[src,'b_py'] + by_py = Pby*f[src,'b_py'] + bz_py = Pbz*f[src,'b_py'] + if 'tzx' in self.rxType: + f_part_complex = (- by_px*bz_py + by_py*bz_px)/(bx_px*by_py - bx_py*by_px) + if 'tzy' in self.rxType: + f_part_complex = ( bx_px*bz_py + bx_py*bz_px)/(bx_px*by_py - bx_py*by_px) + else: NotImplementedError('Projection of {:s} receiver type is not implemented.'.format(self.rxType)) # Get the real or imag component diff --git a/simpegMT/Utils/dataUtils.py b/simpegMT/Utils/dataUtils.py index efa32509..1c0dd742 100644 --- a/simpegMT/Utils/dataUtils.py +++ b/simpegMT/Utils/dataUtils.py @@ -132,6 +132,8 @@ def convert3Dto1Dobject(MTdata,rxType3D='zyx'): # Find the unique locations # Need to find the locations recDataTemp = MTdata.toRecArray() + # Check if survey.std has been assigned. + ## NEED TO: write this... # Calculte and add the DET of the tensor to the recArray if 'det' in rxType3D: Zon = (recDataTemp['zxxr']+1j*recDataTemp['zxxi'])*(recDataTemp['zyyr']+1j*recDataTemp['zyyi']) @@ -170,7 +172,7 @@ def convert3Dto1Dobject(MTdata,rxType3D='zyx'): sur1D.dobs = dataVec # Need to take MTdata.survey.std and split it as well. std=0.05 - sur1D.std = np.abs(sur1D.dobs*std) + 0.01*np.linalg.norm(sur1D.dobs) + sur1D.std = np.abs(sur1D.dobs*std) #+ 0.01*np.linalg.norm(sur1D.dobs) mtData1DList.append(dat1D) # Return the the list of data.