def plot_lon(self, ax=None, label=True, fmt='k-', **kwargs): if ax is None: ax = plt.gca() plt.sca(ax) self.make_axis_circular(ax) self.generate_position() v = celsius.deg_unwrap(self.iau_pos[2]) for i in [-1,0,1]: plt.plot(self.t, v + i * 360, fmt, **kwargs) if label: celsius.ylabel(r'$\varphi$') plt.ylim(0., 360.)
def plot_surface_map(orbits, ax=None, param="time", cmap=None, norm=None, **kwargs): import mars.field_models import pickle from matplotlib.cm import summer if ax is None: ax = plt.gca() else: plt.sca(ax) if cmap is None: cmap = summer setup_lat_lon_ax(ax=ax) try: mars.field_models.plot_lat_lon_field(value="|B|", cax=celsius.make_colorbar_cax(half=True, upper=True)) except NotImplementedError as e: pass if not "ais_index" in celsius.datastore: celsius.datastore["ais_index"] = mex.ais.get_ais_index() g = celsius.datastore["ais_index"] g = [v for k, v in g.items() if k in orbits] if not g: raise ValueError("No data?") for gg in g: gg["iau_pos"][2, :] = celsius.deg_unwrap(gg["iau_pos"][2, :]) if param is None: for gg in g: for i in (-1, 0, 1): plt.plot(gg["iau_pos"][2, :] + i * 360.0, gg["iau_pos"][1, :], **kwargs) if param == "sza": if norm is None: norm = plt.Normalize(vmin=0.0, vmax=180.0) title = "SZA / deg" elif param == "time": if norm is None: norm = plt.Normalize(vmin=mex.orbits[min(orbits)].start, vmax=mex.orbits[max(orbits)].finish) title = "Time / ET" elif param == "alt": if norm is None: norm = plt.Normalize(vmin=0.0, vmax=mex.mars_mean_radius_km) title = "Alt. / km" else: raise ValueError("Unrecognised parameter % s" % param) cmap = summer lc = None lc_kw = dict(cmap=cmap, norm=norm, linewidths=4, max_step=10.0) for gg in g: for i in (-1.0, 0.0, 1.0): if param == "sza": lc = celsius.map_along_line( gg["iau_pos"][2, :] + i * 360.0, gg["iau_pos"][1, :], gg["sza"], time=gg["time"], **lc_kw ) if param == "time": lc = celsius.map_along_line( gg["iau_pos"][2, :] + i * 360.0, gg["iau_pos"][1, :], gg["time"], time=gg["time"], **lc_kw ) if param == "alt": lc = celsius.map_along_line( gg["iau_pos"][2, :] + i * 360.0, gg["iau_pos"][1, :], gg["iau_pos"][0, :], time=gg["time"], **lc_kw ) # plt.scatter(gg['iau_pos[2,:], gg['iau_pos[1,:], c=gg['sza, # s=10., vmin=30, vmax=150, edgecolor='none') if lc: c = plt.colorbar(lc, cax=celsius.make_colorbar_cax(half=True, upper=False)) c.set_label(title) else: raise ValueError("Nothing mapped :(") plt.sca(ax) return lc