Futurize 1, futurize 2, pasteurize.

This commit is contained in:
Brendan Smithyman
2016-07-16 14:17:02 -05:00
parent 362975d2bd
commit ca8d8f8c2d
197 changed files with 2618 additions and 1235 deletions
+40 -29
View File
@@ -1,6 +1,17 @@
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from builtins import open
from builtins import int
from future import standard_library
standard_library.install_aliases()
from builtins import map
from builtins import range
from past.utils import old_div
from SimPEG import np, Utils
import BaseDC as DC
import BaseDC as IP
from . import BaseDC as DC
from . import BaseDC as IP
import warnings
def getActiveindfromTopo(mesh, topo):
@@ -67,7 +78,7 @@ def readUBC_DC3Dobstopo(filename,mesh,topo,probType="CC"):
if "!" in line.split(): continue
elif line == '\n': continue
elif line == ' \n': continue
temp = map(float, line.split())
temp = list(map(float, line.split()))
# Read a line for the current electrode
if len(temp) == 5: # SRC: Only X and Y are provided (assume no topography)
#TODO consider topography and assign the closest cell center in the earth
@@ -211,8 +222,8 @@ def plot_pseudoSection(DCsurvey, axs, surveyType='dipole-dipole', unitType='volt
MN = np.abs(Rx[1][:,0] - Rx[0][:,0])
# Create mid-point location
Cmid = (Tx[0][0] + Tx[1][0])/2
Pmid = (Rx[0][:,0] + Rx[1][:,0])/2
Cmid = old_div((Tx[0][0] + Tx[1][0]),2)
Pmid = old_div((Rx[0][:,0] + Rx[1][:,0]),2)
# Change output for unitType
if unitType == 'volt':
@@ -228,16 +239,16 @@ def plot_pseudoSection(DCsurvey, axs, surveyType='dipole-dipole', unitType='volt
elif surveyType == 'dipole-dipole':
leg = data * 2*np.pi / ( 1/MA - 1/MB - 1/NB + 1/NA )
leg = data * 2*np.pi / ( old_div(1,MA) - old_div(1,MB) - old_div(1,NB) + old_div(1,NA) )
else:
print """unitType must be 'pole-dipole' | 'dipole-dipole' """
print("""unitType must be 'pole-dipole' | 'dipole-dipole' """)
break
if unitType == 'appConductivity':
leg = np.log10(abs(1./leg))
leg = np.log10(abs(old_div(1.,leg)))
rho = np.hstack([rho,leg])
elif unitType == 'appResistivity':
@@ -246,11 +257,11 @@ def plot_pseudoSection(DCsurvey, axs, surveyType='dipole-dipole', unitType='volt
rho = np.hstack([rho,leg])
else:
print """unitType must be 'appResistivity' | 'appConductivity' | 'volt' """
print("""unitType must be 'appResistivity' | 'appConductivity' | 'volt' """)
break
midx = np.hstack([midx, ( Cmid + Pmid )/2 ])
midz = np.hstack([midz, -np.abs(Cmid-Pmid)/2 + (Tx[0][2] + Tx[1][2])/2 ])
midx = np.hstack([midx, old_div(( Cmid + Pmid ),2) ])
midz = np.hstack([midz, old_div(-np.abs(Cmid-Pmid),2) + old_div((Tx[0][2] + Tx[1][2]),2) ])
# Grid points
grid_x, grid_z = np.mgrid[np.min(midx):np.max(midx), np.min(midz):np.max(midz)]
@@ -337,14 +348,14 @@ def gen_DCIPsurvey(endl, mesh, surveyType, AM_sep, MN_sep, nrx):
# Mesure survey length and direction
dl_len = xy_2_r(endl[0,0],endl[1,0],endl[0,1],endl[1,1])
dl_x = ( endl[1,0] - endl[0,0] ) / dl_len
dl_y = ( endl[1,1] - endl[0,1] ) / dl_len
dl_x = old_div(( endl[1,0] - endl[0,0] ), dl_len)
dl_y = old_div(( endl[1,1] - endl[0,1] ), dl_len)
nstn = np.floor( dl_len / AM_sep )
nstn = np.floor( old_div(dl_len, AM_sep) )
# Compute discrete pole location along line
stn_x = endl[0,0] + np.array(range(int(nstn)))*dl_x*AM_sep
stn_y = endl[0,1] + np.array(range(int(nstn)))*dl_y*AM_sep
stn_x = endl[0,0] + np.array(list(range(int(nstn))))*dl_x*AM_sep
stn_y = endl[0,1] + np.array(list(range(int(nstn))))*dl_y*AM_sep
# Create line of P1 locations
M = np.c_[stn_x, stn_y, np.ones(nstn).T*mesh.vectorNz[-1]]
@@ -376,15 +387,15 @@ def gen_DCIPsurvey(endl, mesh, surveyType, AM_sep, MN_sep, nrx):
AB = xy_2_r(tx[0,1],endl[1,0],tx[1,1],endl[1,1])
# Number of receivers to fit
nstn = np.min([np.floor( (AB - MN_sep) / AM_sep ) , nrx])
nstn = np.min([np.floor( old_div((AB - MN_sep), AM_sep) ) , nrx])
# Check if there is enough space, else break the loop
if nstn <= 0:
continue
# Compute discrete pole location along line
stn_x = N[ii,0] + dl_x*MN_sep + np.array(range(int(nstn)))*dl_x*AM_sep
stn_y = N[ii,1] + dl_y*MN_sep + np.array(range(int(nstn)))*dl_y*AM_sep
stn_x = N[ii,0] + dl_x*MN_sep + np.array(list(range(int(nstn))))*dl_x*AM_sep
stn_y = N[ii,1] + dl_y*MN_sep + np.array(list(range(int(nstn))))*dl_y*AM_sep
# Create receiver poles
# Create line of P1 locations
@@ -417,17 +428,17 @@ def gen_DCIPsurvey(endl, mesh, surveyType, AM_sep, MN_sep, nrx):
max_y = endl[1,1] - dl_y * MN_sep
box_l = np.sqrt( (min_x - max_x)**2 + (min_y - max_y)**2 )
box_w = box_l/2.
box_w = old_div(box_l,2.)
nstn = np.floor( box_l / AM_sep )
nstn = np.floor( old_div(box_l, AM_sep) )
# Compute discrete pole location along line
stn_x = min_x + np.array(range(int(nstn)))*dl_x*AM_sep
stn_y = min_y + np.array(range(int(nstn)))*dl_y*AM_sep
stn_x = min_x + np.array(list(range(int(nstn))))*dl_x*AM_sep
stn_y = min_y + np.array(list(range(int(nstn))))*dl_y*AM_sep
# Define number of cross lines
nlin = int(np.floor( box_w / AM_sep ))
lind = range(-nlin,nlin+1)
nlin = int(np.floor( old_div(box_w, AM_sep) ))
lind = list(range(-nlin,nlin+1))
ngrad = nstn * len(lind)
@@ -449,7 +460,7 @@ def gen_DCIPsurvey(endl, mesh, surveyType, AM_sep, MN_sep, nrx):
srcClass = DC.SrcDipole([rxClass], M[0,:], N[-1,:])
SrcList.append(srcClass)
else:
print """surveyType must be either 'pole-dipole', 'dipole-dipole' or 'gradient'. """
print("""surveyType must be either 'pole-dipole', 'dipole-dipole' or 'gradient'. """)
survey = DC.SurveyDC(SrcList)
return survey, Tx, Rx
@@ -668,7 +679,7 @@ def readUBC_DC3Dobs(fileName, rtype = 'DC'):
obsfile = np.genfromtxt(fileName,delimiter=' \n',dtype=np.str,comments='!')
else:
print "rtype must be 'DC'(default) | 'IP'"
print("rtype must be 'DC'(default) | 'IP'")
# Pre-allocate
srcLists = []
@@ -983,7 +994,7 @@ def xy_2_lineID(DCsurvey):
ang2 = np.abs(vec3.dot(vec4))
# If the angles are smaller then 45d, than next point is on a new line
if ((ang1 < np.cos(np.pi/4.)) | (ang2 < np.cos(np.pi/4.))) & (np.all(np.r_[r1,r2,r3,r4] > 0)):
if ((ang1 < np.cos(old_div(np.pi,4.))) | (ang2 < np.cos(old_div(np.pi,4.)))) & (np.all(np.r_[r1,r2,r3,r4] > 0)):
# Re-initiate start and mid-point location
xy0 = A[:2]
@@ -1023,7 +1034,7 @@ def r_unit(p1,p2):
if r!=0:
vec = dx/r
vec = old_div(dx,r)
else:
vec = np.zeros(len(p1))