Changeset 26563
- Timestamp:
- Jan 12, 2010, 12:29:32 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/tools/gpc1_find_images.pl (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/gpc1_find_images.pl
r26548 r26563 3 3 use DBI; 4 4 use Getopt::Std; 5 getopts('h FARCPp:BLMDWIYTvx:n:c:w:s:O:S:N:',\%opt);5 getopts('hEFARCPp:BLMDWIJVYTvx:n:c:w:s:d:e:O:S:N:',\%opt); 6 6 #getopt('xncwOS:hARCW',\%opt); 7 7 unless (exists($opt{O})) { … … 34 34 } 35 35 36 # abcdefghijklmnopqrstuvwxyz 37 #used: 38 # ABCDEF LMNOP RST W Y 39 # c h n s vwx 36 40 if (exists($opt{h})) { 37 41 print "USAGE find_images.pl ... \n"; 38 42 print " -h This help\n"; 39 print " -R Return raw data.\n"; 40 print " -C Return chip stage data.\n"; 41 print " -W Return warp stage data.\n"; 43 print " -R Return Raw data.\n"; 44 print " -C Return Chip stage data.\n"; 45 print " -E Return camEra stage data.\n"; 46 print " -W Return Warp stage data.\n"; 47 print " -T Get the sTacks for a given input.\n"; 48 print " -J Get the dIff stage data (warps only for now).\n"; 42 49 print " -A Return not just fits images.\n"; 43 50 print " -F Convert to real filenames.\n"; … … 45 52 print " -B Return burntool table.\n"; 46 53 print " -M Include masks in results.\n"; 54 print " -L Return the log files from this stage.\n"; 47 55 print " -D Return only pre-destreaked images.\n"; 48 56 print " -Y Yes, I want the raw, even if it's not been processed.\n"; 49 print " - T Get the sTacks for a given input.\n";57 print " -V Return the cmf or smf files.\n"; 50 58 print " -v Be verbose on output.\n"; 51 59 print " \n"; 52 60 print " -x <exp_id> Specify a exp_id.\n"; 53 61 print " -c <chip_id> ...\n"; 62 print " -e <cam_id> ...\n"; 54 63 print " -w <warp_id> ...\n"; 55 64 print " -s <stack_id> ...\n"; 65 print " -d <diff_id> ...\n"; 56 66 print " -n <exp_name> ...\n"; 57 67 print " \n"; … … 66 76 $dbname = 'gpc1'; 67 77 $dbserver = 'ippdb01'; 68 $dbuser = 'ipp ';69 $dbpass = 'ipp ';78 $dbuser = 'ippuser'; 79 $dbpass = 'ippuser'; 70 80 $db = DBI->connect("DBI:mysql:database=${dbname};host=${dbserver};" . 71 81 "mysql_socket=" . DB_SOCKET(), … … 75 85 76 86 if ($opt{Y}) { 77 $sth_base = "SELECT warp_id,warpRun.workdir,chipRun.chip_id,chipRun.workdir,rawExp.exp_name,rawExp.exp_id,rawExp.workdir,rawExp.dateobs,rawExp.pon_time,0,'nostack' from warpRun RIGHT OUTER JOIN fakeRun USING(fake_id) RIGHT OUTER JOIN camRun USING(cam_id) RIGHT OUTER JOIN chipRun USING(chip_id) RIGHT OUTER JOIN rawExp USING (exp_id)";87 $sth_base = "SELECT warp_id,warpRun.workdir,chipRun.chip_id,chipRun.workdir,rawExp.exp_name,rawExp.exp_id,rawExp.workdir,rawExp.dateobs,rawExp.pon_time,0,'nostack',camRun.cam_id,camRun.workdir,0,'nodiff' from warpRun RIGHT OUTER JOIN fakeRun USING(fake_id) RIGHT OUTER JOIN camRun USING(cam_id) RIGHT OUTER JOIN chipRun USING(chip_id) RIGHT OUTER JOIN rawExp USING (exp_id)"; 78 88 } 79 89 else { 80 $sth_base = "SELECT warp_id,warpRun.workdir,chipRun.chip_id,chipRun.workdir,rawExp.exp_name,rawExp.exp_id,rawExp.workdir,rawExp.dateobs,rawExp.pon_time,0,'nostack' from warpRun JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING (exp_id)";90 $sth_base = "SELECT warp_id,warpRun.workdir,chipRun.chip_id,chipRun.workdir,rawExp.exp_name,rawExp.exp_id,rawExp.workdir,rawExp.dateobs,rawExp.pon_time,0,'nostack',camRun.cam_id,camRun.workdir,0,'nodiff' from warpRun JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING (exp_id)"; 81 91 } 82 92 … … 95 105 if (exists($opt{w})) { 96 106 push @sth_adds, "warpRun.warp_id = $opt{w}"; 107 } 108 if (exists($opt{e})) { 109 push @sth_adds, "camRun.cam_id = $opt{e}"; 97 110 } 98 111 if (exists($opt{s})||exists($opt{T})) { … … 107 120 $sth_base .= ' JOIN stackInputSkyfile USING (warp_id) JOIN stackSumSkyfile USING (stack_id) JOIN stackRun USING (stack_id)'; 108 121 # print "$sth_base\n"; 122 } 123 if (exists($opt{J})||(exists($opt{d}))) { 124 if (exists($opt{d})&&($opt{d} != 0)) { 125 push @sth_adds, "diffRun.diff_id = $opt{d}"; 126 } 127 $sth_base =~ s/0,'nodiff'/diffRun.diff_id,diffSkyfile.path_base/; 128 if (exists($opt{J})) { 129 # $sth_base .= ' RIGHT OUTER '; 130 } 131 $sth_base .= ' JOIN diffInputSkyfile ON (warpRun.warp_id = diffInputSkyfile.warp1 OR warpRun.warp_id = diffInputSkyfile.warp2) JOIN diffRun USING (diff_id) JOIN diffSkyfile USING (diff_id)'; 109 132 } 110 133 if ($#sth_adds != -1) { … … 124 147 ($warp_id, $warp_workdir, $chip_id, $chip_workdir, 125 148 $exp_name, $exp_id, $exp_workdir, $exp_dateobs, $exp_pontime, 126 $stack_id, $stack_sumfile_uri) = @{ $rr }; 149 $stack_id, $stack_sumfile_uri, 150 $cam_id, $cam_workdir, 151 $diff_id, $diff_workdir 152 ) = @{ $rr }; 127 153 if ($stack_id == 0) { 128 154 $stack_sumfile_uri = ''; … … 132 158 if (exists($opt{I})) { 133 159 $stack_id = 0; # Ditto. 160 $cam_id = 0; 161 $diff_id = 0; 134 162 } 135 163 if (exists($opt{N})) { … … 231 259 close(NLS); 232 260 } 261 if (exists($opt{E})) { 262 open(NLS,"neb-ls $cam_workdir/${exp_name}.${exp_id}/ |") || die "can't neb-ls"; 263 while (<NLS>) { 264 chomp; 265 if (is_valid_cam($_)) { 266 push @scan, $_; 267 $found++; 268 } 269 } 270 close(NLS); 271 } 233 272 if (exists($opt{W})) { 234 273 open(NLS,"neb-ls $warp_workdir/${exp_name}.${exp_id}/ |") || die "can't neb-ls"; … … 241 280 } 242 281 } 282 if (exists($opt{J})) { 283 @diff_tmp = split /\//, $diff_workdir; 284 $diff_prefix = pop(@diff_tmp); 285 $diff_true_dir = join '/',@diff_tmp; 286 287 open(NLS,"neb-ls $diff_true_dir |") || die "can't neb-ls"; 288 while (<NLS>) { 289 chomp; 290 if (is_valid_diff($_)) { 291 push @scan, $_; 292 $found++; 293 } 294 } 295 } 243 296 if (exists($opt{s})||exists($opt{T})) { 244 297 if (defined($stack_sumfile_uri)) { … … 354 407 } 355 408 } 409 elsif ($opt{V} && ($key =~ /cmf/)) { 410 return(1); 411 } 356 412 elsif ($key !~ /fits/) { 357 413 return(0); # Not a fits … … 375 431 } 376 432 433 sub is_valid_cam { 434 my $key = shift; 435 if ($key =~ /\.cm\./) { 436 if ($opt{A}) { 437 return(1); 438 } 439 elsif ($opt{L} && ($key =~ /log/)) { 440 return(1); 441 } 442 elsif ($opt{V} && ($key =~ /smf/)) { 443 return(1); 444 } 445 } 446 return(0); 447 } 448 449 sub is_valid_diff { 450 my $key = shift; 451 if ($key =~ /$diff_prefix/) { 452 if ($opt{D} && ($key !~ /SR/)) { 453 return(0); # Not destreaked when required 454 } 455 if (($opt{S} ne '')&&($key !~ /$opt{S}/)) { 456 return(0); # Not the requested skycell 457 } 458 if (($opt{O} ne '')&& !(is_mapped($key,$opt{O}))) { 459 return(0); # Not the remapped OTA requested 460 } 461 462 if ($opt{A}) { 463 return(1); # You asked for all, 464 } 465 elsif ($opt{L}) { 466 if ($key =~ /log/) { 467 return(1); 468 } 469 else { 470 return(0); 471 } 472 } 473 elsif ($opt{V} && ($key =~ /cmf/)) { 474 return(1); 475 } 476 elsif ($key !~ /fits/) { 477 return(0); # Not a fits 478 } 479 elsif ($key =~ /wt.fits/) { 480 return(0); # No handler for weight right now. 481 } 482 elsif ($key =~ /mask/) { 483 if ($opt{M}) { 484 return(1); # Requested mask 485 } 486 else { 487 return(0); 488 } 489 } 490 else { 491 return(1); # Should be just the warp. 492 } 493 } 494 495 return(0); 496 } 377 497 sub is_valid_warp { 378 498 my $key = shift; … … 402 522 } 403 523 } 524 elsif ($opt{V} && ($key =~ /cmf/)) { 525 return(1); 526 } 404 527 elsif ($key !~ /fits/) { 405 528 return(0); # Not a fits … … 421 544 return(0); 422 545 } 423 424 425 426 427
Note:
See TracChangeset
for help on using the changeset viewer.
