def plot_peak_altitude(self, ax=None, true_color='k', apparent_color='grey'): if ax is None: ax = plt.gca() plt.sca(ax) for d in self.digitization_list: if d.is_invertible(): if d.altitude.size == 0: try: d.invert(substitute_fp=ais_code.ne_to_fp(4.)) except BaseException as e: print(e) continue if apparent_color: plt.plot(d.time, d.altitude[-1], marker='.', ms=self.marker_size, color=apparent_color) alt = mex.iau_pgr_alt_lat_lon_position(float(d.time))[0] plt.plot(d.time, alt - d.traced_delay[-1] * ais_code.speed_of_light_kms / 2., marker='.', color=true_color, ms=self.marker_size) celsius.ylabel(r'$h_{max} / km$') plt.ylim(0o1, 249)
def orbit_plots(orbit_list=[8020, 8021, 8022, 8023, 8024, 8025], resolution=200, ax=None): if ax is None: ax = plt.gca() plt.sca(ax) orbits = {} props = dict(marker="None", hold=True, mec=None, linestyle="-", markeredgewidth=0.0) # props = dict(marker='o', hold=True,mec='None',line style='None',markeredgewidth=0.0) for orbit in orbit_list: orbit_t = mex.orbits[orbit] print(orbit, orbit_t.start, orbit_t.finish) t = np.linspace(orbit_t.start, orbit_t.finish, resolution) pos = mex.iau_pgr_alt_lat_lon_position(t) # orbits[orbit] = dict(lat = np.rad2deg(pos[2]), lon = np.rad2deg(np.unwrap(pos[1])), # alt=pos[0] - mex.mars_mean_radius_km, t=t) orbits[orbit] = dict(lat=pos[1], lon=np.rad2deg(np.unwrap(np.deg2rad(pos[2]))), alt=pos[0], t=t) ll = plt.plot(orbits[orbit]["lon"], orbits[orbit]["lat"], label=str(orbit), **props) plt.plot( orbits[orbit]["lon"] + 360.0, orbits[orbit]["lat"], label="_nolegend_", color=ll[0].get_color(), **props ) plt.plot( orbits[orbit]["lon"] - 360.0, orbits[orbit]["lat"], label="_nolegend_", color=ll[0].get_color(), **props ) plt.xlim(-180, 180) plt.ylim(-90, 90) plt.xlabel("Longitude / deg") plt.ylabel("Latitude / deg") plt.legend(loc="center left", bbox_to_anchor=(1.01, 0.5), numpoints=1, title="Orbit") ax.xaxis.set_major_locator(celsius.CircularLocator()) ax.yaxis.set_major_locator(celsius.CircularLocator())
def update(self): """ This redraws the various axes """ plt.sca(self.ig_ax) plt.cla() if debug: print('DEBUG: Plotting ionogram...') alpha = 0.5 self.current_ionogram.interpolate_frequencies() # does nothing if not required self.current_ionogram.plot(ax=self.ig_ax, colorbar=False, vmin=self.vmin, vmax=self.vmax, color='white', verbose=debug, overplot_digitization=True,alpha=alpha,errors=False, overplot_model=False, overplot_expected_ne_max=True) if debug: print('DEBUG: ... done') plt.colorbar(cax=self.cbar_ax, orientation='horizontal', ticks=mpl.ticker.MultipleLocator()) plt.sca(self.cbar_ax) plt.xlabel(r'spec. dens. / $V^2m^{-2}Hz^{-1}$') plt.sca(self.ig_ax) # Plasma and cyclotron lines if len(self.selected_plasma_lines) > 0: extent = plt.ylim() for v in self.selected_plasma_lines: plt.vlines(v, extent[0], extent[1], 'red',alpha=alpha) if len(self.selected_cyclotron_lines) > 0: extent = plt.xlim() for v in self.selected_cyclotron_lines: plt.hlines(v, extent[0], extent[1], 'red',alpha=alpha) f = self.current_ionogram.digitization.morphology_fp_local if np.isfinite(f): plt.vlines( np.arange(1., 5.) * f / 1E6, plt.ylim()[0], plt.ylim()[1], color='red', lw=1.,alpha=alpha) # If current digitization is invertible, do it and plot it if self.current_ionogram.digitization: if debug: print('DEBUG: Inverting, computing model...') d = self.current_ionogram.digitization plt.sca(self.ne_ax) plt.cla() if d.is_invertible(): winning = d.invert() if winning & np.all(d.density > 0.) & np.all(d.altitude > 0.): plt.plot(d.density, d.altitude, color='k') plt.xlim(5.E1, 5E5) plt.ylim(0,499) alt = np.arange(0., 499., 5.) if self.current_ionogram.sza < 89.9: plt.plot(self.ionospheric_model(alt, np.deg2rad(self.current_ionogram.sza)), alt, color='green') plt.grid() plt.xscale('log') plt.xlabel(r'$n_e / cm^{-3}$') plt.ylabel('alt. / km') fname = self.digitization_db.filename if len(fname) > 30: fname = fname[:10] + '...' + fname[-20:] plt.title('Database: ' + fname) if debug: print('DEBUG: Plotting timeseries....') # Timeseries integrated bar plt.sca(self.tser_ax) plt.cla() plt.imshow(self.tser_arr[::-1,:], vmin=self.vmin, vmax=self.vmax, interpolation='Nearest', extent=self.extent, origin='upper',aspect='auto') plt.xlim(self.extent[0], self.extent[1]) plt.ylim(self.extent[2], self.extent[3]) plt.ylim(0., 5.5) plt.vlines(self.current_ionogram.time, self.extent[2], self.extent[3], self.stored_color) plt.hlines(self.timeseries_frequency, self.extent[0], self.extent[1], self.stored_color, 'dashed') plt.ylabel('f / MHz') # Frequency bar plt.sca(self.freq_ax) plt.cla() freq_extent = (self.extent[0], self.extent[1], ais.ais_max_delay*1E3, ais.ais_min_delay*1E3) inx = 1.0E6 * (self.current_ionogram.frequencies.shape[0] * self.timeseries_frequency) /\ (self.current_ionogram.frequencies[-1] - self.current_ionogram.frequencies[0]) self._freq_bar_data = self.tser_arr_all[:,int(inx),:] plt.imshow(self.tser_arr_all[:,int(inx),:], vmin=self.vmin, vmax=self.vmax, interpolation='Nearest', extent=freq_extent, origin='upper',aspect='auto') plt.xlim(freq_extent[0], freq_extent[1]) plt.ylim(freq_extent[2], freq_extent[3]) plt.vlines(self.current_ionogram.time, freq_extent[2],freq_extent[3], self.stored_color) plt.ylabel(r'$\tau_D / ms$') title = "AISTool v%s, Orbit = %d, Ionogram=%s " % (__version__, self.orbit, celsius.spiceet_to_utcstr(self.current_ionogram.time, fmt='C')) if self.browsing: title += '[Browsing] ' if self.minimum_interaction_mode: title += '[Quick] ' if self._digitization_saved == False: title += 'UNSAVED ' if self.get_status() is not None: title += '[Status = %s] ' % self.get_status() pos, sza = mex.mso_r_lat_lon_position(float(self.current_ionogram.time), sza=True) title += '\nMSO: Altitude = %.1f km, Elevation = %.1f, Azimuth = %.1f deg, SZA = %.1f' % (pos[0] - mex.mars_mean_radius_km, mex.modpos(pos[1]), mex.modpos(pos[2]), sza) pos = mex.iau_pgr_alt_lat_lon_position(float(self.current_ionogram.time)) title += '\nIAU: Altitude = %.1f km, Latitude = %.1f, Longitude = %.1f deg' % ( pos[0], pos[1], mex.modpos(pos[2])) plt.sca(self.tser_ax) plt.title(title) # Message history: if len(self._messages): txt = '' for i, s in enumerate(self._messages): txt += str(i + self._message_counter) + ': ' + s + '\n' plt.annotate(txt, (0.05, 0.995), xycoords='figure fraction', fontsize=8, horizontalalignment='left', verticalalignment='top') # Axis formatters need redoing after each cla() nf = mpl.ticker.NullFormatter loc_f = celsius.SpiceetLocator() loc_t = celsius.SpiceetLocator() self.freq_ax.xaxis.set_major_formatter(celsius.SpiceetFormatter(loc_f)) self.tser_ax.xaxis.set_major_formatter(nf()) self.freq_ax.xaxis.set_major_locator(loc_f) self.tser_ax.xaxis.set_major_locator(loc_t) if debug: print('DEBUG: drawing...') self.figure.canvas.draw() return self