예제 #1
0
        axy.set_major_formatter(
            plt.FuncFormatter(
                lambda s, a: r'$%i^\circ$' % np.round(s * 180 / np.pi)))
    ax.set_xlim(-np.pi, np.pi)
    ax.set_ylim(-np.pi / 2, np.pi / 2)

    return ax


plt.figure()
ax = mercator_axes()
ax.grid(True)
plot_tissot_ellipse(circ_long[:, None],
                    circ_lat,
                    radius,
                    ax=ax,
                    fc='k',
                    alpha=0.3,
                    lw=0)
ax.set_title('Mercator projection')

#------------------------------------------------------------
# Other projections can be done more automatically
plt.figure(figsize=(10, 8))
plt.subplots_adjust(hspace=0,
                    wspace=0.1,
                    left=0.05,
                    right=0.95,
                    bottom=0.05,
                    top=1.0)
예제 #2
0
#   For more information, see http://astroML.github.com
import numpy as np
from matplotlib import pyplot as plt
from astroML.plotting import plot_tissot_ellipse

# ------------------------------------------------------------
# generate a latitude/longitude grid
circ_long = np.linspace(-np.pi, np.pi, 13)[1:-1]
circ_lat = np.linspace(-np.pi / 2, np.pi / 2, 7)[1:-1]
radius = 10 * np.pi / 180.0

# ------------------------------------------------------------
# Plot the built-in projections
plt.figure(figsize=(10, 8))
plt.subplots_adjust(hspace=0, wspace=0.1, left=0.05, right=0.95, bottom=0.05, top=1.0)

for (i, projection) in enumerate(["Hammer", "Aitoff", "Mollweide", "Lambert"]):
    ax = plt.subplot(221 + i, projection=projection.lower())

    ax.xaxis.set_major_locator(plt.FixedLocator(np.pi / 3 * np.linspace(-2, 2, 5)))
    ax.xaxis.set_minor_locator(plt.FixedLocator(np.pi / 6 * np.linspace(-5, 5, 11)))
    ax.yaxis.set_major_locator(plt.FixedLocator(np.pi / 6 * np.linspace(-2, 2, 5)))
    ax.yaxis.set_minor_locator(plt.FixedLocator(np.pi / 12 * np.linspace(-5, 5, 11)))

    ax.grid(True, which="minor")

    plot_tissot_ellipse(circ_long[:, None], circ_lat, radius, ax=ax, fc="k", alpha=0.3, linewidth=0)
    ax.set_title("%s projection" % projection)

plt.show()
예제 #3
0
#------------------------------------------------------------
# generate a latitude/longitude grid
circ_long = np.linspace(-np.pi, np.pi, 13)[1:-1]
circ_lat = np.linspace(-np.pi / 2, np.pi / 2, 7)[1:-1]
radius = 10 * np.pi / 180.



#------------------------------------------------------------
# plot Mercator projection: we need to set this up manually
def mercator_axes():
    ax = plt.axes(aspect=1.0)
    ax.set_xticks(np.pi / 6 * np.linspace(-5, 5, 11))
    ax.set_yticks(np.pi / 12 * np.linspace(-5, 5, 11))
    for axy in (ax.xaxis, ax.yaxis):
        axy.set_major_formatter(plt.FuncFormatter(lambda s, a: r'$%i^\circ$'
                                                  % np.round(s * 180 / np.pi)))
    ax.set_xlim(-np.pi, np.pi)
    ax.set_ylim(-np.pi / 2, np.pi / 2)

    return ax

plt.figure()
ax = mercator_axes()
ax.grid(True)
plot_tissot_ellipse(circ_long[:, None], circ_lat, radius,
                    ax=ax, fc='k', alpha=0.3, lw=0)
ax.set_title('Mercator projection')

