IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33388


Ignore:
Timestamp:
Feb 29, 2012, 9:57:20 AM (14 years ago)
Author:
eugene
Message:

working on test script

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

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20111122/Ohana/src/addstar/src/mkcmf.c

    r33376 r33388  
    1414void gauss_init (int Nbin);
    1515double rnd_gauss (double mean, double sigma);
    16 void writeStars_PS1_V2 (FTable *ftable, double *X, double *Y, double *M, int *Flag, int Nstars);
     16void writeStars_PS1_V2 (FTable *ftable, double *X, double *Y, double *M, unsigned int *Flag, int Nstars);
    1717void writeStars_PS1_V1 (FTable *ftable, double *X, double *Y, double *M, int Nstars);
    1818void writeStars_PS1_DEV_1 (FTable *ftable, double *X, double *Y, double *M, int Nstars);
     
    2727  // load a text table with X,Y,Mag (instrumental?)
    2828
    29   int N, Nstars, NSTARS, found, *Flag;
     29  int N, Nstars, NSTARS, found;
     30  unsigned int *Flag;
    3031  double *X, *Y, *M, Xmax, Ymax;
    3132
     
    181182  ALLOCATE (Y, double, NSTARS);
    182183  ALLOCATE (M, double, NSTARS);
    183   ALLOCATE (Flag, int, NSTARS);
     184  ALLOCATE (Flag, unsigned int, NSTARS);
    184185
    185186  Xmax = Ymax = 0;
     
    187188    int status;
    188189    double ra, dec, mag, xobs, yobs, xraw, yraw, mraw;
    189     int flags;
     190    unsigned int flags;
    190191    if (FROM_COORDS) {
    191192      status = fscanf (f, "%lf %lf %lf %lf %lf %lf", &ra, &dec, &mag, &xraw, &yraw, &mraw);
     
    196197    if (status == EOF) break;
    197198    if (READ_FLAGS) {
    198       status = fscanf (f, "%d", &flags);
     199      status = fscanf (f, "%x", &flags);
    199200      if (status == EOF) {
    200201          fprintf (stderr, "error: missing flag for last star?\n");
    201202          exit (1);
    202203      }
    203       Flag[Nstars] = mraw;
     204      Flag[Nstars] = flags;
    204205    } else {
    205206      Flag[Nstars] = 0;
     
    218219      REALLOCATE (Y, double, NSTARS);
    219220      REALLOCATE (M, double, NSTARS);
    220       REALLOCATE (Flag, int, NSTARS);
     221      REALLOCATE (Flag, unsigned int, NSTARS);
    221222    }
    222223    Nstars ++;
     
    274275  }
    275276  if (!strcmp(type, "PS1_V2")) {
    276     writeStars_PS1_V2 (&ftable, X, Y, M, Nstars);
     277    writeStars_PS1_V2 (&ftable, X, Y, M, Flag, Nstars);
    277278    found = TRUE;
    278279  }
     
    517518}
    518519
    519 void writeStars_PS1_V2 (FTable *ftable, double *X, double *Y, double *M, int *Flag, int Nstars) {
     520void writeStars_PS1_V2 (FTable *ftable, double *X, double *Y, double *M, unsigned int *Flag, int Nstars) {
    520521
    521522  int i;
     
    544545
    545546    // randomly give poor PSFQF values
    546     if ((BAD_PSFQF_FRAC > 0.0) && (drand48() < BAD_PSFQF_FRAC*Nstars)) {
     547    if ((BAD_PSFQF_FRAC > 0.0) && (drand48() < BAD_PSFQF_FRAC)) {
    547548      stars[i].psfQual   = 0.25;
    548549    } else {
  • branches/eam_branches/ipp-20111122/Ohana/src/addstar/test/relphot.reject.dvo

    r33376 r33388  
    3333  $CHIP_DX = 1000
    3434  $CHIP_DY = 1000
     35  $DEFECT_FRAC = 0.03
    3536  if (not($?VERBOSE)) set VERBOSE = 0
    3637
     
    5253
    5354  # sequence to count images (only used in this function)
    54   create tmpseq 0 9
     55  # XXX  TEST create tmpseq 0 9
     56  create tmpseq 0 3
    5557
    5658  ##### mjd and zpt values for ubercal'ed images
    5759
    58   $filt_uc:n = 9
     60  $filt_uc:n = tmpseq[]
    5961  create filtN_uc 0 $filt_uc:n
    6062  $filt_uc:0 = g;  filtN_uc[0] = 1
    6163  $filt_uc:1 = g;  filtN_uc[1] = 1
    6264  $filt_uc:2 = g;  filtN_uc[2] = 1
    63   $filt_uc:3 = r;  filtN_uc[3] = 2
    64   $filt_uc:4 = r;  filtN_uc[4] = 2
    65   $filt_uc:5 = r;  filtN_uc[5] = 2
    66   $filt_uc:6 = i;  filtN_uc[6] = 3
    67   $filt_uc:7 = i;  filtN_uc[7] = 3
    68   $filt_uc:8 = i;  filtN_uc[8] = 3
     65  # $filt_uc:3 = r;  filtN_uc[3] = 2
     66  # $filt_uc:4 = r;  filtN_uc[4] = 2
     67  # $filt_uc:5 = r;  filtN_uc[5] = 2
     68  # $filt_uc:6 = i;  filtN_uc[6] = 3
     69  # $filt_uc:7 = i;  filtN_uc[7] = 3
     70  # $filt_uc:8 = i;  filtN_uc[8] = 3
    6971
    7072  # airmass slopes for this sequnece
     
    8587  mjd_uc[1] = 55000.02
    8688  mjd_uc[2] = 55000.03
    87   mjd_uc[3] = 55015.01
    88   mjd_uc[4] = 55015.02
    89   mjd_uc[5] = 55015.03
    90   mjd_uc[6] = 55025.01
    91   mjd_uc[7] = 55025.02
    92   mjd_uc[8] = 55025.03
     89  # mjd_uc[3] = 55015.01
     90  # mjd_uc[4] = 55015.02
     91  # mjd_uc[5] = 55015.03
     92  # mjd_uc[6] = 55025.01
     93  # mjd_uc[7] = 55025.02
     94  # mjd_uc[8] = 55025.03
    9395
    9496  ##### mjd and zpt values for not-ubercal'ed images
    9597
    96   $filt_nc:n = 9
     98  $filt_nc:n = tmpseq[]
    9799  create filtN_nc 0 $filt_nc:n
    98100  $filt_nc:0 = g;  filtN_nc[0] = 1
    99101  $filt_nc:1 = g;  filtN_nc[1] = 1
    100102  $filt_nc:2 = g;  filtN_nc[2] = 1
    101   $filt_nc:3 = r;  filtN_nc[3] = 2
    102   $filt_nc:4 = r;  filtN_nc[4] = 2
    103   $filt_nc:5 = r;  filtN_nc[5] = 2
    104   $filt_nc:6 = i;  filtN_nc[6] = 3
    105   $filt_nc:7 = i;  filtN_nc[7] = 3
    106   $filt_nc:8 = i;  filtN_nc[8] = 3
     103  # $filt_nc:3 = r;  filtN_nc[3] = 2
     104  # $filt_nc:4 = r;  filtN_nc[4] = 2
     105  # $filt_nc:5 = r;  filtN_nc[5] = 2
     106  # $filt_nc:6 = i;  filtN_nc[6] = 3
     107  # $filt_nc:7 = i;  filtN_nc[7] = 3
     108  # $filt_nc:8 = i;  filtN_nc[8] = 3
    107109
    108110  # airmass slopes for these sequnece
     
    124126  mjd_nc[1] = 55000.12
    125127  mjd_nc[2] = 55000.13
    126   mjd_nc[3] = 55015.11
    127   mjd_nc[4] = 55015.12
    128   mjd_nc[5] = 55015.13
    129   mjd_nc[6] = 55025.11
    130   mjd_nc[7] = 55025.12
    131   mjd_nc[8] = 55025.13
     128  # mjd_nc[3] = 55015.11
     129  # mjd_nc[4] = 55015.12
     130  # mjd_nc[5] = 55015.13
     131  # mjd_nc[6] = 55025.11
     132  # mjd_nc[7] = 55025.12
     133  # mjd_nc[8] = 55025.13
    132134end
    133135
     
    163165  end
    164166
    165   # parallel-ize the database (goes to $catdir.p0)
    166   mkparallel $catdir
    167 
    168   ### SERIAL database tests
    169 
    170167  # run setphot on the serial db and check that the images now match the expected values
    171168  exec setphot -reset -update -ubercal testzpt.fits -D CATDIR $catdir
     
    178175
    179176  # run relphot on the serial db and check that the images now match the expected values
     177  if ($VERBOSE) echo 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 >& log.relphot.s0
    180178  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 >& log.relphot.s0
    181179  for i 0 mjd_uc[]
     
    186184  end
    187185
    188   ### PARALLEL database tests
    189 
    190   # run setphot on the parallel db and check that the images now match the expected values
    191   exec setphot -reset -parallel -update -ubercal testzpt.fits -D CATDIR $catdir.p0
    192 
    193   # bring the detections back to the local db
    194   # exec dvodist -in $catdir.p0 >& log.dvodist.in
    195   # XXX this should now not be needed
    196 
    197   # check the results
    198   for i 0 mjd_uc[]
    199     ckexposure $catdir.p0 mjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i setphot_uc
    200   end
    201   for i 0 mjd_nc[]
    202     ckexposure $catdir.p0 mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i setphot_nc
    203   end
    204 
    205   # run relphot on the parallel db and check that the images now match the expected values
    206   exec relphot -parallel g,r,i -v -region 9.5 10.5 19.5 20.5 -D CATDIR $catdir.p0 -D STAR_TOOFEW 1 -D SIGMA_LIM 0.07 -statmode WT_MEAN -cloud-limit 0.5 -keep-ubercal -D IMAGE_OFFSET 0.5 -update >& log.relphot.p0
    207 
    208   for i 0 mjd_uc[]
    209     ckexposure $catdir.p0 mjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i relphot
    210   end
    211   for i 0 mjd_nc[]
    212     ckexposure $catdir.p0 mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i relphot
    213   end
    214 
    215186  tapDONE
    216 end
    217 
    218 macro qt
    219 
    220   ## SER
    221 
    222   # run setphot on the serial db and check that the images now match the expected values
    223   exec setphot -reset -update -ubercal testzpt.fits -D CATDIR $catdir
    224   for i 0 mjd_uc[]
    225     ckexposure $catdir mjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i setphot_uc
    226   end
    227   for i 0 mjd_nc[]
    228     ckexposure $catdir mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i setphot_nc
    229   end
    230 
    231   # run relphot on the serial db and check that the images now match the expected values
    232   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 >& log.relphot.s0
    233   for i 0 mjd_uc[]
    234     ckexposure $catdir mjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i relphot
    235   end
    236   for i 0 mjd_nc[]
    237     ckexposure $catdir mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i relphot
    238   end
    239 
    240   ## PAR
    241 
    242   # run setphot on the parallel db and check that the images now match the expected values
    243   exec setphot -reset -parallel -update -ubercal testzpt.fits -D CATDIR $catdir.p0
    244 
    245   # check the results
    246   for i 0 mjd_uc[]
    247     ckexposure $catdir.p0 mjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i setphot_uc
    248   end
    249   for i 0 mjd_nc[]
    250     ckexposure $catdir.p0 mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i setphot_nc
    251   end
    252  
    253   # run relphot on the parallel db and check that the images now match the expected values
    254   exec relphot -parallel g,r,i -v -region 9.5 10.5 19.5 20.5 -D CATDIR $catdir.p0 -D STAR_TOOFEW 1 -D SIGMA_LIM 0.07 -statmode WT_MEAN -cloud-limit 0.5 -keep-ubercal -D IMAGE_OFFSET 0.5 -update >& log.relphot.p0
    255 
    256   for i 0 mjd_uc[]
    257     ckexposure $catdir.p0 mjd_uc[$i] zpt_uc[$i] exptime_uc[$i] airmass_uc[$i] $filt_uc:$i relphot
    258   end
    259   for i 0 mjd_nc[]
    260     ckexposure $catdir.p0 mjd_nc[$i] zpt_nc[$i] exptime_nc[$i] airmass_nc[$i] $filt_nc:$i relphot
    261   end
    262187end
    263188
     
    456381    $options = $options -photcode GPC1.$FILTER.XY$ix\$iy
    457382    $options = $options -no-noise
     383    $options = $options -flags
     384    $options = $options -bad-psfqf-frac $DEFECT_FRAC
    458385    $options = $options -size $CHIP_DX $CHIP_DY
    459386    $options = $options -crpix {0.5*$CHIP_DX} {0.5*$CHIP_DY}
     
    512439  end
    513440 
    514   # XXX REJECT : I can deviate a single object here easily (save to a file)
    515   # how to set flags?
    516   # need to update mkcmf to read in flags values, set them here manually
     441  # create bad detections / detections to ignore or avoid, save to a file?
     442
     443  # create 3 types of things to ignore / avoid
     444  # * badPhot (deviate the photometry)
     445  # * badFlag (set a bad flag bit)
     446  # * poorFlag (set a bad flag bit)
     447  set badPhot  = rnd(stars_r) <  $DEFECT_FRAC
     448  set badFlag  = rnd(stars_r) <  $DEFECT_FRAC
     449  set poorFlag = rnd(stars_r) <  $DEFECT_FRAC
     450
     451  # create deviant photometry (1%)
     452  # I'm setting the flag value 0x02 (EXTMODEL) if the object is deviated.  This is a simple way to pass the info
     453  set stars_mi = stars_mi + 0.2*badPhot
     454  set stars_fl = zero(stars_mi) + 0x00000080*badFlag + 0x00000100*poorFlag + 0x00000002*badPhot
     455
     456  # bad flags that we sould respect:
     457  # PM_SOURCE_MODE_FAIL             = 0x00000008, ///< Fit (non-linear) failed (non-converge, off-edge, run to zero)
     458  # PM_SOURCE_MODE_SATSTAR          = 0x00000080, ///< Source model peak is above saturation
     459  # PM_SOURCE_MODE_BADPSF           = 0x00000400, ///< Failed to get good estimate of object's PSF
     460  # PM_SOURCE_MODE_DEFECT           = 0x00000800, ///< Source is thought to be a defect
     461  # PM_SOURCE_MODE_SATURATED        = 0x00001000, ///< Source is thought to be saturated pixels (bleed trail)
     462  # PM_SOURCE_MODE_CR_LIMIT         = 0x00002000, ///< Source has crNsigma above limit
     463  # PM_SOURCE_MODE_MOMENTS_FAILURE  = 0x00008000, ///< could not measure the moments
     464  # PM_SOURCE_MODE_SKY_FAILURE      = 0x00010000, ///< could not measure the local sky
     465  # PM_SOURCE_MODE_SKYVAR_FAILURE   = 0x00020000, ///< could not measure the local sky variance
     466  # PM_SOURCE_MODE_SIZE_SKIPPED     = 0x10000000, ///< size could not be determined
     467
     468  # poor flags that we should respect:
     469  # PM_SOURCE_MODE_POOR             = 0x00000010, ///< Fit succeeds, but low-SN, high-Chisq, or large (for PSF -- drop?)
     470  # PM_SOURCE_MODE_PAIR             = 0x00000020, ///< Source fitted with a double psf
     471  # PM_SOURCE_MODE_BLEND            = 0x00000100, ///< Source is a blend with other sources
     472  # PM_SOURCE_MODE_BELOW_MOMENTS_SN = 0x00040000, ///< moments not measured due to low S/N
     473  # PM_SOURCE_MODE_BLEND_FIT        = 0x00400000, ///< source was fitted as a blend
     474  # PM_SOURCE_MODE_ON_SPIKE         = 0x20000000, ///< peak lands on diffraction spike
     475  # PM_SOURCE_MODE_ON_GHOST         = 0x40000000, ///< peak lands on ghost or glint
     476  # PM_SOURCE_MODE_OFF_CHIP         = 0x80000000, ///< peak lands off edge of chip
    517477
    518478  # delete the output file before writing
    519479  exec rm -f $1
    520   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
     480  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
    521481end
    522482
Note: See TracChangeset for help on using the changeset viewer.