#!/usr/bin/perl -w
#

# This script captures data from an ATOVS daily data files and writes
# the data to ODS files.

print " ";
print "Capturing ATOVS data into ODS format";
print " ";
system "date";
print "\n\n";


chdir "/data/smcd/nprovs/source/ods_capture/atovs";


# Determine the date of the data to process

$data_day = time();

#$data_day -= (2 * 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;



# =============================================================================
# R1

symlink "/data/smcd/nprovs/data/matchup/DailyFiles_incoming/rerodf.r1", "in.file" or warn "Cannot link to in.file";
symlink "/data/smcd/nprovs/data/ods/atovs_r1.ods", "out.file" or warn "Cannot link to out.file";
symlink "/data/smcd/nprovs/source/ods_capture/atovs/atovs1500.xml", "parm.file" or warn "Cannot link to parm.file";
symlink "/data/smcd/nprovs/source/ods_capture/atovs/edgeparm_rodf1500.txt", "fileparm.file" or warn "Cannot link to fileparm.file";

system "/data/smcd/nprovs/source/ods_capture/atovs/createODSFromAtovsRODF1500.x \"ATOVS R1\"";


unlink "in.file" or warn "Cannot unlink in.file";
unlink "out.file" or warn "Cannot unlink out.file";
unlink "parm.file" or warn "Cannot unlink parm.file";
unlink "fileparm.file" or warn "Cannot unlink fileparm.file";


# Create an image from the ODS file and send the image to the STAR web site
# for routine monitoring

# Build the command line executable an then run it

$input_file   = sprintf("file:/data/smcd/nprovs/data/ods/atovs_r1.ods");
$parm_file    = sprintf("parmfile:/data/smcd/nprovs/source/graphics/imagemaker/defaults/atovs.xml");
$output_file  = sprintf("output:/net/www/www/smcd/opdb/poes/monitor/images/atovs_r1_%d.png", $wday);
$thumb_file   = sprintf("thumbnail:/net/www/www/smcd/opdb/poes/monitor/images/atovs_r1_thumb_%d.png", $wday);
$thumb_width  = sprintf("thumbwidth:150");
$thumb_height = sprintf("thumbheight:100");
$verbose      = sprintf("verbose:no");
$file_info    = sprintf("file_info:no");


$exec = sprintf("/usr/bin/java -Djava.awt.headless=true -jar /data/smcd/nprovs/source/graphics/imagemaker/ImageMaker.jar %s %s %s %s %s %s %s %s", $input_file, $parm_file, $output_file, $thumb_file, $thumb_width, $thumb_height, $verbose, $file_info);

system $exec;



# =============================================================================
# R2

symlink "/data/smcd/nprovs/data/matchup/DailyFiles_incoming/rerodf.r2", "in.file" or warn "Cannot link to in.file";
symlink "/data/smcd/nprovs/data/ods/atovs_r2.ods", "out.file" or warn "Cannot link to out.file";
symlink "/data/smcd/nprovs/source/ods_capture/atovs/atovs1500.xml", "parm.file" or warn "Cannot link to parm.file";
symlink "/data/smcd/nprovs/source/ods_capture/atovs/edgeparm_rodf1500.txt", "fileparm.file" or warn "Cannot link to fileparm.file";

system "/data/smcd/nprovs/source/ods_capture/atovs/createODSFromAtovsRODF1500.x \"ATOVS R2\"";


unlink "in.file" or warn "Cannot unlink in.file";
unlink "out.file" or warn "Cannot unlink out.file";
unlink "parm.file" or warn "Cannot unlink parm.file";
unlink "fileparm.file" or warn "Cannot unlink fileparm.file";


# Create an image from the ODS file and send the image to the STAR web site
# for routine monitoring

# Build the command line executable an then run it

$input_file   = sprintf("file:/data/smcd/nprovs/data/ods/atovs_r2.ods");
$parm_file    = sprintf("parmfile:/data/smcd/nprovs/source/graphics/imagemaker/defaults/atovs.xml");
$output_file  = sprintf("output:/net/www/www/smcd/opdb/poes/monitor/images/atovs_r2_%d.png", $wday);
$thumb_file   = sprintf("thumbnail:/net/www/www/smcd/opdb/poes/monitor/images/atovs_r2_thumb_%d.png", $wday);
$thumb_width  = sprintf("thumbwidth:150");
$thumb_height = sprintf("thumbheight:100");
$verbose      = sprintf("verbose:no");
$file_info    = sprintf("file_info:no");


