snippet_venus.VenusBoundaries

__author__ = 'moa'

"""
Plotting Venus boundaries as described in Martinecz et al. (2008), "Location of the bow shock and ion composition
boundaries at Venus — initial determinations from Venus Express ASPERA-4" PSS 56, 780-784.
"""

import matplotlib.pyplot as plt
import matplotlib.patches as patch
import numpy as np


def main():

    fig, ax = plt.subplots(1, 1, figsize=[10, 10])

    # Plot Venus as a circle
    circle = plt.Circle((0, 0), 1, color='g', fill=False, lw=5)

    # Plot the ICB (a circle at x<0 and a regression line at x>0)
    circle1 = patch.Arc((0, 0), 2*1.109, 2*1.109, angle=0.0, theta1=0.0, theta2=90.0, color='b', lw=5)

    x_lims = np.arange(-2., 0.01, 0.01)
    k = -0.097
    d = 1.109
    ICB_line = k * x_lims + d
    plt.plot(x_lims, ICB_line, 'b', lw=5)

    # Plot the bow shock
    l = 1.303
    e = 1.056
    x0 = 0.788
    angle = np.arange(0, 180, 0.01)*np.pi/180

    BS_radius = l/(1 + e*np.cos(angle))
    BS_x = BS_radius*np.cos(angle) + x0
    BS_y = BS_radius*np.sin(angle)
    plt.plot(BS_x[BS_x < BS_radius+x0], BS_y[BS_x < BS_radius+x0], 'r', lw=5)

    # Add text of the boundaries
    plt.annotate('VENUS', xy=(0.4, 0.1), xycoords='axes fraction', xytext=(0, 0), textcoords='offset points',
                 va='top', fontsize=48)
    plt.annotate('BS', xy=(0.7, 0.4), xycoords='axes fraction', xytext=(0, 0), textcoords='offset points',
                 va='top', fontsize=48)
    plt.annotate('IMB', xy=(0.2, 0.35), xycoords='axes fraction', xytext=(0, 0), textcoords='offset points',
                 va='top', fontsize=48)

    ax.set_xlim(-2., 2.)
    ax.set_ylim(0, 4.)
    ax.set_ylabel('Rcyl VSO $[R_V]$', fontsize=32)
    ax.set_xlabel('X VSO $[R_V]$', fontsize=32)
    ax.tick_params(labelsize=32)
    fig.gca().add_artist(circle)
    fig.gca().add_artist(circle1)
    ax.xaxis.set_ticks(np.arange(-2., 2.01, 1.))
    ax.yaxis.set_ticks(np.arange(0., 4.01, 1.))
    plt.savefig('VenusBoundaries.pdf', bbox_inches='tight')

    plt.show()


if __name__ == '__main__':
    main()