IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33376


Ignore:
Timestamp:
Feb 27, 2012, 11:38:59 AM (14 years ago)
Author:
eugene
Message:

relphot tests

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

Legend:

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

    r33279 r33376  
    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 Nstars);
     16void writeStars_PS1_V2 (FTable *ftable, double *X, double *Y, double *M, 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);
     
    2020
    2121int ADDNOISE = TRUE;
     22float BAD_PSFQF_FRAC = 0.0;
    2223
    2324int main (int argc, char **argv) {
     
    2627  // load a text table with X,Y,Mag (instrumental?)
    2728
    28   int N, Nstars, NSTARS, found;
     29  int N, Nstars, NSTARS, found, *Flag;
    2930  double *X, *Y, *M, Xmax, Ymax;
    3031
     
    125126  }
    126127
     128  // expect a field with the photom flags for each detection
     129  int READ_FLAGS = FALSE;
     130  if ((N = get_argument (argc, argv, "-flags"))) {
     131    remove_argument (N, &argc, argv);
     132    READ_FLAGS = TRUE;
     133  }
     134
    127135  // add support for all cmf types
    128136  ADDNOISE = TRUE;
     
    130138    remove_argument (N, &argc, argv);
    131139    ADDNOISE = FALSE;
     140  }
     141
     142  // random bad PSF_QF values
     143  if ((N = get_argument (argc, argv, "-bad-psfqf-frac"))) {
     144    remove_argument (N, &argc, argv);
     145    BAD_PSFQF_FRAC = atof(argv[N]);
     146    remove_argument (N, &argc, argv);
    132147  }
    133148
     
    166181  ALLOCATE (Y, double, NSTARS);
    167182  ALLOCATE (M, double, NSTARS);
     183  ALLOCATE (Flag, int, NSTARS);
    168184
    169185  Xmax = Ymax = 0;
    170186  while (1) {
    171187    int status;
     188    double ra, dec, mag, xobs, yobs, xraw, yraw, mraw;
     189    int flags;
    172190    if (FROM_COORDS) {
    173       double ra, dec, mag, xraw, yraw, mraw;
    174191      status = fscanf (f, "%lf %lf %lf %lf %lf %lf", &ra, &dec, &mag, &xraw, &yraw, &mraw);
    175       if (status != EOF) {
    176         RD_to_XY (&X[Nstars], &Y[Nstars], ra, dec, &coords);
     192      RD_to_XY (&xobs, &yobs, ra, dec, &coords);
     193    } else {
     194      status = fscanf (f, "%lf %lf %lf", &xobs, &yobs, &mraw);
     195    }
     196    if (status == EOF) break;
     197    if (READ_FLAGS) {
     198      status = fscanf (f, "%d", &flags);
     199      if (status == EOF) {
     200          fprintf (stderr, "error: missing flag for last star?\n");
     201          exit (1);
    177202      }
    178       M[Nstars] = mraw;
     203      Flag[Nstars] = mraw;
    179204    } else {
    180       status = fscanf (f, "%lf %lf %lf", &X[Nstars], &Y[Nstars], &M[Nstars]);
    181     }
    182     if (status == EOF) break;
    183    
     205      Flag[Nstars] = 0;
     206    }
     207
     208    X[Nstars] = xobs;
     209    Y[Nstars] = yobs;
     210    M[Nstars] = mraw;
     211
    184212    Xmax  = MAX(Xmax, X[Nstars]);
    185213    Ymax  = MAX(Ymax, Y[Nstars]);
     
    190218      REALLOCATE (Y, double, NSTARS);
    191219      REALLOCATE (M, double, NSTARS);
     220      REALLOCATE (Flag, int, NSTARS);
    192221    }
    193222    Nstars ++;
     
    488517}
    489518
    490 void writeStars_PS1_V2 (FTable *ftable, double *X, double *Y, double *M, int Nstars) {
     519void writeStars_PS1_V2 (FTable *ftable, double *X, double *Y, double *M, int *Flag, int Nstars) {
    491520
    492521  int i;
     
    514543    }
    515544
     545    // randomly give poor PSFQF values
     546    if ((BAD_PSFQF_FRAC > 0.0) && (drand48() < BAD_PSFQF_FRAC*Nstars)) {
     547      stars[i].psfQual   = 0.25;
     548    } else {
     549      stars[i].psfQual   = PSFQUAL;
     550    }
     551   
    516552    stars[i].dX = FX * fSN;
    517553    stars[i].dY = FY * fSN;
     
    527563    stars[i].fy        = FY;
    528564    stars[i].df        = DF;
    529     stars[i].psfQual   = PSFQUAL;
    530565    stars[i].nFrames   = 1;
    531     stars[i].flags     = FLAGS;
     566    stars[i].flags     = Flag[i];
    532567  }
    533568
Note: See TracChangeset for help on using the changeset viewer.