Changeset 11551 for trunk/psastro/src/psastroConvert.c
- Timestamp:
- Feb 1, 2007, 12:10:36 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroConvert.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroConvert.c
r10855 r11551 1 1 # include "psastro.h" 2 // XXXleak free 2006.04.272 // leak free 2006.04.27 3 3 4 4 bool psastroConvertFPA (pmFPA *fpa, psMetadata *recipe) { … … 29 29 } 30 30 31 // XXXpass/apply the WCS information?31 // pass/apply the WCS information? 32 32 bool psastroConvertReadout (pmReadout *readout, psMetadata *recipe) { 33 33 34 bool status; 35 36 // PSPHOT.SOURCES carries the pmSource objects (from psphot analysis or loaded externally) 34 37 psArray *sources = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.SOURCES"); 35 38 if (sources == NULL) 36 39 return false; 37 40 38 psArray *rawstars = pmSourceToAstromObj (sources); 41 // convert the pmSource objects into pmAstromObj objects (drop !STAR and SATSTAR?) 42 psArray *inStars = pmSourceToAstromObj (sources); 39 43 40 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.RAWSTARS", PS_DATA_ARRAY, "astrometry objects", rawstars);41 ps LogMsg ("psastro", 4, "loaded %ld sources\n", rawstars->n);44 // sort in ascending magnitude order 45 psArraySort (inStars, psastroSortByMag); 42 46 43 psFree (rawstars); 47 // we are going to select the brighter Nmax subset for astrometry 48 int nMax = psMetadataLookupS32 (&status, recipe, "PSASTRO.MAX.NSTAR"); 49 if (!status || (nMax < 10)) nMax = 300; // 10 is really somewhat absurd as a lower limit 50 51 // choose the first nMax sources 52 psArray *rawStars = psArrayAlloc (PS_MIN (nMax, inStars->n)); 53 for (int i = 0; i < rawStars->n; i++) { 54 rawStars->data[i] = psMemIncrRefCounter (inStars->data[i]); 55 } 56 57 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.RAWSTARS", PS_DATA_ARRAY, "astrometry objects", rawStars); 58 psLogMsg ("psastro", 4, "loaded %ld sources, using %ld of %ld good sources\n", sources->n, rawStars->n, inStars->n); 59 60 psFree (inStars); 61 psFree (rawStars); 44 62 45 63 return true; 46 64 } 47 65 48 // XXXselect a magnitude range?66 // select a magnitude range? 49 67 psArray *pmSourceToAstromObj (psArray *sources) { 50 68 … … 55 73 56 74 // only accept the PSF sources? 75 // XXX drop SATSTAR? 57 76 if (source->type != PM_SOURCE_TYPE_STAR) continue; 58 77 … … 79 98 return objects; 80 99 } 100 101 // sort by Mag (ascending) 102 int psastroSortByMag (const void **a, const void **b) 103 { 104 pmAstromObj *A = *(pmAstromObj **) a; 105 pmAstromObj *B = *(pmAstromObj **) b; 106 107 psF32 mA = (isfinite(A->Mag)) ? A->Mag : FLT_MAX; 108 psF32 mB = (isfinite(B->Mag)) ? B->Mag : FLT_MAX; 109 110 psF32 diff = mA - mB; 111 if (diff > FLT_EPSILON) return (+1); 112 if (diff < FLT_EPSILON) return (-1); 113 return (0); 114 } 115
Note:
See TracChangeset
for help on using the changeset viewer.
