| 1 |
#!/usr/bin/perl -w |
| 2 |
|
| 3 |
=head1 NAME |
| 4 |
|
| 5 |
our_wrapper.pl - a wrapper calling provided algorithms |
| 6 |
|
| 7 |
=head1 SYNOPSIS |
| 8 |
|
| 9 |
our_wrapper.pl --program 'text' |
| 10 |
--inputfiles file1.xml,file2.xml |
| 11 |
--varfiles varInfo1.xml,varInfo2.xml |
| 12 |
--zfiles zfile1.xml,zfile2.xml |
| 13 |
--variables variable1,variable2 |
| 14 |
--bbox west,south,east,north |
| 15 |
--starttime YYYY-MM-DDTHH:MI:SSZ |
| 16 |
--endtime YYYY-MM-DDTHH:MI:SSZ |
| 17 |
[--comparison comparison_type] |
| 18 |
[--dateline-method stitch] |
| 19 |
[--debug [0-3]] |
| 20 |
[--time-axis] |
| 21 |
[--output-type (filelist|ncfile)] |
| 22 |
[--units units1,units2,units-cfg.xml] |
| 23 |
|
| 24 |
=head1 DESCRIPTION |
| 25 |
|
| 26 |
time_code.pl simplifies and regularizes the calling arguments for |
| 27 |
provided algorithims. |
| 28 |
=over |
| 29 |
|
| 30 |
=item --program |
| 31 |
|
| 32 |
Filename (no directory, ideally) of algorithm executable, plus any fixed |
| 33 |
arguments as necessary. E.g., "kmeans.pl -k 3" |
| 34 |
|
| 35 |
=item --inputfiles |
| 36 |
|
| 37 |
Comma separated list of input XML G6 Manifest files. |
| 38 |
There is typically only file for most 1-variable-at-a-time services |
| 39 |
(like area averager), but it may be two files for some comparisons. |
| 40 |
|
| 41 |
=item --varfiles |
| 42 |
|
| 43 |
Comma separated list of input XML files with informatino about the data fields. |
| 44 |
There is typically only file for most 1-variable-at-a-time services |
| 45 |
(like area averager), but it may be two files for some comparisons. |
| 46 |
|
| 47 |
=item --variables |
| 48 |
|
| 49 |
Comma separated list of variables |
| 50 |
There is typically only one for most 1-variable-at-a-time services |
| 51 |
(like area averager), but it may be two for some comparisons. |
| 52 |
|
| 53 |
=item --bbox |
| 54 |
|
| 55 |
Comma-separated west,south,east,north boundaries. |
| 56 |
Typically, the algorithm is expected to subset within these boundaries. |
| 57 |
|
| 58 |
=item --outfile |
| 59 |
|
| 60 |
Output XML manifest file listing the file(s) created by the algorithm. |
| 61 |
|
| 62 |
=item --zfiles |
| 63 |
|
| 64 |
Comma separated list of input XML zslice files, showing what z level the user |
| 65 |
has selected. |
| 66 |
|
| 67 |
=item --starttime |
| 68 |
|
| 69 |
Start time in format YYYY-MM-DDTHH:MM:SSZ. |
| 70 |
|
| 71 |
=item --endtime |
| 72 |
|
| 73 |
End time in format YYYY-MM-DDTHH:MM:SSZ. |
| 74 |
|
| 75 |
=item --comparison |
| 76 |
|
| 77 |
Word or phrase describing the comparison type, |
| 78 |
e.g., "minus", "divided by", "regressed against" |
| 79 |
|
| 80 |
=item --debug |
| 81 |
|
| 82 |
Debug level, 0-3. |
| 83 |
|
| 84 |
=item --output-file-root |
| 85 |
|
| 86 |
Root for the filename of the output data file. |
| 87 |
|
| 88 |
=item --session-dir |
| 89 |
|
| 90 |
Session directory. Default is '.'. |
| 91 |
|
| 92 |
=item --time-axis |
| 93 |
|
| 94 |
Whether the output data has a time axis. This is true for someting and time-axis. |
| 95 |
If unset, assumes no time axis. |
| 96 |
This is what controls whether Something::Visualizer::TimeTics is invoked. |
| 97 |
|
| 98 |
=item --output-type |
| 99 |
|
| 100 |
If assigned the value 'filelist', the wrapper treats the output file argument as the |
| 101 |
name of the file that lists all the output files |
| 102 |
|
| 103 |
=item --units units1.xml,units2.xml,units-cfg.xml |
| 104 |
|
| 105 |
This argument tells the wrapper and/or algorithm to do units conversion, taking |
| 106 |
a comma-separated list of destination units: |
| 107 |
the first one (or two for comparison) is the user |
| 108 |
input, the last one is the units conversion configuration file. |
| 109 |
|
| 110 |
=cut |
| 111 |
|
| 112 |
# $Id: our_wrapper.pl,v 1.16 2015/04/16 22:15:42 cls Exp $ |
| 113 |
# -@@@ GSdd4 |
| 114 |
|
| 115 |
use strict; |
| 116 |
use Getopt::Long; |
| 117 |
use Something::Algorithm::Wrapper; |
| 118 |
|
| 119 |
use vars qw($program $comparison $bbox |
| 120 |
$inputfiles $outfile $zfiles $varfiles $units |
| 121 |
$variables $starttime $endtime |
| 122 |
$mintimesteps $outputfileroot |
| 123 |
$sessiondir |
| 124 |
$comparison |
| 125 |
$name |
| 126 |
$debug |
| 127 |
$dateline |
| 128 |
$time_axis |
| 129 |
$output_type |
| 130 |
$shapefile |
| 131 |
$group |
| 132 |
$jobs |
| 133 |
); |
| 134 |
|
| 135 |
GetOptions( |
| 136 |
"program=s" => \$program, |
| 137 |
"name=s" => \$name, |
| 138 |
"starttime=s" => \$starttime, |
| 139 |
"endtime=s" => \$endtime, |
| 140 |
"bbox=s" => \$bbox, |
| 141 |
"inputfiles=s" => \$inputfiles, |
| 142 |
"outfile=s" => \$outfile, |
| 143 |
"varfiles=s" => \$varfiles, |
| 144 |
"zfiles=s" => \$zfiles, |
| 145 |
"variables=s" => \$variables, |
| 146 |
"minimum-time-steps=i" => \$mintimesteps, |
| 147 |
"output-file-root=s" => \$outputfileroot, |
| 148 |
"session-dir=s" => \$sessiondir, |
| 149 |
"comparison=s" => \$comparison, |
| 150 |
"dateline=s" => \$dateline, |
| 151 |
"debug=i" => \$debug, |
| 152 |
"time-axis" => \$time_axis, |
| 153 |
"output-type=s" => \$output_type, |
| 154 |
"units=s" => \$units, |
| 155 |
"group=s" => \$group, |
| 156 |
"shapefile|S=s" => \$shapefile, |
| 157 |
"jobs=i" => \$jobs |
| 158 |
); |
| 159 |
my %args = ( |
| 160 |
'program' => $program, |
| 161 |
'name' => $name, |
| 162 |
'time-axis' => $time_axis, |
| 163 |
'dateline' => $dateline, |
| 164 |
'starttime' => $starttime, |
| 165 |
'endtime' => $endtime, |
| 166 |
'bbox' => $bbox, |
| 167 |
'outfile' => $outfile, |
| 168 |
'output-file-root' => $outputfileroot, |
| 169 |
'debug' => $debug, |
| 170 |
'varfiles' => $varfiles, |
| 171 |
'variables' => $variables, |
| 172 |
'inputfiles' => $inputfiles, |
| 173 |
'session-dir' => $sessiondir, |
| 174 |
'zfiles' => $zfiles, |
| 175 |
'output-type' => $output_type, |
| 176 |
'units' => $units, |
| 177 |
'group' => $group, |
| 178 |
'shapefile' => $shapefile, |
| 179 |
'jobs' => $jobs |
| 180 |
); |
| 181 |
|
| 182 |
if ($comparison) { |
| 183 |
$args{'comparison'} = $comparison; |
| 184 |
$args{'minimum-time-steps'} = $mintimesteps; |
| 185 |
} |
| 186 |
my $outnc = Something::Algorithm::Wrapper::run(%args); |
| 187 |
exit( !( -s $outnc ) ); |