$exec = sprintf("/usr/bin/java -Djava.awt.headless=true -jar /data/smcd/nprovs/source/graphics/imagemaker/ImageMaker.jar %s %s %s %s %s %s %s %s", $input_file, $parm_file, $output_file, $thumb_file, $thumb_width, $thumb_height, $verbose, $file_info);

system $exec;



# =============================================================================
# ATOVS A8

symlink "/data/smcd/nprovs/data/matchup/DailyFiles_incoming/rrodf1000.a8", "in.file" or warn "Cannot link to in.file";
symlink "/data/smcd/nprovs/data/ods/atovs_a8.ods", "out.file" or warn "Cannot link to out.file";
symlink "/data/smcd/nprovs/source/ods_capture/atovs/atovs1000.xml", "parm.file" or warn "Cannot link to parm.file";
symlink "/data/smcd/nprovs/source/ods_capture/atovs/edgeparm_rodf1000.txt", "fileparm.file" or warn "Cannot link to fileparm.file";

system "/data/smcd/nprovs/source/ods_capture/atovs/createODSFromAtovsRODF1000.x \"ATOVS A8\"";

unlink "in.file" or warn "Cannot unlink in.file";
unlink "out.file" or warn "Cannot unlink out.file";
unlink "parm.file" or warn "Cannot unlink parm.file";
unlink "fileparm.file" or warn "Cannot unlink fileparm.file";


# Create an image from the ODS file and send the image to the STAR web site
# for routine monitoring

# Build the command line executable an then run it

$input_file   = sprintf("file:/data/smcd/nprovs/data/ods/atovs_a8.ods");
$parm_file    = sprintf("parmfile:/data/smcd/nprovs/source/graphics/imagemaker/defaults/atovs.xml");
$output_file  = sprintf("output:/net/www/www/smcd/opdb/poes/monitor/images/atovs_a8_%d.png", $wday);
$thumb_file   = sprintf("thumbnail:/net/www/www/smcd/opdb/poes/monitor/images/atovs_a8_thumb_%d.png", $wday);
$thumb_width  = sprintf("thumbwidth:150");
$thumb_height = sprintf("thumbheight:100");
$verbose      = sprintf("verbose:no");
$file_info    = sprintf("file_info:no");


$exec = sprintf("/usr/bin/java -Djava.awt.headless=true -jar /data/smcd/nprovs/source/graphics/imagemaker/ImageMaker.jar %s %s %s %s %s %s %s %s", $input_file, $parm_file, $output_file, $thumb_file, $thumb_width, $thumb_height, $verbose, $file_info);

system $exec;



# =============================================================================
# ATOVS M1

symlink "/data/smcd/nprovs/data/matchup/DailyFiles_incoming/rrodf1000.m1", "in.file" or warn "Cannot link to in.file";
symlink "/data/smcd/nprovs/data/ods/atovs_m1.ods", "out.file" or warn "Cannot link to out.file";
symlink "/data/smcd/nprovs/source/ods_capture/atovs/atovs1000.xml", "parm.file" or warn "Cannot link to parm.file";
symlink "/data/smcd/nprovs/source/ods_capture/atovs/edgeparm_rodf1000.txt", "fileparm.file" or warn "Cannot link to fileparm.file";

system "/data/smcd/nprovs/source/ods_capture/atovs/createODSFromAtovsRODF1000.x \"ATOVS M1\"";

unlink "in.file" or warn "Cannot unlink in.file";
unlink "out.file" or warn "Cannot unlink out.file";
unlink "parm.file" or warn "Cannot unlink parm.file";
unlink "fileparm.file" or warn "Cannot unlink fileparm.file";


# Create an image from the ODS file and send the image to the STAR web site
# for routine monitoring

# Build the command line executable an then run it

$input_file   = sprintf("file:/data/smcd/nprovs/data/ods/atovs_m1.ods");
$parm_file    = sprintf("parmfile:/data/smcd/nprovs/source/graphics/imagemaker/defaults/atovs.xml");
$output_file  = sprintf("output:/net/www/www/smcd/opdb/poes/monitor/images/atovs_m1_%d.png", $wday);
$thumb_file   = sprintf("thumbnail:/net/www/www/smcd/opdb/poes/monitor/images/atovs_m1_thumb_%d.png", $wday);
$thumb_width  = sprintf("thumbwidth:150");
$thumb_height = sprintf("thumbheight:100");
$verbose      = sprintf("verbose:no");
$file_info    = sprintf("file_info:no");


$exec = sprintf("/usr/bin/java -Djava.awt.headless=true -jar /data/smcd/nprovs/source/graphics/imagemaker/ImageMaker.jar %s %s %s %s %s %s %s %s", $input_file, $parm_file, $output_file, $thumb_file, $thumb_width, $thumb_height, $verbose, $file_info);