plt.show()
예제 #4
0
    def plot_star_projected(self):
        # projections: ['Hammer', 'Aitoff', 'Mollweide', 'Lambert']
        projection = 'Hammer'

        # Plot the built-in projections
        plt.figure(figsize=(10, 10))
        ax = plt.subplot(211, projection=projection.lower())
        ax2 = plt.subplot(212)

        # plot latitude/longitude grid
        ax.xaxis.set_major_locator(plt.FixedLocator(np.pi / 3
                                                    * np.linspace(-2, 2, 5)))
        ax.xaxis.set_minor_locator(plt.FixedLocator(np.pi / 6
                                                    * np.linspace(-5, 5, 11)))
        ax.yaxis.set_major_locator(plt.FixedLocator(np.pi / 6
                                                    * np.linspace(-2, 2, 5)))
        ax.yaxis.set_minor_locator(plt.FixedLocator(np.pi / 12
                                                    * np.linspace(-5, 5, 11)))

        ax.grid(True, which='minor', color='gray', ls=':')
        ax.set_title(self.index)

        # plot transit path
        in_transit_times = self.lc.mask_out_of_transit(self.transit_params, oot_duration_fraction=0)['times'].jd
        # transit_chord_X, transit_chord_Y, transit_chord_Z = planet_position_cartesian(in_transit_times, self.transit_params)
        # transit_chord_x, transit_chord_y, transit_chord_z = project_planet_to_stellar_surface(transit_chord_X, transit_chord_Y)
        # transit_chord_x_s, transit_chord_y_s, transit_chord_z_s = observer_view_to_stellar_view(transit_chord_x,
        #                                                                                         transit_chord_y,
        #                                                                                         transit_chord_z,
        #                                                                                         self.transit_params,
        #                                                                                         in_transit_times)
        # transit_chord_r, transit_chord_theta, transit_chord_phi = cartesian_to_spherical(transit_chord_x_s,
        #                                                                                  transit_chord_y_s,
        #                                                                                  transit_chord_z_s)

        latitude, longitude = times_to_occulted_lat_lon(in_transit_times, self.transit_params)

        ax.scatter(longitude, latitude, color='k', s=0.7, alpha=0.5)


        # plot tissot ellipses for samples from the gaussian spots
        skip_every = 20000  # plots 50 ellipses per spot
        times = self.chains[::skip_every, 1::3].T
        amplitudes = self.chains[::skip_every, 0::3].T
        n_spots = times.shape[0]
        colors = ['b', 'g', 'r']
        while n_spots > len(colors):
            colors.extend(colors)

        for i, time, amplitude in zip(range(len(times)), times, amplitudes):
            X, Y, Z = planet_position_cartesian(time, self.transit_params)
            spot_x, spot_y, spot_z = project_planet_to_stellar_surface(X, Y)
            spot_x_s, spot_y_s, spot_z_s = observer_view_to_stellar_view(spot_x, spot_y, spot_z, self.transit_params, time)
            spot_r, spot_theta, spot_phi = cartesian_to_spherical(spot_x_s, spot_y_s, spot_z_s)

            longitude = spot_theta
            latitude = np.pi/2 - spot_phi

            alpha = np.median(amplitude)/self.transit_params.rp**2/25
            radius = 2*self.transit_params.rp  # from s=r*theta
            plot_tissot_ellipse(longitude, latitude, radius, ax=ax, linewidth=0,
                                fc=colors[i], alpha=alpha)

        # plot transit+spots model
        model = spotted_transit_model(self.best_params, self.lc.times.jd,
                                      self.transit_params)
        individual_models = spotted_transit_model_individuals(self.best_params,
                                                              self.lc.times.jd,
                                                              self.transit_params)

        errorbar_props = dict(fmt='.', color='k', capsize=0, ecolor='gray')


        min_jd_int = int(self.lc.times.jd.min())
        ax2.errorbar(self.lc.times.jd - min_jd_int, self.lc.fluxes,
                       self.lc.errors, **errorbar_props)
        ax2.plot(self.lc.times.jd - min_jd_int, model, 'r', lw='3')

        for individual_model in individual_models:
            ax2.plot(self.lc.times.jd - min_jd_int, individual_model, 'b')

        ax2.set_xlabel('JD - {0}'.format(min_jd_int))
        ax2.set_ylabel('Flux')