I have the following script where I am trying to manipulate portions of the headers in the beginning and then I want to convert the matrix from scientific to floating point:
#!/usr/bin/perl
use strict;
############################################################
#Insert name and location of file from STK after "my $input"
############################################################
my $input = 'C:\Documents and Settings\My Documents\Stk 6.0\STK scripts\OCO_acs.e';
my @output;
open (FILE, "$input");
my @array = <FILE>;
for (@array) {
my ($col1, $col2, $col3, $col4, $col5, $col6, $col7, $col8) = split(/\s+/, $_);
my $line = "$col1 $col2 $col3 $col4 $col5 $col6 $col7 $col8";
if ($line=~m/^\d/) {
push (@output, $line);
}
}
my $NoAtP=@output;
#######################################################
#Insert desired name of the STK .a output file after >
#Change ScenarioEpoch as necessary
#######################################################
open (OUTFILE, ">28day_ephemeris_stk3p0_format.e");
print OUTFILE "stk.v.3.0\n";
print OUTFILE "\n";
print OUTFILE "BEGIN Ephemeris\n";
print OUTFILE "\n";
print OUTFILE " NumberofAttitudePoints $NoAtP\n";
print OUTFILE " 15 Oct 2008 12:00:00.00\n";
print OUTFILE " EphemerisEciTimePosVel\n";
foreach my $entry(@output) {
print OUTFILE "$entry\n";
}
Here is an example of what the file looks like before modifying it:
stk.v.3.0
BEGIN Ephemeris
NumberOfEphemerisPoints 40321
ScenarioEpoch 15 Oct 2008 12:00:00.000
EphemerisEciTimePosVel
0.00000000000000e+000 -5.10704934943446e+006 -4.30468742388535e+006 2.34134338660962e+006 1.14622110187997e+003 2.44791644659563e+003 7.00081996659693e+003
6.00000000000000e+001 -5.02804956947231e+006 -4.14946215282220e+006 2.75587684053564e+006 1.48771794293052e+003 2.73281630226811e+003 6.82905617631048e+003
But I want it to look like this:
stk.v.3.0
BEGIN Ephemeris
NumberOfEphemerisPoints 40321
ScenarioEpoch 15 Oct 2008 12:00:00.000
EphemerisEciTimePosVel
0 -5107049.34943446 -4304687.42388535 2341343.38660962 1146.22110187997 2447.91644659563 2447.91644659563
#!/usr/bin/perl
use strict;
############################################################
#Insert name and location of file from STK after "my $input"
############################################################
my $input = 'C:\Documents and Settings\My Documents\Stk 6.0\STK scripts\OCO_acs.e';
my @output;
open (FILE, "$input");
my @array = <FILE>;
for (@array) {
my ($col1, $col2, $col3, $col4, $col5, $col6, $col7, $col8) = split(/\s+/, $_);
my $line = "$col1 $col2 $col3 $col4 $col5 $col6 $col7 $col8";
if ($line=~m/^\d/) {
push (@output, $line);
}
}
my $NoAtP=@output;
#######################################################
#Insert desired name of the STK .a output file after >
#Change ScenarioEpoch as necessary
#######################################################
open (OUTFILE, ">28day_ephemeris_stk3p0_format.e");
print OUTFILE "stk.v.3.0\n";
print OUTFILE "\n";
print OUTFILE "BEGIN Ephemeris\n";
print OUTFILE "\n";
print OUTFILE " NumberofAttitudePoints $NoAtP\n";
print OUTFILE " 15 Oct 2008 12:00:00.00\n";
print OUTFILE " EphemerisEciTimePosVel\n";
foreach my $entry(@output) {
print OUTFILE "$entry\n";
}
Here is an example of what the file looks like before modifying it:
stk.v.3.0
BEGIN Ephemeris
NumberOfEphemerisPoints 40321
ScenarioEpoch 15 Oct 2008 12:00:00.000
EphemerisEciTimePosVel
0.00000000000000e+000 -5.10704934943446e+006 -4.30468742388535e+006 2.34134338660962e+006 1.14622110187997e+003 2.44791644659563e+003 7.00081996659693e+003
6.00000000000000e+001 -5.02804956947231e+006 -4.14946215282220e+006 2.75587684053564e+006 1.48771794293052e+003 2.73281630226811e+003 6.82905617631048e+003
But I want it to look like this:
stk.v.3.0
BEGIN Ephemeris
NumberOfEphemerisPoints 40321
ScenarioEpoch 15 Oct 2008 12:00:00.000
EphemerisEciTimePosVel
0 -5107049.34943446 -4304687.42388535 2341343.38660962 1146.22110187997 2447.91644659563 2447.91644659563