system $exec;



# =============================================================================
# ATOVS M2

symlink "/data/smcd/nprovs/data/matchup/DailyFiles_incoming/rrodf1000.m2", "in.file" or warn "Cannot link to in.file";
symlink "/data/smcd/nprovs/data/ods/atovs_m2.ods", "out.file" or warn "Cannot link to out.file";
symlink "/data/smcd/nprovs/source/ods_capture/atovs/atovs1000.xml", "parm.file" or warn "Cannot link to parm.file";
symlink "/data/smcd/nprovs/source/ods_capture/atovs/edgeparm_rodf1000.txt", "fileparm.file" or warn "Cannot link to fileparm.file";

system "/data/smcd/nprovs/source/ods_capture/atovs/createODSFromAtovsRODF1000.x \"ATOVS M2\"";

unlink "in.file" or warn "Cannot unlink in.file";
unlink "out.file" or warn "Cannot unlink out.file";
unlink "parm.file" or warn "Cannot unlink parm.file";
unlink "fileparm.file" or warn "Cannot unlink fileparm.file";


# Create an image from the ODS file and send the image to the STAR web site
# for routine monitoring

# Build the command line executable an then run it

$input_file   = sprintf("file:/data/smcd/nprovs/data/ods/atovs_m2.ods");
$parm_file    = sprintf("parmfile:/data/smcd/nprovs/source/graphics/imagemaker/defaults/atovs.xml");
$output_file  = sprintf("output:/net/www/www/smcd/opdb/poes/monitor/images/atovs_m2_%d.png", $wday);
$thumb_file   = sprintf("thumbnail:/net/www/www/smcd/opdb/poes/monitor/images/atovs_m2_thumb_%d.png", $wday);
$thumb_width  = sprintf("thumbwidth:150");
$thumb_height = sprintf("thumbheight:100");
$verbose      = sprintf("verbose:no");
$file_info    = sprintf("file_info:no");


$exec = sprintf("/usr/bin/java -Djava.awt.headless=true -jar /data/smcd/nprovs/source/graphics/imagemaker/ImageMaker.jar %s %s %s %s %s %s %s %s", $input_file, $parm_file, $output_file, $thumb_file, $thumb_width, $thumb_height, $verbose, $file_info);

system $exec;



# =============================================================================
# ATOVS OA11

symlink "/data/smcd/nprovs/data/matchup/DailyFiles_incoming/rrodf.oa11", "in.file" or warn "Cannot link to in.file";
symlink "/data/smcd/nprovs/data/ods/atovs_oa11.ods", "out.file" or warn "Cannot link to out.file";
symlink "/data/smcd/nprovs/source/ods_capture/atovs/atovs1000.xml", "parm.file" or warn "Cannot link to parm.file";
symlink "/data/smcd/nprovs/source/ods_capture/atovs/edgeparm_rodf1000.txt", "fileparm.file" or warn "Cannot link to fileparm.file";

system "/data/smcd/nprovs/source/ods_capture/atovs/createODSFromAtovsRODF1000.x \"ATOVS OA11\"";

unlink "in.file" or warn "Cannot unlink in.file";
unlink "out.file" or warn "Cannot unlink out.file";
unlink "parm.file" or warn "Cannot unlink parm.file";
unlink "fileparm.file" or warn "Cannot unlink fileparm.file";


# Create an image from the ODS file and send the image to the STAR web site
# for routine monitoring

# Build the command line executable an then run it

$input_file   = sprintf("file:/data/smcd/nprovs/data/ods/atovs_oa11.ods");
$parm_file    = sprintf("parmfile:/data/smcd/nprovs/source/graphics/imagemaker/defaults/atovs.xml");
$output_file  = sprintf("output:/net/www/www/smcd/opdb/poes/monitor/images/atovs_oa11_%d.png", $wday);
$thumb_file   = sprintf("thumbnail:/net/www/www/smcd/opdb/poes/monitor/images/atovs_oa11_thumb_%d.png", $wday);
$thumb_width  = sprintf("thumbwidth:150");
$thumb_height = sprintf("thumbheight:100");
$verbose      = sprintf("verbose:no");
$file_info    = sprintf("file_info:no");


$exec = sprintf("/usr/bin/java -Djava.awt.headless=true -jar /data/smcd/nprovs/source/graphics/imagemaker/ImageMaker.jar %s %s %s %s %s %s %s %s", $input_file, $parm_file, $output_file, $thumb_file, $thumb_width, $thumb_height, $verbose, $file_info);

system $exec;


# end of file
