def rotate_data(NSEMdata, rot_angle): ''' Function that rotates clockwise by rotation angle (- negative for a counter-clockwise rotation) **Required** :param SimPEG.EM.NSEM.Data NSEMdata: NSEM data object to process :param float rot_angle: Rotation angel in degrees, positive for clockwise rotation ''' recData = NSEMdata.toRecArray('Complex') impData = rec_to_ndarr(recData[['zxx', 'zxy', 'zyx', 'zyy']].copy(), complex) # Make the rotation matrix # c,s,zxx,zxy,zyx,zyy = sympy.symbols('c,s,zxx,zxy,zyx,zyy') # rotM = sympy.Matrix([[c,-s],[s, c]]) # zM = sympy.Matrix([[zxx,zxy],[zyx,zyy]]) # rotM*zM*rotM.T # [c*(c*zxx - s*zyx) - s*(c*zxy - s*zyy), c*(c*zxy - s*zyy) + s*(c*zxx - s*zyx)], # [c*(c*zyx + s*zxx) - s*(c*zyy + s*zxy), c*(c*zyy + s*zxy) + s*(c*zyx + s*zxx)]]) s = np.sin(-np.deg2rad(rot_angle)) c = np.cos(-np.deg2rad(rot_angle)) rotMat = np.array([[c, -s], [s, c]]) rotData = (rotMat.dot(impData.reshape(-1, 2, 2).dot(rotMat.T))).transpose( 1, 0, 2).reshape(-1, 4) outRec = recData.copy() for nr, comp in enumerate(['zxx', 'zxy', 'zyx', 'zyy']): outRec[comp] = rotData[:, nr] return Data.fromRecArray(outRec)
def resampleNSEMdataAtFreq(NSEMdata, freqs): """ Function to resample NSEMdata at set of frequencies """ # Make a rec array NSEMrec = NSEMdata.toRecArray().data # Find unique locations uniLoc = np.unique(NSEMrec[['x','y','z']]) uniFreq = NSEMdata.survey.freqs # Get the comps dNames = NSEMrec.dtype # Loop over all the locations and interpolate for loc in uniLoc: # Find the index of the station ind = np.sqrt(np.sum((rec_to_ndarr(NSEMrec[['x','y','z']]) - rec_to_ndarr(loc))**2,axis=1)) < 1. # Find dist of 1 m accuracy # Make a temporary recArray and interpolate all the components tArrRec = np.concatenate((simpeg.mkvc(freqs,2),np.ones((len(freqs),1))*rec_to_ndarr(loc),np.nan*np.ones((len(freqs),12))),axis=1).view(dNames) for comp in ['zxxr','zxxi','zxyr','zxyi','zyxr','zyxi','zyyr','zyyi','tzxr','tzxi','tzyr','tzyi']: int1d = sciint.interp1d(NSEMrec[ind]['freq'],NSEMrec[ind][comp],bounds_error=False) tArrRec[comp] = simpeg.mkvc(int1d(freqs),2) # Join together try: outRecArr = recFunc.stack_arrays((outRecArr,tArrRec)) except NameError: outRecArr = tArrRec # Make the NSEMdata and return return Data.fromRecArray(outRecArr)
def resampleNSEMdataAtFreq(NSEMdata, freqs): """ Function to resample NSEMdata at set of frequencies """ # Make a rec array NSEMrec = NSEMdata.toRecArray().data # Find unique locations uniLoc = np.unique(NSEMrec[['x', 'y', 'z']]) uniFreq = NSEMdata.survey.freqs # Get the comps dNames = NSEMrec.dtype # Loop over all the locations and interpolate for loc in uniLoc: # Find the index of the station ind = np.sqrt( np.sum((rec_to_ndarr(NSEMrec[['x', 'y', 'z']]) - rec_to_ndarr(loc)) **2, axis=1)) < 1. # Find dist of 1 m accuracy # Make a temporary recArray and interpolate all the components tArrRec = np.concatenate( (simpeg.mkvc(freqs, 2), np.ones( (len(freqs), 1)) * rec_to_ndarr(loc), np.nan * np.ones( (len(freqs), 12))), axis=1).view(dNames) for comp in [ 'zxxr', 'zxxi', 'zxyr', 'zxyi', 'zyxr', 'zyxi', 'zyyr', 'zyyi', 'tzxr', 'tzxi', 'tzyr', 'tzyi' ]: int1d = sciint.interp1d(NSEMrec[ind]['freq'], NSEMrec[ind][comp], bounds_error=False) tArrRec[comp] = simpeg.mkvc(int1d(freqs), 2) # Join together try: outRecArr = recFunc.stack_arrays((outRecArr, tArrRec)) except NameError: outRecArr = tArrRec # Make the NSEMdata and return return Data.fromRecArray(outRecArr)
def rotateData(NSEMdata, rotAngle): ''' Function that rotates clockwist by rotAngle (- negative for a counter-clockwise rotation) ''' recData = NSEMdata.toRecArray('Complex') impData = rec_to_ndarr(recData[['zxx', 'zxy', 'zyx', 'zyy']], complex) # Make the rotation matrix # c,s,zxx,zxy,zyx,zyy = sympy.symbols('c,s,zxx,zxy,zyx,zyy') # rotM = sympy.Matrix([[c,-s],[s, c]]) # zM = sympy.Matrix([[zxx,zxy],[zyx,zyy]]) # rotM*zM*rotM.T # [c*(c*zxx - s*zyx) - s*(c*zxy - s*zyy), c*(c*zxy - s*zyy) + s*(c*zxx - s*zyx)], # [c*(c*zyx + s*zxx) - s*(c*zyy + s*zxy), c*(c*zyy + s*zxy) + s*(c*zyx + s*zxx)]]) s = np.sin(-np.deg2rad(rotAngle)) c = np.cos(-np.deg2rad(rotAngle)) rotMat = np.array([[c, -s], [s, c]]) rotData = (rotMat.dot(impData.reshape(-1, 2, 2).dot(rotMat.T))).transpose( 1, 0, 2).reshape(-1, 4) outRec = recData.copy() for nr, comp in enumerate(['zxx', 'zxy', 'zyx', 'zyy']): outRec[comp] = rotData[:, nr] return Data.fromRecArray(outRec)
def rotateData(NSEMdata, rotAngle): ''' Function that rotates clockwist by rotAngle (- negative for a counter-clockwise rotation) ''' recData = NSEMdata.toRecArray('Complex') impData = rec_to_ndarr(recData[['zxx','zxy','zyx','zyy']],complex) # Make the rotation matrix # c,s,zxx,zxy,zyx,zyy = sympy.symbols('c,s,zxx,zxy,zyx,zyy') # rotM = sympy.Matrix([[c,-s],[s, c]]) # zM = sympy.Matrix([[zxx,zxy],[zyx,zyy]]) # rotM*zM*rotM.T # [c*(c*zxx - s*zyx) - s*(c*zxy - s*zyy), c*(c*zxy - s*zyy) + s*(c*zxx - s*zyx)], # [c*(c*zyx + s*zxx) - s*(c*zyy + s*zxy), c*(c*zyy + s*zxy) + s*(c*zyx + s*zxx)]]) s = np.sin(-np.deg2rad(rotAngle)) c = np.cos(-np.deg2rad(rotAngle)) rotMat = np.array([[c,-s],[s,c]]) rotData = (rotMat.dot(impData.reshape(-1,2,2).dot(rotMat.T))).transpose(1,0,2).reshape(-1,4) outRec = recData.copy() for nr,comp in enumerate(['zxx','zxy','zyx','zyy']): outRec[comp] = rotData[:,nr] return Data.fromRecArray(outRec)