def main(orbit=8021, close=True, debug=False, fname=None, fig=None, verbose=False, output_fname=None, **kwargs): if close: plt.close('all') if fname is None: fname = mex.locate_data_directory() + \ 'marsis/ais_digitizations/%05d/%05d.dig' % ( (orbit // 1000) * 1000, orbit) try: print('DB: ', fname) a = AISReview(orbit, debug=debug, db_filename=fname, fig=fig, verbose=verbose) a.main(**kwargs) except Exception as e: print('AISReview Failed: ', e) raise
def main(self, fname=None, show=False, figurename=None, save=False, along_orbit=False, set_cmap=True): # if len(a.digitization_list) < 100: # return if set_cmap: plt.hot() fig = plt.figure(figsize=(8.27, 11.69), dpi=70) n = 8 + 4 + 1 + 1 + 1 hr = np.ones(n) hr[-4:] = 0.5 g = mpl.gridspec.GridSpec(n,1, hspace=0.1, height_ratios=hr, bottom=0.06, right=0.89) axes = [] prev = None for i in range(n): axes.append(plt.subplot(g[i], sharex=prev)) axes[i].set_xlim(self.extent[0], self.extent[1]) axes[i].yaxis.set_major_locator( mpl.ticker.MaxNLocator(prune='upper', nbins=5, steps=[1,2,5,10])) l = celsius.SpiceetLocator() axes[i].xaxis.set_major_locator(l) axes[i].xaxis.set_major_formatter( celsius.SpiceetFormatter(locator=l)) prev = axes[-1] axit = iter(axes) self.plot_aspera_ima(ax=next(axit), inverted=False) self.plot_aspera_els(ax=next(axit)) self.plot_mod_b(ax=next(axit)) self.plot_ne(ax=next(axit)) self.plot_timeseries(ax=next(axit)) self.plot_frequency_range(ax=next(axit), f_min=0.0, f_max=0.2, colorbar=True) # self.plot_frequency_range(ax=axit.next(), f_min=0.2, f_max=0.5) self.plot_frequency(ax=next(axit), f=0.5) # self.plot_frequency(ax=axit.next(), f=0.75) self.plot_frequency(ax=next(axit), f=1.) # self.plot_frequency(ax=axit.next(), f=1.52) self.plot_frequency(ax=next(axit), f=2.) self.plot_tec(ax=next(axit)) # twx = plt.twinx() # t = mex.sub_surface.read_tec(self.start_time, self.finish_time) # good = t['FLAG'] == 1 # plt.plot(t['EPHEMERIS_TIME'][good], t['TEC'][good], 'k.', mew=0.) # plt.ylabel(r'$TEC / m^{-2}$') # plt.yscale('log') # plt.ylim(3E13, 2E16) # self.plot_profiles(ax=axit.next()) # self.plot_profiles_delta(ax=axit.next()) # self.plot_peak_altitude(ax=axit.next()) # self.plot_peak_density(ax=axit.next()) self.plot_profiles(ax=next(axit)) # self.plot_tec(ax=axit.next()) self.plot_altitude(ax=next(axit)) self.plot_lat(ax=next(axit)) self.plot_lon(ax=next(axit)) self.plot_sza(ax=next(axit)) # axes[-1].xaxis.set_major_formatter(celsius.SpiceetFormatter()) for i in range(n-1): plt.setp( axes[i].get_xticklabels(), visible=False ) axes[i].set_xlim(self.extent[0], self.extent[1]) l = celsius.SpiceetLocator() axes[i].xaxis.set_major_locator(l) axes[i].xaxis.set_major_formatter( celsius.SpiceetFormatter(locator=l)) plt.annotate("Orbit %d, plot start: %s, newest digitization: %s" % ( self.orbit, celsius.spiceet_to_utcstr(self.extent[0],fmt='C')[0:17], self._newest), (0.5, 0.93), xycoords='figure fraction', ha='center') if save: if figurename is None: fname = mex.locate_data_directory() + ('ais_plots/v0.9/%05d/%d.pdf' % ((self.orbit // 1000) * 1000, self.orbit)) else: fname = figurename print('Writing %s' % fname) d = os.path.dirname(fname) if not os.path.exists(d) and d: os.makedirs(d) plt.savefig(fname) if show: plt.show() else: plt.close(fig) plt.close('all') if along_orbit: # fig = plt.figure() fig, ax = plt.subplots(2, 1, squeeze=True, figsize=(4,4), dpi=70, num=plt.gcf().number + 1) plt.subplots_adjust(hspace=0.3,wspace=0.0, right=0.85) self.density_along_orbit(ax[0], vmax=4.) self.modb_along_orbit(ax[1], vmax=100.) if save: fname = mex.locate_data_directory() + ('ais_plots/A0_v0.9/%05d/%d.pdf' % ((self.orbit // 1000) * 1000, self.orbit)) print('Writing %s' % fname) d = os.path.dirname(fname) if not os.path.exists(d): os.makedirs(d) plt.savefig(fname) if show: plt.show() else: plt.close(fig) plt.close('all')
def stacked_f_plots(start=7894, finish=None, show=True, frequencies=[0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 2.0, 3.0]): gc.enable() if finish is None: finish = start + 1 plt.close("all") fig = plt.figure(figsize = celsius.paper_sizes['A4']) orbits = list(range(start, finish)) if len(orbits) > 1: show = False # plt.hot() for o in orbits: plt.clf() gc.collect() fname = mex.locate_data_directory() + 'marsis/ais_digitizations/%05d/%05d.dig' % ((o // 1000) * 1000, o) try: a = AISReview(o, debug=True, db_filename=fname) except Exception as e: print(e) continue n = len(frequencies) + 4 hr = np.ones(n) hr[0] = 2. g = mpl.gridspec.GridSpec(n,1, hspace=0.1, height_ratios=hr) axes = [] prev = None for i in range(n): axes.append(plt.subplot(g[i], sharex=prev)) axes[i].set_xlim(a.extent[0], a.extent[1]) axes[i].yaxis.set_major_locator(mpl.ticker.MaxNLocator(prune='upper', nbins=5, steps=[1,2,5,10])) axes[i].xaxis.set_major_locator(celsius.SpiceetLocator()) axes[i].xaxis.set_major_formatter(celsius.SpiceetFormatter()) prev = axes[-1] ax = iter(axes) a.plot_timeseries(ax=next(ax)) a.plot_frequency_range(ax=next(ax), f_min=0.0, f_max=0.2) for i, f in enumerate(frequencies): a.plot_frequency_altitude(ax=next(ax), f=f) plt.sca(next(ax)) b = a.quick_field_model(a.t) plt.plot(a.t, np.sqrt(np.sum(b**2., 0)), 'k-') plt.plot(a.t, b[0], 'r-') plt.plot(a.t, b[1], 'g-') plt.plot(a.t, b[2], 'b-') celsius.ylabel(r'$B_{SC} / nT$') plt.sca(next(ax)) ion_pos = a.iau_pos ion_pos[0,:] = 150.0 + mex.mars_mean_radius_km bion = a.field_model(ion_pos) plt.plot(a.t, np.sqrt(np.sum(bion**2., 0)), 'k-') plt.plot(a.t, bion[0], 'r-') plt.plot(a.t, bion[1], 'g-') plt.plot(a.t, bion[2], 'b-') celsius.ylabel(r'$B_{150} / nT$') for i in range(n-1): ax = axes[i] plt.setp( ax.get_xticklabels(), visible=False ) ax.xaxis.set_major_formatter(celsius.SpiceetFormatter()) plt.annotate("Orbit %d, plot start: %s" % (o, celsius.spiceet_to_utcstr(a.extent[0])[0:14]), (0.5, 0.93), xycoords='figure fraction', ha='center') if show: plt.show() gc.collect()
# maRS radio sounder data handler import numpy as np import matplotlib.pylab as plt import matplotlib as mpl import glob import mex maRs_data_directory = mex.locate_data_directory() + '/maRs/' class maRSSounding(object): """docstring for maRSSounding""" def __init__(self, time, load=True): super(maRSSounding, self).__init__() self.loaded = False if load: self.load(time) def plot(self, ax=None, labels=True): """docstring for plot""" if not self.loaded: raise mex.MEXException('Data not loaded') if ax == None: ax = plt.gca() plt.plot(self.density, self.geopotential_height, 'k-') if labels: plt.xlabel(r'$n_e / cm^{-3}$')