This file is indexed.

/usr/bin/gpiv_piv2vec is in gpivtools-mpi 0.6.0-3build1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
#!/usr/bin/perl -w

#  piv2vec - Inserts a third and fifth column of a PIV data stream in order 
#            to prepare a data file for plotmtv vector representation.
#
#   Copyright (C) 2002 Gerber van der Graaf

#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2, or (at your option)
#   any later version.

#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.

#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software Foundation,
#   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#------------------------------------------------------------------

$VERSION = q$Id: piv2vec.pl,v 1.8 2007-01-29 14:26:54 gerber Exp $;
$HELP = "Adds header to piv data for a vector plot with Plotmtv";
$USAGE = "gpiv_piv2vec [-al length][-au \"units\"[-flipx][-flipy][-g][-h]
        [-p][-s scale][-tl label][-v][-xl label][-yl label] ][filename]
        < input > output

keys:
-al:    plots a vector annotation of 'length'
-au:    plots a vector annotation of 'units'
-flipx: flips the plot in x-direction; x data from high to low
-flipy: flips the plot in y-direction; y data from high to low
-g:     launches plotmtv
-h:     on-line help
-nd:    combined with -g; adds option -nodate (only ps output doesn't
        contain date!)
-k:     keep plot-file
-s:     vector scale (default: 1 px)
-tl:    defines top label (title) (with -f default: \"file_name\")
-v:     prints version
-xl:    defines x-label (default: \"x (pixels)\")
-yl:    defines y-label (default: \"y (pixels)\")
filename:       input PIV data file. Substitutes stdin and stdout
";


#----------------- Command line arguments handling ----------
#$opt_fn = 0;
# $opt_an = 0;
$opt_g = 0;
$opt_h = 0;
$opt_k = 0;
$opt_v = 0;
# $opt_s = 0;
$filename_logic = 0;
# $flipx = 0;
# $flipy = 0;
$opt_nd = 0;

use Getopt::Long;
#$result = 
GetOptions("g|graphic", "h|help", "k|keep", "v|version",
"s|scale=f" => \$vscale,
'tl|toplabel=s' => \$top_label,
'xl|xlabel=s' => \$x_label,
'yl|ylabel=s' => \$y_label,
'nd|no_date',
'al|annotation_length=f' => \$length_an,
'au|annotation_unit=s' => \$unit_an,
"flipx", "flipy",
);


if ($opt_h) {
  print ("$HELP\n");
  print ("$USAGE\n");
  exit;
}
if ($opt_v) {
  print ("$VERSION\n");
  exit;
}


if ($#ARGV == 0) {
    $filename_logic = 1;
    $filename = shift (@ARGV);
} elsif ($#ARGV == -1) {
    printf ("\nUsage: $USAGE\n");
    exit;
}

if ($opt_g && !$filename_logic) {
  print ("graphic output needs filename");
  exit;
}


sub FileBase {
#--------------- extracts file basename from a full filename
 my ($file_base_name, $file_extension);
 @file_fields = split(/\./,$_[0]);
 pop @file_fields;
 $file_base_name = join(".", @file_fields);
 return $file_base_name;
}

$file_basename = FileBase($filename);


#------------------------------- default parameters
if (!$unit_an) {$unit_an = "px"}
if (!$vscale) {$vscale = 1.0}

if ($file_basename && !$top_label) {$top_label = $file_basename}
if (!$x_label) {$x_label = "x (pixels)"}
if (!$y_label) {$x_label = "y (pixels)"}


#--------------- Initializing variables

$line = 0;
$x_max = -10000;
$x_min = 10000;
$y_max = 0;
$y_max = -1000;
$y_min = 1000;


#-------------------- Defines location and value of third component
$insert_3_loc = 0.0;
$insert_3_val = 0.0;


if ($filename_logic == 0) {
} elsif  ($filename_logic == 1) {
}


#--------------- Inserts data with third component (necesary for Plotmtv)

if ($filename_logic == 0) {
#------------------------------- Inserts header
  print("\$ DATA=VECTOR\n");
  print("\% vscale=$vscale\n");
  print("\% equalscale\n");
  if ($top_label) {
    print("\% toplabel = \"$top_label\"\n");
  } else {
    print("\% toplabel = \" \"\n");
  }
  if ($x_label) {print("\% xlabel = \"$x_label\"\n");}
  if ($y_label) {print("\% ylabel = \"$y_label\"\n");}
  if ($opt_flipx) {print("\% xflip\n");}
  if ($opt_flipy) {print("\% yflip\n");}
  while (<STDIN>) {
    chomp;

  if ($_ ne "" && (!/^(\#|;)/)) {  #skip blank lines, # or ; signs at first col

    s/,/./g;                    #substitutes eventually komma's by dot 
                                #(for example at LaVision's code)
    s/^ *//;                    #removes eventually leading space

      @words = split(/\s+/,$_);      #splitting line $_ up in words
                                   #same as @words = split
    $px[$line]=$words[0];
    $py[$line]=$words[1];
    $dx[$line]=$words[2];
    $dy[$line]=$words[3];


#------------------------------- Testing if they are numbers
    if ($#words == 5 ) {
      if (($px[$line] =~ /\d/) && ($py[$line] =~ /\d/) && ($dx[$line] =~ /\d/) &&
	  ($dy[$line] =~ /\d/) && ($snr[$line] =~ /\d/)) {
	$snr[$line]=$words[4];
      }
    } elsif ($#words == 6 ) {
      if (($px[$line] =~ /\d/) && ($py[$line] =~ /\d/) && ($dx[$line] =~ /\d/) &&
	  ($dy[$line] =~ /\d/) && ($snr[$line] =~ /\d/) && ($peak[$line] =~ /\d/) ) {
	$snr[$line]=$words[4];
	$peak[$line]=$words[5];
      }
    } else {
      if (($px[$line] =~ /\d/) && ($py[$line] =~ /\d/) && ($dx[$line] =~ /\d/) &&
	  ($dy[$line] =~ /\d/)) {
      }
    }
#----------------------- If vector annotation; calculate min and max values
    if ($length_an) {
      if ($px[$line] > $x_max) {$x_max = $px[$line];}
      if ($px[$line] < $x_min) {$x_min = $px[$line];}
      if ($py[$line] > $y_max) {$y_max = $py[$line];}
      if ($py[$line] < $y_min) {$y_min = $py[$line];}
    }

    $line++;
  }
  }

$nlines = $line;
#----------------------- If vector annotation; print to stdout
  if ($length_an) {
    $x1_an = $x_min+($x_max-$x_min)/2.;
    $x2_an = $x1_an + $length_an*$vscale;
    if ($opt_flipy){
      $y1_an = $y_min-$y_max*0.1;
      $y2_an = $y_min-$y_max*0.1;
    } else {
      $y1_an = $y_max+$y_max*0.1;
      $y2_an = $y_max+$y_max*0.1;
    }
      printf("\n@ arrow x1=%f y1=%f z1=0.0 x2=%f y2=%f z2=0.0 \\
linetype=1 linecolor=0 clip=false linelabel=\"%6.2f %s\"\n\n", 
	     $x1_an, $y1_an, $x2_an, $y2_an, $length_an, $unit_an);
  }

#----------------------- Print data
  for ($line=0; $line < $nlines; $line++) {
    if ($#words == 5 ) {
      print("$px[$line] $py[$line] $insert_3_loc $dx[$line] $dy[$line] $insert_3_val $snr[$line]\n");
    } elsif ($#words == 6 ) {
	print("$px[$line] $py[$line] $insert_3_loc $dx[$line] $dy[$line] $insert_3_val $snr[$line] $peak[$line]\n");
    } else {
	print("$px[$line] $py[$line] $insert_3_loc $dx[$line] $dy[$line] $insert_3_val\n");
      }
  }



} elsif  ($filename_logic == 1) {
#------------------------------- filename handling
  $file_name_piv=$file_basename.".piv";
  $file_name_vec=$file_basename.".vec";
  $infile=$file_name_piv;
  $outfile=$file_name_vec;
#  print "\ninfile=$infile outfile=$outfile";
  open (IN,"$infile") || die 'PIV2VEC error: can\'t open $infile';
  open (OUT,">$outfile") || die 'PIV2VEC error: can\'t open $outfile';

#------------------------------- Inserts header
  print(OUT "\$ DATA=VECTOR\n");
  print(OUT "\% vscale=$vscale\n");
  print(OUT "\% equalscale\n");
  if ($top_label) {
    print(OUT "\% toplabel = \"$top_label\"\n");
  } else {
    print(OUT "\% toplabel = \" \"\n");
  }
  if ($x_label) {print(OUT "\% xlabel = \"$x_label\"\n");}
  if ($y_label) {print(OUT "\% ylabel = \"$y_label\"\n");}
  if ($opt_flipx) {print(OUT "\% xflip\n");}
  if ($opt_flipy) {print(OUT "\% yflip\n");}


  while (<IN>) {
    chomp;
    if ($_ ne "" && (!/^(\#|;)/)) {  #skip blank lines, # or ; signs at first col

    s/,/./g;                    #substitutes eventually komma's by dot 
                                #(for example at LaVision's code)
    s/^ *//;                    #removes eventually leading space
      @words = split(/\s+/,$_);      #splitting line $_ up in words
                                   #same as @words = split
    $px[$line] = $words[0];
    $py[$line] = $words[1];
    $dx[$line] = $words[2];
    $dy[$line] = $words[3];
    $snr[$line] = $words[4];
    $peak[$line] = $words[5];
###printf("\n** AA:: peak = $peak[$line] ** \n");

#------------------------------- Testing if they are numbers
    if ($#words == 5 ) {
      if (($px[$line] =~ /\d/) && ($py[$line] =~ /\d/) && ($dx[$line] =~ /\d/) &&
	  ($dy[$line] =~ /\d/) && ($snr[$line] =~ /\d/)) {
#	$snr[$line]=$words[4];
      }
    } elsif ($#words == 6 ) {
      if (($px[$line] =~ /\d/) && ($py[$line] =~ /\d/) && ($dx[$line] =~ /\d/) &&
	  ($dy[$line] =~ /\d/) && ($snr[$line] =~ /\d/) && ($peak[$line] =~ /\d/) ) {
#	$snr[$line]=$words[4];
#	$peak[$line]=$words[5];
      }
    } else {
      if (($px[$line] =~ /\d/) && ($py[$line] =~ /\d/) && ($dx[$line] =~ /\d/) &&
	  ($dy[$line] =~ /\d/)) {
      }
    }
#----------------------- If vector annotation; calculate min and max values
#----------------------- of location for placing annotation
    if ($length_an) {
      if ($px[$line] > $x_max) {$x_max = $px[$line];}
      if ($px[$line] < $x_min) {$x_min = $px[$line];}
      if ($py[$line] > $y_max) {$y_max = $py[$line];}
      if ($py[$line] < $y_min) {$y_min = $py[$line];}
    }

    $line++;
  }
}


$nlines = $line;
#----------------------- If vector annotation; print to file
  if ($length_an) {
    $x1_an = $x_min+($x_max-$x_min)/2.;
    $x2_an = $x1_an + $length_an*$vscale;
    if ($opt_flipy){
      $y1_an = $y_min-$y_max*0.1;
      $y2_an = $y_min-$y_max*0.1;
    } else {
      $y1_an = $y_max+$y_max*0.1;
      $y2_an = $y_max+$y_max*0.1;
    }
      print("\nx1_an=$x1_an x2_an=$x2_an");
      printf(OUT "\n@ arrow x1=%f y1=%f z1=0.0 x2=%f y2=%f z2=0.0 \\
linetype=1 linecolor=0 clip=false linelabel=\"%6.2f %s\"\n\n", 
	     $x1_an, $y1_an, $x2_an, $y2_an, $length_an, $unit_an);
  }

#----------------------- Print data
  for ($line=0; $line < $nlines; $line++) {
      if ($#words == 5 ) {
###printf("\n** BB:: NO words == $#words snr = $snr[$line] peak = $peak[$line]**\n");
	if ($peak[$line] != -1) {            # $peak[$line] != 0 && 
	print(OUT "$px[$line] $py[$line] $insert_3_loc $dx[$line] $dy[$line] $insert_3_val $snr[$line]\n");
	}
      } elsif ($#words == 6 ) {
	  print(OUT "$px[$line] $py[$line] $insert_3_loc $dx[$line] $dy[$line] $insert_3_val $snr[$line] $peak[$line]\n");
      } else {
	print(OUT "$px[$line] $py[$line] $insert_3_loc $dx[$line] $dy[$line] $insert_3_val\n");
      }
  }
close (IN) || die 'PIV2VEC error: can\'t close $infile';
close (OUT) || die 'PIV2VEC error: can\'t close $outfile';
}

#------------------------------- Launches Plotmtv and cleans
if ($opt_g) {
  if ($opt_nd) {
    @args=("plotmtv", "-nodate", $file_name_vec);
  } else {
    @args=("plotmtv", $file_name_vec);
  }
  system (@args) == 0 || die "PIV2VEC error: system @args failed: $?";
  if (!$opt_k) {
    @args=("rm", $file_name_vec);
    system (@args) == 0 || die "PIV2VEC error: system @args failed: $?";
  }
}
print ("\n");