def plot_mod_b(self, fmt='k.', ax=None, field_model=True, errors=True, field_color='blue', br=True, t_offset=0., label=True, **kwargs): if ax is None: ax = plt.gca() plt.sca(ax) sub = [d for d in self.digitization_list if np.isfinite(d.td_cyclotron)] if len(sub) == 0: print("No digitizations with marked cyclotron frequency lines") return t = np.array([d.time for d in sub]) b = np.array([d.td_cyclotron for d in sub]) e = np.array([d.td_cyclotron_error for d in sub]) # print b # print e b, e = ais_code.td_to_modb(b, e) b *= 1.E9 e *= 1.E9 if errors: for tt,bb,ee in zip(t,b,e): plt.plot((tt,tt),(bb+ee,bb-ee), color='lightgrey',linestyle='solid',marker='None') plt.plot(tt,bb,fmt,ms=self.marker_size, **kwargs) # plt.errorbar(t, b, e, fmt=fmt, ms=self.marker_size, **kwargs) else: plt.plot(t, b, fmt, ms=self.marker_size, **kwargs) if field_model: self.generate_position() if field_color is None: field_color = fmt[0] # b = self.quick_field_model(self.t) self._computed_field_model = self.field_model(self.iau_pos) bmag = np.sqrt(np.sum(self._computed_field_model**2., 0)) plt.plot(self.t - t_offset, bmag, color=field_color, ls='-') if br: plt.plot(self.t - t_offset, self._computed_field_model[0], 'r-') plt.plot(self.t - t_offset, -1. * self._computed_field_model[0], 'r', ls='dashed') model_at_value = np.interp(t, self.t, bmag) inx = (model_at_value > 100.) & ((b / model_at_value) < 0.75) plt.plot(t[inx], b[inx], 'ro', mec='r', mfc='none', ms=5., mew=1.2) if label: celsius.ylabel(r'$\mathrm{|B|/nT}$') plt.ylim(0., 200)
def modb_along_orbit(self, ax=None, annotate=True, bg_color='dimgrey', cmap=None, vmin=0., vmax=20.): if ax is None: ax = plt.gca() if cmap is None: cmap = plt.cm.autumn cmap.set_bad('dimgrey',0.) cmap.set_under('dimgrey',0.) td_cyclotron_list = [d for d in self.digitization_list if np.isfinite(d.td_cyclotron)] plt.sca(ax) mex.plot_planet(lw=3.) mex.plot_bs(lw=1., ls='dashed', color='k') mex.plot_mpb(lw=1., ls='dotted', color='k') ax.set_aspect('equal','box') plt.xlim(2,-2) plt.autoscale(False,tight=True) plt.ylim(0., 1.999) if annotate: plt.annotate('%d' % self.orbit, (0.05, 0.85), xycoords='axes fraction', va='top') def f_x(pos): return pos[0] / mex.mars_mean_radius_km def f_y(pos): return np.sqrt(pos[1]**2. + pos[2]**2.) / mex.mars_mean_radius_km # def f_y(pos): # return pos[2] / mex.mars_mean_radius_km plt.plot( f_x(self.mso_pos), f_y(self.mso_pos), color=bg_color, lw=2., zorder=-10) inx = np.interp(np.array([d.time for d in self.ionogram_list]), self.t, np.arange(self.t.shape[0])) inx = inx.astype(int) plt.plot(f_x(self.mso_pos[:,inx]), f_y(self.mso_pos[:,inx]), color=bg_color, ls='None',marker='o', ms=8., mew=0., mec=bg_color, zorder=-9) if td_cyclotron_list: val = np.empty_like(self.t) + np.nan for t, v in [(float(f.time), 1E9 * ais_code.td_to_modb(f.td_cyclotron)) for f in td_cyclotron_list]: val[np.abs(self.t - t) < ais_code.ais_spacing_seconds] = v points = np.array([f_x(self.mso_pos), f_y(self.mso_pos)]).T.reshape(-1, 1, 2) segments = np.concatenate([points[:-1], points[1:]], axis=1) lc = LineCollection(segments, cmap=cmap, norm=plt.Normalize(vmin=vmin, vmax=vmax, clip=True)) lc.set_array(val) lc.set_linewidth(5) plt.gca().add_collection(lc) else: lc = None plt.ylabel(r'$\rho / R_M$') # plt.ylabel(r'$z / R_M$') plt.xlabel(r'$x / R_M$') if lc: old_ax = plt.gca() plt.colorbar(lc, cax = celsius.make_colorbar_cax(offset=0.001, height=0.8) ).set_label(r'$|B| / nT$') plt.sca(old_ax)