Changeset 27619
- Timestamp:
- Apr 6, 2010, 12:23:59 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/tools/microtest.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/microtest.pl
r27612 r27619 20 20 my ($verbose); # Verbosity? 21 21 my ($save_temps); # Save temporary outputs? 22 my ($clusters_raw, $clusters_ds9, $streaks_ ds9); # Output modes22 my ($clusters_raw, $clusters_ds9, $streaks_raw, $streaks_ds9); # Output modes 23 23 24 24 GetOptions( … … 32 32 'clusters-raw' => \$clusters_raw, # Output raw x,y for clusters? 33 33 'clusters-ds9' => \$clusters_ds9, # Output ds9 region files of clusters? 34 'streaks-raw' => \$streaks_raw, # Output raw x,y for streaks? 34 35 'streaks-ds9' => \$streaks_ds9, # Output ds9 region files of streaks? 35 36 'verbose' => \$verbose, # Verbosity? … … 79 80 80 81 # Format the clusters file 81 open my $clusters File, "$clusters" or die "Cannot open clusters file $clusters: $!";82 open my $clustersInput, "$clusters" or die "Cannot open clusters file $clusters: $!"; 82 83 my ($radecFile, $radecName) = tempfile( "/tmp/microtest.XXXX", 83 84 UNLINK => !$save_temps, SUFFIX => '.dat' ); 84 my @contents = <$clusters File>; # Contents of clusters file85 my @contents = <$clustersInput>; # Contents of clusters file 85 86 foreach my $line (@contents) { 86 87 $line =~ s/^\s*//; … … 89 90 defined $ra and defined $dec and $ra !~ /[[:alpha:]]/ and $dec !~ /[[:alpha:]]/; 90 91 } 91 close $clusters File;92 close $clustersInput; 92 93 close $radecFile; 93 94 … … 96 97 ) or die "Unable to execute SQL: $DBI::errstr"; 97 98 98 open my $outFile, "> $label.${name}.clusters.xy" or die "Cannot open output file: $!" if defined $clusters_raw; 99 open my $clustersFile, "> $label.${name}.clusters.xy" or die "Cannot open output file: $!" if defined $clusters_raw; 100 print $clustersFile "# chip cell x y ra dec\n" if defined $clusters_raw; 101 my (@streak1, @streak2, $num_streaks); 102 if (defined $streaks_raw) { 103 $num_streaks = `head -n 1 $streaks`; 104 chomp $num_streaks; 105 } 99 106 foreach my $chip (@$chips) { 100 107 my $class = $chip->{class_id}; … … 117 124 my $cellName = $line[6]; 118 125 119 print $ outFile "$chipName $cellName $x $y $ra $dec\n";126 print $clustersFile "$chipName $cellName $x $y $ra $dec\n"; 120 127 } 121 128 } 129 130 if (defined $streaks_raw) { 131 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 132 run(command => "$ppCoord -astrom $astrom -raw $uri -streaks $streaks -all -radians", 133 verbose => $verbose); 134 die "Unable to run ppCoord" unless $success; 135 136 my @lines = split(/\n/, join("", @$stdout_buf)); 137 my $index = 0; 138 foreach my $line (@lines) { 139 my @line = split /\s+/, $line; 140 141 my $ra1 = $line[0]; 142 my $dec1 = $line[1]; 143 my $ra2 = $line[2]; 144 my $dec2 = $line[3]; 145 my $x1 = $line[5]; 146 my $y1 = $line[6]; 147 my $chipName1 = $line[7]; 148 my $cellName1 = $line[8]; 149 my $x2 = $line[9]; 150 my $y2 = $line[10]; 151 my $chipName2 = $line[11]; 152 my $cellName2 = $line[12]; 153 154 if ($x1 ne "nan" and $y1 ne "nan") { 155 my $streak = $streak1[$index]; 156 unless (defined $streak) { 157 $streak = { 'ra' => $ra1, 158 'dec' => $dec1, 159 'x' => $x1, 160 'y' => $y1, 161 'chip' => $chipName1, 162 'cell' => $cellName1 163 }; 164 $streak1[$index] = $streak; 165 } 166 } 167 if ($x2 ne "nan" and $y2 ne "nan") { 168 my $streak = $streak2[$index]; 169 unless (defined $streak) { 170 $streak = { 'ra' => $ra2, 171 'dec' => $dec2, 172 'x' => $x2, 173 'y' => $y2, 174 'chip' => $chipName2, 175 'cell' => $cellName2 176 }; 177 $streak2[$index] = $streak; 178 } 179 } 180 $index++; 181 } 182 } 183 122 184 123 185 if (defined $clusters_ds9) { … … 136 198 137 199 } 138 close $outFile if defined $clusters_raw; 200 close $clustersFile if defined $clusters_raw; 201 202 if (defined $streaks_raw) { 203 open my $streaksFile, "> $label.${name}.streaks.xy" or die "Cannot open output file: $!"; 204 print $streaksFile "# chip1 cell1 x1 y1 chip2 cell2 x2 y2 ra1 dec1 ra2 dec2\n"; 205 for (my $i = 0; $i < $num_streaks; $i++) { 206 my $s1 = $streak1[$i]; 207 my $s2 = $streak2[$i]; 208 209 my $ra1 = $s1->{ra}; 210 my $dec1 = $s1->{dec}; 211 my $ra2 = $s2->{ra}; 212 my $dec2 = $s2->{dec}; 213 my $x1 = $s1->{x}; 214 my $y1 = $s1->{y}; 215 my $chipName1 = $s1->{chip}; 216 my $cellName1 = $s1->{cell}; 217 my $x2 = $s2->{x}; 218 my $y2 = $s2->{y}; 219 my $chipName2 = $s2->{chip}; 220 my $cellName2 = $s2->{cell}; 221 222 if (defined $ra1 and defined $dec1 and defined $ra2 and defined $dec2 and 223 defined $x1 and defined $y1 and defined $chipName1 and defined $cellName1 and 224 defined $x2 and defined $y2 and defined $chipName2 and defined $cellName2) { 225 print $streaksFile "$chipName1 $cellName1 $x1 $y1 $chipName2 $cellName2 $x2 $y2 $ra1 $dec1 $ra2 $dec2\n"; 226 } else { 227 print $streaksFile "UNKNOWN UNKNOWN nan nan UNKNOWN UNKNOWN nan nan nan nan nan nan\n"; 228 } 229 } 230 close $streaksFile; 231 232 } 233 139 234 }
Note:
See TracChangeset
for help on using the changeset viewer.
