Changeset 27838 for branches/tap_branches/psastro/src/psastroConvert.c
- Timestamp:
- May 3, 2010, 8:41:49 AM (16 years ago)
- Location:
- branches/tap_branches
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
psastro/src/psastroConvert.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/tap_branches
- Property svn:mergeinfo changed
-
branches/tap_branches/psastro/src/psastroConvert.c
r23303 r27838 1 1 /** @file psastroConvert.c 2 2 * 3 * @brief 3 * @brief 4 4 * 5 5 * @ingroup libpsastro … … 47 47 48 48 // PSPHOT.SOURCES carries the pmSource objects (from psphot analysis or loaded externally) 49 psArray *sources = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.SOURCES"); 50 if (sources == NULL) 51 return false; 49 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 50 psAssert (detections, "missing detections?"); 51 52 psArray *sources = detections->allSources; 53 psAssert (sources, "missing sources?"); 52 54 53 55 // convert the pmSource objects into pmAstromObj objects (drop !STAR and SATSTAR?) … … 61 63 // XXX need to exit gracefully is inStars->n is 0 (or 1?) 62 64 63 // we are going to select the brighter Nmax subset for astrometry 65 // we are going to select the brighter Nmax subset for astrometry 64 66 int nMax = psMetadataLookupS32 (&status, recipe, "PSASTRO.MAX.NRAW"); 65 67 if (!status || !nMax) nMax = inStars->n; 66 68 67 // we are going to select the brighter Nmax subset for astrometry 69 // we are going to select the brighter Nmax subset for astrometry 68 70 float iMagMax = psMetadataLookupF32 (&status, recipe, "PSASTRO.MAX.INST.MAG.RAW"); 69 71 float iMagMin = psMetadataLookupF32 (&status, recipe, "PSASTRO.MIN.INST.MAG.RAW"); 70 72 71 // we are going to select the brighter Nmax subset for astrometry 73 // we are going to select the brighter Nmax subset for astrometry 72 74 pmSourceMode skip = PM_SOURCE_MODE_DEFAULT; 73 75 char *ignoreList = psMetadataLookupStr (&status, recipe, "PSASTRO.IGNORE"); … … 75 77 psArray *list = psStringSplitArray (ignoreList, ",", false); 76 78 for (int i = 0; i < list->n; i++) { 77 pmSourceMode mode = pmSourceModeFromString (list->data[i]);78 if (mode == PM_SOURCE_MODE_DEFAULT) {79 psWarning ("unknown source mode in PSASTRO.IGNORE, skipping");80 continue;81 }82 skip |= mode;79 pmSourceMode mode = pmSourceModeFromString (list->data[i]); 80 if (mode == PM_SOURCE_MODE_DEFAULT) { 81 psWarning ("unknown source mode in PSASTRO.IGNORE, skipping"); 82 continue; 83 } 84 skip |= mode; 83 85 } 84 86 psFree (list); … … 97 99 98 100 for (int i = 0; (i < inStars->n) && (j < rawStars->n); i++) { 99 int n = index->data.S32[i];100 pmSource *source = sources->data[n];101 int n = index->data.S32[i]; 102 pmSource *source = sources->data[n]; 101 103 102 104 psTrace ("psastro", 6, "mag: %f +/- %f, mode: %x, skip: %x\n", source->psfMag, source->errMag, source->mode, skip); 103 105 104 if (source->mode & skip) { 105 nModeSkip ++;106 continue;107 }106 if (source->mode & skip) { 107 nModeSkip ++; 108 continue; 109 } 108 110 109 if ((iMagMax != 0.0) && (source->psfMag > iMagMax)) {110 nFaintSkip ++;111 continue;112 }113 if ((iMagMin != 0.0) && (source->psfMag < iMagMin)) {114 nBrightSkip ++;115 continue;116 }117 if (!isfinite(source->psfMag)) {118 nInfSkip ++;119 continue;120 }121 mMin = PS_MIN (mMin, source->psfMag);122 mMax = PS_MAX (mMax, source->psfMag);123 rawStars->data[j] = psMemIncrRefCounter (inStars->data[n]);124 j++;111 if ((iMagMax != 0.0) && (source->psfMag > iMagMax)) { 112 nFaintSkip ++; 113 continue; 114 } 115 if ((iMagMin != 0.0) && (source->psfMag < iMagMin)) { 116 nBrightSkip ++; 117 continue; 118 } 119 if (!isfinite(source->psfMag)) { 120 nInfSkip ++; 121 continue; 122 } 123 mMin = PS_MIN (mMin, source->psfMag); 124 mMax = PS_MAX (mMax, source->psfMag); 125 rawStars->data[j] = psMemIncrRefCounter (inStars->data[n]); 126 j++; 125 127 } 126 128 rawStars->n = j; 127 129 128 130 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.RAWSTARS", PS_DATA_ARRAY, "astrometry objects", rawStars); 131 129 132 psLogMsg ("psastro", 4, "loaded %ld sources, using %ld of %ld good sources (inst mag: %f to %f)\n", sources->n, rawStars->n, inStars->n, mMin, mMax); 130 133 psLogMsg ("psastro", 4, "skip reasons: mode: %d, faint: %d, bright: %d, inf: %d\n", nModeSkip, nFaintSkip, nBrightSkip, nInfSkip); … … 146 149 147 150 // only accept the PSF sources? 148 // XXX drop SATSTAR?151 // XXX drop SATSTAR? 149 152 // if (source->type != PM_SOURCE_TYPE_STAR) continue; 150 153 … … 153 156 154 157 psF32 *PAR = model->params->data.F32; 158 psF32 *dPAR = model->dparams->data.F32; 155 159 156 160 pmAstromObj *obj = pmAstromObjAlloc (); 157 161 158 162 // is the source magnitude calibrated in any sense? 159 obj->pix->x = PAR[PM_PAR_XPOS]; 160 obj->pix->y = PAR[PM_PAR_YPOS]; 163 obj->pix->x = PAR[PM_PAR_XPOS]; 164 obj->pix->y = PAR[PM_PAR_YPOS]; 165 obj->pix->xErr = dPAR[PM_PAR_XPOS]; 166 obj->pix->yErr = dPAR[PM_PAR_YPOS]; 161 167 obj->Mag = source->psfMag; 168 obj->dMag = source->errMag; 162 169 163 170 // XXX do we have the information giving the readout and cell offset?
Note:
See TracChangeset
for help on using the changeset viewer.
