Changeset 39055
- Timestamp:
- Nov 6, 2015, 10:03:51 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/tools/bills/comparestackdetections (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/bills/comparestackdetections
r39014 r39055 7 7 use Pod::Usage qw( pod2usage ); 8 8 use File::Basename; 9 9 use File::Temp qw( tempdir tempfile ); 10 use PS::IPP::Config 1.01 qw( :standard ); 10 11 11 12 my $joinType = '1and2'; … … 21 22 my $testdata; 22 23 23 my ($verbose, $save_temps); 24 my ($checkdeltas, $verbose, $save_temps); 25 26 my $label = 'SAS.20141118.sc8'; 24 27 25 28 GetOptions( 29 "label=s" => \$label, 26 30 "testdata=s" => \$testdata, 27 31 "join=s" => \$joinType, 32 "check" => \$checkdeltas, 28 33 "verbose|v" => \$verbose, 29 34 "save-temps" => \$save_temps, 30 35 ) or pod2usage( 2 ); 31 36 32 die "usage: $0 <stack batch file> <out> [--testdata <location of testdata directory]\n" unless (scalar @ARGV == 2);37 die "usage: $0 <stack batch file> <out> --label <skycal label> | --testdata <location of testdata directory\n" unless (scalar @ARGV == 2); 33 38 34 39 $in = shift; … … 53 58 54 59 my @cmfs; 55 if ($testdata) {56 for (my $i=1; $i<=5; $i++) {57 my $stack_id = $stackIDs[$i];58 my $cmf = 'none';59 if ($ stack_id > 0) {60 for (my $i=1; $i<=5; $i++) { 61 my $stack_id = $stackIDs[$i]; 62 my $cmf = 'none'; 63 if ($stack_id > 0) { 64 if ($testdata) { 60 65 $cmf = sprintf "%s/stack.%02d.cmf", $testdata, $stack_id; 66 } else { 67 my $path_base = `staticskytool -skycalresult -label $label -stack_id $stack_id | grep path_base | awk '{print \$3}'`; 68 chomp $path_base; 69 die "failed to find skycal result for $stack_id $label\n" unless $path_base; 70 $cmf = $path_base . ".cmf"; 61 71 } 62 $cmfs[$i] = $cmf; 63 print "$filters[$i] $stack_id $cmf\n" if $verbose; 64 } 65 } else { 66 # XXX: look up the cmf for this stack here 67 die "this program only works in test mode right now\n"; 68 } 69 72 } 73 $cmfs[$i] = $cmf; 74 print "$filters[$i] $stack_id $cmf\n" if $verbose; 75 } 70 76 71 77 my $outfile; … … 75 81 next if $cmf eq 'none'; 76 82 83 my $base = basename($cmf); 84 77 85 my $filter = $filters[$i]; 78 my $ippjoined = $filter . "_joined" . basename($cmf);86 my $ippjoined = $filter . "_joined" . $base; 79 87 80 88 $command = "joinstackcmf $cmf $ippjoined"; 81 89 $command .= " --ofmt fits"; 82 90 $command .= " --test" if $testdata; 91 $command .= " --verbose" if $verbose; 83 92 84 93 runcommand($command); … … 86 95 my $stackColumn = $filter . "stackImageID"; 87 96 my $idColumn = $filter . "ippDetectID"; 88 $outfile = $filter . "_matched" . basename($cmf);97 $outfile = $filter . "_matched" . $base; 89 98 90 99 $command = "$stilts tmatch2 in1=$input'#StackObjectAttributes' in2=$ippjoined matcher=2d out=$outfile ofmt=fits" … … 104 113 } 105 114 115 my @deltas; 106 116 my $list = getStackColumns(); 107 117 my $cmd = "'"; … … 121 131 my $dcol = "d_$col"; 122 132 $cmd .= "addcol -after $col $dcol $equation;"; 133 push @deltas, $dcol; 123 134 } 124 135 $cmd .= "'"; … … 128 139 runcommand($command); 129 140 unlink($outfile) unless $save_temps; 141 142 if ($checkdeltas) { 143 $save_temps = 1; 144 my ($manafile, $mananame) = tempfile( "/var/tmp/manacmds.XXXX", UNLINK => !$save_temps); 145 print "$mananame\n" if $save_temps; 146 print $manafile (<<HERE); 147 \$limit = 1e-9 148 output /dev/null 149 macro checkdelta 150 \$col = \$1 151 \$thislimit = \$limit 152 subset good = \$col where \$col != -999 153 \$length = good[] 154 for i 0 10 155 subset d = good where abs(good) > \$thislimit 156 \$noutliers = d[] 157 if (\$noutliers > 0) 158 echo \$col has \$noutliers out of \$length with difference > \$thislimit 159 \$thislimit = \$thislimit * 10 160 else 161 return 162 end 163 end 164 end 165 HERE 166 167 print $manafile "\nmacro dotests\n"; 168 foreach my $col (@deltas) { 169 print $manafile " checkdelta $col\n"; 170 } 171 print $manafile "end\n"; 172 173 print $manafile "datafile $out\n"; 174 print $manafile "read -fits StackObjectAttributes"; 175 foreach my $col (@deltas) { 176 print $manafile " $col"; 177 } 178 print $manafile "\n"; 179 180 181 print $manafile "output stdout\n"; 182 print $manafile "dotests\n"; 183 close $manafile; 184 185 system "echo input $mananame | mana"; 186 } 130 187 131 188 exit 0; … … 188 245 x_apFlux AP_FLUX *x_zpFactor/x_expTime 189 246 x_apFluxErr AP_FLUX_SIG *x_zpFactor/x_expTime 190 x_apFillFac AP_NPIX /(3.14159265359* pow(AP_MAG_RADIUS_x-0.5,2))247 x_apFillFac AP_NPIX /(3.14159265359*AP_MAG_RADIUS_x*AP_MAG_RADIUS_x) 191 248 x_apRadius AP_MAG_RADIUS *abs(PLTSCALE_x) 192 249 x_KronFlux KRON_FLUX *x_zpFactor/x_expTime
Note:
See TracChangeset
for help on using the changeset viewer.
