Changeset 38309
- Timestamp:
- May 22, 2015, 8:09:22 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20150419/Ohana/src/addstar/test/relphot.flatcorr.dvo
r38304 r38309 21 21 if (not($?PLOT)) set PLOT = 0 22 22 23 $USE_CELL_OFFSETS = 1 24 $SET_UC_RESID = 1 23 $USE_CELL_OFFSETS = 1; # turn on non-zero cell offsets 24 $SET_UC_RESID = 1; # write a non-zero resid value to the ubercal table (should not have an impact) 25 25 26 26 27 # set various global variables … … 35 36 echo ADDSTAR_RADIUS 1.0 36 37 echo CATMODE SPLIT 37 echo CATFORMAT PS1_V2 38 echo CATFORMAT PS1_V5 39 # echo CATFORMAT PS1_V2 -- must be at least PS1_V3 for ubercaldist to work 38 40 echo SKY_DEPTH 4 39 41 echo CAMERA gpc1 … … 64 66 echo "10110 GPC1.r.XY10 dep $zpt_nominal:r $klam_nominal:r 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 65 67 echo "10111 GPC1.r.XY11 dep $zpt_nominal:r $klam_nominal:r 0.000 - - 0.0000 0 1 0.015 0.000 1.000 0.000 0x0000 0x0000 0xe0440130 0x1003bc88" 68 echo "2011 2MASS_J ref 0.000 0.000 0.000 - - 0.0000 0 6 0.080 0.000 2.000 0.000 0x0000 0x0000 0x0000 0x0000" 69 echo "3001 SYNTH.g ref 0.000 0.000 0.000 - - 0.0000 0 1 nan 0.000 2.000 0.600 0x0000 0x0000 0x0000 0x0000" 66 70 output stdout 67 71 … … 77 81 $CHIP_DX = 1000 78 82 $CHIP_DY = 1000 83 $DEFECT_FRAC = 0.03 84 $OFFSET_FRAC_UC = 0.0 85 $OFFSET_FRAC_NC = 0.5 79 86 80 87 # we have two sets of images: ubercaled and not-ubercaled … … 149 156 init 150 157 mkzptfile 151 mkstars 500 158 mkstars 1000 159 160 catdir $catdir 161 162 mk2mass $fileroot $catdir 163 ck2mass addstar 164 165 mksynth $fileroot $catdir 166 cksynth addstar 167 168 # to add a valid tycho test, I need to generate a zpt table for tycho as well 169 mktycho $fileroot $catdir 170 cktycho addstar 171 break 152 172 153 173 tapPLAN {((mjd_uc[]*4 + mjd_nc[]*4) + (mjd_uc[] + mjd_nc[]) + (mjd_uc[] + mjd_nc[])) / 3} … … 179 199 ckexposure $catdir mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i relphot 180 200 end 201 ck2mass relphot 181 202 182 203 tapDONE … … 241 262 242 263 skyregion {$RA_CENTER - 0.2/dcos($DEC_CENTER)} {$RA_CENTER + 0.2/dcos($DEC_CENTER)} {$DEC_CENTER - 0.2} {$DEC_CENTER + 0.2} 243 mextract ra dec mag xccd yccd where (abs(time - $MJD_IMAGE) < 0.0001)264 mextract ra dec mag xccd yccd dbflags photflags where (abs(time - $MJD_IMAGE) < 0.0001) 244 265 245 266 match2d -closest ra dec stars_ra stars_dec 0.001 -index1 index1 -index2 index2 … … 252 273 set dm = mag - stars_mag_m 253 274 275 set good_photom = (not(photflags & 0x02)) 276 foreach field dm xccd yccd 277 subset $field\_good = $field if good_photom 278 end 279 254 280 if ($PLOT) 255 281 dev -n 1 256 lim mag dm; clear; box; plot mag dm 282 lim mag dm; clear; box; plot mag dm; plot -c red -pt 7 mag dm where (photflags & 0x00000002) 283 echo "red points are known bad photometry" 257 284 end 258 285 259 286 # reproduce eddie's esoteric padding 260 set cell_xbin = max(0 , min(1 , int((xccd + 8) / ($CHIP_DX / $NCELL_X))))261 set cell_ybin = max(0 , min(1 , int((yccd + 10) / ($CHIP_DY / $NCELL_Y))))262 subset dm00 = dm if (cell_xbin == 0) && (cell_ybin == 0)263 subset dm01 = dm if (cell_xbin == 0) && (cell_ybin == 1)264 subset dm10 = dm if (cell_xbin == 1) && (cell_ybin == 0)265 subset dm11 = dm if (cell_xbin == 1) && (cell_ybin == 1)287 set cell_xbin = max(0 , min(1 , int((xccd_good + 8) / ($CHIP_DX / $NCELL_X)))) 288 set cell_ybin = max(0 , min(1 , int((yccd_good + 10) / ($CHIP_DY / $NCELL_Y)))) 289 subset dm00 = dm_good if (cell_xbin == 0) && (cell_ybin == 0) 290 subset dm01 = dm_good if (cell_xbin == 0) && (cell_ybin == 1) 291 subset dm10 = dm_good if (cell_xbin == 1) && (cell_ybin == 0) 292 subset dm11 = dm_good if (cell_xbin == 1) && (cell_ybin == 1) 266 293 267 294 # uncorrected values behave like this: … … 298 325 299 326 if ("$MODE" == "setphot_uc") 300 vstat -q dm 301 sprintf line "setphot_uc ZP %8.2f $FILTER %6.3f %6.3f %6.3f: %7.4f %7.4f : %3d" $MJD_IMAGE $ZPT_REAL $ZPT_REAL_NORM $ZPT_NOMINAL $MEAN $SIGMA dm []327 vstat -q dm_good 328 sprintf line "setphot_uc ZP %8.2f $FILTER %6.3f %6.3f %6.3f: %7.4f %7.4f : %3d" $MJD_IMAGE $ZPT_REAL $ZPT_REAL_NORM $ZPT_NOMINAL $MEAN $SIGMA dm_good[] 302 329 tapOK {abs($MEAN) < 0.005} "$line" 330 331 subset tmp = dm if (dbflags & 0x00008000) 332 tapOK {tmp[] == dm[]} "ubercal detections have ubercal bit set" 333 334 imextract MCAL FLAGS where (abs(time - $MJD_IMAGE) < 0.0001) 335 subset tmp = FLAGS if (FLAGS & 0x0000200) 336 tapOK {tmp[] == FLAGS[]} "ubercal images have ubercal bit set" 337 303 338 return 304 339 end 305 340 306 341 if ("$MODE" == "setphot_nc") 307 vstat -q dm 308 sprintf line "setphot_nc ZP %8.2f $FILTER %6.3f %6.3f %6.3f: %7.4f %7.4f : %3d" $MJD_IMAGE $ZPT_REAL $ZPT_REAL_NORM $ZPT_NOMINAL $MEAN $SIGMA dm []342 vstat -q dm_good 343 sprintf line "setphot_nc ZP %8.2f $FILTER %6.3f %6.3f %6.3f: %7.4f %7.4f : %3d" $MJD_IMAGE $ZPT_REAL $ZPT_REAL_NORM $ZPT_NOMINAL $MEAN $SIGMA dm_good[] 309 344 tapOK {abs($MEAN - $ZPT_NOMINAL + $ZPT_REAL_NORM) < 0.005} "$line" 345 346 subset tmp = dm if (not(dbflags & 0x00008000)) 347 tapOK {tmp[] == dm[]} "non-ubercal detections do NOT have ubercal bit set" 348 349 imextract FLAGS where (abs(time - $MJD_IMAGE) < 0.0001) 350 subset tmp = FLAGS if (not(FLAGS & 0x0000200)) 351 tapOK {tmp[] == FLAGS[]} "non-ubercal images do NOT have ubercal bit set" 352 310 353 return 311 354 end 312 355 313 356 if ("$MODE" == "relphot") 314 vstat -q dm 315 sprintf line "relphot ZP %8.2f $FILTER %6.3f %6.3f %6.3f: %7.4f %7.4f : %3d" $MJD_IMAGE $ZPT_REAL $ZPT_REAL_NORM $ZPT_NOMINAL $MEAN $SIGMA dm []357 vstat -q dm_good 358 sprintf line "relphot ZP %8.2f $FILTER %6.3f %6.3f %6.3f: %7.4f %7.4f : %3d" $MJD_IMAGE $ZPT_REAL $ZPT_REAL_NORM $ZPT_NOMINAL $MEAN $SIGMA dm_good[] 316 359 tapOK {abs($MEAN) < 0.005} "$line" 360 361 mextract ra dec dbflags 362 subset rs = ra if (dbflags & 0x8000) 363 subset ds = dec if (dbflags & 0x8000) 364 avmatch rs ds 0.1 $FILTER\:flags $FILTER\:uc_dist 365 366 subset tmp = rs if ($FILTER\:flags & 0x8) 367 tapOK {tmp[] == rs[]} "objects with ubercal detections have ubercal bit set (tmp[] vs rs[])" 368 369 subset tmp = rs if ($FILTER\:uc_dist < 0.1) 370 tapOK {tmp[] == rs[]} "objects with ubercal detections have ubercal dist of 0.0" 317 371 return 318 372 end … … 377 431 $options = -mjd $MJD 378 432 $options = $options -radec $ra $dec 379 $options = $options -type PS1_V2 433 434 #$options = $options -type PS1_V2 435 #$options = $options -type PS1_V3 436 #$options = $options -type PS1_V4 437 $options = $options -type PS1_V5 438 380 439 $options = $options -coords 381 440 $options = $options -photcode GPC1.$FILTER.XY$ix\$iy 382 441 $options = $options -no-noise 442 $options = $options -flags 443 $options = $options -bad-psfqf-frac $DEFECT_FRAC 383 444 $options = $options -size $CHIP_DX $CHIP_DY 384 445 $options = $options -crpix {0.5*$CHIP_DX} {0.5*$CHIP_DY} … … 429 490 end 430 491 431 write -f "%10.6f %10.6f %7.3f %6.1f %6.1f %7.3f" $1 stars_r stars_d stars_mr stars_x stars_y stars_mi 492 # create bad detections / detections to ignore or avoid, save to a file? 493 494 # create 3 types of things to ignore / avoid 495 # * badPhot (deviate the photometry) 496 # * badFlag (set a bad flag bit) 497 # * poorFlag (set a bad flag bit) 498 set badPhot = rnd(stars_r) < $DEFECT_FRAC 499 set badFlag = rnd(stars_r) < $DEFECT_FRAC 500 set poorFlag = rnd(stars_r) < $DEFECT_FRAC 501 502 # create deviant photometry (1%) 503 # I'm setting the flag value 0x02 (EXTMODEL) if the object is deviated. This is a simple way to pass the info 504 set stars_mi = stars_mi + 0.2*badPhot 505 set stars_fl = zero(stars_mi) + 0x00000080*badFlag + 0x00000100*poorFlag + 0x00000002*badPhot 506 507 # bad flags that we sould respect: 508 # PM_SOURCE_MODE_FAIL = 0x00000008, ///< Fit (non-linear) failed (non-converge, off-edge, run to zero) 509 # PM_SOURCE_MODE_SATSTAR = 0x00000080, ///< Source model peak is above saturation 510 # PM_SOURCE_MODE_BADPSF = 0x00000400, ///< Failed to get good estimate of object's PSF 511 # PM_SOURCE_MODE_DEFECT = 0x00000800, ///< Source is thought to be a defect 512 # PM_SOURCE_MODE_SATURATED = 0x00001000, ///< Source is thought to be saturated pixels (bleed trail) 513 # PM_SOURCE_MODE_CR_LIMIT = 0x00002000, ///< Source has crNsigma above limit 514 # PM_SOURCE_MODE_MOMENTS_FAILURE = 0x00008000, ///< could not measure the moments 515 # PM_SOURCE_MODE_SKY_FAILURE = 0x00010000, ///< could not measure the local sky 516 # PM_SOURCE_MODE_SKYVAR_FAILURE = 0x00020000, ///< could not measure the local sky variance 517 # PM_SOURCE_MODE_SIZE_SKIPPED = 0x10000000, ///< size could not be determined 518 519 # poor flags that we should respect: 520 # PM_SOURCE_MODE_POOR = 0x00000010, ///< Fit succeeds, but low-SN, high-Chisq, or large (for PSF -- drop?) 521 # PM_SOURCE_MODE_PAIR = 0x00000020, ///< Source fitted with a double psf 522 # PM_SOURCE_MODE_BLEND = 0x00000100, ///< Source is a blend with other sources 523 # PM_SOURCE_MODE_BELOW_MOMENTS_SN = 0x00040000, ///< moments not measured due to low S/N 524 # PM_SOURCE_MODE_BLEND_FIT = 0x00400000, ///< source was fitted as a blend 525 # PM_SOURCE_MODE_ON_SPIKE = 0x20000000, ///< peak lands on diffraction spike 526 # PM_SOURCE_MODE_ON_GHOST = 0x40000000, ///< peak lands on ghost or glint 527 # PM_SOURCE_MODE_OFF_CHIP = 0x80000000, ///< peak lands off edge of chip 528 529 write -f "%10.6f %10.6f %7.3f %6.1f %6.1f %7.3f 0x%x" $1 stars_r stars_d stars_mr stars_x stars_y stars_mi stars_fl 432 530 end 433 531 … … 450 548 set stars_ra = $RA_CENTER + $RA_RANGE * (rnd(tmp) - 0.5) / 3600 / dcos ($DEC_CENTER) 451 549 set stars_dec = $DEC_CENTER + $DEC_RANGE * (rnd(tmp) - 0.5) / 3600 452 set stars_mag = 15.0 + 4.0 * rnd(tmp) 550 set stars_mag = 10.0 + 10.0 * rnd(tmp) 551 set stars_dmag = 0.02 + 0.1*rnd(tmp) 552 end 553 554 macro mk2mass 555 if ($0 != 3) 556 echo "USAGE: mk2mass (fileroot) (catdir)" 557 break 558 end 559 560 local ROOT CATDIR 561 562 $ROOT = $1 563 $CATDIR = $2 564 565 set stars_flags = 0x00c00000*(rnd(stars_ra) < 0.1) + 0x7*(rnd(stars_ra) < 0.8) 566 write $ROOT.2mass.dat -f "%10.6f %10.6f %6.3f %6.3f 0x%x" stars_ra stars_dec stars_mag stars_dmag stars_flags 567 568 tapEXEC addstar -ref $ROOT.2mass.dat -D CATDIR $CATDIR -D CAMERA gpc1 -quick-airmass -photcode 2MASS_J 569 570 set r_2mass = stars_ra 571 set d_2mass = stars_dec 572 set m_2mass = stars_mag 573 set dm_2mass = stars_dmag 574 set fl_2mass = stars_flags 575 end 576 577 macro ck2mass 578 if ($0 != 2) 579 echo "USAGE: ck2mass (stage)" 580 break 581 end 582 583 if ("$1" == "addstar") 584 skyregion {$RA_CENTER - 0.2/dcos($DEC_CENTER)} {$RA_CENTER + 0.2/dcos($DEC_CENTER)} {$DEC_CENTER - 0.2} {$DEC_CENTER + 0.2} 585 mextract ra dec mag xccd yccd dbflags photflags where (photcode == 2011) 586 tapOK {ra[] == r_2mass[]} "read in as many 2mass stars as we generated" 587 588 match2d -closest ra dec r_2mass d_2mass 0.001 -index1 index1 -index2 index2 589 subset tmp = index1 if (index1 >= 0) 590 tapOK {tmp[] == ra[]} "2mass sources match those generated" 591 end 592 593 if ("$1" == "relphot") 594 subset rs = r_2mass if (fl_2mass & 0x00c00000) 595 subset ds = d_2mass if (fl_2mass & 0x00c00000) 596 avmatch rs ds 0.1 flags 597 subset tmp = rs if (flags & 0x02000000); # extended in 2mass 598 tapOK {tmp[] == rs[]} "2mass extended objects properly marked" 599 600 subset rs = r_2mass if (fl_2mass & 0x07) 601 subset ds = d_2mass if (fl_2mass & 0x07) 602 avmatch rs ds 0.1 flags 603 subset tmp = rs if (flags & 0x08000000); # extended in 2mass 604 tapOK {tmp[] == rs[]} "2mass good objects properly marked" 605 end 606 end 607 608 macro mksynth 609 if ($0 != 3) 610 echo "USAGE: mksynth (fileroot) (catdir)" 611 break 612 end 613 614 local ROOT CATDIR 615 616 $ROOT = $1 617 $CATDIR = $2 618 619 subset r_synth = stars_ra if (stars_mag < 17) 620 subset d_synth = stars_dec if (stars_mag < 17) 621 subset m_synth = stars_mag if (stars_mag < 17) 622 subset dm_synth = stars_dmag if (stars_mag < 17) 623 subset fl_synth = stars_flags if (stars_mag < 17) 624 625 write $ROOT.synth.dat -f "%10.6f %10.6f %6.3f %6.3f 0x%x" r_synth d_synth m_synth dm_synth fl_synth 626 627 tapEXEC addstar -ref $ROOT.synth.dat -D CATDIR $CATDIR -D CAMERA gpc1 -quick-airmass -photcode SYNTH.g 628 end 629 630 macro cksynth 631 if ($0 != 2) 632 echo "USAGE: cksynth (stage)" 633 break 634 end 635 636 if ("$1" == "addstar") 637 skyregion {$RA_CENTER - 0.2/dcos($DEC_CENTER)} {$RA_CENTER + 0.2/dcos($DEC_CENTER)} {$DEC_CENTER - 0.2} {$DEC_CENTER + 0.2} 638 mextract ra dec mag xccd yccd dbflags photflags where (photcode == 3001) 639 tapOK {ra[] == r_synth[]} "read in as many synth stars as we generated" 640 641 match2d -closest ra dec r_synth d_synth 0.001 -index1 index1 -index2 index2 642 subset tmp = index1 if (index1 >= 0) 643 tapOK {tmp[] == ra[]} "synth sources match those generated" 644 end 645 646 if ("$1" == "relphot") 647 subset rs = r_synth if (m_synth < 13.5) 648 subset ds = d_synth if (m_synth < 13.5) 649 avmatch rs ds 0.1 g:flags 650 subset tmp = rs if (g:flags & 0x04); # synth used for photometry 651 tapOK {tmp[] == rs[]} "synth objects used for photometry properly marked" 652 end 653 end 654 655 macro mktycho 656 if ($0 != 3) 657 echo "USAGE: mktycho (fileroot) (catdir)" 658 break 659 end 660 661 local ROOT CATDIR 662 663 $ROOT = $1 664 $CATDIR = $2 665 666 subset r_tycho = stars_ra if (stars_mag < 12) 667 subset d_tycho = stars_dec if (stars_mag < 12) 668 subset m_tycho = stars_mag if (stars_mag < 12) 669 subset dm_tycho = stars_dmag if (stars_mag < 12) 670 subset fl_tycho = stars_flags if (stars_mag < 12) 671 672 write $ROOT.tycho.dat -f "%10.6f %10.6f %6.3f %6.3f 0x%x" r_tycho d_tycho m_tycho dm_tycho fl_tycho 673 674 tapEXEC addstar -ref $ROOT.tycho.dat -D CATDIR $CATDIR -D CAMERA gpc1 -quick-airmass -photcode TYCHO.g 675 676 $KAPA = kapa -noX 677 dev -n tmpdev 678 section default -imtool none 679 resize 50 50 680 region $RA_CENTER $DEC_CENTER 0.2 681 create tmp 0 1 682 cdensify tmpmap tmp tmp 683 set map = zero(tmpmap) + 0.2 684 close 685 $KAPA = kapa 686 687 local filter 688 foreach filter g r i z y 689 if ("$filter" == "g") 690 wd map $ROOT.synthzpts.fits -bitpix -32 -bzero 0.0 -bscale 1.0 691 end 692 keyword map EXTNAME -w "map_$filter" 693 wd map $ROOT.synthzpts.fits -bitpix -32 -bzero 0.0 -bscale 1.0 -extend 694 end 695 end 696 697 macro cktycho 698 if ($0 != 2) 699 echo "USAGE: cktycho (stage)" 700 break 701 end 702 703 if ("$1" == "addstar") 704 skyregion {$RA_CENTER - 0.2/dcos($DEC_CENTER)} {$RA_CENTER + 0.2/dcos($DEC_CENTER)} {$DEC_CENTER - 0.2} {$DEC_CENTER + 0.2} 705 mextract ra dec mag xccd yccd dbflags photflags where (photcode == 3001) 706 tapOK {ra[] == r_tycho[]} "read in as many tycho stars as we generated" 707 708 match2d -closest ra dec r_tycho d_tycho 0.001 -index1 index1 -index2 index2 709 subset tmp = index1 if (index1 >= 0) 710 tapOK {tmp[] == ra[]} "tycho sources match those generated" 711 end 712 713 if ("$1" == "relphot") 714 subset rs = r_tycho if (m_tycho < 13.5) 715 subset ds = d_tycho if (m_tycho < 13.5) 716 avmatch rs ds 0.1 g:flags 717 subset tmp = rs if (g:flags & 0x04); # tycho used for photometry 718 tapOK {tmp[] == rs[]} "tycho objects used for photometry properly marked" 719 end 453 720 end 454 721
Note:
See TracChangeset
for help on using the changeset viewer.
