Beispiel #1
0
    def plot_orbit(self, plotfile, nsamp=100):

        coeffs = self.coeffs[0].T
        coords = self.coords / 1e3

        t = self.time
        time = np.linspace(self.t_start, self.t_stop, nsamp)

        if self.centered:
            time_cent = time - self.t_mean

            poly = np.asarray([
                np.polyval(coeffs[ii, :], time_cent) + mean_coords[ii]
                for ii in range(3)
            ]).T

        else:
            poly = np.asarray(
                [np.polyval(coeffs[ii, :], time) for ii in range(3)]).T

        poly /= 1e3

        gpt = Gnuplot()

        gpt.output(plotfile, term="pngcairo", fontsize=8)

        gpt.axis_format("x", "")
        gpt.margins(bmargin=3.5)
        gpt("set tics font ',8'")

        gpt.multiplot(3,
                      portrait=True,
                      title="Fit of orbital vectors - "
                      "degree of polynom: {}".format(self.deg))

        ylabels = ("X [km]", "Y [km]", "Z [km]")

        for ii in range(3):

            gpt.ylabel(ylabels[ii])

            points = gpt.data(t,
                              coords[:, ii],
                              title="Orbital coordinates",
                              vith=linedef(point_type="empty_circle"))

            fit = gpt.data(time,
                           poly[:, ii],
                           title="Fitted polynom",
                           vith="lines")

            if ii == 2:
                gpt("set format x")
                gpt.xlabel("Time [s]")

            gpt.plot(points, fit)