Changeset 21934
- Timestamp:
- Feb 20, 2009, 11:02:01 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/register_imfile.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/register_imfile.pl
r20118 r21934 17 17 use Storable qw(freeze thaw); 18 18 use File::Basename qw( basename); 19 use IPC:: Cmd 0.36 qw( can_runrun );19 use IPC::Run qw( harness run ); 20 20 use PS::IPP::Config 1.01 qw( :standard ); 21 21 use PS::IPP::Metadata::Config; 22 23 my $PI = 3.141592653589793238462643383279502; 22 use Math::Trig; 24 23 25 24 my $ipprc = PS::IPP::Config->new(); # IPP configuration … … 58 57 # Look for programs we need 59 58 my $missing_tools; 60 my $regtool = can_run('regtool') or (warn "Can't find regtool" and $missing_tools = 1); 61 my $ppStats = can_run('ppStats') or (warn "Can't find ppStats" and $missing_tools = 1); 62 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 59 my $regtool = `which regtool` or (warn "Can't find regtool" and $missing_tools = 1); 60 my $ppStats = `which ppStats` or (warn "Can't find ppStats" and $missing_tools = 1); 61 my $ppStatsFromMetadata = `which ppStatsFromMetadata` or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 62 chomp $regtool; 63 chomp $ppStats; 64 chomp $ppStatsFromMetadata; 65 63 66 64 67 if ($missing_tools) { … … 80 83 # Run ppStats on the input file 81 84 { 82 my $command = "$ppStats $uri -recipe PPSTATS $RECIPE -level | $ppStatsFromMetadata - - REGISTER_IMFILE"; # Command to run ppStats and ppStatsFromMetadata 83 $command .= " -dbname $dbname" if defined $dbname; 84 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 85 cache_run(command => $command, verbose => $verbose); 86 unless ($success) { 87 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 88 &my_die ("Unable to perform ppStats on exposure id $exp_id: $error_code", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $error_code); 89 } 90 foreach my $line (@$stdout_buf) { 91 $cmdflags .= " $line"; 92 } 93 chomp $cmdflags; 85 my $command1 = "$ppStats $uri -recipe PPSTATS $RECIPE -level"; 86 my $command2 = "$ppStatsFromMetadata - - REGISTER_IMFILE"; 87 88 # Since there are no spaces in the arguments, we can get away with this: 89 my @command1 = split(/ /, $command1); 90 my @command2 = split(/ /, $command2); 91 92 # Run ppStats 93 my ($in1, $out1, $err1); # Buffers for ppStats 94 my $h1 = harness \@command1, \$in1, \$out1, \$err1; 95 print "[Running $command1]\n"; 96 my $result1 = run $h1; 97 print $out1; 98 print $err1; 99 &my_die("Unable to perform ppStats on exposure id $exp_id: " . $h1->result(), $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $h1->result() ) unless $result1; 100 101 print "[Running " . join(' ', @command2) . "]\n"; 102 my ($out2, $err2); # Buffers for ppStatsFromMetadata 103 my $h2 = harness \@command2, \$out1, \$out2, \$err2; 104 print "[Running $command2]\n"; 105 my $result2 = run $h2; 106 print $out2; 107 print $err2; 108 &my_die("Unable to perform ppStatsFromMetadata on exposure id $exp_id: " . $h2->result(), $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $h2->result() ) unless $result2; 109 chomp $out2; 110 $cmdflags = $out2; 94 111 } 95 112 … … 123 140 # if the needed data is available, pass it to sunmoon: 124 141 if ($longitude && $latitude && $ra && $dec && $dateobs) { 125 126 $longitude *= 12.0 / $PI; # longitude is reported in West radians; sunmoon wants it in West Hours127 $latitude *= 180.0 / $PI; # latitude is reported in North radians; sunmoon wants it in North Degrees128 $ra *= 180.0 / $PI; # ra is reported in radians; sunmoon wants it in degrees129 $dec *= 180.0 / $PI; # dec is reported in radians; sunmoon wants it in degrees142 143 $longitude *= 12.0 / pi; # longitude is reported in West radians; sunmoon wants it in West Hours 144 $latitude *= 180.0 / pi; # latitude is reported in North radians; sunmoon wants it in North Degrees 145 $ra *= 180.0 / pi; # ra is reported in radians; sunmoon wants it in degrees 146 $dec *= 180.0 / pi; # dec is reported in radians; sunmoon wants it in degrees 130 147 131 148 my $sunmoon_cmd = "sunmoon -latitude $latitude -longitude $longitude -elevation $elevation $dateobs $ra $dec"; … … 137 154 138 155 if ($?) { 139 warn ("failure running $sunmoon_cmd, not supplying\n");156 warn ("failure running $sunmoon_cmd, not supplying\n"); 140 157 } else { 141 $command .= " $sunmoon_data";158 $command .= " $sunmoon_data"; 142 159 } 143 160 }
Note:
See TracChangeset
for help on using the changeset viewer.
