Changeset 38298
- Timestamp:
- May 21, 2015, 7:43:37 PM (11 years ago)
- Location:
- branches/eam_branches/ipp-20150419/Ohana/src/relphot
- Files:
-
- 8 edited
-
include/relphot.h (modified) (2 diffs)
-
src/StarOps.c (modified) (5 diffs)
-
src/args.c (modified) (1 diff)
-
src/reload_catalogs.c (modified) (2 diffs)
-
src/relphot_objects.c (modified) (2 diffs)
-
src/relphot_synthphot.c (modified) (1 diff)
-
src/setMrelCatalog.c (modified) (13 diffs)
-
src/synthetic_zpts.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20150419/Ohana/src/relphot/include/relphot.h
r38297 r38298 496 496 int setMrel_catalog_alt (Catalog *catalog, int Nc, int isSetMrelFinal, FlatCorrectionTable *flatcorr, SetMrelInfo *results, int Nsecfilt); 497 497 int setMrelAverageExposure (Catalog *catalog, int cat, off_t ave, int Nsecfilt, int isSetMrelFinal, FlatCorrectionTable *flatcorr, SetMrelInfo *results); 498 int setMrelAverageStack (Catalog *catalog, int cat, off_t ave, int Nsecfilt, FlatCorrectionTable *flatcorr , SetMrelInfo *results);498 int setMrelAverageStack (Catalog *catalog, int cat, off_t ave, int Nsecfilt, FlatCorrectionTable *flatcorr); 499 499 int setMrelAverageForcedWarp (Catalog *catalog, int cat, off_t ave, int Nsecfilt, FlatCorrectionTable *flatcorr, SetMrelInfo *results); 500 500 … … 565 565 int magStatsByRanking (StatDataSet *dataset, StatType *stats); 566 566 567 SynthZeroPoints *SynthZeroPointsLoad (char *filename); 567 int SynthZeroPointsLoad (char *filename); 568 SynthZeroPoints *SynthZeroPointsGet (); 568 569 569 570 int relphot_synthphot (int hostID, char *hostpath); -
branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/StarOps.c
r38297 r38298 253 253 254 254 for (i = 0; i < Ncatalog; i++) { 255 // pass == -1 for anything other than the final pass 256 switch (SET_MREL_VERSION) { 257 case 0: 258 setMrel_catalog (catalog, i, -1, flatcorr, &results, Nsecfilt); 259 break; 260 case 1: 261 setMrel_catalog_alt (catalog, i, FALSE, flatcorr, &results, Nsecfilt); 262 break; 263 default: 264 fprintf (stderr, "invalid setMrel version %d (use 0 or 1)\n", SET_MREL_VERSION); 265 exit (2); 266 } 255 setMrel_catalog_alt (catalog, i, FALSE, flatcorr, &results, Nsecfilt); 267 256 SetMrelInfoAccum (&summary, &results); 268 257 } … … 274 263 } 275 264 265 // setMrelOutput is NOT threaded because we read/write catalogs one at a time (for now) 276 266 int setMrelOutput (Catalog *catalog, int Ncatalog, FlatCorrectionTable *flatcorr) { 277 267 278 268 int i; 279 269 280 // fprintf (stderr, "this version of setMrel is invalid for now\n");281 // exit (1);282 283 270 int Nsecfilt = GetPhotcodeNsecfilt (); 284 271 … … 288 275 289 276 for (i = 0; i < Ncatalog; i++) { 290 switch (SET_MREL_VERSION) { 291 // case 0: 292 // setMrel_catalog (catalog, i, pass, flatcorr, &results, Nsecfilt); 293 // break; 294 case 1: 295 setMrel_catalog_alt (catalog, i, TRUE, flatcorr, &results, Nsecfilt); 296 break; 297 default: 298 fprintf (stderr, "invalid setMrel version %d (use 1)\n", SET_MREL_VERSION); 299 exit (2); 300 } 277 setMrel_catalog_alt (catalog, i, TRUE, flatcorr, &results, Nsecfilt); 301 278 SetMrelInfoAccum (&summary, &results); 302 279 } … … 384 361 385 362 while (1) { 386 387 363 off_t i = getNextCatalogForThread(threadinfo->Ncatalog); 388 364 if (i == -1) { … … 394 370 FlatCorrectionTable *flatcorr = threadinfo->flatcorr; 395 371 396 // pass == -1 for anything other than the final pass 397 switch (SET_MREL_VERSION) { 398 case 0: 399 setMrel_catalog (catalog, i, -1, flatcorr, &results, Nsecfilt); 400 break; 401 case 1: 402 setMrel_catalog_alt (catalog, i, FALSE, flatcorr, &results, Nsecfilt); 403 break; 404 default: 405 fprintf (stderr, "invalid setMrel version %d (use 0 or 1)\n", SET_MREL_VERSION); 406 exit (2); 407 } 372 setMrel_catalog_alt (catalog, i, FALSE, flatcorr, &results, Nsecfilt); 408 373 SetMrelInfoAccum (&threadinfo->summary, &results); 409 374 } -
branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/args.c
r38062 r38298 331 331 } 332 332 333 // if -synthphot_zpts is supplied, the map of corrections needed for the synthetic photometry is supplied 334 // and used to tie down the synthetic magnitudes 335 SYNTH_ZERO_POINTS = NULL; 336 if ((N = get_argument (argc, argv, "-synthphot_zpts"))) { 337 remove_argument (N, &argc, argv); 338 myAssert (N < argc, "missing argument to -synthphot_means"); 339 SYNTH_ZERO_POINTS = strcreate (argv[N]); 340 remove_argument (N, &argc, argv); 341 } 342 343 // if -synthphot is chosen, an artificial w-band measurement is generated for each object 344 // with r and i photometry. this was used to apply the ubercal photometry to w-band images. 333 345 SyntheticPhotometry = FALSE; 334 346 if ((N = get_argument (argc, argv, "-synthphot"))) { -
branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/reload_catalogs.c
r37907 r38298 32 32 return; 33 33 } 34 35 // load the ZP corrections here 36 if (SYNTH_ZERO_POINTS) SynthZeroPointsLoad (SYNTH_ZERO_POINTS); 34 37 35 38 if (VERBOSE) fprintf (stderr, "re-loading catalog data\n"); … … 230 233 if (UPDATE_CATFORMAT) { snprintf (tmpline, 1024, "%s -update-catformat %s", command, UPDATE_CATFORMAT); strcpy (command, tmpline); } 231 234 if (BOUNDARY_TREE) { snprintf (tmpline, 1024, "%s -boundary-tree %s", command, BOUNDARY_TREE); strcpy (command, tmpline); } 235 if (SYNTH_ZERO_POINTS) { snprintf (tmpline, 1024, "%s -synthphot-zpts %s", command, SYNTH_ZERO_POINTS); strcpy (command, tmpline); } 232 236 if (SET_MREL_VERSION != 1) { snprintf (tmpline, 1024, "%s -set-mrel-version %d", command, SET_MREL_VERSION); strcpy (command, tmpline); } 233 237 if (AreaSelect) { snprintf (tmpline, 1024, "%s -area %f %f %f %f", command, AreaXmin, AreaXmax, AreaYmin, AreaYmax); strcpy (command, tmpline); } -
branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/relphot_objects.c
r37807 r38298 29 29 return TRUE; 30 30 } 31 32 // load the ZP corrections here 33 if (SYNTH_ZERO_POINTS) SynthZeroPointsLoad (SYNTH_ZERO_POINTS); 31 34 32 35 // load data from each region file, only use bright stars … … 165 168 if (!KEEP_UBERCAL) { snprintf (tmpline, 1024, "%s -reset-ubercal", command); strcpy (command, tmpline); } 166 169 if (SET_MREL_VERSION != 1) { snprintf (tmpline, 1024, "%s -set-mrel-version %d", command, SET_MREL_VERSION); strcpy (command, tmpline); } 170 if (SYNTH_ZERO_POINTS) { snprintf (tmpline, 1024, "%s -synthphot-zpts %s", command, SYNTH_ZERO_POINTS); strcpy (command, tmpline); } 167 171 168 172 fprintf (stderr, "command: %s\n", command); -
branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/relphot_synthphot.c
r38062 r38298 28 28 29 29 // load the ZP corrections here 30 SynthZeroPoints *zpts = SynthZeroPointsLoad (SYNTH_ZERO_POINTS); 30 SynthZeroPointsLoad (SYNTH_ZERO_POINTS); 31 SynthZeroPoints *zpts = SynthZeroPointsGet (); 31 32 if (!zpts) exit (2); 32 33 -
branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/setMrelCatalog.c
r38297 r38298 4 4 5 5 # define SKIP_THIS_MEAS(REASON) { \ 6 measureT[k].dbFlags |= ID_MEAS_SKIP_PHOTOM; \7 if (measure) { \8 measure[k].dbFlags |= ID_MEAS_SKIP_PHOTOM; \9 } \10 6 results->REASON ++; \ 11 7 continue; } 12 8 13 9 # define SKIP_THIS_MEAS_STACK(REASON) { \ 14 measure[k].dbFlags |= ID_MEAS_SKIP_PHOTOM; \15 10 continue; } 16 11 … … 57 52 // only apply Stack operation on setMrelFinal in first pass 58 53 if (isSetMrelFinal && !IS_DIFF_DB) { 59 setMrelAverageStack (&catalog[Nc], Nc, j, Nsecfilt, flatcorr , results);54 setMrelAverageStack (&catalog[Nc], Nc, j, Nsecfilt, flatcorr); 60 55 } 61 56 … … 86 81 // 4) some reference photcode of some kind can be specified as fixed and have a high weight 87 82 88 static SynthZeroPoints *synthzpts = NULL;89 90 83 // set mean of chip measurements (selected by photcode range for now): 91 84 int setMrelAverageExposure (Catalog *catalog, int cat, off_t ave, int Nsecfilt, int isSetMrelFinal, FlatCorrectionTable *flatcorr, SetMrelInfo *results) { … … 95 88 96 89 // we are guaranteed to have averageT, but not average 97 AverageTiny *averageT = &catalog[ cat].averageT[ave];90 AverageTiny *averageT = &catalog[0].averageT[ave]; 98 91 99 92 off_t measureOffset = averageT->measureOffset; 100 MeasureTiny *measureT = &catalog[ cat].measureT[measureOffset];93 MeasureTiny *measureT = &catalog[0].measureT[measureOffset]; 101 94 102 95 // we are NOT guaranteed to have average, measure, secfilt 103 Average *average = catalog[ cat].average ? &catalog[cat].average[ave] : NULL;104 Measure *measure = catalog[ cat].measure ? &catalog[cat].measure[measureOffset] : NULL;105 SecFilt *secfilt = catalog[ cat].secfilt ? &catalog[cat].secfilt[ave*Nsecfilt] : NULL;106 char *measureRank = catalog[ cat].measureRank ? &catalog[cat].measureRank[measureOffset] : NULL;96 Average *average = catalog[0].average ? &catalog[0].average[ave] : NULL; 97 Measure *measure = catalog[0].measure ? &catalog[0].measure[measureOffset] : NULL; 98 SecFilt *secfilt = catalog[0].secfilt ? &catalog[0].secfilt[ave*Nsecfilt] : NULL; 99 char *measureRank = catalog[0].measureRank ? &catalog[0].measureRank[measureOffset] : NULL; 107 100 108 101 // we are measuring means for 3 types of mags: psf, ap, kron. … … 159 152 160 153 // force the use of SYN even if we have PS1 mags? 161 if (is GPC1synth(measureT[k].photcode)) {154 if (isSetMrelFinal && isGPC1synth(measureT[k].photcode)) { 162 155 results->haveSYN[Nsec] = TRUE; 163 156 results->measSYN[Nsec] = k; … … 185 178 Mcal = measureT[k].Mcal; // check that this is zero for loaded REF value 186 179 } else { 180 // getMcal_alt returns image[].Mcal modified by flatcorr(image.photom_map_id,x,y) 187 181 Mcal = getMcal_alt (meas, cat, flatcorr, measureT[k].Xccd, measureT[k].Yccd); 188 182 if (isnan(Mcal)) SKIP_THIS_MEAS(Ncal); … … 240 234 results->psfData[Nsec].errlist[Npsf] = dMpsf; 241 235 results->psfData[Nsec].wgtlist[Npsf] = isUbercal ? UBERCAL_WEIGHT : 1.0; 242 results->psfData[Nsec].ranking[Npsf] = measureRank [k];236 results->psfData[Nsec].ranking[Npsf] = measureRank ? measureRank[k] : 0; 243 237 results->psfData[Nsec].measSeq[Npsf] = k; 244 238 results->psfData[Nsec].Nlist ++; 245 } else {246 measureT[k].dbFlags |= ID_MEAS_SKIP_PHOTOM; // XXX is this used outside of relphot?247 if (measure) measure[k].dbFlags |= ID_MEAS_SKIP_PHOTOM;248 results->Nsys ++;249 239 } 250 240 … … 264 254 } 265 255 } 256 257 SynthZeroPoints *synthzpts = SynthZeroPointsGet(); 266 258 267 259 // now calculate the mean stats for the Nsec bands. … … 325 317 int minRank = (Nranking > 0) ? results->psfData[Nsec].ranking[0] : 10; 326 318 327 // when running -averages, we have no information about the images, so we cannot set this328 if (results->minUbercalDist[Nsec] > -1) {329 secfilt[Nsec].ubercalDist = results->minUbercalDist[Nsec];330 }331 332 319 if (isSetMrelFinal) { 320 // when running -averages, we have no information about the images, so we cannot set this 321 if (results->minUbercalDist[Nsec] > -1) { 322 secfilt[Nsec].ubercalDist = results->minUbercalDist[Nsec]; 323 } 324 333 325 if (Nranking) { 334 326 secfilt[Nsec].Mstdev = psfstats->sigma; … … 412 404 } 413 405 414 # if (0)415 // set mean of chip measurements (selected by photcode range for now):416 int setMrelAverageExposure_old (off_t measureOffset, int cat, int pass, FlatCorrectionTable *flatcorr, SetMrelInfo *results, Average *average, AverageTiny *averageT, SecFilt *secfilt, Measure *measure, MeasureTiny *measureT, off_t *found) {417 418 off_t k;419 float Msys = 0, Mcal= 0, Mmos = 0, Mgrid = 0;420 421 // we are measuring means for 3 types of mags: psf, ap, kron. I am using the psf mag422 // error for the ap mags, but krons have their own errors. it is an open question if I423 // should be doing weighted or unweighted fits (this is a user option)424 double *Mpsflist = results->Mpsflist;425 double *dpsflist = results->dpsflist;426 double *wpsflist = results->wpsflist;427 428 double *Maplist = results->Maplist;429 double *daplist = results->daplist;430 double *waplist = results->waplist;431 432 double *Mkronlist = results->Mkronlist;433 double *dkronlist = results->dkronlist;434 double *wkronlist = results->wkronlist;435 436 StatType *psfstats = &results->psfstats;437 StatType *apstats = &results->apstats;438 StatType *kronstats = &results->kronstats;439 440 int isSetMrelFinal = (pass >= 0);441 442 // option for a test print443 if (FALSE && (average[0].objID == 0x7146) && (average[0].catID == 0x49d8)) {444 fprintf (stderr, "test obj\n");445 print_measure_set_alt (average, secfilt, measure);446 }447 448 int GoodPS1 = FALSE;449 int Good2MASS = FALSE;450 int Galaxy2MASS = FALSE;451 452 int NextPS1 = 0;453 int NpsfPS1 = 0;454 455 int Ns;456 for (Ns = 0; Ns < Nphotcodes; Ns++) {457 458 int thisCode = photcodes[Ns][0].code;459 int Nsec = GetPhotcodeNsec(thisCode);460 461 /* calculate the average mag in this SEC photcode for a single star */462 463 /* star/photcodes already calibrated */464 if ( isSetMrelFinal && found[Nsec]) continue;465 466 // skip bad stars467 if (!isSetMrelFinal && (secfilt[Nsec].flags & STAR_BAD)) continue;468 469 int NexpPS1 = 0;470 int Ncode = 0;471 int Next = 0;472 int haveSynth = FALSE;473 int havePS1 = FALSE;474 475 int forceSynth = FALSE;476 int forceSynthEntry = -1;477 478 int haveUbercal = FALSE;479 480 int minUbercalDist = 1000;481 482 off_t meas = measureOffset;483 484 float psfQfMax = 0.0;485 float psfQfPerfMax = 0.0;486 487 int Nap = 0;488 int Npsf = 0;489 int Nkron = 0;490 for (k = 0; k < averageT[0].Nmeasure; k++, meas++) {491 492 // skip measurements that do not match the current photcode493 PhotCode *code = GetPhotcodebyCode (measureT[k].photcode);494 if (!code) continue;495 if (code->equiv != thisCode) { continue; }496 Ncode ++;497 498 // are we a PS1 exposure photcode?499 if (isGPC1chip(measureT[k].photcode)) NexpPS1 ++;500 501 // SKIP gpc1 stack data502 if (isGPC1stack(measureT[k].photcode)) continue;503 504 // SKIP gpc1 forced-warp data505 if (isGPC1warp(measureT[k].photcode)) continue;506 507 if (isSetMrelFinal) {508 if (measure[k].psfQF > psfQfMax) psfQfMax = measure[k].psfQF;509 if (measure[k].psfQFperf > psfQfPerfMax) psfQfPerfMax = measure[k].psfQFperf;510 }511 512 if (measureT[k].dbFlags & MEAS_BAD) SKIP_THIS_MEAS(Nbad);513 514 if (getImageEntry (meas, cat) < 0) {515 // measurements without an image are either external reference photometry or516 // data for which the associated image has not been loaded (probably because of517 // overlaps). Msys + measure.Mcal is our best guess of the true magnitude518 Mmos = Mgrid = 0;519 Mcal = measureT[k].Mcal; // check that this is zero for loaded REF value520 } else {521 Mcal = getMcal_alt (meas, cat, flatcorr, measureT[k].Xccd, measureT[k].Yccd);522 if (isnan(Mcal)) SKIP_THIS_MEAS(Ncal);523 Mmos = getMmos (meas, cat);524 if (isnan(Mmos)) SKIP_THIS_MEAS(Nmos);525 Mgrid = getMgrid (meas, cat);526 if (isnan(Mgrid)) SKIP_THIS_MEAS(Ngrid);527 }528 529 // skip some absurd values NAN, < 0.0, > 30.0530 Msys = PhotSysTiny (&measureT[k], &averageT[0], &secfilt[0], MAG_CLASS_PSF);531 if (isnan(Msys)) SKIP_THIS_MEAS(Nsys);532 if (Msys < 0.0) SKIP_THIS_MEAS(Nsys);533 if (Msys > 30.0) SKIP_THIS_MEAS(Nsys);534 535 int myUbercalDist = getUbercalDist(meas, cat);536 minUbercalDist = MIN(minUbercalDist, myUbercalDist);537 538 int isUbercal = (measureT[k].dbFlags & ID_MEAS_PHOTOM_UBERCAL);539 float dMpsf = MAX (hypot(measureT[k].dM, code->photomErrSys), MIN_ERROR);540 541 if (isUbercal) haveUbercal = TRUE; // haveUbercal is set per secfilt, isUbercal is per measure542 543 if (isSetMrelFinal) {544 // special options for PS1 data545 if ((measure[k].photcode >= 10000) && (measure[k].photcode <= 10500)) {546 // count the extended detections547 if (!isnan(measure[k].Map)) {548 float dMagAp = measure[k].M - measure[k].Map;549 float SigmaAp = hypot(0.1, 2.5*measure[k].dM);550 // XXX this is still quite ad hoc, but at least it:551 // (a) converges to 0.1 mag offset at the bright end552 // (b) converges to 0.5 mag offset at the faint end (dM = 0.2)553 if (dMagAp > SigmaAp) {554 Next ++;555 NextPS1 ++;556 } else {557 NpsfPS1 ++;558 }559 }560 havePS1 = TRUE;561 }562 563 // count extended detections for 2MASS (XXX NOTE hardwired photcodes 2011, 2012, 2013)564 if ((measure[k].photcode >= 2011) && (measure[k].photcode <= 2013)) {565 if (measure[k].photFlags & 0x00c00000) {566 Next ++;567 Galaxy2MASS = TRUE;568 }569 if (pass == 0) {570 if (measure[k].photFlags & 0x00000007) {571 Good2MASS = TRUE;572 } else {573 // detections without one of these bits should only be used in PASS_1574 SKIP_THIS_MEAS(Nbad);575 }576 }577 }578 579 // Blindly accepth the SYNTH mags if we are above saturation, otherwise,580 // ignore SYNTH photcodes until PASS == 4 (where we also accept saturated stars)581 if ((measure[k].photcode >= 3001) && (measure[k].photcode <= 3005)) {582 // something of a hack: force object to use synth values if synth mags >>583 // saturation (3pi instrumental mags < -15)584 float MaxMagForceSynth = NAN;585 switch (measure[k].photcode) {586 case 3001:587 MaxMagForceSynth = 13.64;588 break;589 case 3002:590 MaxMagForceSynth = 13.76;591 break;592 case 3003:593 MaxMagForceSynth = 13.74;594 break;595 case 3004:596 MaxMagForceSynth = 12.94;597 break;598 case 3005:599 MaxMagForceSynth = 12.01;600 break;601 }602 if (measureT[k].M < MaxMagForceSynth) {603 forceSynth = TRUE;604 forceSynthEntry = Npsf;605 } else {606 if (pass < 4) {607 SKIP_THIS_MEAS(Nbad);608 }609 haveSynth = TRUE;610 }611 }612 613 // Map (Maplist) and Mkron (Mkronlist,dkronlist) are used to calculate mean mags per filter614 float Map = PhotCat (&measure[k], MAG_CLASS_APER);615 if (!isnan(Map)) {616 Maplist[Nap] = Map - Mcal - Mmos - Mgrid;617 daplist[Nap] = dMpsf;// XXX check on this...618 waplist[Nap] = isUbercal ? UBERCAL_WEIGHT : 1.0;619 Nap ++;620 }621 622 float Mkron = PhotCat (&measure[k], MAG_CLASS_KRON);623 if (!isnan(Mkron)) {624 Mkronlist[Nkron] = Mkron - Mcal - Mmos - Mgrid;625 dkronlist[Nkron] = measure[k].dMkron;626 wkronlist[Nkron] = isUbercal ? UBERCAL_WEIGHT : 1.0;627 Nkron ++;628 }629 } // if (isSetMrelFinal)630 631 // dlist gives the error per measurement, wlist gives the weight632 // we can modify the error and weight in a few ways:633 // 1) MIN_ERROR guarantees a floor634 // 2) photomErrSys is added in quadrature as a sytematic error, set per photcode635 // 3) UBERCAL measurements can have their weight increased by a big factor to help tie down the averages636 // 4) some reference photcode of some kind can be specified as fixed and have a high weight637 Mpsflist[Npsf] = Msys - Mcal - Mmos - Mgrid;638 dpsflist[Npsf] = dMpsf;639 wpsflist[Npsf] = isUbercal ? UBERCAL_WEIGHT : 1.0;640 641 // NOTE:642 // Msys is measure[i].M + zp corrections643 // Mcal is image[j].Mcal644 // Mmos and Mgrid are offsets for mosaic and grid645 646 // tie down reference photometry if the -refcode (code) option is selected647 // eg, -refcode g_SDSS648 // this probably makes no sense in the context of multifilter analysis649 // XXX probably need to use the photocde table to assign reference mag weights.650 if (refPhotcode) {651 if (code->code == refPhotcode->code) {652 wpsflist[Npsf] = UBERCAL_WEIGHT;653 }654 }655 Npsf ++;656 }657 658 int Nminmeas = isSetMrelFinal ? 1 : STAR_TOOFEW + 1;659 660 // XXX : ugh : another hard-wired photcode entry...661 if (isSetMrelFinal && (pass == 0)) {662 if ((thisCode < 6) || (thisCode == 9)) {663 secfilt[Nsec].Ncode = NexpPS1;664 } else {665 secfilt[Nsec].Ncode = Ncode; // 2MASS data if it exists666 }667 }668 669 // when performing the grid analysis, STAR_TOOFEW should be set to 1;670 if (Npsf < Nminmeas) { /* too few measurements */671 // fprintf (f, "%10.6f %10.6f %d %d %d\n", averageT[0].R, averageT[0].D, measureT[0].imageID, Npsf, STAR_TOOFEW);672 secfilt[Nsec].flags |= ID_STAR_FEW;673 if (Ncode == 0) {674 results->Ncode ++;675 } else {676 results->Nfew ++;677 }678 continue;679 } else {680 secfilt[Nsec].flags &= ~ID_STAR_FEW;681 }682 683 if (forceSynth) {684 // use the single SYNTH value instead of the other mags here685 myAssert ((forceSynthEntry < Npsf) && (forceSynthEntry >= 0), "programming error");686 Mpsflist[0] = Mpsflist[forceSynthEntry];687 dpsflist[0] = dpsflist[forceSynthEntry];688 wpsflist[0] = wpsflist[forceSynthEntry];689 Npsf = 1;690 }691 liststats (Mpsflist, dpsflist, wpsflist, Npsf, psfstats);692 693 secfilt[Nsec].M = psfstats->mean;694 secfilt[Nsec].dM = psfstats->error;695 secfilt[Nsec].Mchisq = (psfstats->Nmeas > 1) ? psfstats->chisq : NAN;696 697 // when running -averages, we have no information about the images, so we cannot set this698 if (minUbercalDist > -1) {699 secfilt[Nsec].ubercalDist = minUbercalDist;700 }701 702 if (isSetMrelFinal) {703 found[Nsec] = TRUE;704 705 secfilt[Nsec].Mstdev = psfstats->sigma; // Mstdev is in millimags (not enough space for more precision)706 // secfilt[Nsec].Ncode = Ncode;707 secfilt[Nsec].Nused = psfstats->Nmeas;708 709 secfilt[Nsec].Mmax = psfstats->max;710 secfilt[Nsec].Mmin = psfstats->min;711 712 secfilt[Nsec].psfQfMax = psfQfMax;713 secfilt[Nsec].psfQfPerfMax = psfQfPerfMax;714 715 // NOTE : use the modified weight for apmags as well as psf mags716 liststats (Maplist, daplist, waplist, Nap, apstats);717 secfilt[Nsec].Map = Nap > 0 ? apstats->mean : NAN;718 secfilt[Nsec].dMap = Nap > 0 ? apstats->error : NAN;719 secfilt[Nsec].sMap = Nap > 0 ? apstats->sigma : NAN;720 secfilt[Nsec].NusedAp = Nap;721 722 liststats (Mkronlist, dkronlist, wkronlist, Nkron, kronstats);723 secfilt[Nsec].Mkron = Nkron > 0 ? kronstats->mean : NAN;724 secfilt[Nsec].dMkron = Nkron > 0 ? kronstats->error : NAN;725 secfilt[Nsec].sMkron = Nkron > 0 ? kronstats->sigma : NAN;726 secfilt[Nsec].NusedKron = Nkron;727 728 // NOTE: for 2MASS measurements, Next should be 1, as should N729 if ((Next > 0) && (Next > 0.5*Npsf)) {730 secfilt[Nsec].flags |= ID_SECF_OBJ_EXT;731 }732 733 switch (pass) {734 case 0:735 secfilt[Nsec].flags |= ID_PHOTOM_PASS_0;736 if (havePS1) GoodPS1 = TRUE;737 break;738 case 1:739 secfilt[Nsec].flags |= ID_PHOTOM_PASS_1;740 if (havePS1) GoodPS1 = TRUE;741 break;742 case 2:743 secfilt[Nsec].flags |= ID_PHOTOM_PASS_2;744 if (havePS1) GoodPS1 = TRUE;745 break;746 case 3:747 secfilt[Nsec].flags |= ID_PHOTOM_PASS_3;748 break;749 case 4:750 secfilt[Nsec].flags |= ID_PHOTOM_PASS_4;751 break;752 }753 if (haveSynth) {754 secfilt[Nsec].flags |= ID_SECF_USE_SYNTH;755 }756 if (havePS1) {757 secfilt[Nsec].flags |= ID_SECF_HAS_PS1;758 }759 if (haveUbercal) {760 secfilt[Nsec].flags |= ID_SECF_USE_UBERCAL;761 }762 }763 }764 765 if (isSetMrelFinal) {766 if (pass == 0) {767 DVOAverageFlags flagBits = ID_OBJ_EXT | ID_OBJ_EXT_ALT | ID_OBJ_GOOD | ID_OBJ_GOOD_ALT;768 // we attempt to set a few flags here; reset those bits before trying:769 average[0].flags &= ~flagBits;770 }771 772 if (NextPS1 && (NextPS1 > NpsfPS1)) {773 average[0].flags |= ID_OBJ_EXT;774 }775 if (GoodPS1) {776 average[0].flags |= ID_OBJ_GOOD;777 }778 if (Galaxy2MASS) {779 average[0].flags |= ID_OBJ_EXT_ALT;780 }781 if (Good2MASS) {782 average[0].flags |= ID_OBJ_GOOD_ALT;783 }784 }785 return (TRUE);786 }787 # endif788 789 406 // only apply Stack operation on setMrelFinal in first pass 790 407 // this function has 3 goals, not to be confused: … … 792 409 // 2) select the BEST detections per filter (regardless of PRIMARY) 793 410 // 3) apply the zero point and AB->Jy transformations 794 int setMrelAverageStack (Catalog *catalog, int cat, off_t ave, int Nsecfilt, FlatCorrectionTable *flatcorr , SetMrelInfo *results) {411 int setMrelAverageStack (Catalog *catalog, int cat, off_t ave, int Nsecfilt, FlatCorrectionTable *flatcorr) { 795 412 796 413 // we are guaranteed to have average, measure, secfilt 797 Average *average = &catalog[ cat].average[ave];414 Average *average = &catalog[0].average[ave]; 798 415 off_t measureOffset = average->measureOffset; 799 416 int Nmeasure = average->Nmeasure; 800 417 801 Measure *measure = &catalog[ cat].measure[measureOffset];802 SecFilt *secfilt = &catalog[ cat].secfilt[ave*Nsecfilt];418 Measure *measure = &catalog[0].measure[measureOffset]; 419 SecFilt *secfilt = &catalog[0].secfilt[ave*Nsecfilt]; 803 420 804 421 off_t k; … … 900 517 } 901 518 902 // NOTE: negative and insignificant vluesvalues are allowed, but not NAN flux values519 // NOTE: negative and insignificant flux values are allowed, but not NAN flux values 903 520 Finst = PhotFluxInst (&measure[k], MAG_CLASS_PSF); 904 521 if (isnan(Finst)) SKIP_THIS_MEAS_STACK(Ninst); … … 1028 645 1029 646 // we are guaranteed to have average, measure, secfilt 1030 Average *average = &catalog[ cat].average[ave];1031 Measure *measure = &catalog[ cat].measure[measureOffset];1032 SecFilt *secfilt = &catalog[ cat].secfilt[ave*Nsecfilt];647 Average *average = &catalog[0].average[ave]; 648 Measure *measure = &catalog[0].measure[measureOffset]; 649 SecFilt *secfilt = &catalog[0].secfilt[ave*Nsecfilt]; 1033 650 1034 651 off_t k; -
branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/synthetic_zpts.c
r38062 r38298 7 7 static char *extname[5] = {"map_g", "map_r", "map_i", "map_z", "map_y"}; 8 8 9 SynthZeroPoints *SynthZeroPointsLoad (char *filename) { 9 static SynthZeroPoints *zpts = NULL; 10 11 int SynthZeroPointsLoad (char *filename) { 10 12 11 13 FILE *f = fopen (filename, "r"); 12 14 if (!f) { 13 15 fprintf (stderr, "ERROR: cannot open file %s\n", filename); 14 return NULL;16 return FALSE; 15 17 } 16 18 … … 23 25 // map_y 24 26 25 SynthZeroPoints *zpts = NULL;26 27 ALLOCATE (zpts, SynthZeroPoints, 1); 27 28 … … 29 30 if (VERBOSE) fprintf (stderr, "can't read header\n"); 30 31 fclose (f); 31 return NULL;32 return FALSE; 32 33 } 33 34 … … 49 50 zpts->Ny = zpts->matrix[0].Naxis[1]; 50 51 52 return TRUE; 53 } 54 55 SynthZeroPoints *SynthZeroPointsGet () { 51 56 return zpts; 52 57 } 53
Note:
See TracChangeset
for help on using the changeset viewer.
