IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38304


Ignore:
Timestamp:
May 22, 2015, 9:43:44 AM (11 years ago)
Author:
eugene
Message:

fix up relphot test to get setphot right, zero points right

Location:
branches/eam_branches/ipp-20150419/Ohana/src/addstar/test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20150419/Ohana/src/addstar/test/relphot.flatcorr.dvo

    r38301 r38304  
    1414# * no other mechanism to tell DVO about a flat-field correction
    1515
     16$TAP_BREAK = 1
     17$TAP_VERBOSE = 1
    1618input tap.dvo
    1719
    1820# set globals
    19 if (not($?PLOT)) set PLOT = 0
     21if (not($?PLOT)) set PLOT = 0
     22
     23$USE_CELL_OFFSETS = 1
     24$SET_UC_RESID = 1
    2025
    2126# set various global variables
    2227macro init
     28  # generate a fake ptolemy.rc (to make this a contained test)
     29  exec rm -f ptolemy.rc
     30  output ptolemy.rc
     31    echo "\#"
     32    echo PHOTCODE_FILE dvo.photcodes
     33    echo GSCFILE GSCregions.tbl
     34    echo ZERO_PT 25.0
     35    echo ADDSTAR_RADIUS 1.0
     36    echo CATMODE                 SPLIT
     37    echo CATFORMAT               PS1_V2
     38    echo SKY_DEPTH               4
     39    echo CAMERA                  gpc1
     40    echo CAMERA_CONFIG           dvo.layout
     41    echo "input dvo.config"
     42  output stdout
     43
     44  # we need to define a photcode table consistent with the fake construction
     45  $zpt_nominal:g = 24.0
     46  $zpt_nominal:r = 24.5
     47
     48  # klam is negative, so klam*(airmass - 1) increases the zero point
     49  $klam_nominal:g = -0.15
     50  $klam_nominal:r = -0.10
     51
     52  # generate a fake dvo.photcode
     53  exec rm -f dvo.photcodes
     54  output dvo.photcodes
     55    echo "\# code  name                type    zero  slope offset c1    c2   slope   zero  equiv  sys scale   scale  sys     poor   bad     poor   bad"
     56    echo "1     g                    sec   0.000  0.000 0.000     1     3 0.0000     0  1051   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000"
     57    echo "2     r                    sec   0.000  0.000 0.000     2     3 0.0000     0  1052   0.000 0.000 0.000  0.000   0x0000 0x0000  0x0000 0x0000"
     58    echo "10000 GPC1.g.XY00          dep  $zpt_nominal:g $klam_nominal:g 0.000     -     - 0.0000     0     1   0.015 0.000 1.000  0.000   0x0000 0x0000  0xe0440130 0x1003bc88"
     59    echo "10001 GPC1.g.XY01          dep  $zpt_nominal:g $klam_nominal:g 0.000     -     - 0.0000     0     1   0.015 0.000 1.000  0.000   0x0000 0x0000  0xe0440130 0x1003bc88"
     60    echo "10010 GPC1.g.XY10          dep  $zpt_nominal:g $klam_nominal:g 0.000     -     - 0.0000     0     1   0.015 0.000 1.000  0.000   0x0000 0x0000  0xe0440130 0x1003bc88"
     61    echo "10011 GPC1.g.XY11          dep  $zpt_nominal:g $klam_nominal:g 0.000     -     - 0.0000     0     1   0.015 0.000 1.000  0.000   0x0000 0x0000  0xe0440130 0x1003bc88"
     62    echo "10100 GPC1.r.XY00          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"
     63    echo "10101 GPC1.r.XY01          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"
     64    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    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"
     66  output stdout     
     67
    2368  $RA_CENTER = 10.0
    2469  $DEC_CENTER = 20.0
     
    3378  $CHIP_DY = 1000
    3479
    35   # images are loaded into dvo with GPC1 photcodes, so we need to get the nominal zps for those filters
    36   $zpt_nominal:g = 24.00
    37   $zpt_nominal:r = 24.80
    38   $zpt_nominal:i = 24.74
    39   $zpt_nominal:z = 24.26
    40   $zpt_nominal:y = 23.41
    41 
    42   # klam is negative, so klam*(airmass - 1) increase the zero point
    43   $klam_nominal:g =  0.00
    44   $klam_nominal:r = -0.10
    45   $klam_nominal:i = -0.04
    46   $klam_nominal:z = -0.03
    47   $klam_nominal:y = -0.03
    48 
    4980  # we have two sets of images: ubercaled and not-ubercaled
    5081
    51   # sequence to count images (only used in this function)
    52   create tmpseq 0 1
    53 
    54   $filt_uc:n = 1
    55   $filt_uc:0 = g
    56   $filt_uc:1 = g
    57   $filt_uc:2 = g
    58   $filt_uc:3 = r
    59   $filt_uc:4 = r
    60   $filt_uc:5 = r
    61   $filt_uc:6 = i
    62   $filt_uc:7 = i
    63   $filt_uc:8 = i
    64 
    65   # airmass slopes for these sequnece
     82  # the number of exposures is defined by filt_uc:n
     83  list filt_uc -split g g g g r r r r
     84  $filt_uc:n = 2
     85
     86  # tmpseq is used to generate vectors in this function
     87  create tmpseq 0 $filt_uc:n
     88
     89  # exptime and airmasses for uc images
     90  set exptime_uc = 10.0 + zero(tmpseq)
     91  set airmass_uc =  1.3 + zero(tmpseq)
    6692  set klam_uc = zero(tmpseq)
    67   for i 0 tmpseq[]
    68     klam_uc[$i] = $klam_nominal:$filt_uc:$i
    69   end   
    70 
    71   # mjd and zpt values for ubercal'ed imaged
    72   set exptime_uc = 10.0 + zero(tmpseq)
    73   set airmass_uc = 1.3 + zero(tmpseq)
     93  set zpt_uc = zero(tmpseq)
    7494
    7595  # ubercal zero points are defined as ZP_nominal + 2.5log(exptime) + K*(airmass - 1.0)
    7696  # note that K is defined as a negative value (is this sensible?)
    77   set zpt_uc = 24.0 + 2.5*log(exptime_uc) + klam_uc*(airmass_uc - 1.0) + tmpseq*0.0050 - 0.0025
    78 
    79   set mjd_uc = zero(zpt_uc)
    80   mjd_uc[0] = 55000.01
    81   # mjd_uc[1] = 55000.02
    82   # mjd_uc[2] = 55000.03
    83   # mjd_uc[3] = 55015.01
    84   # mjd_uc[4] = 55015.02
    85   # mjd_uc[5] = 55015.03
    86   # mjd_uc[6] = 55025.01
    87   # mjd_uc[7] = 55025.02
    88   # mjd_uc[8] = 55025.03
     97
     98  # zero points and airmass slopes for these sequnece
     99  for i 0 $filt_uc:n
     100    klam_uc[$i] = $klam_nominal:$filt_uc:$i
     101    zpt_uc[$i]  = $zpt_nominal:$filt_uc:$i + 2.5*log(exptime_uc[$i]) + klam_uc[$i]*(airmass_uc[$i] - 1.0) + 0.04*rnd(klam_uc[$i]) - 0.02
     102  # zpt_uc[$i]  = $zpt_nominal:$filt_uc:$i + 2.5*log(exptime_uc[$i]) + klam_uc[$i]*(airmass_uc[$i] - 1.0)
     103  end   
     104  set mjd_uc = 55000.00 + 0.01*(tmpseq % 3) + 10.0*int(tmpseq / 3)
    89105
    90106  # mjd and zpt values for not-ubercal'ed images
    91   $filt_nc:n = 1
    92   $filt_nc:0 = g
    93   $filt_nc:1 = g
    94   $filt_nc:2 = g
    95   $filt_nc:3 = r
    96   $filt_nc:4 = r
    97   $filt_nc:5 = r
    98   $filt_nc:6 = i
    99   $filt_nc:7 = i
    100   $filt_nc:8 = i
     107  list filt_nc -split g g g g r r r r
     108  $filt_nc:n = 2
     109
     110  # tmpseq is used to generate vectors in this function
     111  create tmpseq 0 $filt_nc:n
     112
     113  # place this within a valid season (55000.0 - 55010.0 - 55020.0 - 55030.0)
     114  set exptime_nc = 10.0 + zero(tmpseq)
     115  set airmass_nc =  1.6 + zero(tmpseq)
     116  set klam_nc = zero(tmpseq)
     117  set zpt_nc = zero(tmpseq)
    101118
    102119  # airmass slopes for these sequnece
    103   set klam_nc = zero(tmpseq)
    104   for i 0 tmpseq[]
    105     klam_nc[$i] = $klam_nominal:$filt_nc:$i
     120  for i 0 $filt_nc:n
     121    klam_nc[$i] = $klam_nominal:$filt_nc:$i
     122    zpt_nc[$i]  = $zpt_nominal:$filt_nc:$i + 2.5*log(exptime_nc[$i]) + klam_nc[$i]*(airmass_nc[$i] - 1.0) + 0.08*rnd(klam_nc[$i]) - 0.04
     123  # zpt_nc[$i]  = $zpt_nominal:$filt_nc:$i + 2.5*log(exptime_nc[$i]) + klam_nc[$i]*(airmass_nc[$i] - 1.0)
    106124  end   
    107 
    108   # place this within a valid season (55000.0 - 55010.0 - 55020.0 - 55030.0)
    109   set exptime_nc = 15.0 + zero(tmpseq)
    110   set airmass_nc = 1.6 + zero(tmpseq)
    111 
    112   # ubercal zero points are defined as ZP_nominal + 2.5log(exptime) + K*(airmass - 1.0)
    113   set zpt_nc = 25.0 + 2.5*log(exptime_nc) + klam_nc*(airmass_nc - 1.0) - tmpseq*0.0050 + 0.0025
    114 
    115   set mjd_nc = zero(zpt_nc)
    116   mjd_nc[0] = 55000.11
    117   # mjd_nc[1] = 55000.12
    118   # mjd_nc[2] = 55000.13
    119   # mjd_nc[3] = 55015.11
    120   # mjd_nc[4] = 55015.12
    121   # mjd_nc[5] = 55015.13
    122   # mjd_nc[6] = 55025.11
    123   # mjd_nc[7] = 55025.12
    124   # mjd_nc[8] = 55025.13
     125  set mjd_nc = 55000.10 + 0.01*(tmpseq % 3) + 10.0*int(tmpseq / 3)
     126
     127  delete tmpseq
    125128end
    126129
     
    139142  mkdir $rootdir
    140143
     144  break -auto off
    141145  exec rm -rf $catdir
     146  exec rm -rf $fileroot*
     147  break -auto on
    142148
    143149  init
     
    149155  # generate the basic images and check they were correctly ingested by dvo
    150156  mksequence $fileroot $catdir
    151   for i 0 mjd_uc[] 3
    152     echo ckexposure $catdir mjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i raw
     157  for i 0 mjd_uc[]
    153158    ckexposure $catdir mjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i raw
    154     break
    155   end
    156   for i 0 mjd_nc[] 3
     159  end
     160  for i 0 mjd_nc[]
    157161    ckexposure $catdir mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i raw
    158162  end
    159163
    160164  # run setphot on the db and check that the images now match the expected values
    161   exec setphot -update -ubercal testzpt.fits -D CATDIR $catdir
    162   for i 0 mjd_uc[] 3
     165  tapEXEC setphot -update -ubercal testzpt.fits -D CATDIR $catdir
     166  for i 0 mjd_uc[]
    163167    ckexposure $catdir mjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i setphot_uc
    164168  end
    165   for i 0 mjd_nc[] 3
     169  for i 0 mjd_nc[]
    166170    ckexposure $catdir mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i setphot_nc
    167171  end
    168172
    169173  # run relphot on the db and check that the images now match the expected values
    170   exec relphot g,r,i -v -region 9.5 10.5 19.5 20.5 -D CATDIR $catdir -D STAR_TOOFEW 1 -D SIGMA_LIM 0.07 -statmode WT_MEAN -cloud-limit 0.5 -keep-ubercal -D IMAGE_OFFSET 0.5 -update >& tmp.log
    171   for i 0 mjd_uc[] 3
     174  tapEXEC relphot -images g,r -v -region 9.5 10.5 19.5 20.5 -D CATDIR $catdir -D STAR_TOOFEW 1 -D SIGMA_LIM 0.07 -statmode WT_MEAN -cloud-limit 0.5 -D IMAGE_OFFSET 0.5 -update
     175  for i 0 mjd_uc[]
    172176    ckexposure $catdir mjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i relphot
    173177  end
    174   for i 0 mjd_nc[] 3
     178  for i 0 mjd_nc[]
    175179    ckexposure $catdir mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i relphot
    176180  end
     
    253257  end
    254258
    255   set cell_xbin = int(xccd / ($CHIP_DX / $NCELL_X))
    256   set cell_ybin = int(yccd / ($CHIP_DY / $NCELL_Y))
     259  # 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))))
    257262  subset dm00 = dm if (cell_xbin == 0) && (cell_ybin == 0)
    258263  subset dm01 = dm if (cell_xbin == 0) && (cell_ybin == 1)
     
    282287 
    283288        set dm_adjust = dm$ix\$iy - $ZPT_NOMINAL + $ZPT_REAL_NORM + cell_off[$ix][$iy]
    284         echo set dm_adjust = dm$ix\$iy - $ZPT_NOMINAL + $ZPT_REAL_NORM + cell_off[$ix][$iy]
    285 
    286         vstat dm_adjust
    287         tapOK {abs($MEAN) < 0.005} "addstar raw ZP $MJD_IMAGE $FILTER"
     289        # echo set dm_adjust = dm$ix\$iy - $ZPT_NOMINAL + $ZPT_REAL_NORM + cell_off[$ix][$iy]
     290
     291        vstat -q dm_adjust
     292        sprintf line "addstar raw ZP %8.2f $FILTER %6.3f %6.3f %6.3f: %7.4f %7.4f : cell%d%d %6.3f : %3d" $MJD_IMAGE $ZPT_REAL $ZPT_REAL_NORM $ZPT_NOMINAL $MEAN $SIGMA $ix $iy cell_off[$ix][$iy] dm_adjust[]
     293        tapOK {abs($MEAN) < 0.005} "$line"
    288294      end
    289295    end
     
    293299  if ("$MODE" == "setphot_uc")
    294300    vstat -q dm
    295     tapOK {abs($MEAN) < 0.005} "setphot_uc  ZP $MJD_IMAGE $FILTER"
     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[]
     302    tapOK {abs($MEAN) < 0.005} "$line"
    296303    return
    297304  end
     
    299306  if ("$MODE" == "setphot_nc")
    300307    vstat -q dm
    301     tapOK {abs($MEAN - $ZPT_NOMINAL + $ZPT_REAL_NORM) < 0.005} "setphot_nc  ZP $MJD_IMAGE $FILTER"
     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[]
     309    tapOK {abs($MEAN - $ZPT_NOMINAL + $ZPT_REAL_NORM) < 0.005} "$line"
    302310    return
    303311  end
     
    305313  if ("$MODE" == "relphot")
    306314    vstat -q dm
    307     tapOK {abs($MEAN) < 0.005} "relphot    ZP $MJD_IMAGE $FILTER"
     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[]
     316    tapOK {abs($MEAN) < 0.005} "$line"
    308317    return
    309318  end
     
    320329
    321330  # we have defined a set of mjd and zero point values for ubercal'ed images
    322   # for i 0 mjd_uc[]
    323   for i 0 mjd_uc[] 1
     331  for i 0 mjd_uc[]
    324332    mkexposure $1.uc.$i $RA_CENTER $DEC_CENTER zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] mjd_uc[$i] $filt_uc:$i $2
    325333  end
    326   return
    327334
    328335  # we have a second set of mjd and zero point values for non-ubercal'ed images
    329   # for i 0 mjd_nc[]
    330   for i 0 mjd_nc[] 1
     336  for i 0 mjd_nc[]
    331337    mkexposure $1.nc.$i $RA_CENTER $DEC_CENTER zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] mjd_nc[$i] $filt_nc:$i $2
    332338  end
     
    339345 end
    340346
    341  local ix iy date time datetime ra dec ROOT RAo DECo ZPT MJD FILTER EXPTIME AIRMASS CATDIR
     347 local ix iy date time datetime ra dec ROOT RAo DECo ZPT MJD FILTER EXPTIME AIRMASS CATDIR cmd
    342348
    343349 $ROOT    = $1
     
    379385    $options = $options -airmass $AIRMASS
    380386    $options = $options -exptime $EXPTIME
    381     exec mkcmf test.in.txt $ROOT.$ix.$iy.cmf $options
    382     echo mkcmf test.in.txt $ROOT.$ix.$iy.cmf $options
    383    
     387
     388    tapEXEC mkcmf test.in.txt $ROOT.$ix.$iy.cmf $options
     389
    384390    # the fake images have inconsistent ra,dec and airmass,sidtime values
    385     echo addstar $ROOT.$ix.$iy.cmf -D CATDIR $CATDIR -D CAMERA gpc1 -quick-airmass
    386     exec addstar $ROOT.$ix.$iy.cmf -D CATDIR $CATDIR -D CAMERA gpc1 -quick-airmass
    387   end
    388   return
     391    tapEXEC addstar $ROOT.$ix.$iy.cmf -D CATDIR $CATDIR -D CAMERA gpc1 -quick-airmass
     392  end
    389393 end
    390394end
     
    411415  subset stars_mr = stars_mag if valid
    412416
    413   set cell_x = int(stars_x / ($CHIP_DX / $NCELL_X))
    414   set cell_y = int(stars_y / ($CHIP_DX / $NCELL_X))
     417  # note eddie's esoteric padding rule:
     418  set cell_x = max(0 , min(1 , int((stars_x +  8) / ($CHIP_DX / $NCELL_X))))
     419  set cell_y = max(0 , min(1 , int((stars_y + 10) / ($CHIP_DX / $NCELL_X))))
    415420
    416421  # eddie says: M_real = M_inst + zpt + ff_offset
     
    471476  # create a single flat-field correction map for a single chip
    472477  mcreate cell_off 2 2
    473   cell_off[0][0] =  0.01
    474   cell_off[1][0] = -0.01
    475   cell_off[0][1] =  0.02
    476   cell_off[1][1] = -0.02
     478  if ($USE_CELL_OFFSETS)
     479    cell_off[0][0] =  0.05
     480    cell_off[1][0] = -0.03
     481    cell_off[0][1] =  0.08
     482    cell_off[1][1] = -0.10
     483  end
    477484
    478485  # in the correction table, we have an image of the full exposure
     
    487494    for iyc 0 $NCELL_Y
    488495      for ix 0 $NCHIP_X
     496        set tcell_off = cell_off
     497        if ($ix < 4)
     498          rotate tcell_off 180
     499        end
    489500        for ixc 0 $NCELL_X
    490           concat cell_off[$ixc][$iyc] image_offset
     501          concat tcell_off[$ixc][$iyc] image_offset
    491502        end
    492503      end
     
    504515  set mjd_obs = mjd_uc
    505516  set zp = zpt_uc
    506   set resid = 0.02*rnd(zpt_uc) - 0.01
     517
     518  if ($SET_UC_RESID)
     519    set resid = 0.02*rnd(zpt_uc) - 0.01
     520  else
     521    set resid = zero(zpt_uc)
     522  end
    507523
    508524  delete -q flatcorr
  • branches/eam_branches/ipp-20150419/Ohana/src/addstar/test/tap.dvo

    r34405 r38304  
    33if (not($?TAP_BREAK)) set TAP_BREAK = 0
    44if (not($?TAP_VERBOSE)) set TAP_VERBOSE = 0
     5
     6macro tapEXEC
     7  if ($0 < 3)
     8    echo "USAGE: tapEXEC (command)"
     9    break
     10  end
     11
     12  local i cmd result
     13
     14  $cmd = ""
     15  for i 1 $0
     16    $cmd = $cmd $$i
     17  end
     18
     19  if ($TAP_VERBOSE >= 2) echo $cmd
     20
     21  break -auto off
     22  exec $cmd >& tap.log
     23  $result = $STATUS
     24  break -auto on
     25
     26  if (not($result))
     27    exec cat tap.log
     28    echo "not ok : $cmd"
     29    $TAP_NFAIL ++
     30    $TAP_LAST = 0
     31    if ($TAP_BREAK)
     32     break
     33    end
     34  else
     35    if ($TAP_VERBOSE >= 1) echo "ok : $cmd"
     36    $TAP_LAST = 1
     37  end
     38  $TAP_NDONE ++
     39end
    540
    641macro tapOK
     
    1146
    1247  if ($1)
    13     if ($TAP_VERBOSE)
     48    if ($TAP_VERBOSE >= 1)
    1449      echo "ok : $2"
    1550    end
Note: See TracChangeset for help on using the changeset viewer.