From ad20c73f18dacbf25495b2a195e9d680616eeb4b Mon Sep 17 00:00:00 2001 From: GudniRos Date: Mon, 16 Nov 2015 01:53:26 -0800 Subject: [PATCH] Added support of Complex recarray for fromRecArray function --- simpegMT/DataMT.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/simpegMT/DataMT.py b/simpegMT/DataMT.py index 03b88045..6ad911f6 100644 --- a/simpegMT/DataMT.py +++ b/simpegMT/DataMT.py @@ -106,14 +106,20 @@ class DataMT(Survey.Data): # Find that data for 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)] + rxTypes = [ comp for comp in recArray.dtype.names if (len(comp)==4 or len(comp)==3) and 'z' in comp] for rxType in rxTypes: # Find index of not nan values in rxType notNaNind = ~np.isnan(dFreq[rxType]) 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].copy()) + if dFreq[rxType].dtype.name in 'complex128': + rxList.append(simpegMT.SurveyMT.RxMT(locs,rxType+'r')) + dataList.append(dFreq[rxType][notNaNind].real.copy()) + rxList.append(simpegMT.SurveyMT.RxMT(locs,rxType+'i')) + dataList.append(dFreq[rxType][notNaNind].imag.copy()) + else: + rxList.append(simpegMT.SurveyMT.RxMT(locs,rxType)) + dataList.append(dFreq[rxType][notNaNind].copy()) srcList.append(src(rxList,freq)) # Make a survey