All pastes #1804745 Raw Edit

gnu

public text v1 · immutable
#1804745 ·published 2010-02-21 16:32 UTC
rendered paste body
#!/usr/bin/perl######################## This programm calculates flow rates# from 2 files# * weight.txt (weigth as a func of time)# * range.txt (ranges of interest)# it fits in ranges the curve with a straight line# and report in flow.txt the results######################## Francois Boulogne# <boulogne at fast.u-psud.fr>#######################use warnings;open (RANGE, "<range.txt") or warn "cannot open range.txt";open(FLOW,">flow.txt") or warn "cannot open flow.txt";print FLOW "#number // flow rate(g/s) // error\n";my $count =1;while (<RANGE>){	# take back the range	@range = split(/ /,$_);	chomp(@range);	#remove old stuffs	system ("rm -f fit.log");	#write a gnuplot command file	open (GNUPLOT, ">gnuplot.gnu") or warn "cannot write gnuplot.gnu";	print GNUPLOT "fit \[$range[0]:$range[1]\] coeffa*x+coeffb \"weight\.txt\" u 1:2:(0.01) via coeffa,coeffb \n";	close(GNUPLOT) or warn "cannot close gnuplot.gnu";	#execute gnuplot	`gnuplot gnuplot.gnu`; 	print "END OF GNUPLOT\n";	open(FITLOG,"<fit.log") or warn "cannot open fit.log";	while(<FITLOG>)	{		# look for final set of parameters	 		if ($_ =~ s/(\w+)\s+=\s(.*?)\s+\+\/\-\s+(.*?)\s+\((.*?)\%\)/$1 $2 $3 $4/)		{			 #variable-value-error-%			@string = split(/ /,$_);			if ( $string[0] eq 'coeffa')			{			      print FLOW "$count $string[1] $string[2]\n";			      $count++;			}		}		}	close(FITLOG);}close(RANGE);close(FLOW);# Mr Propersystem ("rm -f gnuplot.gnu");system ("rm -f fit.log");