- Timestamp:
- Jan 11, 2015, 2:05:35 PM (12 years ago)
- Location:
- branches/eam_branches/ipp-20140904
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
psastro/src/psastroZeroPoint.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20140904
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20140904/psastro/src/psastroZeroPoint.c
r33643 r37804 20 20 pmCell *cell = NULL; 21 21 pmReadout *readout = NULL; 22 float refminMag,refmaxMag; 22 23 23 24 // select the current recipe … … 59 60 } 60 61 62 // MEH -- RefMagLimit for ZP with photcode option (merr probably better but not an option) 63 // -- defualt is to use general config value (no hardcode..) 64 if (!psastroZeroPointRefMagLimitFromRecipe (&refminMag, &refmaxMag, fpa, recipe)) { 65 psLogMsg ("psastro", PS_LOG_INFO, "failed to load ref min,maxMag data from recipe"); 66 return false; 67 } 68 61 69 // if we measure the zero point by exposure, accumulate the dMag values here: 62 70 psVector *dMag = NULL; 71 // MEH -- also the number of refcat sources used 72 int zpt_nref = 0; 63 73 64 74 float fpaZP = 0.0; // Average zero point … … 81 91 82 92 // calculate dMag for the matched stars 83 dMag = psastroZeroPointReadoutAccum (dMag, readout, exptime); 84 93 //dMag = psastroZeroPointReadoutAccum (dMag, readout, exptime); 94 // MEH -- additional limits should be available for ZP if just robust mean and w/ stack skycal 95 dMag = psastroZeroPointReadoutAccum (dMag, readout, exptime, refminMag, refmaxMag); 85 96 if (!byExposure) { 86 97 // calculate dMag for the matched stars just for this readout (well, chip) 87 98 psMetadata *header = psMetadataLookupMetadata (&status, readout->analysis, "PSASTRO.HEADER"); 88 99 psastroZeroPointAnalysis (header, dMag, zeropt, recipe); 100 // MEH -- per readout N refcat, min/max mag -- added here, not part of median/edge process 101 zpt_nref += dMag->n; 102 psMetadataAddS32 (header, PS_LIST_TAIL, "ZPT_NREF", PS_META_REPLACE, "N refcat sources for zero point", dMag->n); 103 psMetadataAddF32 (header, PS_LIST_TAIL, "ZPT_MIN", PS_META_REPLACE, "min refcat mag for zero point", refminMag); 104 psMetadataAddF32 (header, PS_LIST_TAIL, "ZPT_MAX", PS_META_REPLACE, "max refcat mag for zero point", refmaxMag); 89 105 psFree (dMag); 90 106 dMag = NULL; … … 95 111 numZP++; 96 112 } 113 97 114 98 115 … … 110 127 } 111 128 psastroZeroPointAnalysis (header, dMag, zeropt, recipe); 129 //MEH -- all N refcat sources here 130 zpt_nref = dMag->n; 112 131 psFree (dMag); 113 132 dMag = NULL; … … 141 160 // calculate dMag for the matched stars just for this readout (well, chip) 142 161 psMetadata *header = psMetadataLookupMetadata (&status, readout->analysis, "PSASTRO.HEADER"); 143 144 162 psMetadataAddF32 (header, PS_LIST_TAIL, "ZPT_OBS", PS_META_REPLACE, "measured zero point", zptObs); 145 163 psMetadataAddF32 (header, PS_LIST_TAIL, "ZPT_REF", PS_META_REPLACE, "reference zero point", zptRef); 146 164 psMetadataAddF32 (header, PS_LIST_TAIL, "ZPT_ERR", PS_META_REPLACE, "error on zero point", zptErr); 147 165 psMetadataAddF32 (header, PS_LIST_TAIL, "ZPT_OFF", PS_META_REPLACE, "zero point offset", zptOff); 166 //MEH -- per readout N refcat, MIN/MAX for consistency 167 psMetadataAddS32 (header, PS_LIST_TAIL, "ZPT_NREF", PS_META_REPLACE, "N refcat sources for zero point", zpt_nref); 168 psMetadataAddF32 (header, PS_LIST_TAIL, "ZPT_MIN", PS_META_REPLACE, "min refcat mag for zero point", refminMag); 169 psMetadataAddF32 (header, PS_LIST_TAIL, "ZPT_MAX", PS_META_REPLACE, "max refcat mag for zero point", refmaxMag); 148 170 } 149 171 } … … 151 173 } 152 174 175 // MEH add N refcat, min/max mag to primary header 176 psMetadata *header = psMetadataLookupMetadata (&status, fpa->analysis, "PSASTRO.HEADER"); 177 if (!header) { 178 header = psMetadataAlloc (); 179 psMetadataAddMetadata (fpa->analysis, PS_LIST_TAIL, "PSASTRO.HEADER", PS_META_REPLACE, "psastro header stats", header); 180 psFree (header); 181 } 182 psMetadataAddS32 (header, PS_LIST_TAIL, "ZPT_NREF", PS_META_REPLACE, "Total N refcat sources for zero point", zpt_nref); 183 psMetadataAddF32 (header, PS_LIST_TAIL, "ZPT_MIN", PS_META_REPLACE, "min refcat mag for zero point", refminMag); 184 psMetadataAddF32 (header, PS_LIST_TAIL, "ZPT_MAX", PS_META_REPLACE, "max refcat mag for zero point", refmaxMag); 153 185 154 186 psMetadataItem *item = psMetadataLookup(fpa->concepts, "FPA.ZP"); … … 162 194 * accumulate the dMag values from this readout 163 195 */ 164 psVector *psastroZeroPointReadoutAccum(psVector *dMag, pmReadout *readout, float exptime ) {196 psVector *psastroZeroPointReadoutAccum(psVector *dMag, pmReadout *readout, float exptime, float refminMag, float refmaxMag) { 165 197 166 198 bool status; … … 191 223 // XXX I should be applying the airmass term here or in psastroLoadRefstars 192 224 // (ie, ref->Mag would be a prediction for a given star. 193 float value = ref->Mag - raw->Mag - 2.5*log10(exptime); 194 psVectorAppend (dMag, value); 225 // MEH -- only append if in allowed ref mag range -- may want merr but not available.. 226 if ( ref->Mag >= refminMag && ref->Mag <= refmaxMag ){ 227 float value = ref->Mag - raw->Mag - 2.5*log10(exptime); 228 psVectorAppend (dMag, value); 229 } 195 230 } 196 231 return dMag; … … 490 525 continue; 491 526 } 492 } 527 //MEH null is a pain.. so only log if set 528 psLogMsg ("psastro", PS_LOG_INFO, "found GHOST_MAX_MAG %f",*ghostMaxMag); 529 } 530 //MEH what zpt is set to 531 psLogMsg ("psastro", PS_LOG_INFO, "found ZEROPT %f",*zeropt); 493 532 psFree (iter); 494 533 return true; … … 497 536 return false; 498 537 } 538 539 540 541 bool psastroZeroPointRefMagLimitFromRecipe (float *refminMag, float *refmaxMag, pmFPA *fpa, psMetadata *recipe) { 542 543 bool status; 544 float tmpmin,tmpmax; 545 546 // MEH -- duplicate psastroZeroPointFromRecipe for ZeroPoint adding RefMag limits with photcode option for extra restrictions 547 // must have non-photcode dependent setting -- use as default rather than a hardcoded value 548 *refminMag = psMetadataLookupF32 (&status, recipe, "REFSTAR.ZP.MIN.MAG"); 549 //if (!status) *refminMag = -5.0; 550 if (!status) { 551 psLogMsg ("psastro", PS_LOG_INFO, "RefMagLimit is missing REFSTAR.ZP.MIN.MAG"); 552 return false; 553 } 554 *refmaxMag = psMetadataLookupF32 (&status, recipe, "REFSTAR.ZP.MAX.MAG"); 555 //if (!status) *refmaxMag = 30.0; 556 if (!status) { 557 psLogMsg ("psastro", PS_LOG_INFO, "RefMagLimit is missing REFSTAR.ZP.MAX.MAG"); 558 return false; 559 } 560 561 // select the filter; default to any photcode and mag limit otherwise 562 char *filter = psMetadataLookupStr (&status, fpa->concepts, "FPA.FILTERID"); 563 if (!status) ESCAPE ("RefMagLimit missing FPA.FILTER in concepts"); 564 565 // need to select the PHOTCODE.DATA folder that matches our filter 566 psMetadataItem *item = psMetadataLookup (recipe, "PHOTCODE.DATA"); 567 if (!item) ESCAPE ("RefMagLimit PHOTCODE.DATA folders missing"); 568 if (item->type != PS_DATA_METADATA_MULTI) ESCAPE ("RefMagLimit PHOTCODE.DATA not a multi"); 569 570 // PHOTCODE.DATA is a multi of metadata items 571 psListIterator *iter = psListIteratorAlloc(item->data.list, PS_LIST_HEAD, false); 572 573 psMetadataItem *refItem = NULL; 574 while ((refItem = psListGetAndIncrement (iter))) { 575 if (refItem->type != PS_DATA_METADATA) ESCAPE ("RefMagLimit PHOTCODE.DATA entry is not a metadata folder"); 576 577 char *refFilter = psMetadataLookupStr (&status, refItem->data.md, "FILTER"); 578 if (!status) { 579 // always seems to happen once, commented out in ZeroPoint above as well 580 //psLogMsg ("psastro", PS_LOG_INFO, "RefMagLimit PHOTCODE.DATA recipe folder is missing FILTER"); 581 continue; 582 } 583 584 // does this entry match the current filter? 585 if (strcmp (refFilter, filter)) continue; 586 587 psLogMsg ("psastro", PS_LOG_DETAIL, "RefMagLimit PHOTCODE.DATA found for filter %s", filter); 588 589 // -- may set one or other or both -- no reason to log if found or often not 590 tmpmin = psMetadataLookupF32 (&status, refItem->data.md, "REFSTAR.ZP.MIN.MAG"); 591 if (status) { 592 *refminMag = tmpmin; 593 } 594 tmpmax = psMetadataLookupF32 (&status, refItem->data.md, "REFSTAR.ZP.MAX.MAG"); 595 if (status) { 596 *refmaxMag = tmpmax; 597 } 598 // once finds filter, should free and return true but multiple groups cause issue so just go through all groups now 599 //psFree (iter); 600 //return true; 601 } 602 603 // log out set values 604 psLogMsg ("psastro", PS_LOG_INFO, "using REFSTAR.ZP.MIN.MAG %f",*refminMag); 605 psLogMsg ("psastro", PS_LOG_INFO, "using REFSTAR.ZP.MAX.MAG %f",*refmaxMag); 606 607 psFree (iter); 608 return true; 609 } 610
Note:
See TracChangeset
for help on using the changeset viewer.
