Changeset 37829
- Timestamp:
- Jan 12, 2015, 12:37:04 PM (12 years ago)
- Location:
- branches/eam_branches/ipp-pv3-20140717-merge/psastro/src
- Files:
-
- 3 edited
-
psastro.h (modified) (1 diff)
-
psastroChooseRefstars.c (modified) (2 diffs)
-
psastroZeroPoint.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-pv3-20140717-merge/psastro/src/psastro.h
r36837 r37829 154 154 155 155 bool psastroZeroPoint (pmConfig *config); 156 psVector *psastroZeroPointReadoutAccum(psVector *dMag, pmReadout *readout, float exptime );156 psVector *psastroZeroPointReadoutAccum(psVector *dMag, pmReadout *readout, float exptime, float refminMag, float refmaxMag); 157 157 bool psastroZeroPointAnalysis (psMetadata *header, psVector *dMag, float zeropt, psMetadata *recipe); 158 158 bool psastroZeroPointFromRecipe (float *zeropt, float *exptime, float *ghostMaxMag, pmFPA *fpa, psMetadata *recipe); 159 bool psastroZeroPointRefMagLimitFromRecipe (float *refminMag, float *refmaxMag, pmFPA *fpa, psMetadata *recipe); 159 160 160 161 psStats *psastroStatsPercentile (psVector *myVector, psMetadata *recipe); -
branches/eam_branches/ipp-pv3-20140717-merge/psastro/src/psastroChooseRefstars.c
r35715 r37829 66 66 psF32 clampMagMin = psMetadataLookupF32 (&status, recipe, "REFSTAR_CLAMP_MAG_MIN"); 67 67 if (!status) clampMagMin = -5.0; 68 //MEH adding max option as well -- really should not be hardcoded.. 69 psF32 clampMagMax = psMetadataLookupF32 (&status, recipe, "REFSTAR_CLAMP_MAG_MAX"); 70 if (!status) clampMagMax = 30.0; 71 psWarning("Will skip/clamp refstar with brighter/fainter magnitude %f/%f\n",clampMagMin,clampMagMax); 72 68 73 69 74 // de-activate all files except PSASTRO.REFSTARS … … 109 114 110 115 if (ref->Mag < clampMagMin) { 111 psWarning("Skipping refstar with abusrd magnitude %f ra: %f dec: %f\n", 112 ref->Mag, RAD_TO_DEG(ref->sky->r), RAD_TO_DEG(ref->sky->d)); 116 //psWarning("Skipping refstar with abusrd magnitude %f ra: %f dec: %f\n", 117 // ref->Mag, RAD_TO_DEG(ref->sky->r), RAD_TO_DEG(ref->sky->d)); 118 psTrace ("psastro", 6, "Skipping by clamp refstar with bright magnitude %f ra: %f dec: %f\n", 119 ref->Mag, RAD_TO_DEG(ref->sky->r), RAD_TO_DEG(ref->sky->d)); 120 goto skip; 121 } 122 //MEH option for max mag clamp also -- need to change psWarning (to log) to trace and above for bright.. 123 if (ref->Mag > clampMagMax) { 124 //psWarning("Skipping by clamp refstar with faint magnitude %f ra: %f dec: %f\n", 125 // ref->Mag, RAD_TO_DEG(ref->sky->r), RAD_TO_DEG(ref->sky->d)); 126 psTrace ("psastro", 6, "Skipping by clamp refstar with faint magnitude %f ra: %f dec: %f\n", 127 ref->Mag, RAD_TO_DEG(ref->sky->r), RAD_TO_DEG(ref->sky->d)); 113 128 goto skip; 114 129 } -
branches/eam_branches/ipp-pv3-20140717-merge/psastro/src/psastroZeroPoint.c
r33643 r37829 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.
