Changeset 27442 for trunk/tools/microtest.pl
- Timestamp:
- Mar 24, 2010, 5:17:10 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/tools/microtest.pl (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/microtest.pl
r27438 r27442 16 16 my ($label); # Label of interest 17 17 my ($verbose); # Verbosity? 18 my ($save_temps); # Save temporary outputs? 18 19 19 20 GetOptions( … … 24 25 'label=s' => \$label, # Label of interest 25 26 'verbose' => \$verbose, # Verbosity? 27 'save-temps' => \$save_temps, # Save temporary outputs? 26 28 ) or die "Unable to parse arguments.\n"; 27 29 die "Unknown option: @ARGV\n" if @ARGV; … … 42 44 # Exposures of interest 43 45 my $exps = $db->selectall_arrayref( 44 "SELECT exp_id, exp_name, magic_id, outrootFROM magicRun JOIN rawExp USING(exp_id) WHERE label = '$label' AND magicRun.state = 'full'",46 "SELECT exp_id, exp_name, magic_id, magicRun.outroot AS magic_path, camProcessedExp.path_base AS cam_path FROM magicRun JOIN rawExp USING(exp_id) WHERE label = '$label' AND magicRun.state = 'full'", 45 47 Slice => {} 46 48 ) or die "Unable to execute SQL: $DBI::errstr"; … … 50 52 my $name = $exp->{exp_name}; # Exposure name 51 53 my $magic = $exp->{magic_id}; # Magic identifier 52 my $outroot = $exp->{outroot}; # Output root for magic 54 my $magic_path = $exp->{magic_path}; # Output root for magic 55 my $cam_path = $exp->{cam_path}; # Output root for camera 53 56 54 my $clusters = "$ outroot/$id/$id.mgc.$magic.verify/${id}_clusterPos.txt"; # File with cluster RA,Dec57 my $clusters = "${magic_path}/$id/$id.mgc.$magic.verify/${id}_clusterPos.txt"; # File with cluster RA,Dec 55 58 die "Cannot find clusters file $clusters" unless -e $clusters; 56 59 57 my ($tempFile, $tempName) = tempfile( "/tmp/chip.$exp_id.$class_id.deburned.XXXX",58 UNLINK => !$save_temps, SUFFIX => '.fits' );60 my $astrom = "${cam_path}.smf"; # Astrometry file 61 die "Cannot find astrometry file $astrom" unless -e $astrom; 59 62 60 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 61 run(command => "$ppCoord , verbose => $verbose); 63 # Format the clusters file 64 open my $clustersFile, "$clusters" or die "Cannot open clusters file $clusters: $!"; 65 my ($radecFile, $radecName) = tempfile( "/tmp/microtest.XXXX", 66 UNLINK => !$save_temps, SUFFIX => '.dat' ); 67 my @contents = <$clustersFile>; # Contents of clusters file 68 foreach my $line (@contents) { 69 $line =~ s/^\s*//; 70 my ($ra, $dec) = split /\s+/, $line; 71 print $radecFile "$ra $dec\n" if defined $ra and defined $dec and $ra !~ /\w/ and $dec !~ /\w/; 72 } 73 close $clustersFile; 74 close $radecFile; 75 76 my $raws = $db->selectcol_arrayref("SELECT uri FROM rawImfile where exp_id = $id") or 77 die "Unable to execute SQL: $DBI::errstr"; 78 79 open my $outFile, "${name}_clusters.xy" or die "Cannot open output file: $!"; 80 foreach my $raw (@$raws) { 81 # my $resolved = `neb-locate --path $raw`; # Resolved filename 82 # chomp $resolved; 83 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 84 run(command => "$ppCoord -astrom $astrom -raw $raw -radec $radecName", verbose => $verbose); 85 die "Unable to run ppCoord" unless $success; 86 87 foreach my $line (@$stdout_buf) { 88 my @line = split /\s+/, $line; 89 90 my $ra = $line[0]; 91 my $dec = $line[1]; 92 my $x = $line[3]; 93 my $y = $line[4]; 94 my $chip = $line[5]; 95 my $cell = $line[6]; 96 97 print $outFile "$chip $cell $x $y $ra $dec\n"; 98 } 99 } 100 close $outFile; 101 }
Note:
See TracChangeset
for help on using the changeset viewer.
