#!/usr/bin/perl -w
#
use File::Copy;


# This script replaces week old images in the web site monitor directory
# with "not available yet" images

print " ";
print "Removing week-old images from the monitor directory";
print " ";
system "date";
print "\n\n";


chdir "/net/www/www/smcd/opdb/poes/monitor/images";




# =====================================================================
# Determine the date of the data to process (normally should be 
# set to the previous day)

$data_day = time();

#$data_day -= (0 * 86400);
$data_day -= (1 * 86400);

($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($data_day);
$year += 1900;
$mon++;
$sec = 0;
$min = 0;
$hour = 12;
#$wday = 0;
$yday = 0;
$isdst = 0;

my $day_of_data = ($year * 10000) + ($mon * 100) + $mday;


# Replace the old images with the "not available" images

$file = sprintf("airs_%d.png", $wday);
$thumb_file = sprintf("airs_thumb_%d.png", $wday);
copy("not_available.png", $file);
copy("not_available_thumb.png", $thumb_file);
printf("Airs replaced\n");

$file = sprintf("atovs_a8_%d.png", $wday);
$thumb_file = sprintf("atovs_a8_thumb_%d.png", $wday);
copy("not_available.png", $file);
copy("not_available_thumb.png", $thumb_file);
printf("ATOVS A8 replaced\n");

$file = sprintf("atovs_m1_%d.png", $wday);
$thumb_file = sprintf("atovs_m1_thumb_%d.png", $wday);
copy("not_available.png", $file);
copy("not_available_thumb.png", $thumb_file);
printf("ATOVS M1 replaced\n");

$file = sprintf("atovs_m2_%d.png", $wday);
$thumb_file = sprintf("atovs_m2_thumb_%d.png", $wday);
copy("not_available.png", $file);
copy("not_available_thumb.png", $thumb_file);
printf("ATOVS M2 replaced\n");

$file = sprintf("atovs_oa11_%d.png", $wday);
$thumb_file = sprintf("atovs_oa11_thumb_%d.png", $wday);
copy("not_available.png", $file);
copy("not_available_thumb.png", $thumb_file);
printf("ATOVS OA11 replaced\n");

$file = sprintf("atovs_r1_%d.png", $wday);
$thumb_file = sprintf("atovs_r1_thumb_%d.png", $wday);
copy("not_available.png", $file);
copy("not_available_thumb.png", $thumb_file);
printf("ATOVS R1 replaced\n");

$file = sprintf("atovs_r2_%d.png", $wday);
$thumb_file = sprintf("atovs_r2_thumb_%d.png", $wday);
copy("not_available.png", $file);
copy("not_available_thumb.png", $thumb_file);
printf("ATOVS R2 replaced\n");

$file = sprintf("cosmic_%d.png", $wday);
$thumb_file = sprintf("cosmic_thumb_%d.png", $wday);
copy("not_available.png", $file);
copy("not_available_thumb.png", $thumb_file);
printf("COSMIC replaced\n");

$file = sprintf("crimss_%d.png", $wday);
$thumb_file = sprintf("crimss_thumb_%d.png", $wday);
copy("not_available.png", $file);
copy("not_available_thumb.png", $thumb_file);
printf("Crimss replaced\n");

$file = sprintf("eu_iasi_%d.png", $wday);
$thumb_file = sprintf("eu_iasi_thumb_%d.png", $wday);
copy("not_available.png", $file);
copy("not_available_thumb.png", $thumb_file);
printf("Eu Iasi replaced\n");

$file = sprintf("iasi_%d.png", $wday);
$thumb_file = sprintf("iasi_thumb_%d.png", $wday);
copy("not_available.png", $file);
copy("not_available_thumb.png", $thumb_file);
printf("NOAA Iasi replaced\n");

$file = sprintf("mirs_oper_metopb_%d.png", $wday);
$thumb_file = sprintf("mirs_oper_metopb_thumb_%d.png", $wday);
copy("not_available.png", $file);
copy("not_available_thumb.png", $thumb_file);
printf("MIRS Oper Metop-B replaced\n");

$file = sprintf("mirs_oper_noaa_%d.png", $wday);
$thumb_file = sprintf("mirs_oper_noaa_thumb_%d.png", $wday);
copy("not_available.png", $file);
copy("not_available_thumb.png", $thumb_file);
printf("MIRS Oper NOAA replaced\n");

$file = sprintf("mirs_oper_npp_%d.png", $wday);
$thumb_file = sprintf("mirs_oper_npp_thumb_%d.png", $wday);
copy("not_available.png", $file);
copy("not_available_thumb.png", $thumb_file);
printf("MIRS Oper NPP replaced\n");

$file = sprintf("mirs_oper_ssmis_%d.png", $wday);
$thumb_file = sprintf("mirs_oper_ssmis_thumb_%d.png", $wday);
copy("not_available.png", $file);
copy("not_available_thumb.png", $thumb_file);
printf("MIRS Oper SSMIS replaced\n");

$file = sprintf("mirs_test_metopb_%d.png", $wday);
$thumb_file = sprintf("mirs_test_metopb_thumb_%d.png", $wday);
copy("not_available.png", $file);
copy("not_available_thumb.png", $thumb_file);
printf("MIRS Test MetOp-B replaced\n");

$file = sprintf("mirs_test_noaa_%d.png", $wday);
$thumb_file = sprintf("mirs_test_noaa_thumb_%d.png", $wday);
copy("not_available.png", $file);
copy("not_available_thumb.png", $thumb_file);
printf("MIRS Test NOAA replaced\n");

$file = sprintf("mirs_test_npp_%d.png", $wday);
$thumb_file = sprintf("mirs_test_npp_thumb_%d.png", $wday);
copy("not_available.png", $file);
copy("not_available_thumb.png", $thumb_file);
printf("MIRS Test NPP replaced\n");

$file = sprintf("mirs_test_ssmis_f16_%d.png", $wday);
$thumb_file = sprintf("mirs_test_ssmis_f16_thumb_%d.png", $wday);
copy("not_available.png", $file);
copy("not_available_thumb.png", $thumb_file);
printf("MIRS Test SSMIS F16 replaced\n");

$file = sprintf("mirs_test_ssmis_ff18_%d.png", $wday);
$thumb_file = sprintf("mirs_test_ssmis_f18_thumb_%d.png", $wday);
copy("not_available.png", $file);
copy("not_available_thumb.png", $thumb_file);
printf("MIRS Test SSMIS F18 replaced\n");

$file = sprintf("nucaps_%d.png", $wday);
$thumb_file = sprintf("nucaps_thumb_%d.png", $wday);
copy("not_available.png", $file);
copy("not_available_thumb.png", $thumb_file);
printf("NUCAPS replaced\n");

# end of file
