#!/usr/local/bin/perl
# Update the IVM HTML documents to reflect the current images
setpriority(0,0,getpriority(0,0)+6); # nice the process
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime;
$year+=1900;
++$yday;
++$mon;
if (length($mon) < 2) {$mon = "0".$mon;}
if (length($mday) < 2) {$mday = "0".$mday;}
if (length($hour) < 2) {$hour = "0".$hour;}
if (length($min) < 2) {$min = "0".$min;}
if (length($sec) < 2) {$sec = "0".$sec;}
$now = "
$year-$mon-$mday $hour:$min:$sec UT
";
if (@ARGV < 1) {die "Please specify a directory @ARGV ... dies at";}
$RootPath = "$ENV{'WEB_ROOT'}/IVM/".$ARGV[0];
$WWWRoot = "/IVM/".$ARGV[0];
if (! -d "$RootPath") {print STDERR "$RootPath does not exist"; exit;} # directory exists?
# Read directory
opendir(GIFDIR,"$RootPath"); # Read directory
@giffiles = grep(/(ivm\.gif)$/i,readdir(GIFDIR));
closedir(GIFDIR);
if (@giffiles >= 1) {
grep($_ = "$WWWRoot/".$_,@giffiles); # Add root to file names
grep($_ = substr($_,0,length($_)-4),@giffiles); # Get rid of the .gif
}
# Sort the list of gif files by file name
sub by_file_name {
(reverse(split(m|/|,$a)))[0] cmp (reverse(split(m|/|,$b)))[0];
}
@giffiles = sort by_file_name @giffiles;
# Set HTML Header and Footer
$html_header = <<"HEADER_END";
Imaging Vector Magnetograph: $ARGV[0]
HEADER_END
$html_legend = <<"LEGEND_END";
Each magnetogram is a 168 kbyte GIF image. Celestial north is at the top;
east is at the left. The magnetogram is displayed as four panels:
- Continuum brightness
- This is in arbitrary units, but on a linear scale.
- Line-of-sight component of magnetic field
- Projection of magnetic field vector onto the line between the solar feature
and the observer. The units are Gauss. The color changes linearly with the cube
root of the field strength, to better show both strong and weak features. Thus if
the top of the scale is 1000 = 10^3, the midpoint is 5^3 or 125.
- Transverse component of magnetic field
- Magnitude of the projection of the field vector onto the plane perpendicular to
the line of sight. The units are Gauss; cube-root scaling is used here too.
- Direction of transverse component
- The orientation of the transverse component is indicated by the pixel color,
as in the key wheel at the lower left. Note that there is a 180-degree ambiguity in
the direction: the polarization data does not tell us whether the field vector points
to the right or to the left.
LEGEND_END
$html_footer = <<"FOOTER_END";
Email the webmaster
Last Update: $now
FOOTER_END
# Generate the HTML file
print "$html_header\n";
if (@giffiles < 1) {
# No gif files in the directory
print "
No Data $ARGV[0]
\n\n";
} else {
print "IVM Magnetograms from $ARGV[0]
\n";
print "$html_legend\n";
print "
\n";
print "\n";
$column = 0;
foreach $file (@giffiles) {
if ($column == 0) { print "\n"; }
@file_path = split(m|/|,$file);
print " \n";
print " $file_path[$#file_path] | \n";
if (++$column >= 3) {
$column = 0;
print "
\n";
}
}
if ($column != 0) { print "\n"; }
print "
\n\n";
}
print "$html_footer\n";
exit;
Last modified: Thu Jul 27 15:46:15 HST 2006