aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetIOASCII/src/util
diff options
context:
space:
mode:
authorhawke <>2003-07-07 12:09:00 +0000
committerhawke <>2003-07-07 12:09:00 +0000
commit6895cd0f1f3980603447af128918d26eb2d88c87 (patch)
tree7c5aa99e2dfcc34d033a7cdc14e83a8e4c0fe8a6 /Carpet/CarpetIOASCII/src/util
parente749277b1e79eb11a30bb7d7de9480fd71207b7c (diff)
Another perl utility for converting CarpetIOASCII gnuplot output to ygraph. This one removes all the "redundant" points on the coarser grids, replacing them with the fine grid data.
Another perl utility for converting CarpetIOASCII gnuplot output to ygraph. This one removes all the "redundant" points on the coarser grids, replacing them with the fine grid data. Note that it does not give informative headers in the final files. Neither does it check that the output lines are aligned for different refinement levels - you may end up with very strange pictures. darcs-hash:20030707120930-58737-3d2a40384503d0aac9961f76261fa59294bbf5b8.gz
Diffstat (limited to 'Carpet/CarpetIOASCII/src/util')
-rwxr-xr-xCarpet/CarpetIOASCII/src/util/Carpet2ygraphCat.pl62
1 files changed, 8 insertions, 54 deletions
diff --git a/Carpet/CarpetIOASCII/src/util/Carpet2ygraphCat.pl b/Carpet/CarpetIOASCII/src/util/Carpet2ygraphCat.pl
index 669c8e64b..5c312d66f 100755
--- a/Carpet/CarpetIOASCII/src/util/Carpet2ygraphCat.pl
+++ b/Carpet/CarpetIOASCII/src/util/Carpet2ygraphCat.pl
@@ -16,90 +16,44 @@ my $fh = new FileHandle(">$file") || die "Unable to open file \"$file\".";
my %data;
my $time = -1;
my $new = 0;
-my $currentit = -1;
-my $lastit = -1;
-my @datatoprint;
-my $nsets = 1;
-my $maxlength = 0;
-my @lengths;
-
-$lengths[0]=0;
while (<CARPETFILE>)
{
$line = $_;
- if ($line =~ "iteration") {
- @itline = split(/ +/,$line);
- $currentit = @itline[2];
- }
- elsif ($line =~ /^#/)
+ if ($line =~ /^#/)
{
#Do nothing for headers!
}
elsif ($line =~ /([0-9+-ed.]+)*/)
{
- @dataline = split(/[ \t]+/,$line);
- if ($currentit != $lastit)
+ @dataline = split(/ +/,$line);
+ if ($dataline[8] - $time > 1.e-10)
{
if ($new)
{
- push(@datatoprint,"\n\n\"Time = ".$time."\n");
+ print $fh "\n\n\"Time = ",$time,"\n";
my @sortedcoords = sort numerically (keys %data);
my $localcoord;
foreach $localcoord (@sortedcoords)
{
- push(@datatoprint, $localcoord." ".$data{$localcoord});
+ print $fh $localcoord." ".$data{$localcoord};
}
- $maxlength = $maxlength > (scalar @sortedcoords) ? $maxlength : (scalar @sortedcoords);
- $lengths[$nsets-1]=(scalar @sortedcoords);
- $nsets++;
- $lengths[$nsets-1]=0;
- %data=();
}
$new++;
$time = $dataline[8];
- $lastit = $currentit;
+
}
my $coord = $dataline[9+$ARGV[0]];
my $val = $dataline[12];
$data{$coord} = $val;
}
}
-push(@datatoprint, "\n\"Time = ",$time,"\n");
+print $fh "\n\"Time = ",$time,"\n";
my @sortedcoords = sort numerically (keys %data);
my $localcoord;
foreach $localcoord (@sortedcoords)
{
- push(@datatoprint, $localcoord." ".$data{$localcoord});
-}
-$maxlength = $maxlength > (scalar @sortedcoords) ? $maxlength : (scalar @sortedcoords);
-$lengths[$nsets-1]=(scalar @sortedcoords);
-$nsets++;
-$lengths[$nsets-1]=0;
-
-my $oldline="";
-$nouts=0;
-my $set=0;
-foreach $line (@datatoprint) {
- if ($line =~ "Time") {
- if ($oldline) {
- for (my $i=$lengths[$set-1]; $i<$maxlength;$i++) {
- $nouts++;
- print $fh $oldline;
- }
- }
- $set++;
- print $fh $line;
- }
- else {
- $nouts++;
- print $fh $line;
- $oldline=$line
- }
-}
-for (my $i=$lengths[$set-1]; $i<$maxlength;$i++) {
- $nouts++;
- print $fh $oldline;
+ print $fh $localcoord." ".$data{$localcoord};
}
sub numerically {$a <=> $b;}