Changeset 20268
- Timestamp:
- Oct 19, 2008, 1:52:18 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroZeroPoint.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroZeroPoint.c
r19290 r20268 1 1 # include "psastroInternal.h" 2 3 bool psastroZeroPointReadout(psArray *rawstars, psArray *refstars, psArray *matches);4 2 5 3 bool psastroZeroPoint (pmConfig *config) { 6 4 5 float zeropt, exptime; 7 6 pmChip *chip = NULL; 8 7 pmCell *cell = NULL; … … 29 28 // is this needed? yes, if we didn't do SingleChip astrometry first 30 29 if (!psastroMosaicSetMatch (fpa, recipe, 0)) { 31 psError(PSASTRO_ERR_UNKNOWN, false, "failed to match raw and ref stars for mosaic"); 30 psError(PSASTRO_ERR_UNKNOWN, false, "failed to match raw and ref stars for mosaic"); 31 return false; 32 } 33 34 // XXX eventually: look up the photcode info from the recipe, use the ZEROPT and A_0 terms 35 // to determine transparency = Mref - Mraw - 2.5*log10(exptime) - ZEROPT - A_0*Color_ref 36 // to get there, we need: a) getstar to write out the color-term magnitudes and b) the 37 // pmAstromObj to carry a color value as well. 38 39 // really error-out here? or just skip? 40 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, fpa, recipe)) { 41 psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe"); 32 42 return false; 33 43 } … … 48 58 if (! readout->data_exists) { continue; } 49 59 50 // select the raw objects for this readout 51 psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS"); 52 if (rawstars == NULL) { continue; } 60 // calculate dMag for the matched stars 61 psastroZeroPointReadout (readout, zeropt, exptime); 53 62 54 // select the raw objects for this readout55 psArray *refstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.REFSTARS");56 if (refstars == NULL) { continue; }57 58 psArray *matches = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.MATCH");59 if (matches == NULL) { continue; }60 61 // calculate dMag for the matched stars62 psastroZeroPointReadout (rawstars, refstars, matches);63 63 } 64 64 } … … 69 69 } 70 70 71 // XXX for now, let's just measure <dMag> and sigma_dMag 72 // XXX a test comment 73 bool psastroZeroPointReadout(psArray *rawstars, psArray *refstars, psArray *matches) { 71 // we measure <dMag> and \sigma_dMag and write them to the header 72 bool psastroZeroPointReadout(pmReadout *readout, float zeropt, float exptime) { 73 74 bool status; 75 76 // select the raw objects for this readout 77 psArray *rawstars = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.RAWSTARS"); 78 if (rawstars == NULL) return false; 79 80 // select the raw objects for this readout 81 psArray *refstars = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.REFSTARS"); 82 if (refstars == NULL) return false; 83 84 psArray *matches = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.MATCH"); 85 if (matches == NULL) return false; 74 86 75 87 psVector *dMag = psVectorAllocEmpty (100, PS_TYPE_F32); … … 84 96 pmAstromObj *ref = refstars->data[match->ref]; 85 97 86 dMag->data.F32[Npts] = ref->Mag - raw->Mag ;98 dMag->data.F32[Npts] = ref->Mag - raw->Mag - 2.5*log10(exptime); 87 99 psVectorExtend (dMag, 100, 1); 88 100 Npts++; … … 101 113 psStats *stats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV); 102 114 psVectorStats (stats, dMag, NULL, NULL, 0); 103 fprintf (stderr, "zero point %f +/- %f\n", stats->clippedMean, stats->clippedStdev); 115 fprintf (stderr, "zero point %f +/- %f using %d stars; transparency %f\n", stats->clippedMean, stats->clippedStdev, Npts, zeropt - stats->clippedMean); 116 117 psMetadata *header = psMetadataLookupMetadata (&status, readout->analysis, "PSASTRO.HEADER"); 118 119 psMetadataAddF32 (header, PS_LIST_TAIL, "ZPT_OBS", PS_META_REPLACE, "measured zero point", stats->clippedMean); 120 psMetadataAddF32 (header, PS_LIST_TAIL, "ZPT_REF", PS_META_REPLACE, "measured zero point", zeropt); 121 psMetadataAddF32 (header, PS_LIST_TAIL, "ZPT_ERR", PS_META_REPLACE, "measured zero point", stats->clippedStdev); 122 psMetadataAddF32 (header, PS_LIST_TAIL, "ZPT_OFF", PS_META_REPLACE, "measured zero point", zeropt - stats->clippedMean); 104 123 105 124 psFree (dMag); … … 107 126 return true; 108 127 } 128 129 # define ESCAPE(MSG) { \ 130 psLogMsg ("psastro", PS_LOG_INFO, MSG); \ 131 return false; } 132 133 bool psastroZeroPointFromRecipe (float *zeropt, float *exptime, pmFPA *fpa, psMetadata *recipe) { 134 135 bool status; 136 137 // select the filter; default to fixed photcode and mag limit otherwise 138 char *filter = psMetadataLookupStr (&status, fpa->concepts, "FPA.FILTERID"); 139 if (!status) ESCAPE ("missing FPA.FILTER in concepts"); 140 141 *exptime = psMetadataLookupF32 (&status, fpa->concepts, "FPA.EXPOSURE"); 142 if (!status) ESCAPE ("missing FPA.EXPOSURE in concepts"); 143 144 // we need to select the PHOTCODE.DATA folder that matches our filter 145 psMetadataItem *item = psMetadataLookup (recipe, "PHOTCODE.DATA"); 146 if (!item) ESCAPE ("PHOTCODE.DATA folders missing"); 147 if (item->type != PS_DATA_METADATA_MULTI) ESCAPE ("PHOTCODE.DATA not a multi"); 148 149 // PHOTCODE.DATA is a multi of metadata items 150 psListIterator *iter = psListIteratorAlloc(item->data.list, PS_LIST_HEAD, false); 151 152 psMetadataItem *refItem = NULL; 153 while ((refItem = psListGetAndIncrement (iter))) { 154 if (refItem->type != PS_DATA_METADATA) ESCAPE ("PHOTCODE.DATA entry is not a metadata folder"); 155 156 char *refFilter = psMetadataLookupStr (&status, refItem->data.md, "FILTER"); 157 if (!status) { 158 psLogMsg ("psastro", PS_LOG_INFO, "a PHOTCODE.DATA recipe folder is missing FILTER"); 159 continue; 160 } 161 162 // does this entry match the current filter? 163 if (strcmp (refFilter, filter)) continue; 164 165 psLogMsg ("psastro", PS_LOG_DETAIL, "PHOTCODE.DATA found for filter %s", filter); 166 167 *zeropt = psMetadataLookupF32 (&status, refItem->data.md, "ZEROPT"); 168 if (!status) { 169 psLogMsg ("psastro", PS_LOG_INFO, "a PHOTCODE.DATA recipe folder is missing FILTER"); 170 continue; 171 } 172 psFree (iter); 173 return true; 174 } 175 psFree (iter); 176 return false; 177 }
Note:
See TracChangeset
for help on using the changeset viewer.
