def __spacetime_diagram_o_frame(self): # from (x',t') to (x,t) def tr(x_prime, t_prime): x_prime, t_prime = np.asarray(x_prime), np.asarray(t_prime) return self.lorentz_transformations.transform( x_prime, t_prime, -self.velocity) # form (x,t) to (x',t') def inv_tr(x, t): x, t = np.asarray(x), np.asarray(t) return self.lorentz_transformations.transform(x, t, self.velocity) grid_helper = GridHelperCurveLinear((tr, inv_tr)) ax = Subplot(self.fig, 1, 2, 1, grid_helper=grid_helper) if self.showOPrime \ else Subplot(self.fig, 1, 1, 1, grid_helper=grid_helper) self.fig.add_subplot(ax) ax.set_xlabel("x", loc="center") ax.set_ylabel("t", loc="center") # O' x axis ax.axis["x1"] = x1 = ax.new_floating_axis(1, 0) x1.label.set_text("x'") # O' t axis ax.axis["t1"] = t1 = ax.new_floating_axis(0, 0) t1.label.set_text("t'") self.__add_x_and_y_axis(ax) ax.format_coord = self.__format_coord_o_frame self.__remove_ticks(ax, x1, t1) self.world_lines_plotter.plot(plt, ax, self.velocity)
for x_T in x_T_levels: ax.plot(x_T, y_all_p, color=(1.0, 0.5, 0.5)) for x_theta in x_thetas: ax.plot(x_theta, y_all_p, color=(1.0, 0.7, 0.7)) for x_mixing_ratio in x_mixing_ratios: good = p_all >= 600 # restrict mixing ratio lines to below 600 mb ax.plot(x_mixing_ratio[good], y_all_p[good], color=(0.8, 0.8, 0.6)) n_moist = len(theta_ep_mesh) moist_colors = ((0.6, 0.9, 0.7), ) * n_moist ax.contour(x_from_Tp(mesh_T + C_to_K, mesh_p), y_from_p(mesh_p), theta_ep_mesh, theta_ep_levels, colors=moist_colors) ax.axis((x_min, x_max, y_min, y_max)) def format_coord(x, y): T, p = to_thermo(x, y) return "{0:5.1f} C, {1:5.1f} mb".format(float(T), float(p)) ax.format_coord = format_coord ax.plot(x_snd_Td, y_snd_p, linewidth=2, color='g') ax.plot(x_snd_T, y_snd_p, linewidth=2, color='r') plt.show()
for yi in y_p_levels: ax.plot((x_min, x_max), (yi,yi), color = (1.0, 0.8, 0.8)) for x_T in x_T_levels: ax.plot(x_T, y_all_p, color=(1.0, 0.5, 0.5)) for x_theta in x_thetas: ax.plot(x_theta, y_all_p, color=(1.0, 0.7, 0.7)) for x_mixing_ratio in x_mixing_ratios: good = p_all >= 600 # restrict mixing ratio lines to below 600 mb ax.plot(x_mixing_ratio[good], y_all_p[good], color = (0.8, 0.8, 0.6)) n_moist = len(theta_ep_mesh) moist_colors = ((0.6, 0.9, 0.7),)*n_moist ax.contour(x_from_Tp(mesh_T+C_to_K, mesh_p), y_from_p(mesh_p), theta_ep_mesh, theta_ep_levels, colors = moist_colors) ax.axis((x_min, x_max, y_min, y_max)) def format_coord(x, y): T, p = to_thermo(x, y) return "{0:5.1f} C, {1:5.1f} mb".format(float(T), float(p)) ax.format_coord = format_coord ax.plot(x_snd_Td, y_snd_p, linewidth = 2, color = 'g') ax.plot(x_snd_T, y_snd_p, linewidth = 2, color = 'r') plt.show()