#!/usr/bin/perl -w

use lib "d:/Programs/Perl/lib";

use strict;
use Math::Spline;
#use PDL::Interpolate;

use Sci::Ellipsometry;

my $filepath = "SpecialResponse.csv";
my $Data = new Ellipsometry;
my ($nData, $pLabelArray, @pDataArray) = $Data->Read($filepath);
if(!defined $nData) {
	print "Error: Can not read [$filepath].\n";
	exit;
}
my $pX = $Data->GetData(0, "wl");
my $pY = $Data->GetData(1, "P");
if(!$pX or !$pY) {
	print "Error: NULL pX or pY[$pX, $pY].\n";
	exit;
}
my $spline=new Math::Spline($pX, $pY);
my $dx = $pX->[1] - $pX->[0];
for(my $i = 0 ; $i < $nData ; $i++) {
	my $x = $pX->[$i];
	my $y = $spline->evaluate($x+$dx/2.0);
	print "$x, $pY->[$i], $y\n";
}
