[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
20020605: GIF (tm) creation by McIDAS in a Perl script
- Subject: 20020605: GIF (tm) creation by McIDAS in a Perl script
- Date: Wed, 05 Jun 2002 12:45:57 -0600
>From: Darren Gallant <address@hidden>
>Organization: UCAR/JOSS
>Keywords: 200206051454.g55EsNJ12608 McIDAS script
Darren,
>thanks for the SSEC contact. i was able to set up GOES11 ADDE. However, my
>gifs are only 640X480 pixels. i'm using MAP command in a bourne shell
>script. how can i get larger gifs?
The answer is at the end of this email, after the Perl script listing.
>From address@hidden Wed Jun 5 09:12:39 2002
#!/usr/bin/perl -w
# Perl script IHOP_get1KMsat.pl
$| = 1;
use FileHandle;
use Time::gmtime;
@bands = qq(1 2 3 4 5);
$month{MAY} = "05";
$month{JUN} = "06";
$main_dir = "/home/gallant/mcidas/ihop";
$area_dir = "$main_dir/data";
$ftp_dir = "/ftp/pub/incoming/catalog/ihop";
#$area_dir = "/seaspace/
$TRUE = 1;$FALSE = 0;
system("dataloc.k ADD GOES11 128.104.110.46");
$ADDE = "GOES11/ALL";
$local = "MYDATA/IMAGES";
# Set directory for AREA files
$prefix = "55";
$cmd = "redirect.k ADD AREA${prefix}\\* \\\"$area_dir";
system($cmd);
$cmd = "redirect.k LIST";
system($cmd);
$sleeptime = 480;
while($TRUE){
#system("imglist.k $ADDE.-20 > imagelist");
open LIST,"imglist.k $ADDE.-100 2>&1 |";
@list = <LIST>;close(LIST);
foreach $line(@list[4..scalar(@list)-2]){
@input = split(' ',$line);
if($input[1] =~ /G-11/ && $input[2] =~ /IMG/){
$pos = $input[0];
$day = sprintf("%02d",$input[3]);
$year = sprintf("20%02d",substr($input[5],0,2));
$julian = sprintf("%003d",substr($input[5],2,3));
$mth = $month{$input[4]};
($hour,$min,$sec) = split(/:/,$input[6]);
$center_lat = $input[7];
$center_lon = $input[8];
$timestamp = sprintf("%s%s%s%s%s",$year,$mth,$day,$hour,$min);
print $timestamp,"\n";
# generate IHOP visible only
$size="700 1500";$latlon="36.5 98.5";
$time = sprintf("%02s%s%02d",$hour,":",$min);
$dest = sprintf("%02d%02d",$prefix,$pos);
$area_file = "ops.goes-11.$timestamp.IHOP_1km_ch1_vis";
$gif_file = $area_file.".gif";
#print "$area_file $gif_file\n";
unless( -e "$area_dir/ops.goes-11.$timestamp.IHOP_1km_ch1_vis"){
$cmd="imgcopy.k $ADDE $local.$dest SIZE=$size LATLON=$latlon ".
"PLACE=CENTER DAY=$julian TIME=$time $time BAND=1";
print $cmd,"\n";$ret=system($cmd);#print "return $ret\n";
if($ret==0){
$cmd = "cp $area_dir/AREA$dest $area_dir/$area_file";
print $cmd,"\n";system($cmd);
&create_GIF;
}
}# end unless
}# end if
}# end foreach
print "sleeping for 8 minutes\n";
sleep($sleeptime);
}#end while
sub create_GIF{
my $tmpfile = "create_IHOP_GIF.tmp";my $cmd;
my $mcidas = FileHandle->new();
open($mcidas,">$main_dir/$tmpfile")||die "Can't open $tmpfile\n";
print $mcidas "#! /bin/sh\n";
print $mcidas "source /home/gallant/.bashrc\n";
print $mcidas "mcenv << EOF\n";
print $mcidas "erase.k\n";
print $mcidas "imgdisp.k $local.$dest LATLON=$latlon PLACE=CENTER
EU=IMAGE\n";
print $mcidas "map.k VH 1 LALO 6 INT=2 2\n";
#print $mcidas "imgdisp.k $local.$dest LATLON=$latlon PLACE=CENTER
EU=IMAGE\n";
#print $mcidas "map.k 1 H\n";
print $mcidas "frmsave.k 1 $area_dir/$gif_file\n";
print $mcidas "exit\n";
print $mcidas "EOF\n\n";
undef $mcidas;chmod(0755,$tmpfile);
$cmd ="$main_dir/$tmpfile";print $cmd,"\n";system($cmd);
$cmd ="cp $area_dir/$gif_file $ftp_dir";print $cmd,"\n";system($cmd);
}# end sub create_GIF
The reason the display that is being generated and the resultant GIF
is 480x640 is that is the default setup by mcenv. Furthermore, mcenv
sets up an environment that only uses 48 display levels for images.
To change this default behaviour, simply change the mcenv invocation.
You can get help on running mcenv online from from your McIDAS system:
HELP mcenv
The flags that you will be most concerned with are '-f' and 'i'. Here
is an example that will change the defaults from 48 image colors for
one frame that is 480x640 to one using 64 colors for a frame that is
600x800:
change:
print $mcidas "mcenv << EOF\n";
to:
print $mcidas "mcenv -i 64 -f 1@600x800 << EOF\n";
Tom