- Timestamp:
- Jun 22, 2012, 3:33:32 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20120601/psphot/test/tap_psphot_varmodel.pro
r33963 r34053 2 2 # -*-sh-*- 3 3 4 # $KAPA = kapa -noX 5 6 # PSF.CONVOLVE : if true, we insert delta functions (and optionally 7 # galaxies) and smooth the image with the psf model 8 # (uses a GAUSS regardless of the model). Note that 9 # PSF.CONVOLVE = T is faster than F, but (a) only 10 # allows Gauss models and (b) only yields quantized 11 # locations 12 13 # config for ppImage to generate chip, mask, weight 14 $ppImageConfig = -recipe PPIMAGE PPIMAGE_N 15 $ppImageConfig = $ppImageConfig -Db BACKGROUND T 16 $ppImageConfig = $ppImageConfig -Db CHIP.FITS T 17 $ppImageConfig = $ppImageConfig -Db CHIP.MASK.FITS T 18 $ppImageConfig = $ppImageConfig -Db CHIP.VARIANCE.FITS T 19 $ppImageConfig = $ppImageConfig -Db BASE.FITS F 20 $ppImageConfig = $ppImageConfig -Db VARIANCE.BUILD T 21 $ppImageConfig = $ppImageConfig -Db PHOTOM F 22 23 # basic options for the these images (filter, location, obstype) 24 $BaseOptions = -type OBJECT -filter r -skymags 20.86 -ra 270.70 -dec -23.70 -pa 0.0 25 $BaseOptions = $BaseOptions -Df PSASTRO:DVO.GETSTAR.MAX.RHO 50000.0 26 27 # create an image with fake sources and insert the resulting cmf file into a dvodb 28 $RefConfig = -camera SIMTEST 29 $RefConfig = $RefConfig -recipe PPSIM STACKTEST.MAKE 30 $RefConfig = $RefConfig -D PSASTRO:PSASTRO.CATDIR catdir.ref 31 $RefConfig = $RefConfig -Db PSF.CONVOLVE F 32 33 # options for the reference image 34 $RefOptions = $BaseOptions -exptime 100.0 35 $RefOptions = $RefOptions -seeing 1.0 36 $RefOptions = $RefOptions -D PSF.MODEL PS_MODEL_GAUSS 37 $RefOptions = $RefOptions -Df STARS.DENSITY 10.0 38 $RefOptions = $RefOptions -Df STARS.SIGMA.LIM 0.5 39 40 # basic config for ppSim with randomly distributed stars and NO galaxies 41 $RealConfig = -camera SIMTEST 42 $RealConfig = $RealConfig -recipe PPSIM STACKTEST.RUN 43 $RealConfig = $RealConfig -D PSASTRO:PSASTRO.CATDIR catdir.ref 44 $RealConfig = $RealConfig -Db STARS.FAKE F 45 $RealConfig = $RealConfig -Db STARS.REAL T 46 $RealConfig = $RealConfig -Db MATCH.DENSITY F 47 $RealConfig = $RealConfig -Db PSF.CONVOLVE F 48 $RealConfig = $RealConfig -Df STARS.DENSITY 10.0 49 $RealConfig = $RealConfig -Df STARS.SIGMA.LIM 2.5 50 $RealConfig = $RealConfig -Db GALAXY.FAKE F 51 $RealConfig = $RealConfig -Db GALAXY.GRID F 52 53 # options for the repeated images 54 $RealOptions = $BaseOptions -exptime 30.0 55 56 $ExtraOptions = -D PSF.MODEL PS_MODEL_GAUSS 57 58 # sample alternate options: 59 # $ppSimOptions = $FakeOptions -D PSF.MODEL PS_MODEL_PS1_V1 60 # $ppSimOptions = $FakeOptions -Df PSF.ARATIO 1.2 61 # $ppSimOptions = $FakeOptions -Df PSF.THETA +30.0 62 # $ppSimOptions = $FakeOptions -D PSF.MODEL PS_MODEL_GAUSS 63 64 list fwhm 65 1.0 66 1.1 67 1.2 68 1.5 69 end 4 # This script includes a set of tests to demonstrate the dependence of the faint-end bias on the weighting scheme 5 # We have 3 weighting schemes : 6 # CONSTANT -- per-pixel weight is fixed (disadvantage: lower S/N, especially for higher sky?) 7 # IMAGE_VAR - per-pixel weight is Poisson from image (disadvantage: faint-end bias) 8 # MODEL_VAR - per-pixel weight is Poisson from model (disadvantage: 2 linear-fit passes) 9 10 # Functions: 11 # 12 # init : initialize variables 13 # mkref : generate a fake reference catalog in a DVO database 14 # mkexp : generate a fake exposure from fake catalog and detrend it (saves basename.in.cmf & basename.fits) 15 # runphot : run psphot on an exposure (saves basename.cmf) 16 # ckchip.mags : generate a set of summary plots for the psphot analysis 17 18 # I would like to produce a grid of tests: 19 # sky (bright, middle, dark) 20 # fwhm (1.0, 1.3, 1.6) 21 # PSF_MODEL input (GAUSS PS1_V1) 22 # PSF_MODEL apply (GAUSS PS1_V1) 23 # variance mode: CONSTANT, IMAGE_VAR, MODEL_VAR 70 24 71 25 macro go 72 73 26 mkdir test 74 27 75 $ExtraOptions = -D PSF.MODEL PS_MODEL_GAUSS 76 mkexp test/image.00 1.0 77 $ExtraOptions = -D PSF.MODEL PS_MODEL_PGAUSS 78 mkexp test/image.01 1.0 79 $ExtraOptions = -D PSF.MODEL PS_MODEL_PS1_V1 80 mkexp test/image.02 1.0 28 local sky fwhm psf_in psf_out 29 30 # mkref creates refimage.* and catdir.ref 31 file catdir.ref found 32 if (not($found)) 33 mkref 34 end 35 36 $KAPA = kapa -noX 37 if (not($?RefConfig)) init 38 39 foreach sky 19.0 20.0 21.0 40 foreach fwhm 1.0 1.3 1.6 41 foreach psf_in GAUSS PS1_V1 42 43 sprintf name "test/test.%02d.%02d.%s" $sky {10*$fwhm} $psf_in 44 # mkexp $name $sky $fwhm $psf_in 45 46 foreach psf_out GAUSS PS1_V1 47 foreach mode CONSTANT IMAGE_VAR MODEL_VAR 48 # runphot $name $name.$psf_out.$mode "-D LINEAR_FIT_VARIANCE_MODE $mode -D PSF_MODEL PS_MODEL_$psf_out" 49 ckchip.mags $name.in.cmf $name.$psf_out.$mode.cmf $name.$psf_out.$mode 0.0 50 end 51 end 52 end 53 end 54 end 81 55 end 82 56 83 57 # create a reference database of fake stars to be used by ppSim below 84 58 macro mkref 59 if (not($?RefConfig)) init 60 85 61 exec rm -rf catdir.ref 86 62 exec rm -f refimage.fits … … 100 76 # create a realistic distribution of fake stars, GAUSS PSF 101 77 macro mkexp 78 if ($0 != 5) 79 echo "USAGE: mkexp basename sky fwhm psf_model" 80 break 81 end 82 83 local fwhm basename psf_model 84 $basename = $1 85 $sky = $2 86 $fwhm = $3 87 $psf_model = $4 88 89 $ExtraOptions = -D PSF.MODEL PS_MODEL_$psf_model 90 91 # create the raw image 92 echo ppSim -seeing $fwhm -skymags $sky -nx 3000 -ny 3000 $RealConfig $RealOptions $ExtraOptions $basename 93 exec ppSim -seeing $fwhm -skymags $sky -nx 3000 -ny 3000 $RealConfig $RealOptions $ExtraOptions $basename 94 exec /bin/mv -f $basename.cmf $basename.in.cmf 95 96 # create the chip output 97 echo ppImage $ppImageConfig -file $basename.fits $basename 98 exec ppImage $ppImageConfig -file $basename.fits $basename 99 end 100 101 # create a realistic distribution of fake stars, GAUSS PSF 102 macro mkexp.deep 102 103 if ($0 != 3) 103 104 echo "USAGE: mkexp basename fwhm" … … 109 110 $fwhm = $2 110 111 112 $RealOptionsDeep = $BaseOptions -exptime 100 113 111 114 # create the raw image 112 echo ppSim -seeing $fwhm -nx 3000 -ny 3000 $RealConfig $RealOptions $ExtraOptions $basename 113 exec ppSim -seeing $fwhm -nx 3000 -ny 3000 $RealConfig $RealOptions $ExtraOptions $basename 115 echo ppSim -seeing $fwhm -nx 3000 -ny 3000 $RealConfig $RealOptionsDeep $ExtraOptions $basename 116 exec ppSim -seeing $fwhm -nx 3000 -ny 3000 $RealConfig $RealOptionsDeep $ExtraOptions $basename 117 exec /bin/mv -f $basename.cmf $basename.in.cmf 118 119 # create the chip output 120 echo ppImage $ppImageConfig -file $basename.fits $basename 121 exec ppImage $ppImageConfig -file $basename.fits $basename 122 end 123 124 # create a realistic distribution of fake stars, GAUSS PSF 125 macro mkexp.bright 126 if ($0 != 3) 127 echo "USAGE: mkexp basename fwhm" 128 break 129 end 130 131 local fwhm basename 132 $basename = $1 133 $fwhm = $2 134 135 # basic options for the these images (filter, location, obstype) 136 $BaseOptions = -type OBJECT -filter r -skymags 20.0 -ra 270.70 -dec -23.70 -pa 0.0 137 $BaseOptions = $BaseOptions -Df PSASTRO:DVO.GETSTAR.MAX.RHO 50000.0 138 $RealOptionsDeep = $BaseOptions -exptime 100 139 140 # create the raw image 141 echo ppSim -seeing $fwhm -nx 3000 -ny 3000 $RealConfig $RealOptionsDeep $ExtraOptions $basename 142 exec ppSim -seeing $fwhm -nx 3000 -ny 3000 $RealConfig $RealOptionsDeep $ExtraOptions $basename 114 143 exec /bin/mv -f $basename.cmf $basename.in.cmf 115 144 … … 133 162 echo psphot -threads 4 -file $basename.ch.fits -mask $basename.ch.mk.fits -variance $basename.ch.wt.fits $outname $options 134 163 exec psphot -threads 4 -file $basename.ch.fits -mask $basename.ch.mk.fits -variance $basename.ch.wt.fits $outname $options 164 end 165 166 # compare two cmf files with extname Chip.psf 167 # things to compare: 168 # * completeness (which sources in (1) are not detected in (2) 169 # * positions (X_PSF, Y_PSF) 170 # * instrumental psf mags 171 # * position errors (no input errors; use a model?) 172 # * measured FWHM? 173 # * kron mags (fluxes) 174 # * etc, etc 175 macro ckchip.mags 176 if ($0 != 5) 177 echo "USAGE: ckchip.mags (raw) (out) (output) (zpt_off)" 178 break 179 end 180 181 list pairs 182 PSF_INST_MAG_out M_raw PSF_INST_MAG_raw 2 -0.21 0.21 V 183 AP_MAG_out M_raw PSF_INST_MAG_raw 2 -0.21 0.21 V 184 end 185 186 load.cmf $1 Chip.psf raw 187 load.cmf $2 Chip.psf out 188 189 # images generated with convolution will not have the right output positions 190 set X_raw = int(X_PSF_raw) + 0.5 191 set Y_raw = int(Y_PSF_raw) + 0.5 192 set M_raw = PSF_INST_MAG_raw + $4 193 set K_out = -2.5*log(KRON_FLUX_out) 194 match2d X_PSF_out Y_PSF_out X_PSF_raw Y_PSF_raw 1.5 -index1 index1 -index2 index2 195 196 local i NX NY nx ny N 197 198 resize 1000 1000 199 200 clear 201 section a0 0.0 0.0 1.0 0.5 202 label -fn courier 14; 203 style -pt 0 -sz 0.4 204 show.pair 0 205 delete -q imag_V dmag_V smag_V Dmag_V dmag_Vraw 206 for imag -11 -6 0.2 207 subset dmsub = delta if (rv > $imag) && (rv < $imag + 0.2) 208 vstat -q dmsub 209 concat $imag imag_V 210 concat $MEAN dmag_V 211 concat $MEDIAN Dmag_V 212 concat $SIGMA smag_V 213 end 214 215 vstat -q dmag_V 216 $offset = $MEDIAN 217 set dmag_V = dmag_V - $offset 218 set Dmag_V = Dmag_V - $offset 219 220 section a1 0.0 0.50 1.0 0.25 221 lim rv -0.025 0.075; label -fn courier 14; box; 222 plot -c red -pt 7 -sz 2.0 imag_V dmag_V 223 plot -c darkgreen -pt 3 -sz 2.0 imag_V Dmag_V 224 # plot -c gold -pt 4 -sz 2.0 imag_V dmag_Vraw 225 plot -c blue -pt 2 -sz 2.0 imag_V smag_V 226 # label -y "mean (red), median (green), unclipped mean (gold), sigma (blue) of delta" 227 label -y "mean (red), median (green), sigma (blue) of delta" 228 sprintf line "OFFSET: %6.3f" $offset 229 textline -frac 0.1 0.8 -fn courier 24 "$line" 230 231 set lChiNorm = log(PSF_CHISQ_out / PSF_NDOF_out) 232 reindex chi = lChiNorm using index1 233 section a2 0.0 0.75 1.0 0.25 234 label -fn courier 14; 235 lim rv chi; box; 236 plot -c red -pt 0 -sz 0.5 rv chi 237 238 label -y "chisq" 239 png -name $3.png 240 241 # section a1 0.0 0.5 1.0 0.5 242 # style -pt 0 -sz 0.4 243 # show.pair 1 244 end 245 246 macro go.phot 247 runphot test.00 test.00.varmode.C "-Db SAVE.RESID T -D LINEAR_FIT_VARIANCE_MODE CONSTANT" 248 runphot test.00 test.00.varmode.I "-Db SAVE.RESID T -D LINEAR_FIT_VARIANCE_MODE IMAGE_VAR" 249 runphot test.00 test.00.varmode.M "-Db SAVE.RESID T -D LINEAR_FIT_VARIANCE_MODE MODEL_VAR" 250 runphot test.00 test.00.varmode.S "-Db SAVE.RESID T -D LINEAR_FIT_VARIANCE_MODE MODEL_SKY" 251 end 252 253 macro go.vars 254 dev -n varC; ckchip.mags test.00.in.cmf test.00.varmode.C.cmf test.00.varmode.C 0.0 255 dev -n varI; ckchip.mags test.00.in.cmf test.00.varmode.I.cmf test.00.varmode.I 0.0 256 dev -n varM; ckchip.mags test.00.in.cmf test.00.varmode.M.cmf test.00.varmode.M 0.0 257 dev -n varS; ckchip.mags test.00.in.cmf test.00.varmode.S.cmf test.00.varmode.S 0.0 135 258 end 136 259 … … 347 470 lim rv $word:4 $word:5; box; plot rv delta 348 471 end 349 label -y '$word:0' -x '$word:2' 472 $line = '$word:0' - '$word:1' 473 label -y "$line" -x '$word:2' 350 474 end 351 475 … … 637 761 end 638 762 763 macro init 764 # config for ppImage to generate chip, mask, weight 765 $ppImageConfig = -recipe PPIMAGE PPIMAGE_N 766 $ppImageConfig = $ppImageConfig -Db BACKGROUND T 767 $ppImageConfig = $ppImageConfig -Db CHIP.FITS T 768 $ppImageConfig = $ppImageConfig -Db CHIP.MASK.FITS T 769 $ppImageConfig = $ppImageConfig -Db CHIP.VARIANCE.FITS T 770 $ppImageConfig = $ppImageConfig -Db BASE.FITS F 771 $ppImageConfig = $ppImageConfig -Db VARIANCE.BUILD T 772 $ppImageConfig = $ppImageConfig -Db PHOTOM F 773 774 # basic options for the these images (filter, location, obstype) 775 $BaseOptions = -type OBJECT -filter r -ra 270.70 -dec -23.70 -pa 0.0 776 $BaseOptions = $BaseOptions -Df PSASTRO:DVO.GETSTAR.MAX.RHO 50000.0 777 778 # PSF.CONVOLVE : if true, we insert delta functions (and optionally 779 # galaxies) and smooth the image with the psf model 780 # (uses a GAUSS regardless of the model). Note that 781 # PSF.CONVOLVE = T is faster than F, but (a) only 782 # allows Gauss models and (b) only yields quantized 783 # locations 784 785 # create an image with fake sources and insert the resulting cmf file into a dvodb 786 $RefConfig = -camera SIMTEST 787 $RefConfig = $RefConfig -recipe PPSIM STACKTEST.MAKE 788 $RefConfig = $RefConfig -D PSASTRO:PSASTRO.CATDIR catdir.ref 789 $RefConfig = $RefConfig -Db PSF.CONVOLVE F 790 791 # options for the reference image 792 $RefOptions = $BaseOptions 793 $RefOptions = $RefOptions -exptime 100.0 794 $RefOptions = $RefOptions -seeing 1.0 795 $RefOptions = $RefOptions -skymags 21.0 796 $RefOptions = $RefOptions -D PSF.MODEL PS_MODEL_GAUSS 797 $RefOptions = $RefOptions -Df STARS.DENSITY 10.0 798 $RefOptions = $RefOptions -Df STARS.SIGMA.LIM 0.5 799 800 # basic config for ppSim with randomly distributed stars and NO galaxies 801 $RealConfig = -camera SIMTEST 802 $RealConfig = $RealConfig -recipe PPSIM STACKTEST.RUN 803 $RealConfig = $RealConfig -D PSASTRO:PSASTRO.CATDIR catdir.ref 804 $RealConfig = $RealConfig -Db STARS.FAKE F 805 $RealConfig = $RealConfig -Db STARS.REAL T 806 $RealConfig = $RealConfig -Db MATCH.DENSITY F 807 $RealConfig = $RealConfig -Db PSF.CONVOLVE F 808 $RealConfig = $RealConfig -Df STARS.DENSITY 10.0 809 $RealConfig = $RealConfig -Df STARS.SIGMA.LIM 2.5 810 $RealConfig = $RealConfig -Db GALAXY.FAKE F 811 $RealConfig = $RealConfig -Db GALAXY.GRID F 812 813 # options for the repeated images 814 $RealOptions = $BaseOptions -exptime 30.0 815 816 # sample alternate options: 817 # $ppSimOptions = $FakeOptions -D PSF.MODEL PS_MODEL_PS1_V1 818 # $ppSimOptions = $FakeOptions -Df PSF.ARATIO 1.2 819 # $ppSimOptions = $FakeOptions -Df PSF.THETA +30.0 820 # $ppSimOptions = $FakeOptions -D PSF.MODEL PS_MODEL_GAUSS 821 822 list fwhm 823 1.0 824 1.1 825 1.2 826 1.5 827 end 828 end 829 639 830 if ($SCRIPT) 640 831 fulltest 4
Note:
See TracChangeset
for help on using the changeset viewer.
