aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/index.py b/index.py
index 7c1b6a1..07cae4c 100644
--- a/index.py
+++ b/index.py
@@ -8,7 +8,6 @@ wavelength region where the PMTs are sensitive to. The data comes from [1].
"""
from __future__ import print_function, division
import numpy as np
-import matplotlib.pyplot as plt
A0 = 0.243905091
A1 = 9.53518094e-3
@@ -40,10 +39,28 @@ def get_index(p, wavelength, T):
if __name__ == '__main__':
import matplotlib.pyplot as plt
+ import argparse
- x = np.linspace(300,500,1000)
- plt.plot(x,get_index(1000,x,10))
+ parser = argparse.ArgumentParser("fit a Taylor series approximation to the inverse of the index of refraction of water")
+ parser.add_argument("--temperature", type=float, default=10.0)
+ parser.add_argument("--density", type=float, default=1000.0)
+ parser.add_argument("--deg", type=int, default=2)
+ parser.add_argument("--x0", type=float, default=400.0)
+ parser.add_argument("--low", type=float, default=300.0)
+ parser.add_argument("--high", type=float, default=600.0)
+ args = parser.parse_args()
+
+ x = np.linspace(args.low,args.high,1000)
+ n = get_index(args.density,x,args.temperature)
+ z = np.polyfit(x-args.x0,1/n, args.deg)
+ p = np.poly1d(z)
+
+ print(p)
+
+ plt.plot(x,1/n,label="data")
+ plt.plot(x,p(x-args.x0),label="fit")
plt.xlabel("Wavelength (nm)")
- plt.ylabel("Index of Refraction")
+ plt.ylabel("1/n")
plt.title("Index of Refraction of Water at 273.15 K")
+ plt.legend()
plt.show()