In [1]:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import pandas as pd
from scipy import optimize as opt
import matplotlib.image as mpimg

In [2]:
from customplotting import *
from dataprocessing import *
from slopes import *

Read in


In [3]:
df = pd.read_excel('Histograms.xlsx', sheetname=None,header=None)

Extract Data


In [4]:
RedIntensity,GreenIntensity,BlueIntensity,RedSTD,GreenSTD,BlueSTD,ExposureTimes = ExcelExtract(df)

First Plots. HSM and Film Data


In [5]:
HSM_Plot(RedIntensity,GreenIntensity,BlueIntensity,RedSTD,GreenSTD,BlueSTD,ExposureTimes)


Curve Fitting


In [6]:
RedRef,RedSlopes,RedIntensity,RedSTD,NewExposureTimes = GetSlopes(RedIntensity,RedSTD,ExposureTimes)
GreenRef,GreenSlopes,GreenIntensity,GreenSTD,NewExposureTimes = GetSlopes(GreenIntensity,GreenSTD,ExposureTimes)
BlueRef,BlueSlopes,BlueIntensity,BlueSTD,NewExposureTimes = GetSlopes(BlueIntensity,BlueSTD,ExposureTimes)

Second Plots. Line Fit on Film Data


In [7]:
Line_Plot(RedIntensity,GreenIntensity,BlueIntensity,RedSTD,GreenSTD,BlueSTD,RedSlopes,GreenSlopes,BlueSlopes,NewExposureTimes)



In [11]:
#Least Difference fitting to guess at layer number values.
#Choosing N such that the difference between calculated reflectivity and measured reflectivity is the least
def NFits(Refl,Color,N_Max):
    i = 2
    difference = abs(Ref(2,Color) - Refl)[0]
    for n in np.arange(3,N_Max+1):
        if abs(Ref(n,Color) - Refl)[0] < difference:
            i = n
            difference = abs(Ref(n,Color) - Refl)[0]
    return i

In [12]:
N_Max = 30 #Choose before curves begin to slope downwards.

In [13]:
Green_Fits = np.array([NFits(GreenRef[i],'green',N_Max) for i in np.arange(0,len(GreenRef))])
Green_Fits


Out[13]:
array([14, 15, 16, 21, 22, 29])

In [14]:
N_Guesses = Green_Fits

Third Plots. True Reflectivity


In [15]:
Ref_Plot(GreenRef,BlueRef,N_Guesses)