Changeset 39012 for trunk/tools
- Timestamp:
- Oct 30, 2015, 8:50:00 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/tools/bills/comparestackdetections (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/bills/comparestackdetections
r39006 r39012 68 68 } 69 69 70 # 71 my @joined; 70 71 my $outfile; 72 my $input = $in; 72 73 for (my $i=1; $i<=5; $i++) { 73 74 my $cmf = $cmfs[$i]; … … 84 85 85 86 my $stackColumn = $filter . "stackImageID"; 86 my $idColumn = $filter . "ippDetectID"; 87 my $outfile = $filter . "_matched" . basename($cmf); 88 $command = "$stilts tmatch2 in1=$in'#StackObjectAttributes' in2=$ippjoined matcher=2d out=$outfile ofmt=fits" 87 my $idColumn = $filter . "ippDetectID"; 88 $outfile = $filter . "_matched" . basename($cmf); 89 90 $command = "$stilts tmatch2 in1=$input'#StackObjectAttributes' in2=$ippjoined matcher=2d out=$outfile ofmt=fits" 89 91 . " values1='$stackColumn $idColumn' values2='STACK_ID IPP_IDET' params=.01 join=$joinType" 90 92 . " fixcols=all suffix1='' suffix2=_$filter ocmd='tablename StackObjectAttributes'"; 91 $in = $outfile;92 93 runcommand($command); 93 } 94 95 if (!$save_temps) { 96 unlink $ippjoined; 97 if ($input ne $in) { 98 unlink $input; 99 } 100 } 101 # input for next round of matches is the output from this one 102 $input = $outfile; 103 } 104 105 my $list = getStackColumns(); 106 my $cmd = "'"; 107 # add x_zpFactor columns 108 for (my $i = 1; $i<=5; $i++) { 109 next if $cmfs[$i] eq 'none'; 110 my $filter = $filters[$i]; 111 my $zp = $filter . "zp"; 112 $cmd .= "addcol -after $zp ${filter}zpFactor 3630.78*pow(10,-0.4*$zp);"; 113 } 114 foreach my $line (@$list) { 115 my ($col, $ipp, $conversion) = split ' ', $line; 116 next if !$ipp; 117 $conversion = "" unless $conversion; 118 my $equation = "$ipp$conversion"; 119 $equation = "$col-$equation"; 120 my $dcol = "d_$col"; 121 $cmd .= "addcol -after $col $dcol $equation;"; 122 } 123 $cmd .= "'"; 124 125 $command = "$stilts tpipe in=$outfile out=$out cmd=$cmd"; 126 127 runcommand($command); 128 unlink($outfile) unless $save_temps; 94 129 95 130 exit 0; 96 97 my $matched = "m." . basename($out);98 99 # $commmand = "$stilts tmatch2 fixcols=dups suffix1=100 my $ippjoined;101 runcommand("matchIppToPsps $in $ippjoined $matched");102 103 if (!$save_temps) {104 unlink $ippjoined;105 }106 107 # runcommand("adddeltacolumns $matched $out");108 109 exit 0;110 111 131 112 132 sub runcommand { … … 119 139 } 120 140 } 141 142 # list of columns from stackObjectAttributes table 143 sub getStackColumns { 144 my $filters = shift; 145 my $cmfs = shift; 146 147 # format of the list is "psps column" "ipp column" "equation to convert ipp value to psps value" 148 # If equation is blank the psps column is the same as the ipp column 149 # columns which begin in x_ have a different value for each of the 5 filters 150 # similarly ipp columns that end in _x have the name col_$filter 151 152 my $list = <<END_OF_LIST; 153 # Note x_zpFactor = 3630.78*pow(10, -0.4*x_zp) 154 155 objID 156 uniquePspsSTid 157 ippObjID 158 randomStackObjID 159 stackDetectRowID 160 primaryDetection 161 bestDetection 162 163 x_ippDetectID IPP_IDET 164 x_stackDetectID 165 x_stackImageID STACK_ID 166 x_xPos X_PSF 167 x_yPos Y_PSF 168 x_xPosErr X_PSF_SIG 169 x_yPosErr Y_PSF_SIG 170 x_psfMajorFWHM PSF_FWHM_MAJ *abs(PLTSCALE_x) 171 x_psfMinorFWHM PSF_FWHM_MIN *abs(PLTSCALE_x) 172 x_psfTheta PSF_THETA 173 x_psfCore PSF_CORE 174 x_psfLikelihood # actually psfLikelihood(EXT_NSIGMA). We assume the formula is ok. 175 x_psfQf PSF_QF 176 x_psfQfPerfect PSF_QF_PERFECT 177 x_psfChiSq PSF_CHISQ 178 x_momentXX MOMENTS_XX *PLTSCALE_x*PLTSCALE_x 179 x_momentXY MOMENTS_XY *PLTSCALE_x*PLTSCALE_x 180 x_momentYY MOMENTS_YY *PLTSCALE_x*PLTSCALE_x 181 x_momentR1 MOMENTS_R1 *abs(PLTSCALE_x) 182 x_momentRH MOMENTS_RH *sqrt(abs(PLTSCALE_x)) 183 184 x_psfFlux PSF_INST_FLUX *x_zpFactor/x_expTime 185 x_psfFluxErr PSF_INST_FLUX_SIG *x_zpFactor/x_expTime 186 187 x_apFlux AP_FLUX *x_zpFactor/x_expTime 188 x_apFluxErr AP_FLUX_SIG *x_zpFactor/x_expTime 189 x_apFillFac AP_NPIX /(3.14159265359*pow(AP_MAG_RADIUS_x-0.5,2)) 190 x_apRadius AP_MAG_RADIUS *abs(PLTSCALE_x) 191 x_KronFlux KRON_FLUX *x_zpFactor/x_expTime 192 x_KronFluxErr KRON_FLUX_ERR *x_zpFactor/x_expTime 193 x_KronRad MOMENTS_R1 *2.5*abs(PLTSCALE_x) 194 x_expTime 195 x_ExtNSigma EXT_NSIGMA 196 x_sky SKY /PLTSCALE_x/PLTSCALE_x*x_zpFactor/x_expTime 197 x_skyErr SKY_SIGMA /PLTSCALE_x/PLTSCALE_x*x_zpFactor/x_expTime 198 x_zp 199 x_PlateScale PLTSCALE 200 END_OF_LIST 201 202 my @lines = split "\n", $list; 203 204 my @output; 205 foreach my $l (@lines) { 206 # skip comment lines and empty lines 207 next if $l =~ '^#'; 208 next if !$l; 209 # strip off trailing comment 210 my ($data, $comment) = split '#', $l; 211 my ($column, $ippColumn, $equation) = split " ", $data; 212 213 $ippColumn = "" unless $ippColumn; 214 $equation = "" unless $equation; 215 if ($column =~ '^x_') { 216 for (my $i=1; $i<=5; $i++) { 217 my $c = $cmfs[$i]; 218 next if $c eq 'none'; 219 my $f = $filters[$i]; 220 my $newCol = $f . substr($column, 2); 221 my $newIpp = ""; 222 if ($ippColumn) { 223 $newIpp = $ippColumn . "_$f"; 224 } 225 my $newEquation = $equation; 226 $newEquation =~ s/_x/_$f/g; 227 $newEquation =~ s/x_/$f/g; 228 my $newline = sprintf "%s\t%s\t%s", $newCol, $newIpp, $newEquation; 229 # print "$newline\n"; 230 push @output, $newline; 231 } 232 } else { 233 # print "$l\n"; 234 push @output, $l; 235 } 236 237 } 238 239 return \@output; 240 } 241
Note:
See TracChangeset
for help on using the changeset viewer.
