Changeset 33376
- Timestamp:
- Feb 27, 2012, 11:38:59 AM (14 years ago)
- Location:
- branches/eam_branches/ipp-20111122/Ohana/src/addstar
- Files:
-
- 1 added
- 1 edited
-
src/mkcmf.c (modified) (10 diffs)
-
test/relphot.reject.dvo (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111122/Ohana/src/addstar/src/mkcmf.c
r33279 r33376 14 14 void gauss_init (int Nbin); 15 15 double rnd_gauss (double mean, double sigma); 16 void writeStars_PS1_V2 (FTable *ftable, double *X, double *Y, double *M, int Nstars);16 void writeStars_PS1_V2 (FTable *ftable, double *X, double *Y, double *M, int *Flag, int Nstars); 17 17 void writeStars_PS1_V1 (FTable *ftable, double *X, double *Y, double *M, int Nstars); 18 18 void writeStars_PS1_DEV_1 (FTable *ftable, double *X, double *Y, double *M, int Nstars); … … 20 20 21 21 int ADDNOISE = TRUE; 22 float BAD_PSFQF_FRAC = 0.0; 22 23 23 24 int main (int argc, char **argv) { … … 26 27 // load a text table with X,Y,Mag (instrumental?) 27 28 28 int N, Nstars, NSTARS, found ;29 int N, Nstars, NSTARS, found, *Flag; 29 30 double *X, *Y, *M, Xmax, Ymax; 30 31 … … 125 126 } 126 127 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 127 135 // add support for all cmf types 128 136 ADDNOISE = TRUE; … … 130 138 remove_argument (N, &argc, argv); 131 139 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); 132 147 } 133 148 … … 166 181 ALLOCATE (Y, double, NSTARS); 167 182 ALLOCATE (M, double, NSTARS); 183 ALLOCATE (Flag, int, NSTARS); 168 184 169 185 Xmax = Ymax = 0; 170 186 while (1) { 171 187 int status; 188 double ra, dec, mag, xobs, yobs, xraw, yraw, mraw; 189 int flags; 172 190 if (FROM_COORDS) { 173 double ra, dec, mag, xraw, yraw, mraw;174 191 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); 177 202 } 178 M[Nstars] = mraw;203 Flag[Nstars] = mraw; 179 204 } 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 184 212 Xmax = MAX(Xmax, X[Nstars]); 185 213 Ymax = MAX(Ymax, Y[Nstars]); … … 190 218 REALLOCATE (Y, double, NSTARS); 191 219 REALLOCATE (M, double, NSTARS); 220 REALLOCATE (Flag, int, NSTARS); 192 221 } 193 222 Nstars ++; … … 488 517 } 489 518 490 void writeStars_PS1_V2 (FTable *ftable, double *X, double *Y, double *M, int Nstars) {519 void writeStars_PS1_V2 (FTable *ftable, double *X, double *Y, double *M, int *Flag, int Nstars) { 491 520 492 521 int i; … … 514 543 } 515 544 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 516 552 stars[i].dX = FX * fSN; 517 553 stars[i].dY = FY * fSN; … … 527 563 stars[i].fy = FY; 528 564 stars[i].df = DF; 529 stars[i].psfQual = PSFQUAL;530 565 stars[i].nFrames = 1; 531 stars[i].flags = F LAGS;566 stars[i].flags = Flag[i]; 532 567 } 533 568
Note:
See TracChangeset
for help on using the changeset viewer.
