Skip to content
Snippets Groups Projects
Commit 8004191d authored by Jörn Ungermann's avatar Jörn Ungermann
Browse files

fixed some pep8 violations

parent 74619d30
No related branches found
No related tags found
No related merge requests found
...@@ -64,10 +64,10 @@ def phase_mag_disc(dim, res, beta, center, radius, height, b_0=1): ...@@ -64,10 +64,10 @@ def phase_mag_disc(dim, res, beta, center, radius, height, b_0=1):
''' '''
# Function for the phase: # Function for the phase:
def phiMag(x, y): def phiMag(x, y):
r = np.hypot(x-x0, y-y0) r = np.hypot(x - x0, y - y0)
r[center[1], center[2]] = 1E-30 r[center[1], center[2]] = 1E-30
result = coeff * Lz * ((y-y0) * np.cos(beta) - (x-x0) * np.sin(beta)) result = coeff * Lz * ((y - y0) * np.cos(beta) - (x - x0) * np.sin(beta))
result *= np.where(r <= R, 1, (R/r)**2) result *= np.where(r <= R, 1, (R / r) ** 2)
return result return result
# Process input parameters: # Process input parameters:
z_dim, y_dim, x_dim = dim z_dim, y_dim, x_dim = dim
...@@ -97,10 +97,10 @@ def phase_mag_sphere(dim, res, beta, center, radius, b_0=1): ...@@ -97,10 +97,10 @@ def phase_mag_sphere(dim, res, beta, center, radius, b_0=1):
''' '''
# Function for the phase: # Function for the phase:
def phiMag(x, y): def phiMag(x, y):
r = np.hypot(x-x0, y-y0) r = np.hypot(x - x0, y - y0)
r[center[1], center[2]] = 1E-30 r[center[1], center[2]] = 1E-30
result = coeff * R**3/r**2 * ((y-y0) * np.cos(beta) - (x-x0) * np.sin(beta)) result = coeff * R ** 3 / r ** 2 * ((y - y0) * np.cos(beta) - (x - x0) * np.sin(beta))
result *= np.where(r > R, 1, (1-(1-(r/R)**2)**(3./2.))) result *= np.where(r > R, 1, (1 - (1 - (r / R) ** 2) ** (3. / 2.)))
return result return result
# Process input parameters: # Process input parameters:
z_dim, y_dim, x_dim = dim z_dim, y_dim, x_dim = dim
...@@ -109,8 +109,8 @@ def phase_mag_sphere(dim, res, beta, center, radius, b_0=1): ...@@ -109,8 +109,8 @@ def phase_mag_sphere(dim, res, beta, center, radius, b_0=1):
R = res * radius R = res * radius
coeff = - 2./3. * pi * b_0 / PHI_0 coeff = - 2./3. * pi * b_0 / PHI_0
# Create grid: # Create grid:
x = np.linspace(res/2, x_dim*res-res/2, num=x_dim) x = np.linspace(res / 2, x_dim * res - res / 2, num=x_dim)
y = np.linspace(res/2, y_dim*res-res/2, num=y_dim) y = np.linspace(res / 2, y_dim * res - res / 2, num=y_dim)
xx, yy = np.meshgrid(x, y) xx, yy = np.meshgrid(x, y)
# Return phase: # Return phase:
return phiMag(xx, yy) return phiMag(xx, yy)
import math import math
def great_circle(float lon1,float lat1,float lon2,float lat2): def great_circle(float lon1, float lat1, float lon2, float lat2):
cdef float radius = 3956.0 cdef float radius = 3956.0
cdef float pi = 3.14159265 cdef float pi = 3.14159265
cdef float x = pi/180.0 cdef float x = pi / 180.0
cdef float a,b,theta,c cdef float a, b, theta,c
a = (90.0-lat1)*(x) a = (90.0 - lat1) * (x)
b = (90.0-lat2)*(x) b = (90.0 - lat2) * (x)
theta = (lon2-lon1)*(x) theta = (lon2 - lon1) * (x)
c = math.acos((math.cos(a)*math.cos(b)) + (math.sin(a)*math.sin(b)*math.cos(theta))) c = math.acos((math.cos(a)*math.cos(b)) + (math.sin(a)*math.sin(b)*math.cos(theta)))
return radius*c return radius*c
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment