Changeset 27612
- Timestamp:
- Apr 5, 2010, 5:31:23 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/tools/microtest.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/microtest.pl
r27572 r27612 16 16 my ($db_host, $db_name, $db_user, $db_pw); # Database details 17 17 my ($label); # Label of interest 18 my ($exp_id); # Exposure of interest 18 19 my ($group); # Data group 19 20 my ($verbose); # Verbosity? 20 21 my ($save_temps); # Save temporary outputs? 22 my ($clusters_raw, $clusters_ds9, $streaks_ds9); # Output modes 21 23 22 24 GetOptions( … … 26 28 'dbpass=s' => \$db_pw, # Database p/w 27 29 'label=s' => \$label, # Label of interest 30 'exp_id=s' => \$exp_id, # Exposure identifier of interest 28 31 'data_group=s' => \$group, # Data group 32 'clusters-raw' => \$clusters_raw, # Output raw x,y for clusters? 33 'clusters-ds9' => \$clusters_ds9, # Output ds9 region files of clusters? 34 'streaks-ds9' => \$streaks_ds9, # Output ds9 region files of streaks? 29 35 'verbose' => \$verbose, # Verbosity? 30 36 'save-temps' => \$save_temps, # Save temporary outputs? … … 48 54 49 55 # Exposures of interest 50 my $sql = "SELECT DISTINCT exp_id, exp_name, magic_id, magicRun.workdir AS magic_path, camProcessedExp.path_base AS cam_path FROM magicRun JOIN rawExp USING(exp_id) JOIN diffRun USING(diff_id) JOIN diffInputSkyfile USING(diff_id) JOIN warpRun ON warpRun.warp_id = diffInputSkyfile.warp1 JOIN fakeRun USING(fake_id) JOIN camProcessedExp USING(cam_id) WHERE magicRun.label = '$label' AND magicRun.state = 'full'"; 56 my $sql = "SELECT DISTINCT exp_id, exp_name, magic_id, magicRun.workdir AS magic_path, camProcessedExp.path_base AS cam_path FROM magicRun JOIN rawExp USING(exp_id) JOIN diffRun USING(diff_id) JOIN diffInputSkyfile USING(diff_id) JOIN warpRun ON warpRun.warp_id = diffInputSkyfile.warp1 JOIN fakeRun USING(fake_id) JOIN camProcessedExp USING(cam_id) WHERE magicRun.state = 'full'"; 57 $sql .= " AND magicRun.label = '$label'" if defined $label; 58 $sql .= " AND magicRun.exp_id = ${exp_id}" if defined $exp_id; 51 59 $sql .= " AND magicRun.data_group = '$group'" if defined $group; 52 60 my $exps = $db->selectall_arrayref($sql, { Slice => {} }) or die "Unable to execute SQL: $DBI::errstr"; … … 63 71 my $clusters = "${magic_path}/$id/$id.mgc.$magic.verify/${id}_clusterPos.txt"; # File with cluster RA,Dec 64 72 die "Cannot find clusters file $clusters" unless $ipprc->file_exists($clusters); 73 74 my $streaks = "${magic_path}/$id/$id.mgc.$magic.root.streaks"; # File with streaks 75 die "Cannot find streaks file $streaks" unless $ipprc->file_exists($streaks); 65 76 66 77 my $astrom = "${cam_path}.smf"; # Astrometry file … … 81 92 close $radecFile; 82 93 83 my $raws = $db->selectcol_arrayref("SELECT uri FROM rawImfile where exp_id = $id") or 84 die "Unable to execute SQL: $DBI::errstr"; 94 my $chips = $db->selectall_arrayref("SELECT class_id, uri FROM rawImfile where exp_id = $id", 95 { Slice => {} } 96 ) or die "Unable to execute SQL: $DBI::errstr"; 85 97 86 open my $outFile, "> $label.${name}.clusters.xy" or die "Cannot open output file: $!"; 87 foreach my $raw (@$raws) { 88 # my $resolved = `neb-locate --path $raw`; # Resolved filename 89 # chomp $resolved; 90 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 91 run(command => "$ppCoord -astrom $astrom -raw $raw -radec $radecName", verbose => $verbose); 92 die "Unable to run ppCoord" unless $success; 98 open my $outFile, "> $label.${name}.clusters.xy" or die "Cannot open output file: $!" if defined $clusters_raw; 99 foreach my $chip (@$chips) { 100 my $class = $chip->{class_id}; 101 my $uri = $chip->{uri}; 93 102 94 my @lines = split(/\n/, join("", @$stdout_buf)); 95 foreach my $line (@lines) { 96 my @line = split /\s+/, $line; 103 if (defined $clusters_raw) { 104 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 105 run(command => "$ppCoord -astrom $astrom -raw $uri -radec $radecName", verbose => $verbose); 106 die "Unable to run ppCoord" unless $success; 97 107 98 my $ra = $line[0]; 99 my $dec = $line[1]; 100 my $x = $line[3]; 101 my $y = $line[4]; 102 my $chip = $line[5]; 103 my $cell = $line[6]; 108 my @lines = split(/\n/, join("", @$stdout_buf)); 109 foreach my $line (@lines) { 110 my @line = split /\s+/, $line; 104 111 105 print $outFile "$chip $cell $x $y $ra $dec\n"; 112 my $ra = $line[0]; 113 my $dec = $line[1]; 114 my $x = $line[3]; 115 my $y = $line[4]; 116 my $chipName = $line[5]; 117 my $cellName = $line[6]; 118 119 print $outFile "$chipName $cellName $x $y $ra $dec\n"; 120 } 106 121 } 122 123 if (defined $clusters_ds9) { 124 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 125 run(command => "$ppCoord -astrom $astrom -radec $radecName -chip $class -ds9 $label.$name.clusters.$class.ds9 -ds9-color blue", 126 verbose => $verbose); 127 die "Unable to run ppCoord" unless $success; 128 } 129 130 if (defined $streaks_ds9) { 131 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 132 run(command => "$ppCoord -astrom $astrom -streaks $streaks -chip $class -ds9 $label.$name.streaks.$class.ds9 -ds9-color red", 133 verbose => $verbose); 134 die "Unable to run ppCoord" unless $success; 135 } 136 107 137 } 108 close $outFile ;138 close $outFile if defined $clusters_raw; 109 139 }
Note:
See TracChangeset
for help on using the changeset viewer.
