Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    def density_along_orbit(self, ax=None, annotate=True, min_fp_local_length=0, bg_color='dimgrey', cmap=None, vmin=1., vmax=3.):
        if cmap is None:
            cmap = plt.cm.autumn
            cmap.set_bad('dimgrey',0.)
            cmap.set_under('dimgrey',0.)

        if ax is None:
            ax = plt.gca()

        fp_local_list = [d for d in self.digitization_list if np.isfinite(d.fp_local)]

        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.9999)

        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=1., 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 fp_local_list:
            val = np.empty_like(self.t) + np.nan
            # for t, v in [(float(f.time), np.log10(ais_code.fp_to_ne(f.maximum_fp_local))) for f in fp_local_list]:
            #     val[np.abs(self.t - t) < ais_code.ais_spacing_seconds] = v

            for f in fp_local_list:
                t = float(f.time)
                # if (f.fp_local_error / f.fp_local) > 0.3:
                #     v = np.log10(20.)
                # else:
                v = np.log10(ais_code.fp_to_ne(f.fp_local))
                # print t, ais_code.fp_to_ne(f.fp_local), f.fp_local_error/f.fp_local > 0.3
                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:
            ticks = [i for i in range(10) if ((float(i)+0.1) > vmin) & ((float(i)-0.1) < vmax)]
            old_ax = plt.gca()
            plt.colorbar(lc, cax = celsius.make_colorbar_cax(offset=0.001, height=0.8),
                            ticks=ticks).set_label(r'$log_{10}\;n_e / cm^{-3}$')
            plt.sca(old_ax)