#!bin/perl

do "parameters.pl";

# Open the file for reading.
open DATA1, "Btoroidal_dp.csv" or die "can't open file $!";
my @data1 = <DATA1>;
close (DATA1);

# Open the file for reading.
open DATA2, "Iplasma_dp.csv" or die "can't open file $!";
my @data2 = <DATA2>;
close (DATA2);

$PeakFactor=2;

open CIL, ">PeakFactor";
print CIL "$PeakFactor";
close (CIL);


for ($i=0;$i<$LineCount;++$i)
{
	@row1=split(';',$data1[$i+1]);
	@row2=split(';',$data2[$i]);
	$Time[$i]=$row1[0];
	$QedgeTime[$i]= $row2[1]==0 ? 0 : 90.3*abs($row1[1]/($row2[1]))*1e3;
	$Q0Time[$i]=$QedgeTime[$i]/($PeakFactor+1);
}

open CIL1, ">QedgeTime.txt";
for ($i=0;$i<$LineCount;$i++)
{
	print CIL1 "$Time[$i]	$QedgeTime[$i]	$Q0Time[$i]\n";
}
close (CIL1);
