Changeset 41716
- Timestamp:
- Jul 13, 2021, 10:31:53 AM (5 years ago)
- Location:
- trunk/tools/eam/teleff
- Files:
-
- 2 edited
-
cammask.pro (modified) (8 diffs)
-
camstats.sh (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/eam/teleff/cammask.pro
r41712 r41716 8 8 if (not($?MATCH_RADIUS)) set MATCH_RADIUS = 2.0 9 9 10 macro get.camera.matches 11 if ($0 != 5) 12 echo "USAGE: get.camera.matches (smfreal) (refsrcs.fits) (outroot) (outversion)" 13 break 14 end 15 16 local i refsrcs 17 $smfreal = $1 18 $refsrcs = $2 19 $outroot = $3 20 $OUTVERSION = $4 21 22 dirname $outroot -var OUTDIR 23 mkdir $OUTDIR 24 25 # load the reference source table 26 # NOTE: Mref is chosen to match filter for this exposure 27 data $refsrcs; read -fits DATA Rref Dref Mref 28 set Nref = ramp(Rref) 29 30 # read in the PHU header 31 rd PHU $smfreal 32 33 # create the chipName list from the smffile and calculate the index numbers 34 list chipsRaw -x "ftable -list $smfreal | grep -n hdr | prcol 1 | sed s/.hdr//" 35 for i 0 $chipsRaw:n 36 list word -splitbychar : $chipsRaw:$i 37 $chipNseq:$i = $word:0 - 3 38 $chipName:$i = $word:1 39 end 40 $chipName:n = $chipsRaw:n 41 $chipNseq:n = $chipsRaw:n 42 43 # find matching entries in smf file 44 for i 0 $chipName:n 45 echo $chipName:$i 46 get.chip.detect.stats $chipName:$i $chipNseq:$i 47 # if we do not have masks, we have not measured Q1refSS, just set to 1.0 48 set Q1refSS = zero(RrefSS) + 1.0 49 50 sprintf output "%s.%s.%s.cam.stf" $outroot $chipName:$i $OUTVERSION 51 write -fits DATA $output RrefSS DrefSS MrefSS XrefSS YrefSS Q1refSS X_PSF_found Y_PSF_found M_PSF_found RA_PSF_found DEC_PSF_found Q1_PSF_found Q2_PSF_found 52 end 53 end 10 $SMF_FIELDS = X_PSF Y_PSF RA_PSF DEC_PSF CAL_PSF_MAG PSF_QF PSF_QF_PERFECT 11 $REF_FIELDS = Rref Dref Mref 12 $XTR_FIELDS = Xref Yref Nref Q1ref 54 13 55 14 macro get.camera.eff … … 87 46 # load the reference source table 88 47 # NOTE: Mref is chosen to match filter for this exposure 89 data $refsrcs; read -fits DATA Rref Dref Mref48 data $refsrcs; read -fits DATA $REF_FIELDS 90 49 set Nref = ramp(Rref) 91 50 … … 93 52 rd PHU $smfreal 94 53 95 # create the chipName list from the smffile and calculate the index numbers 96 # if a chip is missing from the smf, this may be inconsistent with chipMask:n 54 # create the chipName list from the smffile and calculate the index numbers. 55 # NOTE: if a chip is missing from the smf, this may be inconsistent with chipMask:n 56 # XXX for now, we fail is this happens 97 57 list chipsRaw -x "ftable -list $smfreal | grep -n hdr | prcol 1 | sed s/.hdr//" 98 58 for i 0 $chipsRaw:n 99 59 list word -splitbychar : $chipsRaw:$i 100 60 $chipNseq:$i = $word:0 - 3; # this number depends on the number of leading tables 101 $chipName:$i = $word:1 61 if ("$chipName:$i" != "$word:1") 62 echo "ERROR: missing chip from smffile: " $chipName:$i 63 break 64 end 102 65 end 103 66 … … 107 70 get.chip.mask.stats $camMask:$i 108 71 109 sprintf output "%s/%s.%s.%s.cam.stf" $OUTDIR $expname $chipName:$i $OUTVERSION 110 write -fits DATA $output RrefSS DrefSS MrefSS XrefSS YrefSS Q1refSS X_PSF_found Y_PSF_found M_PSF_found Q1_PSF_found Q2_PSF_found 111 end 112 end 113 114 macro get.chip.mask.stats 115 if ($0 != 2) 116 echo "USAGE: get.chip.mask.stats (cammask)" 117 echo " assumes existence of $smfreal vectors (Rref, Dref, Mref) and buffer (PHU)" 118 break 119 end 120 121 local cammask camreal 122 $cammask = $1 123 124 $camreal = `neb-locate -p $cammask` 125 rd -x 0 mk $camreal 126 127 # I have a mask file, now I need to calculate something equiv to psfQf 128 set mkPerfect = (mk == 0) ? zero(mk) + 1 : zero(mk) 129 130 # I want to set an image based on the bit values but I fear 131 # the mask has been converted to a float when read 132 forcedphot mkPerfect XrefSS YrefSS -output Q1refSS 133 134 subset tmp = Q1refSS where (Q1refSS > 0.85) 135 136 echo tmp[] of Q1refSS[] are unmasked 137 end 72 foreach field SMF_FIELDS 73 concat $field\_found $field\_out 74 delete $field\_found 75 end 76 foreach field REF_FIELDS $XTR_FIELDS 77 concat $field\_onchp $field\_out 78 delete $field\_onchp 79 end 80 end 81 82 $OUT_FIELDS = 83 foreach field $SMP_FIELDS $REF_FIELDS $XTR_FIELDS 84 $OUT_FIELDS = $OUT_FIELDS $field\_out 85 end 86 87 sprintf output "%s/%s.%s.%s.cam.stf" $OUTDIR $expname $chipName:$i $OUTVERSION 88 write -fits DATA $output $OUT_FIELDS 89 end 90 91 # We can read the data by EXTNAME or sequence number. Reading by 92 # EXTNAME is more robust against format changes but slow 93 $USE_EXTNAME = 0 138 94 139 95 macro get.chip.detect.stats … … 147 103 end 148 104 149 local chipname chipnseq 105 local chipname chipnseq field NAXIS1 NAXIS2 150 106 $chipname = $1 151 107 $chipnseq = $2 … … 153 109 # read in the CHIP header 154 110 155 # sprintf extname "%s.hdr" $chipname 156 # rd -n $extname hdr $smfreal 157 158 rd -x $chipnseq hdr $smfreal 111 if ($USE_EXTNAME) 112 sprintf extname "%s.hdr" $chipname 113 rd -n $extname hdr $smfreal 114 else 115 rd -x $chipnseq hdr $smfreal 116 end 159 117 160 118 keyword hdr NAXIS1 NAXIS1 … … 169 127 # do we need to grow the range at all? 170 128 set keep = (Rref >= $minR) && (Rref <= $maxR) && (Dref >= $minD) && (Dref <= $maxD) 171 subset RrefS = Rref if keep172 subset DrefS = Drefif keep173 subset MrefS = Mref if keep129 foreach field $REF_FIELDS Nref 130 subset $field\_tmp = $field if keep 131 end 174 132 175 133 # convert the subset coordinates to pixels 176 set Xref S = RrefS177 set Yref S = DrefS178 coords -q hdr -mosaic PHU -c Xref S YrefS134 set Xref_tmp = Rref_tmp 135 set Yref_tmp = Dref_tmp 136 coords -q hdr -mosaic PHU -c Xref_tmp Yref_tmp 179 137 180 138 # generate a subset of sources which are within the boundaries of the chip 181 set keep = (XrefS >= 0) && (XrefS <= $NAXIS1) && (YrefS >= 0) && (YrefS <= $NAXIS2) 182 subset XrefSS = XrefS if keep 183 subset YrefSS = YrefS if keep 184 subset RrefSS = RrefS if keep 185 subset DrefSS = DrefS if keep 186 subset MrefSS = MrefS if keep 139 set keep = (Xref_tmp >= 0) && (Xref_tmp <= $NAXIS1) && (Yref_tmp >= 0) && (Yref_tmp <= $NAXIS2) 140 foreach field $REF_FIELDS Nref Xref Yref 141 subset $field\_onchp = $field\_tmp if keep 142 delete $field\_tmp 143 end 187 144 188 145 # now read the smf detections 189 146 data $smfreal 190 #sprintf extname "%s.psf" $chipname 191 #read -fits $extname X_PSF Y_PSF RA_PSF DEC_PSF CAL_PSF_MAG PSF_QF PSF_QF_PERFECT 192 193 read -fits {$chipnseq+1} -extnum X_PSF Y_PSF RA_PSF DEC_PSF CAL_PSF_MAG PSF_QF PSF_QF_PERFECT 194 195 ## XXX note this is not very efficient because libfits needs to loop over all extensions 196 ## each time until it finds the one it wants (would be better to generate an index and 197 ## use -fits NN -extnum 147 148 if ($USE_EXTNAME) 149 sprintf extname "%s.psf" $chipname 150 read -fits $extname $SMF_FIELDS 151 else 152 read -fits {$chipnseq+1} -extnum $SMF_FIELDS 153 end 198 154 199 155 # match radius currently needs to be larger for MPC objects 200 match2d XrefSS YrefSS X_PSF Y_PSF $MATCH_RADIUS -closest 201 202 reindex X_PSF_found = X_PSF using index1 -keep-unmatched 203 reindex Y_PSF_found = Y_PSF using index1 -keep-unmatched 204 reindex M_PSF_found = CAL_PSF_MAG using index1 -keep-unmatched 205 reindex Q1_PSF_found = PSF_QF using index1 -keep-unmatched 206 reindex Q2_PSF_found = PSF_QF_PERFECT using index1 -keep-unmatched 207 reindex RA_PSF_found = RA_PSF using index1 -keep-unmatched 208 reindex DEC_PSF_found = DEC_PSF using index1 -keep-unmatched 209 210 # set dX = XrefSS - X_PSF_found; subset dXs = dX where (MrefSS < 18); vstat -q dXs 211 # set dY = YrefSS - Y_PSF_found; subset dYs = dY where (MrefSS < 18); vstat -q dYs 212 # set dM = MrefSS - M_PSF_found; subset dMs = dM where (MrefSS < 18); vstat -q dMs 213 214 # measure some stats, eg: 215 # * fraction detected vs mag, filter by PSF_QF, PSF_QF_PERFECT 216 end 217 156 match2d Xref_onchp Yref_onchp X_PSF Y_PSF $MATCH_RADIUS -closest 157 foreach field $SMF_FIELDS 158 reindex $field\_found = $field using index1 -keep-unmatched 159 end 160 end 161 162 macro get.chip.mask.stats 163 if ($0 != 2) 164 echo "USAGE: get.chip.mask.stats (cammask)" 165 echo " assumes existence of source chip positions (Xref_onchp, Yref_onchp)" 166 break 167 end 168 169 local cammask camreal 170 $cammask = $1 171 172 $camreal = `neb-locate -p $cammask` 173 rd -x 0 mk $camreal 174 175 # I have a mask file, now I need to calculate something equiv to psfQf 176 set mkPerfect = (mk == 0) ? zero(mk) + 1 : zero(mk) 177 178 # I want to set an image based on the bit values but I fear 179 # the mask has been converted to a float when read 180 forcedphot mkPerfect Xref_onchp Yref_onchp -output Q1ref_onchp 181 end 182 183 ### utilities 218 184 macro init.radec.range 219 185 $minR = $RA … … 341 307 book delete mybook 342 308 end 309 310 311 #### 312 313 macro get.camera.matches 314 if ($0 != 5) 315 echo "USAGE: get.camera.matches (smfreal) (refsrcs.fits) (outroot) (outversion)" 316 break 317 end 318 319 local i refsrcs 320 $smfreal = $1 321 $refsrcs = $2 322 $outroot = $3 323 $OUTVERSION = $4 324 325 dirname $outroot -var OUTDIR 326 mkdir $OUTDIR 327 328 # load the reference source table 329 # NOTE: Mref is chosen to match filter for this exposure 330 data $refsrcs; read -fits DATA $REF_FIELDS 331 set Nref = ramp(Rref) 332 333 # read in the PHU header 334 rd PHU $smfreal 335 336 # create the chipName list from the smffile and calculate the index numbers 337 list chipsRaw -x "ftable -list $smfreal | grep -n hdr | prcol 1 | sed s/.hdr//" 338 for i 0 $chipsRaw:n 339 list word -splitbychar : $chipsRaw:$i 340 $chipNseq:$i = $word:0 - 3 341 $chipName:$i = $word:1 342 end 343 $chipName:n = $chipsRaw:n 344 $chipNseq:n = $chipsRaw:n 345 346 # find matching entries in smf file 347 for i 0 $chipName:n 348 echo $chipName:$i 349 get.chip.detect.stats $chipName:$i $chipNseq:$i 350 # if we do not have masks, we have not measured Q1refSS, just set to 1.0 351 set Q1ref_onchp = zero(Rref_onchp) + 1.0 352 353 end 354 355 $REF_FIELDS_OUT = $REF_FIELDS Xref Yref Q1ref 356 357 sprintf output "%s.%s.%s.cam.stf" $outroot $chipName:$i $OUTVERSION 358 write -fits DATA $output RrefSS DrefSS MrefSS XrefSS YrefSS Q1refSS X_PSF_found Y_PSF_found M_PSF_found RA_PSF_found DEC_PSF_found Q1_PSF_found Q2_PSF_found 359 360 end 361 -
trunk/tools/eam/teleff/camstats.sh
r41712 r41716 1 2 macro test.mpcfine3 if ($0 != 2)4 echo "USAGE: test.mpcfine (file)"5 break6 end7 8 data $19 read Rr 1 Dr 2 Rc 4 Dc 5 Rp 7 Dp 8 Ra 10 Da 11 Rd 13 Dd 1410 set dRc = 3600*(Rc - Rr)*dcos(Dr)11 set dDc = 3600*(Dc - Dr)12 set dRp = 3600*(Rp - Rc)*dcos(Dr)13 set dDp = 3600*(Dp - Dc)14 set dRa = 3600*(Ra - Rp)*dcos(Dr)15 set dDa = 3600*(Da - Dp)16 set dRd = 3600*(Rd - Ra)*dcos(Dr)17 set dDd = 3600*(Dd - Da)18 19 vstat dRc20 vstat dRp21 vstat dRa22 vstat dRd23 24 end25 26 macro test.mpcorb27 if ($0 != 3)28 echo "USAGE: test.mpcorb (version) (options)"29 break30 end31 32 local Version33 $Version = $134 $Options = $235 36 echo mpcorb_predict moment trange.59396.fits 59375.31398 {200.738197150704-2} {200.738197150704+2} {6.13117829483755-2} {6.13117829483755+2} o9375g0065o.am$Version.fits $Options37 exec mpcorb_predict moment trange.59396.fits 59375.31398 {200.738197150704-2} {200.738197150704+2} {6.13117829483755-2} {6.13117829483755+2} o9375g0065o.am$Version.fits $Options38 get.camera.matches o9375g0065o.1795013.cm.2420887.smf o9375g0065o.am$Version.fits o9375g0065o.t1/o9375g0065o.t1 am$Version39 load.camstats.glob o9375g0065o.t1/o9375g0065o.t1.XY*.am$Version.cam.stf40 41 set dX$Version = Xpsf - Xref42 set dY$Version = Ypsf - Yref43 44 set dR$Version = 3600*(Rpsf - Rref)*dcos(Dref)45 set dD$Version = 3600*(Dpsf - Dref)46 47 plot -pt cir -sz 2 -op 0.3 dR$Version dD$Version48 end49 50 macro replot.mpcorb51 if ($0 != 3)52 echo "USAGE: test.mpcorb (version) (color)"53 break54 end55 56 plot -pt cir -sz 2 -op 0.3 dR$1 dD$1 -c $257 end58 59 macro load.camstats.glob60 if ($0 != 2)61 echo "USAGE: load.camstats.glob (glob)"62 break63 end64 65 delete -q Rref Dref Xref Yref Q1ref Xpsf Ypsf Rpsf Dpsf Q1psf66 67 list name -glob $168 for i 0 $name:n69 70 data $name:$i71 read -fits DATA -sizes72 if ($table:Ny == 0) continue73 read -fits DATA -list-fields -q; list tfields -join allfields; read -fits DATA $allfields74 75 concat RrefSS Rref76 concat DrefSS Dref77 concat XrefSS Xref78 concat YrefSS Yref79 concat Q1refSS Q1ref80 concat X_PSF_found Xpsf81 concat Y_PSF_found Ypsf82 concat RA_PSF_found Rpsf83 concat DEC_PSF_found Dpsf84 concat Q1_PSF_found Q1psf85 end86 end87 1 88 2 macro camstats.glob … … 138 52 set dfracOK = sqrt(numOK_sum) / numTotal_sum 139 53 54 break -auto off 140 55 threshold -q -r magFound fracFound 0.25 -range 25 {magFound[]-1} 56 break -auto on 141 57 $MagLim = $threshold 142 58 … … 208 124 $Mmin = 10 209 125 $Mmax = 25 210 $Mdel = 0. 25126 $Mdel = 0.5 211 127 212 128 delete -q fracFound magFound numFound numTotal numPoss fracPoss numOK fracOK … … 258 174 cplot -c red -op 1.0 -pt box -sz 2.5 RrefCam DrefCam where (not(isnan(Xpsf)) && (Q1psf > 0.85)) 259 175 end 176 177 ############ macros used to test mpcorb_predict 178 179 macro test.mpcfine 180 if ($0 != 2) 181 echo "USAGE: test.mpcfine (file)" 182 break 183 end 184 185 data $1 186 read Rr 1 Dr 2 Rc 4 Dc 5 Rp 7 Dp 8 Ra 10 Da 11 Rd 13 Dd 14 187 set dRc = 3600*(Rc - Rr)*dcos(Dr) 188 set dDc = 3600*(Dc - Dr) 189 set dRp = 3600*(Rp - Rc)*dcos(Dr) 190 set dDp = 3600*(Dp - Dc) 191 set dRa = 3600*(Ra - Rp)*dcos(Dr) 192 set dDa = 3600*(Da - Dp) 193 set dRd = 3600*(Rd - Ra)*dcos(Dr) 194 set dDd = 3600*(Dd - Da) 195 196 vstat dRc 197 vstat dRp 198 vstat dRa 199 vstat dRd 200 201 end 202 203 macro test.mpcorb 204 if ($0 != 3) 205 echo "USAGE: test.mpcorb (version) (options)" 206 break 207 end 208 209 local Version 210 $Version = $1 211 $Options = $2 212 213 echo mpcorb_predict moment trange.59396.v2.fits 59375.31398 {200.738197150704-2} {200.738197150704+2} {6.13117829483755-2} {6.13117829483755+2} o9375g0065o.am$Version.fits 214 exec mpcorb_predict moment trange.59396.v2.fits 59375.31398 {200.738197150704-2} {200.738197150704+2} {6.13117829483755-2} {6.13117829483755+2} o9375g0065o.am$Version.fits 215 get.camera.matches o9375g0065o.1795013.cm.2420887.smf o9375g0065o.am$Version.fits o9375g0065o.t1/o9375g0065o.t1 am$Version 216 load.camstats.glob o9375g0065o.t1/o9375g0065o.t1.XY*.am$Version.cam.stf 217 218 set dX$Version = Xpsf - Xref 219 set dY$Version = Ypsf - Yref 220 221 set dR$Version = 3600*(Rpsf - Rref)*dcos(Dref) 222 set dD$Version = 3600*(Dpsf - Dref) 223 224 plot -pt cir -sz 2 -op 0.3 dR$Version dD$Version 225 end 226 227 macro replot.mpcorb 228 if ($0 != 3) 229 echo "USAGE: test.mpcorb (version) (color)" 230 break 231 end 232 233 plot -pt cir -sz 2 -op 0.3 dR$1 dD$1 -c $2 234 end 235 236 macro load.camstats.glob 237 if ($0 != 2) 238 echo "USAGE: load.camstats.glob (glob)" 239 break 240 end 241 242 delete -q Rref Dref Mref Xref Yref Q1ref Xpsf Ypsf Rpsf Dpsf Mpsf Q1psf 243 244 list name -glob $1 245 for i 0 $name:n 246 247 data $name:$i 248 read -fits DATA -sizes 249 if ($table:Ny == 0) continue 250 read -fits DATA -list-fields -q; list tfields -join allfields; read -fits DATA $allfields 251 252 concat RrefSS Rref 253 concat DrefSS Dref 254 concat XrefSS Xref 255 concat YrefSS Yref 256 concat MrefSS Mref 257 concat Q1refSS Q1ref 258 concat X_PSF_found Xpsf 259 concat Y_PSF_found Ypsf 260 concat RA_PSF_found Rpsf 261 concat DEC_PSF_found Dpsf 262 concat M_PSF_found Mpsf 263 concat Q1_PSF_found Q1psf 264 end 265 end 266
Note:
See TracChangeset
for help on using the changeset viewer.
