import numpy as np
import matplotlib.pyplot as plt
from MicrofacetModel3 import *

'''
     BRDF measurements of the black underlayer background (RU1) and glaze (RU5). Belonging to publication
     Multi-scale optical coherence tomography imaging and visualization of Vermeer's Girl with a Pearl Earring
     https://doi.org/10.1364/OE.390703
'''


def plot(fitted1, fitted2):
    reflect_angles = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]

    Black_OC2A2_RU1_45 = [21.12550792, 21.51965814, 22.00350072, 22.54344499, 23.26885237, 24.02732645, 24.78694708, 25.63664052, 26.60329328, 27.71453192, 28.95471401, 30.20530238, 31.23403327, 32.06952185, 32.36226831, 32.06530757]
    Green_OC5Cb_RU5_45 = [12.78466481, 15.1644459, 18.76103753, 23.93303568, 31.3901636, 42.03449203, 56.38671062, 74.94302567, 99.47766701, 127.3602599, 119.2397545, 100.0386931, 83.39877529, 69.23968636, 57.88954967, 49.34569157]

    plt.scatter(reflect_angles, Black_OC2A2_RU1_45, marker='p', c='#fc8d59', alpha=1.0, label=r'OC2A2 RU1: $\theta_i = 45^{\circ}$')
    plt.scatter(reflect_angles, Green_OC5Cb_RU5_45, marker='<', c='#99d594', alpha=1.0, label=r'OC5Cb RU5: $\theta_i = 45^{\circ}$')
    
    plt.plot(reflect_angles, fitted1, ':', c='#fc8d59', alpha=1.0, label=r'Fitted $\alpha=0.5$: $\theta_i = 45^{\circ}$')
    plt.plot(reflect_angles, fitted2, ':', c='#99d594', alpha=1.0, label=r'Fitted $\alpha=0.05$: $\theta_i = 45^{\circ}$')

    plt.title('Plot of fitted BRDF model')

    plt.grid(True)

    plt.xlabel(r'View angle $\theta_r^{\circ}$')
    plt.ylabel(r'Spectrually averaged BRDF$/sr^{-1}$')

    plt.legend()
    plt.show()

if __name__ == "__main__":
    # fitted data for angle 45 degrees
    # parameters: (alpha, normalization)
    fitted1 = SimMicrofacet(0.5, 7500.0)
    fitted2 = SimMicrofacet(0.05, 2000.0)
    plot(fitted1, fitted2)