def plotPlatesSpeed(self, ax, *args, **kwargs): dt = 2 / 100. / np.sqrt(self.meshCenters.num_vertices()) p0 = np.array(list(self.meshCenters.vp.center)) p1 = p0 + dt * np.array(list(self.plates.vp.speed)) lat0, long0 = Projection().toLatLong(p0, "deg") lat1, long1 = Projection().toLatLong(p1, "deg") lines = [[(long0[i], lat0[i]), (long1[i], lat1[i])] for i, _ in enumerate(lat0)] ax.add_collection( mc.LineCollection(lines, *args, transform=ccrs.Geodetic(), **kwargs))
def plotRelief(self, ax, *args, **kwargs): positions = np.array(list(self.meshCorners.vp.position)) polygons = [] for k, corners in enumerate(self.meshCenters.vp.corners): lat, long = Projection().toLatLong(positions[corners]) polygon = list(zip(long, lat)) polygons.append(polygon) elevations = np.array(list(self.meshCenters.vp.elevation)) cmap_terrain = plt.cm.get_cmap('gist_earth') cmap_ocean = plt.cm.get_cmap('ocean') def color(e): if e > 0: y = np.interp(e, [0, 10], [0.5, 1]) return cmap_terrain(y) else: y = np.interp(e, [-10, 0], [0.25, 0.8]) return cmap_ocean(y) colors = list(map(color, elevations)) ax.add_collection( mc.PolyCollection(polygons, *args, transform=ccrs.Geodetic(), facecolors=colors, **kwargs))
def plotPressure(self, ax, *args, **kwargs): lat, long = Projection().toLatLong(self.meshPoints, "deg") color = list( map(lambda p: [1, 0, 0] if p > 0 else [0.1, 0.1, 1], self.plates.vp.pressure.a)) ax.scatter(long, lat, *args, s=np.abs(self.plates.vp.pressure.a), transform=ccrs.PlateCarree(), c=color, **kwargs)
def randomRelief(planet, planetGenerator): lmax = 100 lmin = 50 degrees = np.arange(lmin, lmax + 1, dtype=np.float) power = 200 / degrees**2 / (2 * degrees + 1) coeffs_global = pysh.SHCoeffs.from_random( power, seed=planetGenerator.random.randint(2**32)) positions = np.array(list(planet.meshCenters.vp.center)) lat, long = Projection().toLatLong(positions) new_elevation = coeffs_global.expand(lat=lat, lon=long) planet.meshCenters.vp.elevation.a += new_elevation
def plotTilesJunctions(self, ax, *args, **kwargs): edges = self.meshCenters.get_edges() segments = np.array(list(self.meshCenters.vp.center))[edges] (x, y, z) = np.shape(segments) segments = np.reshape(segments, (x * y, z)) lat, long = Projection().toLatLong(segments) lat = np.reshape(lat, (x, y)) long = np.reshape(long, (x, y)) lines = [[(slong[0], slat[0]), (slong[1], slat[1])] for slat, slong in zip(lat, long)] ax.add_collection( mc.LineCollection(lines, *args, transform=ccrs.Geodetic(), **kwargs))
def plotPlatesBorders(self, ax, *args, **kwargs): edges = [[int(e.source()), int(e.target())] for e in self.meshCorners.edges() if self.plates.vp.color[self.meshCorners.ep.separates[e][0]] != self.plates.vp.color[self.meshCorners.ep.separates[e][1]]] segments = np.array(list(self.meshCorners.vp.position))[edges] (x, y, z) = np.shape(segments) segments = np.reshape(segments, (x * y, z)) lat, long = Projection().toLatLong(segments) lat = np.reshape(lat, (x, y)) long = np.reshape(long, (x, y)) lines = [[(slong[0], slat[0]), (slong[1], slat[1])] for slat, slong in zip(lat, long)] ax.add_collection( mc.LineCollection(lines, *args, transform=ccrs.Geodetic(), **kwargs))
def plotPlatesTypes(self, ax, *args, **kwargs): positions = np.array(list(self.meshCorners.vp.position)) polygons = [] for k, corners in enumerate(self.meshCenters.vp.corners): lat, long = Projection().toLatLong(positions[corners]) polygon = list(zip(long, lat)) polygons.append(polygon) elevations = np.array(list(self.meshCenters.vp.elevation)) r = np.piecewise(elevations, [elevations < 0], [lambda x: 0, lambda x: 0]) g = np.piecewise(elevations, [elevations < 0], [lambda x: 0, lambda x: 1]) b = np.piecewise(elevations, [elevations < 0], [lambda x: 0.8, lambda x: 0]) colors = np.array([r, g, b]).T ax.add_collection( mc.PolyCollection(polygons, *args, transform=ccrs.Geodetic(), facecolors=colors, **kwargs))
def __init__(self): self.name = "Hillshade Function" self.description = "" self.prepare() self.proj = Projection()
def plotMeshPoints(self, ax, *args, **kwargs): lat, long = Projection().toLatLong(self.meshPoints, "deg") ax.scatter(long, lat, *args, transform=ccrs.PlateCarree(), **kwargs)