Changeset 13275 for trunk/ippScripts/scripts/warp_skycell.pl
- Timestamp:
- May 4, 2007, 4:52:03 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/warp_skycell.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/warp_skycell.pl
r13112 r13275 18 18 use PS::IPP::Metadata::List qw( parse_md_list ); 19 19 20 use PS::IPP::Config qw( 21 $PS_EXIT_SUCCESS 22 $PS_EXIT_UNKNOWN_ERROR23 $PS_EXIT_SYS_ERROR24 $PS_EXIT_CONFIG_ERROR25 $PS_EXIT_PROG_ERROR26 $PS_EXIT_DATA_ERROR27 $PS_EXIT_TIMEOUT_ERROR 28 );20 use PS::IPP::Config qw($PS_EXIT_SUCCESS 21 $PS_EXIT_UNKNOWN_ERROR 22 $PS_EXIT_SYS_ERROR 23 $PS_EXIT_CONFIG_ERROR 24 $PS_EXIT_PROG_ERROR 25 $PS_EXIT_DATA_ERROR 26 $PS_EXIT_TIMEOUT_ERROR 27 caturi 28 ); 29 29 my $ipprc = PS::IPP::Config->new(); # IPP configuration 30 30 use File::Spec; 31 use File::Temp qw( tempfile ); 31 32 32 33 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 84 85 } 85 86 86 # Set output directory 87 if (defined $workdir) { 88 $workdir = $ipprc->convert_filename_absolute( $workdir ); 89 $workdir = File::Spec->catdir( $workdir, "tess_" . $tess_id, "sky_" . $skycell_id ); 90 } else { 91 my $example = $ipprc->convert_filename_absolute( $$imfiles[0]->{uri} ); 92 my ($vol, $dir, $file) = File::Spec->splitpath( $example ); 93 $workdir = $dir; 94 } 95 system "mkdir -p $workdir" unless -d $workdir; 96 97 my $outputFile = "$tess_id.$skycell_id.wrp$warp_id"; # Root name 98 my $outputRoot = File::Spec->catfile( $workdir, $outputFile ); 87 $workdir = caturi( $workdir, "tess_" . $tess_id, "sky_" . $skycell_id ) if defined $workdir; 88 my $outputRoot = $ipprc->file_prepare( "$tess_id.$skycell_id.wrp$warp_id", $workdir, $$imfiles[0]->{uri} ); 99 89 my $outputImage = $ipprc->filename("PSWARP.OUTPUT", $outputRoot, $skycell_id ); 100 90 my $outputBin1 = $ipprc->filename("PSWARP.BIN1", $outputRoot, $skycell_id ); 101 91 my $outputBin2 = $ipprc->filename("PSWARP.BIN2", $outputRoot, $skycell_id ); 102 92 my $outputStats = $outputRoot . '.stats'; 103 my $skyFile = File::Spec->catfile( $workdir, $skycell_id ); # Target sky cell file 104 my $listName = $outputRoot . '.list'; 93 my $skyFile = caturi( $workdir, $skycell_id ); # Target sky cell file 105 94 106 95 # Get list of filenames 107 open my $listFile, "> $listName" or &my_die("Unable to open $listName", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR);96 my ($listFile, $listName) = tempfile( "$tess_id.$skycell_id.wrp$warp_id.list.XXXX", UNLINK => 1); 108 97 foreach my $imfile (@$imfiles) { 109 my $uri = $ipprc->convert_filename_absolute( $imfile->{uri} ); 110 111 print $listFile "$uri\n"; 98 print $listFile ( $imfile->{uri} . "\n"); 112 99 } 113 100 close $listFile; … … 123 110 &my_die("Unable to perform pswarp: $error_code", $warp_id, $skycell_id, $error_code); 124 111 } 125 &my_die("Couldn't find expected output file: $outputImage", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ outputImage;126 &my_die("Couldn't find expected output file: $outputStats", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ outputStats;127 # &my_die("Couldn't find expected output file: $outputBin1", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ outputBin1;128 # &my_die("Couldn't find expected output file: $outputBin2", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ outputBin2;112 &my_die("Couldn't find expected output file: $outputImage", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputImage); 113 &my_die("Couldn't find expected output file: $outputStats", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats); 114 # &my_die("Couldn't find expected output file: $outputBin1", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin1); 115 # &my_die("Couldn't find expected output file: $outputBin2", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin2); 129 116 130 117 # Get the statistics on the warped image 131 118 my $statsFile; # File handle 132 open $statsFile, "$outputStats"or die "Can't open statistics file $outputStats: $!\n";119 open $statsFile, $ipprc->file_resolve($outputStats) or die "Can't open statistics file $outputStats: $!\n"; 133 120 my @contents = <$statsFile>; # Contents of file 134 121 close $statsFile; … … 138 125 } 139 126 140 # Take off the absolute path, to stuff into the database 141 $outputImage = $ipprc->convert_filename_relative( $outputImage ); 142 $outputRoot = $ipprc->convert_filename_relative( $outputRoot ); 143 127 # Add the processed file to the database 144 128 my $bg = ($stats->bg_mean() or 'NAN'); 145 129 my $bg_stdev = ($stats->bg_stdev() or 'NAN'); 146 147 # Add the processed file to the database148 130 unless ($no_update) { 149 131 my $command = "$warptool -addwarped -warp_id $warp_id -skycell_id $skycell_id -tess_id $tess_id" . … … 159 141 exit($error_code); 160 142 } 161 162 unlink $outputStats;163 143 } 164 144
Note:
See TracChangeset
for help on using the changeset viewer.
