#!/bin/perl

do "parameters.pl";


# Open the file for reading.
open DATA, "Uloop_dp.csv" or die "can't open file $!";
my @UloopT = <DATA>;
close (DATA);
open DATA, "Irogowski_dp.csv" or die "can't open file $!";
my @IrogT = <DATA>;
close (DATA);

$Uloop=0;$Irog=0;$Ipl=0;
$Ich_new=0;$Ich_old=0;

open FH, ">Iplasma_dp.csv";
for ($i = 1; $i < $LineCount; ++$i)  
{
    @rowUloop = split(';',$UloopT[$i]);$Uloop=$rowUloop[1];
    @rowIrog = split(';',$IrogT[$i]);$Irog=$rowIrog[1];
    #$Ipl=$rowIrog[1]-($rowUloop[1]/$ChamberResistance);#without chamber induktance
    $Ich_new=($Uloop+$ChamberInduktance*$Ich_old/$DeltaTs)/($ChamberResistance+$ChamberInduktance/$DeltaTs);
    $Ipl=$Irog-$Ich_new;
    $Ich_old=$Ich_new;
    printf FH "%3.2f;%4.3f\n",$rowUloop[0],$Ipl;
}
close (FH);

