% ***********************************************************************
% waterCombinedEx.m
% ***********************************************************************
%
% Data description:
% refractive index (imaginary part) of water (200-2500nm), 
% linearly interpolated from original data (resolution of 5nm) 
%
% Prepared by: Mark Iwanchyshyn on March 2019
%
% ***********************************************************************
%
% Original data sources:
%
% Lower range (200-375nm):
% 	G.M. Hale and M.R. Querry, Optical Constants of Water in the 200-nm to
% 	200-um Wavelength Region, Applied Optics, Vol. 12, No. 3, pp 555-563,
% 	March 1973.
% 
% Medium range (380-720nm):
% 	R.M. Pope and E.S. Fry, Absorption spectrum (380-700nm) of pure water. 
% 	II. Integrating cavity measurements, Applied Optics, V. 36, N. 33,
% 	pp. 8710-8723, November, 1997.
%   Note: the overlapping point at 725nm is ommitted from this source.
%
% Upper range (725-2500nm): 
% 	K.F. Palmer and D. Williams, Optical Properties of water in the near 
% 	infrared, Journal of the Optical Society of America, V.64, 
% 	pp. 1107-1110, August, 1974.
%
% ***********************************************************************
clear all
lower_data=[
1.1000e-07 
9.7800e-08 
8.5600e-08 
7.3400e-08 
6.1200e-08 
4.9000e-08 
4.5900e-08 
4.2800e-08 
3.9700e-08 
3.6600e-08 
3.3500e-08 
3.1500e-08 
2.9500e-08 
2.7500e-08 
2.5500e-08 
2.3500e-08 
2.2000e-08 
2.0500e-08 
1.9000e-08 
1.7500e-08 
1.6000e-08 
1.4960e-08 
1.3920e-08 
1.2880e-08 
1.1840e-08 
1.0800e-08 
9.9400e-09 
9.0800e-09 
8.2200e-09 
7.3600e-09 
6.5000e-09 
5.9000e-09 
5.3000e-09 
4.7000e-09 
4.1000e-09 
3.5000e-09
];
lower_wave = 200:5:375;

lower_SAC = [
0.000113
0.000094
0.000085
0.000081
0.000066
0.000053
0.000047
0.000044
0.000045
0.000048
0.000049
0.000053
0.000063
0.000075
0.000092
0.000096
0.000098
0.000101
0.000106
0.000114
0.000127
0.000136
0.000150
0.000173
0.000204
0.000256
0.000325
0.000396
0.000409
0.000417
0.000434
0.000452
0.000474
0.000511
0.000565
0.000596
0.000619
0.000642
0.000695
0.000772
0.000896
0.001100
0.001351
0.001672
0.002224
0.002577
0.002644
0.002678
0.002755
0.002834
0.002916
0.003012
0.003108
0.003250
0.003400
0.003710
0.004100
0.004290
0.004390
0.004480
0.004650
0.004860
0.005160
0.005590
0.006240
0.00704
0.00827
0.01007
0.01231
];
lower_SAC_wave = 380:5:720;

