Changeset 33329
- Timestamp:
- Feb 22, 2012, 8:20:17 AM (14 years ago)
- Location:
- branches/eam_branches/ipp-20111122/Ohana/src/uniphot
- Files:
-
- 4 edited
-
include/setphot.h (modified) (1 diff)
-
src/initialize_setphot.c (modified) (2 diffs)
-
src/load_zpt_table.c (modified) (1 diff)
-
src/match_zpts_to_images.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/include/setphot.h
r33303 r33329 69 69 ZptTable *load_zpt_ubercal_nometadata PROTO((char *filename, int *nzpts, FlatCorrectionTable *flatcorrTable)); 70 70 int match_flatcorr_to_images PROTO((Image *image, off_t Nimage, FlatCorrectionTable *flatcorrTable)); 71 72 int parse_zpt_offsets PROTO((char *ZPT_OFFSET_FILTERS, char *ZPT_OFFSET_VALUES)); 73 float apply_zpt_offset PROTO((short code)); -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/initialize_setphot.c
r33303 r33329 84 84 } 85 85 86 // -zpt-offsets code[,code,etc] value[,value,etc] 87 // eg: -zpt-offsets g,r,i 0.01,0.02,-0.02 88 char *ZPT_OFFSETS_FILTERS = NULL; 89 char *ZPT_OFFSETS_VALUES = NULL; 90 if ((N = get_argument (argc, argv, "-zpt-offsets"))) { 91 remove_argument (N, &argc, argv); 92 ZPT_OFFSETS_FILTERS = strcreate (argv[N]); 93 remove_argument (N, &argc, argv); 94 ZPT_OFFSETS_VALUES = strcreate (argv[N]); 95 remove_argument (N, &argc, argv); 96 97 parse_zpt_offsets (ZPT_OFFSETS_FILTERS, ZPT_OFFSETS_VALUES); 98 } 99 100 86 101 if (argc != 2) { 87 102 fprintf (stderr, "USAGE: setphot (zptfile) [options]\n"); … … 89 104 fprintf (stderr, " -v : verbose mode\n"); 90 105 fprintf (stderr, " -ubercal : interpret zpt file as a GPC1 ubercal FITS table\n"); 106 fprintf (stderr, " -no-metadata : assume the ubercal FITS table has the layout defined by Eddie Schlafly in Dec 2011\n"); 91 107 fprintf (stderr, " -update : actually write results to detections tables\n"); 92 108 fprintf (stderr, " Note that the dvo db can be specified by -D CATDIR (directory)\n"); -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/load_zpt_table.c
r33241 r33329 350 350 return zpts; 351 351 } 352 353 static short maxCode = 0; 354 static short *zpt_codeval = NULL; 355 static float *zpt_offsets = NULL; 356 static short *zpt_index = NULL; 357 358 int parse_zpt_offsets (char *ZPT_OFFSET_FILTERS, char *ZPT_OFFSET_VALUES) { 359 360 assert (ZPT_OFFSET_FILTERS); 361 assert (ZPT_OFFSET_VALUES); 362 363 char *filters = strcreate(ZPT_OFFSET_FILTERS); 364 char *values = strcreate(ZPT_OFFSET_VALUES); 365 366 char *p1 = filters; 367 char *p2 = values; 368 369 char *filter = NULL; 370 char *value = NULL; 371 372 char *s1 = NULL; 373 char *s2 = NULL; 374 375 // save an array of the zero point offsets and their photcodes 376 int Ncode = 0; 377 int NCODE = 8; 378 ALLOCATE (zpt_codeval, short, NCODE); 379 ALLOCATE (zpt_offsets, float, NCODE); 380 381 while (1) { 382 filter = strtok_r (p1, ",", &s1); 383 if (!filter) break; 384 385 value = strtok_r (p2, ",", &s2); 386 if (!value) { 387 fprintf (stderr, "ERROR: mismatch between list of photcodes and list of offsets\n"); 388 exit (1); 389 } 390 391 // do something here 392 PhotCode *code = GetPhotcodebyName (filter); 393 if (!code) { 394 fprintf (stderr, "ERROR: unknown photcode %s\n", filter); 395 exit (1); 396 } 397 if (code->type != PHOT_SEC) { 398 fprintf (stderr, "ERROR: photcode %s is not an average (SEC) type\n", filter); 399 exit (1); 400 } 401 402 zpt_codeval[Ncode] = code->code; 403 zpt_offsets[Ncode] = atof(value); 404 Ncode ++; 405 406 if (Ncode >= NCODE) { 407 NCODE += 8; 408 REALLOCATE (zpt_codeval, short, NCODE); 409 REALLOCATE (zpt_offsets, float, NCODE); 410 } 411 412 maxCode = MAX(code->code, maxCode); 413 414 p1 = NULL; 415 p2 = NULL; 416 } 417 418 // generate an index to the zpt offsets by the photcode 419 ALLOCATE (zpt_index, short, maxCode + 1); 420 421 int i; 422 for (i = 0; i < maxCode + 1; i++) { 423 zpt_index[i] = -1; 424 } 425 426 for (i = 0; i < Ncode; i++) { 427 short seq = zpt_codeval[i]; 428 if (zpt_index[seq] != -1) { 429 fprintf (stderr, "duplicate photcode in -zpt-offset list\n"); 430 exit (2); 431 } 432 zpt_index[seq] = i; 433 } 434 return TRUE; 435 } 436 437 float apply_zpt_offset (short code) { 438 439 if (!zpt_offsets) return 0.0; 440 441 // code is a primary photcode (but may be out of range, in which case no correction is supplied) 442 if (code <= 0) return 0.0; 443 if (code > maxCode) return 0.0; 444 445 short index = zpt_index[code]; 446 if (index == -1) return 0.0; 447 448 float offset = zpt_offsets[index]; 449 return offset; 450 } -
branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/match_zpts_to_images.c
r33303 r33329 84 84 image[Ni].Mcal = SCALE*code[0].C - zpts[Nz].zpt; 85 85 } 86 87 // if we have defined zero point offsets, then apply them here 88 float offset = apply_zpt_offset (code[0].equiv); 89 assert (isfinite(offset)); 90 image[Ni].Mcal += offset; 91 86 92 image[Ni].dMcal = zpts[Nz].zpt_err; 87 93 image[Ni].flags &= ~ID_IMAGE_PHOTOM_NOCAL; // clear the NOCAL flag
Note:
See TracChangeset
for help on using the changeset viewer.
