#!/usr/bin/perl -w
# A convenient way to copy one image into the frame of another.
use strict;
#delete @ENV{qw(DRAO_FORMAT)};
use DRAORed;
if($#ARGV != 2){
print
"Use: tmapconvrt A B C
A = Input image
B = Any file that has the frame you want
C = output file
";
exit 1;
}
my ($infile, $framefile, $outfile) = @ARGV;
my $cline = "tmapconvrt $infile $framefile $outfile";
my $inind = fileindex($infile);
my $frameind = fileindex($framefile);
my %inmdef = readdef($inind);
my %framedef = readdef($frameind);
open(CONV, "|/usr/local/export/bin/mapconvrt > mapconvrt.log 2>&1")
or die "Could not start /usr/local/export/bin/mapconvrt";
open(CLOG, ">tmapconvrt.clog")
or warn "Could not open tmapconvrt.clog for writing.";
liprint(\*CLOG, \*CONV, "Do you wish to run in batch mo: \n");
liprint(\*CLOG, \*CONV, "Do you want to create a log? [: \n");
liprint(\*CLOG, \*CONV, "Is log file to be printed on e: \n");
#liprint(\*CLOG, \*CONV, "Choice (LQCTSN) [C]: L\n");
liprint(\*CLOG, \*CONV, "Choice (LQCTSN) [C]: C\n");
liprint(\*CLOG, \*CONV, " File definition number [DEFI: $inind\n");
if(defined $inmdef{POLARIZATION} && $inmdef{POLARIZATION} =~ /[QU]/){
liprint(\*CLOG, \*CONV, "Do you wish to continue? [N]: y\n");
}
liprint(\*CLOG, \*CONV, "Scaling factor (optional) for: \n");
liprint(\*CLOG, \*CONV, "Are input data values to be li: \n");
liprint(\*CLOG, \*CONV, " File definition number [DEFI: \n");
liprint(\*CLOG, \*CONV, "File name (max 52 chars) [] (: $outfile\n");
liprint(\*CLOG, \*CONV, "Data type (IRD) [R]: \n");
liprint(\*CLOG, \*CONV,
"Basic element and record dimen: $framedef{DIMENSIONS}\n");
#if(defined($inmdef{NODATA})){
liprint(\*CLOG, \*CONV, " Value to indicate undefine: \n");
#}
liprint(\*CLOG, \*CONV, "Are the parameters that you en: \n");
liprint(\*CLOG, \*CONV, "Sky projection (SEGTVACF) [S]: $framedef{SKYPROJ}\n");
# Maybe this should be if(defined($framedef{CEPOCH})){
if($framedef{SKYPROJ} eq "S"){
liprint(\*CLOG, \*CONV,
"Epoch for projection (1950 or 2000) [2000]: $framedef{CEPOCH}\n");
}
liprint(\*CLOG, \*CONV, "LONGITUDE of reference element: $framedef{REFCX}\n");
liprint(\*CLOG, \*CONV, "LATITUDE of reference record [: $framedef{REFCY}\n");
liprint(\*CLOG, \*CONV, "Reference ELEMENT for longitud: $framedef{REFPX}\n");
liprint(\*CLOG, \*CONV, "Reference RECORD for latitude: $framedef{REFPY}\n");
liprint(\*CLOG, \*CONV, "DELTA LONGITUDE per element (u: $framedef{DELX}\n");
liprint(\*CLOG, \*CONV, "DELTA LATITUDE per record (uns: $framedef{DELY}\n");
liprint(\*CLOG, \*CONV, "Are the parameters that you en: \n");
liprint(\*CLOG, \*CONV, "Do you want a comment? [N]: \n");
liprint(\*CLOG, \*CONV, "Do you want to save this defin: \n");
if(defined $inmdef{UNIT} && $inmdef{UNIT} =~ /K/){
liprint(\*CLOG, *CONV, "brightness-temperature scale: \n");
}
liprint(\*CLOG, \*CONV, "Is special rotation/expansion wanted? [N]: \n");
unless(defined $inmdef{UNIT} && ($inmdef{UNIT} =~ /J(ansk)?y/i ||
$inmdef{UNIT} =~ /K/)){
liprint(\*CLOG, \*CONV, "Are map data angles? [N]: \n");
}
close(CONV) or warn "Error closing mapconvrt";
my $olog = $outfile;
$olog =~ s/\..*/.html/;
my $dummy = checklogd($olog);
my $clog = `ls -t1 mapconvrt*.LOG | head -1`;
chomp $clog;
mvlogww($clog);
open(LOG, ">>logs/index.html") or
die "Ran mapconvrt but could not add entry to index.html";
print LOG "$cline
\n";
close(LOG) or die "Could not close index.html";
open(LOG, ">logs/$olog") or warn "Could not open logs/$olog";
print LOG "$clog
\n";
close(LOG) or die "Could not close logs/$olog";