def _get_stream_func_bdy(self): # calculate stream function on boundary # - continuous on boundary (also should be periodic) import numpy as np import geometry_planar as GP # coordinates of polygon x,y = np.array(self.coords).transpose() Nx = len(x) nvec = np.arange(Nx) sfun = 0*x # for each singularity (just outside polygon) perimeter,resolution,\ spacings,tangent_dirn = GP.curve_info(self.singularities) for i,sing in enumerate(self.singularities): an = self.sing_coeffs[i] branch_dir = np.pi/2.+tangent_dirn[i] atan2 = GP.arctan2_branch(y,x=x,branch_point=sing,branch_dir=branch_dir) atan2 = GP.make_arctan2_cts(atan2) sfun = sfun+an*atan2 self.stream_func_bdy = sfun return
def plot_stream_func_bdy(self, pobj=None, show=True, i_test=None): import numpy as np import shapefile_utils as SFU import geometry_planar as GP if pobj is None: # set a plot object if none exists from matplotlib import pyplot as pobj ss = self.get_arc_length() / 1.e3 # km if i_test is None: # just plot values of stresm function at boundary pobj.plot(ss, self.stream_func_bdy, 'b') out = None xc = np.round(10. * self.coords[0][0] / 1.e3) / 10. # km (1dp) yc = np.round(10. * self.coords[0][1] / 1.e3) / 10. # km (1dp) pobj.xlabel('arc length (km) from ' + str((xc, yc)) + ' (km)') pobj.ylabel('values of stream function') else: # coordinates of polygon x, y = np.array(self.coords).transpose() Nx = len(x) nvec = np.arange(Nx) # for each singularity (just outside polygon) sing = self.singularities[i_test] branch_dir = np.pi / 2. + self.tangent_dirn[i_test] atan2 = GP.arctan2_branch(y, x=x, branch_point=sing, branch_dir=branch_dir) pobj.plot(ss, atan2 / np.pi, 'r') out = [atan2] atan2 = GP.make_arctan2_cts(atan2) pobj.plot(ss, atan2 / np.pi, 'b') out.append(atan2) if show: pobj.show() return out