コード例 #1
0
ファイル: aisreview.py プロジェクト: irbdavid/mex
        def parse_error(d):
            if not np.isfinite(d.fp_local):
                return
            f = ais_code.fp_to_ne(d.fp_local)
            f0 = ais_code.fp_to_ne(d.fp_local + d.fp_local_error)
            f1 = ais_code.fp_to_ne(d.fp_local - d.fp_local_error)
            if errors:
                plt.plot((d.time, d.time),(f0,f1),
                    color='lightgrey', linestyle='solid',
                    marker='None', zorder=-1000,**kwargs)
            plt.plot(d.time, f, fmt, ms=self.marker_size, zorder=1000, **kwargs)

            if full_marsis and hasattr(d, 'maximum_fp_local'):
                plt.plot(d.time, ais_code.fp_to_ne(d.maximum_fp_local),
                    'b.', ms=self.marker_size, zorder=900, **kwargs)

            if full_marsis:
                if np.isfinite(d.morphology_fp_local):
                    v, e = ais_code.fp_to_ne(d.morphology_fp_local,
                                                d.morphology_fp_local_error)
                    plt.errorbar(float(d.time), v, yerr=e,
                            marker='x', ms=1.3, color='purple',
                            zorder=1e90, capsize=0., ecolor='plum')

                if np.isfinite(d.integrated_fp_local):
                    v, e = ais_code.fp_to_ne(d.integrated_fp_local,
                                                d.integrated_fp_local_error)
                    plt.errorbar(float(d.time), v, yerr=e,
                            marker='x', ms=1.3, color='blue',
                            zorder=1e99, capsize=0., ecolor='cyan')
コード例 #2
0
ファイル: aisreview.py プロジェクト: irbdavid/mex
    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)