MGRAV.TXT

Description

MGRAV.TXT is the output from Mgrav.e. This is a bigmap specific data file, similar to SGRAV.TXT. It contains the size of the map, as well as many useful parameters.

        2049        2049
   57.145420074462891       -15.315745353698730       -220.78500366210938     
    0.13277E+03   -0.71393E+02   -0.18624E+03   -0.69832E-01    0.24570E-03    0.95146E+02   -0.47969E+01
    0.13276E+03   -0.71325E+02   -0.18628E+03   -0.69828E-01    0.24570E-03    0.11549E+03   -0.47811E+01
    0.13276E+03   -0.71257E+02   -0.18632E+03   -0.69825E-01    0.24571E-03    0.11527E+03   -0.47653E+01
    0.13275E+03   -0.71189E+02   -0.18636E+03   -0.69821E-01    0.24571E-03    0.11522E+03   -0.47512E+01
    0.13275E+03   -0.71121E+02   -0.18640E+03   -0.69818E-01    0.24572E-03    0.64173E+02   -0.47387E+01
    0.13274E+03   -0.71053E+02   -0.18643E+03   -0.69815E-01    0.24573E-03    0.11524E+03   -0.47271E+01
    0.13274E+03   -0.70985E+02   -0.18646E+03   -0.69813E-01    0.24574E-03    0.64958E+02   -0.47172E+01
    0.13273E+03   -0.70917E+02   -0.18650E+03   -0.69811E-01    0.24576E-03    0.11555E+03   -0.47081E+01
....

Script

Here is a simple perl script that will rip off columns. You run this in unix by "perl scriptname > output.txt"

# Eric E. Palmer - 23 Sep 2012
# Perl script to read a file and output the absolute distance of the first 3 columns
#     or other columns
#     It is assumed that that is the distance that vector is from the center
#     and that it is reading an equa-spaced file

open FILE, "MGRAV.TXT" or die $!;

# Get the map sizes
$data=<FILE>;
chomp ($line);
$data =~ s/\s+/\t/g;
@items = split('  ', $data);  # Break line into an array
$i=$items[1];
$j=$items[2];

# Skip the next line
$dump=<FILE>;

# Loop until you run out of data
$cnt=0;
while (<FILE>) {
   chomp;                  # remove trailing linefeed
   $data = $_;             # 
   $data =~ s/\s+/\t/g;    # convert blocks of spaces to tabs
   @items = split('  ', $data);  # Break line into an array

   # Get data - uncomment out the item you want
   #printf ("%3.5e   ", $items[4]);    # elevation
   #printf ("%3.5e   ", $items[5]);    # acceleration
   #printf ("%3.5f   ", $items[6]);    # potential
   printf ("%3.5f ", $items[7]);    # slope

   # Use this to get topography (or distance from center of gravity)
   #$a=$items[1];          # i
   #$b=$items[2];          # j
   #$c=$items[3];          # k
   #$dist = sqrt ($a*$a + $b*$b + $c*$c); # distance from center 
   #printf ("%3.2f   ", $dist);  #distance (or topography)

   $cnt++;
   if ($cnt >= $i) {
      $cnt=0;
      printf ("\n");
   };
}
close (FILE);
printf ("\n");


MGRAV.TXT (last edited 2018-05-05 21:27:34 by BMittan)