Changeset 26098
- Timestamp:
- Nov 11, 2009, 7:49:02 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/tools/gpc1_find_images.pl (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/gpc1_find_images.pl
r25853 r26098 3 3 use DBI; 4 4 use Getopt::Std; 5 getopts('hFARCPp:B MDWvx:n:c:w:O:S:',\%opt);5 getopts('hFARCPp:BLMDWIvx:n:c:w:s:O:S:N:',\%opt); 6 6 #getopt('xncwOS:hARCW',\%opt); 7 7 unless (exists($opt{O})) { … … 51 51 print " -c <chip_id> ...\n"; 52 52 print " -w <warp_id> ...\n"; 53 print " -s <stack_id> ...\n"; 53 54 print " -n <exp_name> ...\n"; 54 55 print " \n"; … … 71 72 ) or die "Unable to connect to database $DBI::errstr\n"; 72 73 73 $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 from warpRun JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING (exp_id)"; 74 $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)"; 75 74 76 # What do we have? 75 77 @sth_adds = (); … … 86 88 if (exists($opt{w})) { 87 89 push @sth_adds, "warpRun.warp_id = $opt{w}"; 90 } 91 if (exists($opt{s})) { 92 if ($opt{s} != 0) { 93 push @sth_adds, "stackRun.stack_id = $opt{s}"; 94 } 95 $sth_base =~ s/0,"nostack"/stack_id,stackSumSkyfile.uri/; 96 $sth_base .= ' JOIN stackInputSkyfile USING (warp_id) JOIN stackSumSkyfile USING (stack_id) JOIN stackRun USING (stack_id)'; 88 97 } 89 98 if ($#sth_adds != -1) { … … 97 106 $dr = $db->selectall_arrayref( $sth ); 98 107 108 109 %uniq = (); 110 $found = 0; 99 111 foreach $rr (@{ $dr }) { 100 112 ($warp_id, $warp_workdir, $chip_id, $chip_workdir, 101 $exp_name, $exp_id, $exp_workdir, $exp_dateobs, $exp_pontime) = @{ $rr }; 113 $exp_name, $exp_id, $exp_workdir, $exp_dateobs, $exp_pontime, 114 $stack_id, $stack_sumfile_uri) = @{ $rr }; 115 if ($stack_id == 0) { 116 $stack_sumfile_uri = ''; 117 } 102 118 # print (join "\t", @{ $rr }) . "\n"; 103 $exp_pontime = 0; # To stop warnings, but I want this around. 119 # $exp_pontime = 0; # To stop warnings, but I want this around. 120 if (exists($opt{I})) { 121 $stack_id = 0; # Ditto. 122 } 123 if (exists($opt{N})) { 124 if ($found > $opt{N}) { 125 last; 126 } 127 } 104 128 if (exists($opt{P})) { 105 129 $sth_previous = "SELECT exp_name from rawExp where dateobs < '$exp_dateobs' order by dateobs desc limit 1"; … … 127 151 # exit(0); 128 152 } 129 130 131 153 154 %mapping = (); 155 if ((exists($opt{C})&&(exists($opt{S})))|| 156 (exists($opt{W})&&(exists($opt{O})))|| 157 exists($opt{I})) { 158 $sth_mapping = "SELECT skycell_id,class_id from warpSkyCellMap WHERE warp_id = $warp_id"; 159 $mr = $db->selectall_arrayref( $sth_mapping ); 160 foreach $mrr (@{ $mr }) { 161 my ($skycell,$class) = @{ $mrr }; 162 my $raw_class = $class; 163 $raw_class =~ s/xy/ota/i; 164 push @{ $mapping{$skycell} }, $class; 165 push @{ $mapping{$skycell} }, $raw_class; 166 push @{ $mapping{$class} }, $skycell; 167 push @{ $mapping{$raw_class} }, $skycell; 168 } 169 } 170 171 if (exists($opt{I})) { 172 if ($warp_id eq '') { 173 $warp_id = 'NULL'; 174 } 175 if ($stack_id eq '') { 176 $stack_id = 'NULL'; 177 } 178 $line = "$exp_name $exp_id $exp_dateobs $exp_pontime $chip_id $warp_id\t"; 179 if (exists($opt{O})) { 180 foreach $sky (@{ $mapping{$opt{O}} }) { 181 $line .= "$sky\t"; 182 } 183 } 184 if (exists($opt{S})) { 185 foreach $sky (@{ $mapping{$opt{S}} }) { 186 $line .= "$sky\t"; 187 } 188 } 189 $line .= "\n"; 190 unless (exists($uniq{$line})) { 191 print $line; 192 $uniq{$line} = 1; 193 } 194 next; 195 } 132 196 @scan = (); 133 197 if (exists($opt{R})||exists($opt{B})) { … … 135 199 while (<NLS>) { 136 200 chomp; 137 if (($_ =~ /${opt{O}}/)&&((($opt{A})) || ($_ =~ /fits/))) { 138 if (exists($opt{B})) { 139 $_ =~ s/.fits$/.burn.tbl/; 140 } 201 if (is_valid_raw($_)) { 141 202 push @scan, $_; 203 $found++; 142 204 } 143 205 } … … 148 210 while (<NLS>) { 149 211 chomp; 150 if (($_ =~ /${exp_id}.ch/)&&($_ =~ /$chip_id/)&&($_ =~ /$opt{O}/)&& 151 ((($opt{A})) || (($_ =~ /fits/) && 152 ($opt{M} || ($_ !~ /mk.fits/)) && 153 ($_ !~ /wt.fits/)))) { 154 if ($opt{D} && ($_ !~ /SR/)) { 155 next; 156 } 212 if (is_valid_chip($_)) { 157 213 push @scan, $_; 158 214 $found++; 159 215 } 160 216 } … … 165 221 while (<NLS>) { 166 222 chomp; 167 # print "$_\n"; 168 if (($_ =~ /wrp.${warp_id}.$opt{S}/) && ((($opt{A})) || (($_ =~ /fits/) && 169 ($opt{M} || ($_ !~ /mask/)) && 170 ($_ !~ /wt/)))) { 171 if ($opt{D} && ($_ !~ /SR/)) { 172 next; 173 } 223 if (is_valid_warp($_)) { 174 224 push @scan, $_; 175 } 176 } 177 } 178 %uniq = (); 225 $found++; 226 } 227 } 228 } 229 if (exists($opt{s})) { 230 push @scan, $stack_sumfile_uri; 231 $found++; 232 } 233 179 234 foreach $f (@scan) { 180 235 unless (exists($uniq{$f})) { … … 190 245 } 191 246 } 247 248 sub is_mapped { 249 my ($key,$map_string) = @_; 250 251 unless (exists($mapping{$map_string})) { 252 return(0); 253 } 254 255 foreach $v (@{ $mapping{$map_string} }) { 256 if ($key =~ /$v/) { 257 return(1); 258 } 259 } 260 return(0); 261 } 262 263 sub is_valid_raw { 264 my $key = shift; 265 266 if ($opt{A}) { 267 return(1); 268 } 269 elsif ($opt{L}) { 270 if ($key =~ /log/) { 271 return(1); 272 } 273 else { 274 return(0); 275 } 276 } 277 elsif ($opt{B}) { 278 if ($key =~ /burn.tbl/) { 279 return(1); 280 } 281 else { 282 return(0); 283 } 284 } 285 elsif ($key !~ /fits/) { 286 return(0); 287 } 288 else { 289 if (($opt{O} ne '')&&($key !~ /$opt{O}/)) { 290 return(0); # Not the requested OTA 291 } 292 if (($opt{S} ne '')&& !(is_mapped($key,$opt{S}))) { 293 return(0); # Not the remapped skycell requested 294 } 295 if ($key =~ /burn.fits/) { 296 return(0); 297 } 298 return(1); 299 } 300 } 301 302 sub is_valid_chip { 303 my $key = shift; 304 305 306 if ($opt{D} && ($key !~ /SR/)) { 307 return(0); # Not destreaked when required 308 } 309 elsif ($key !~ /${exp_id}.ch/) { 310 return(0); # Not a chip from this exposure 311 } 312 elsif ($key !~ /${chip_id}/) { 313 return(0); # Not from this chip_id 314 } 315 316 if (($opt{O} ne '')&&($key !~ /$opt{O}/)) { 317 return(0); # Not the requested OTA 318 } 319 if (($opt{S} ne '')&& !(is_mapped($key,$opt{S}))) { 320 return(0); # Not the remapped skycell requested 321 } 322 323 if ($opt{A}) { 324 return(1); # You asked for all, 325 } 326 elsif ($opt{L}) { 327 if ($key =~ /log/) { 328 return(1); 329 } 330 else { 331 return(0); 332 } 333 } 334 elsif ($key !~ /fits/) { 335 return(0); # Not a fits 336 } 337 elsif ($key =~ /wt.fits/) { 338 return(0); # No handler for weight right now. 339 } 340 elsif ($key =~ /mk/) { 341 if ($opt{M}) { 342 return(1); # Requested mask 343 } 344 else { 345 return(0); 346 } 347 } 348 elsif ($key =~ /ch.fits/) { 349 return(1); # Should be just the chip 350 } 351 return(0); 352 353 } 354 355 sub is_valid_warp { 356 my $key = shift; 357 358 if ($opt{D} && ($key !~ /SR/)) { 359 return(0); # Not destreaked when required 360 } 361 elsif ($key !~ /wrp.${warp_id}/) { 362 return(0); # Not a warp from this warp_id 363 } 364 if (($opt{S} ne '')&&($key !~ /$opt{S}/)) { 365 return(0); # Not the requested skycell 366 } 367 if (($opt{O} ne '')&& !(is_mapped($key,$opt{O}))) { 368 return(0); # Not the remapped OTA requested 369 } 370 371 if ($opt{A}) { 372 return(1); # You asked for all, 373 } 374 elsif ($opt{L}) { 375 if ($key =~ /log/) { 376 return(1); 377 } 378 else { 379 return(0); 380 } 381 } 382 elsif ($key !~ /fits/) { 383 return(0); # Not a fits 384 } 385 elsif ($key =~ /wt.fits/) { 386 return(0); # No handler for weight right now. 387 } 388 elsif ($key =~ /mask/) { 389 if ($opt{M}) { 390 return(1); # Requested mask 391 } 392 else { 393 return(0); 394 } 395 } 396 else { 397 return(1); # Should be just the warp. 398 } 399 return(0); 400 } 401 402 403 404 405
Note:
See TracChangeset
for help on using the changeset viewer.