upper_SAC = [
0.0134 
0.0186 
0.0238 
0.02548 
0.02716 
0.0279 
0.02765 
0.02682 
0.02586 
0.02492 
0.02405 
0.02317 
0.02238 
0.02162 
0.02088 
0.02025 
0.01963 
0.01927 
0.01933 
0.0199 
0.02409 
0.02828 
0.03193 
0.03475 
0.03757 
0.03952 
0.04089 
0.04225 
0.04436 
0.04696 
0.04956 
0.05253 
0.05575 
0.05897 
0.06266 
0.06707 
0.07147 
0.07759 
0.09053 
0.1035 
0.1164 
0.1363 
0.158 
0.193 
0.238 
0.298 
0.3667 
0.4412 
0.4827 
0.5023 
0.5106 
0.502 
0.4855 
0.469 
0.4425 
0.416 
0.3835 
0.351 
0.318 
0.285 
0.2605 
0.2359 
0.2161 
0.1975 
0.1829 
0.1711 
0.1621 
0.1574 
0.1527 
0.148 
0.1533 
0.1586 
0.1639 
0.1725 
0.1833 
0.1953 
0.212 
0.2287 
0.26 
0.295 
0.3418 
0.4355 
0.5293 
0.6778 
0.8402 
0.985 
1.06 
1.135 
1.188 
1.207 
1.226 
1.236 
1.243 
1.25 
1.25 
1.25 
1.25 
1.24 
1.23 
1.22 
1.203 
1.187 
1.17 
1.15 
1.13 
1.11 
1.098 
1.085 
1.073 
1.085 
1.104 
1.122 
1.167 
1.229 
1.291 
1.359 
1.456 
1.554 
1.651 
1.806 
1.977 
2.148 
2.43 
2.88 
3.33 
3.78 
4.203 
4.618 
5.034 
5.45 
6.418 
7.387 
8.355 
9.781 
13.04 
16.29 
19.55 
22.4 
24.67 
26.93 
29.19 
31.05 
31.3 
31.55 
31.47 
30.9 
30.33 
29.76 
29.19 
28.61 
27.26 
25.72 
24.17 
22.63 
21.15 
19.76 
18.37 
16.99 
15.6 
14.84 
14.08 
13.32 
12.56 
11.91 
11.42 
10.94 
10.45 
9.97 
9.546 
9.21 
8.875 
8.54 
8.204 
7.923 
7.679 
7.435 
7.191 
6.947 
6.744 
6.603 
6.463 
6.323 
6.182 
6.055 
5.98 
5.905 
5.83 
5.755 
5.68 
5.65 
5.65 
5.65 
5.65 
5.65 
5.65 
5.75 
5.85 
5.95 
6.05 
6.15 
6.276 
6.504 
6.732 
6.961 
7.189 
7.417 
7.649 
7.896 
8.143 
8.39 
8.637 
8.884 
9.131 
9.255 
9.349 
9.442 
9.473 
9.46 
9.447 
9.52 
9.72 
9.92 
10.12 
10.32 
10.52 
10.72 
14.8 
21.47 
28.15 
34.82 
41.49 
48.16 
54.83 
62.49 
70.8 
79.11 
87.43 
95.74 
104.1 
112.4 
120.7 
122.7 
120.5 
118.3 
116.1 
113.9 
111.6 
109.4 
104.9 
99.82 
94.71 
89.61 
84.51 
79.41 
74.3 
69.2 
66.25 
63.3 
60.35 
57.4 
54.44 
51.49 
48.54 
45.59 
43.67 
 42 
40.33 
38.67 
 37 
35.33 
33.67 
 32 
30.67 
29.85 
29.03 
28.2 
27.38 
26.56 
25.74 
24.92 
24.09 
23.48 
23.17 
22.86 
22.56 
22.25 
21.94 
21.63 
21.33 
21.02 
20.71 
20.41 
20.1 
19.79 
19.48 
19.4 
19.65 
19.89 
20.14 
20.39 
20.63 
20.88 
21.13 
21.37 
21.62 
21.87 
22.11 
22.36 
22.61 
22.85 
23.24 
23.83 
24.43 
25.02 
25.62 
26.21 
26.8 
27.4 
27.99 
28.59 
29.18 
30.21 
31.35 
32.48 
33.62 
34.75 
35.89 
37.03 
38.16 
39.3 
40.44 
41.57 
43.3 
45.17 
47.04 
48.91 
50.78 
52.65 
54.52 
56.39 
58.26 
60.13 
 62 
64.03 
66.67 
69.31 
71.95 
74.59 
77.22 
79.86 
82.5 
85.14 
87.78 
90.42 
93.06 
95.7 
];
upper_SAC_wave = 725:5:2500;

upper_wave = [lower_SAC_wave, upper_SAC_wave];
SAC_data = [lower_SAC; upper_SAC];
assert(length(upper_wave) == length(SAC_data));
% calculate k from sac
% k = sac * lambda * 1e-7 / (4.0 * 3.14159265358979323846264)
for i=1:length(upper_wave)
	upper_data(i) = SAC_data(i) * upper_wave(i) * 1e-7 / (4.0 * 3.141592653589);
end



data = [lower_data; reshape(upper_data,[],1)];
wave = [lower_wave, upper_wave];

fid=fopen('sand_waterCombinedEx.txt','wb');
for i=1:length(wave)
    fprintf(fid,'%d  %3.4e \n',wave(i),data(i));
end
fclose(fid);


% linear
%plot(wave,data,'b-','linewidth',3);
%axis([min(wave) max(wave) 0 max(data)]);

% log
semilogy(wave,data,'b-','linewidth',3);
axis([min(wave) max(wave) 1e-10 1e-0]);

set(gca,'FontSize', 14);
grid on
title('Water','fontsize',14)
ylabel('extinction coefficient','fontsize',14);
xlabel('wavelength (nm)','fontsize',14);
set(gcf,'PaperUnits','inches','PaperPosition',[0 0 6 5]);
pause
print('-dpng', '-r100','sand_waterCombinedEx.png');
close 
   




