Changeset 26964
- Timestamp:
- Feb 16, 2010, 3:36:17 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
ippconfig/gpc1/format_mef.config (modified) (1 diff)
-
ippconfig/gpc1/format_relphot.config (modified) (1 diff)
-
psModules/src/concepts/pmConcepts.c (modified) (2 diffs)
-
psModules/src/concepts/pmConceptsAverage.c (modified) (4 diffs)
-
psModules/src/objects/pmSourceIO_CMF_PS1_V1.c (modified) (2 diffs)
-
psModules/src/objects/pmSourceIO_CMF_PS1_V2.c (modified) (1 diff)
-
psastro/src/psastroZeroPoint.c (modified) (14 diffs)
-
pswarp/src/pswarpLoop.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippconfig/gpc1/format_mef.config
r23624 r26964 179 179 FPA.AZ STR AZ 180 180 FPA.TEMP STR DETTEM 181 FPA.ZP STR MAG_ZP 181 182 CHIP.ID STR DETECTOR 182 183 CELL.XBIN STR CCDSUM -
trunk/ippconfig/gpc1/format_relphot.config
r23200 r26964 116 116 FPA.AZ STR AZ 117 117 FPA.TEMP STR DETTEM 118 FPA.ZP STR MAG_ZP 118 119 CHIP.ID STR DETECTOR 119 120 CELL.XBIN STR CCDSUM -
trunk/psModules/src/concepts/pmConcepts.c
r26002 r26964 292 292 conceptRegisterF32("FPA.FOCUS", "Telescope focus", NULL, NULL, NULL, false, PM_FPA_LEVEL_FPA); 293 293 conceptRegisterF32("FPA.AIRMASS", "Airmass at boresight", NULL, NULL, NULL, false, PM_FPA_LEVEL_FPA); 294 // XXX p_pmConceptParse_FPA_FILTER -> p_pmConceptParse_FPA_FILTERID (and Format as well)?294 // XXX p_pmConceptParse_FPA_FILTER -> p_pmConceptParse_FPA_FILTERID (and Format as well)? 295 295 conceptRegisterStr("FPA.FILTERID", "Filter used (parsed, abstract name)", p_pmConceptParse_FPA_FILTER, p_pmConceptFormat_FPA_FILTER, NULL, false, PM_FPA_LEVEL_FPA); 296 296 conceptRegisterStr("FPA.FILTER", "Filter used (instrument name)", NULL, NULL, NULL, false, PM_FPA_LEVEL_FPA); … … 334 334 conceptRegisterF32("FPA.TELTEMP.EXTRA", "Telescope Temperatures: extra", p_pmConceptParse_TELTEMPS, NULL, NULL, false, PM_FPA_LEVEL_FPA); 335 335 conceptRegisterF32("FPA.PON.TIME", "Power On Time", NULL, NULL, NULL, false, PM_FPA_LEVEL_FPA); 336 conceptRegisterS32("FPA.BURNTOOL.APPLIED", "[T=applied] Burn streaks applied to image data", p_pmConceptParse_BTOOLAPP,p_pmConceptFormat_BTOOLAPP,NULL,false,PM_FPA_LEVEL_FPA);337 //conceptRegisterBool("FPA.BURNTOOL.APPLIED", "Status of burntool processing", NULL, NULL, NULL, false, PM_FPA_LEVEL_FPA);336 conceptRegisterS32("FPA.BURNTOOL.APPLIED", "[T=applied] Burn streaks applied to image data", p_pmConceptParse_BTOOLAPP,p_pmConceptFormat_BTOOLAPP,NULL,false,PM_FPA_LEVEL_FPA); 337 // conceptRegisterBool("FPA.BURNTOOL.APPLIED", "Status of burntool processing", NULL, NULL, NULL, false, PM_FPA_LEVEL_FPA); 338 338 conceptRegisterF32("FPA.EXPOSURE", "Exposure time (sec)", NULL, NULL, NULL, false, PM_FPA_LEVEL_FPA); 339 conceptRegisterF32("FPA.ZP", "Magnitude zero point", NULL, NULL, NULL, false, PM_FPA_LEVEL_FPA); 339 340 } 340 341 if (!conceptsChip) { -
trunk/psModules/src/concepts/pmConceptsAverage.c
r22706 r26964 36 36 37 37 double time = 0.0; // Time of observation 38 double zp = 0.0; // Zero point 38 39 psTimeType timeSys = 0; // Time system 39 40 char *filter = NULL; // Filter … … 63 64 psTimeConvert(fpaTime, PS_TIME_TAI); 64 65 time += psTimeToMJD(fpaTime); 66 67 zp += psMetadataLookupF32(NULL, fpa->concepts, "FPA.ZP"); 68 65 69 if (num == 1) { 66 70 timeSys = psMetadataLookupS32(NULL, fpa->concepts, "FPA.TIMESYS"); … … 85 89 86 90 time /= (double)num; 91 zp /= (double)num; 87 92 88 93 MD_UPDATE(target->concepts, "FPA.TIMESYS", S32, timeSys); … … 92 97 MD_UPDATE_STR(target->concepts, "FPA.INSTRUMENT", instrument); 93 98 MD_UPDATE_STR(target->concepts, "FPA.DETECTOR", detector); 99 MD_UPDATE(target->concepts, "FPA.ZP", F32, zp); 94 100 95 101 // FPA.TIME needs special care -
trunk/psModules/src/objects/pmSourceIO_CMF_PS1_V1.c
r25754 r26964 69 69 float magOffset = NAN; 70 70 float exptime = psMetadataLookupF32 (&status1, fpa->concepts, "FPA.EXPOSURE"); 71 float zeropt = psMetadataLookupF32 (&status2, imageHeader, "ZPT_OBS"); 72 float zeroptErr = psMetadataLookupF32 (&status2, imageHeader, "ZPT_ERR"); 71 float zeropt = psMetadataLookupF32(&status2, fpa->concepts, "FPA.ZP"); 72 if (!isfinite(zeropt)) { 73 zeropt = psMetadataLookupF32 (&status2, imageHeader, "ZPT_OBS"); 74 } 73 75 if (status1 && status2 && (exptime > 0.0)) { 74 76 magOffset = zeropt + 2.5*log10(exptime); 75 77 } 78 float zeroptErr = psMetadataLookupF32 (&status2, imageHeader, "ZPT_ERR"); 76 79 77 80 // if the sequence is defined, write these in seq order; otherwise … … 477 480 } 478 481 479 # endif 482 # endif 480 483 psArrayAdd (table, 100, row); 481 484 psFree (row); -
trunk/psModules/src/objects/pmSourceIO_CMF_PS1_V2.c
r26893 r26964 69 69 float magOffset = NAN; 70 70 float exptime = psMetadataLookupF32 (&status1, fpa->concepts, "FPA.EXPOSURE"); 71 float zeropt = psMetadataLookupF32 (&status2, imageHeader, "ZPT_OBS"); 72 float zeroptErr = psMetadataLookupF32 (&status2, imageHeader, "ZPT_ERR"); 71 float zeropt = psMetadataLookupF32(&status2, fpa->concepts, "FPA.ZP"); 72 if (!isfinite(zeropt)) { 73 zeropt = psMetadataLookupF32 (&status2, imageHeader, "ZPT_OBS"); 74 } 73 75 if (status1 && status2 && (exptime > 0.0)) { 74 76 magOffset = zeropt + 2.5*log10(exptime); 75 77 } 78 float zeroptErr = psMetadataLookupF32 (&status2, imageHeader, "ZPT_ERR"); 76 79 77 80 // if the sequence is defined, write these in seq order; otherwise -
trunk/psastro/src/psastroZeroPoint.c
r26558 r26964 1 1 /** @file psastroMosaicZeroPoint.c 2 2 * 3 * @brief 3 * @brief 4 4 * 5 5 * @ingroup libpsastro … … 24 24 psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSASTRO_RECIPE); 25 25 if (!recipe) { 26 psError(PSASTRO_ERR_CONFIG, false, "Can't find PSASTRO recipe!\n");27 return false;26 psError(PSASTRO_ERR_CONFIG, false, "Can't find PSASTRO recipe!\n"); 27 return false; 28 28 } 29 29 … … 34 34 pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT"); 35 35 if (!input) { 36 psError(PSASTRO_ERR_CONFIG, false, "Can't find input data!\n");37 return false;36 psError(PSASTRO_ERR_CONFIG, false, "Can't find input data!\n"); 37 return false; 38 38 } 39 39 pmFPA *fpa = input->fpa; … … 55 55 // really error-out here? or just skip? 56 56 if (!psastroZeroPointFromRecipe (&zeropt, &exptime, NULL, fpa, recipe)) { 57 psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe");58 return false;57 psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe"); 58 return false; 59 59 } 60 60 … … 67 67 psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process); 68 68 if (!chip->process || !chip->file_exists) { continue; } 69 if (!chip->toFPA) { continue; }70 71 while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) {69 if (!chip->toFPA) { continue; } 70 71 while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) { 72 72 psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); 73 73 if (!cell->process || !cell->file_exists) { continue; } 74 74 75 // process each of the readouts76 // XXX there can only be one readout per chip, right?77 while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) {78 if (! readout->data_exists) { continue; }79 80 // calculate dMag for the matched stars81 dMag = psastroZeroPointReadoutAccum (dMag, readout, exptime);82 83 if (!byExposure) {84 // calculate dMag for the matched stars just for this readout (well, chip)85 psMetadata *header = psMetadataLookupMetadata (&status, readout->analysis, "PSASTRO.HEADER");86 psastroZeroPointAnalysis (header, dMag, zeropt, recipe);87 psFree (dMag);88 dMag = NULL;89 }90 }91 }75 // process each of the readouts 76 // XXX there can only be one readout per chip, right? 77 while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) { 78 if (! readout->data_exists) { continue; } 79 80 // calculate dMag for the matched stars 81 dMag = psastroZeroPointReadoutAccum (dMag, readout, exptime); 82 83 if (!byExposure) { 84 // calculate dMag for the matched stars just for this readout (well, chip) 85 psMetadata *header = psMetadataLookupMetadata (&status, readout->analysis, "PSASTRO.HEADER"); 86 psastroZeroPointAnalysis (header, dMag, zeropt, recipe); 87 psFree (dMag); 88 dMag = NULL; 89 } 90 } 91 } 92 92 } 93 93 94 94 if (byExposure) { 95 psMetadata *header = psMetadataLookupMetadata (&status, fpa->analysis, "PSASTRO.HEADER"); 96 if (!header) { 97 header = psMetadataAlloc (); 98 psMetadataAddMetadata (fpa->analysis, PS_LIST_TAIL, "PSASTRO.HEADER", PS_META_REPLACE, "psastro header stats", header); 99 psFree (header); 100 } 101 psastroZeroPointAnalysis (header, dMag, zeropt, recipe); 102 psFree (dMag); 103 dMag = NULL; 104 } 95 psMetadata *header = psMetadataLookupMetadata (&status, fpa->analysis, "PSASTRO.HEADER"); 96 if (!header) { 97 header = psMetadataAlloc (); 98 psMetadataAddMetadata (fpa->analysis, PS_LIST_TAIL, "PSASTRO.HEADER", PS_META_REPLACE, "psastro header stats", header); 99 psFree (header); 100 } 101 psastroZeroPointAnalysis (header, dMag, zeropt, recipe); 102 psFree (dMag); 103 dMag = NULL; 104 } 105 106 psMetadataItem *item = psMetadataLookup(fpa->concepts, "FPA.ZP"); 107 item->data.F32 = zeropt; 105 108 106 109 psFree (view); … … 127 130 128 131 if (!dMag) { 129 dMag = psVectorAllocEmpty (100, PS_TYPE_F32);132 dMag = psVectorAllocEmpty (100, PS_TYPE_F32); 130 133 } 131 134 … … 164 167 psStats *stats = NULL; 165 168 if (useMean) { 166 // stats structure and mask for use in measuring the clipping statistic167 // this analysis has too few data points to use the robust median method168 stats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV);169 if (!psVectorStats (stats, dMag, NULL, NULL, 0)) {170 psError(PS_ERR_UNKNOWN, false, "failure to measure zero point by mean");171 return false;172 }169 // stats structure and mask for use in measuring the clipping statistic 170 // this analysis has too few data points to use the robust median method 171 stats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV); 172 if (!psVectorStats (stats, dMag, NULL, NULL, 0)) { 173 psError(PS_ERR_UNKNOWN, false, "failure to measure zero point by mean"); 174 return false; 175 } 173 176 } else { 174 stats = psastroStatsPercentile (dMag, recipe);175 if (!stats) {176 psError(PS_ERR_UNKNOWN, false, "failure to measure zero point by edge");177 return false;178 }177 stats = psastroStatsPercentile (dMag, recipe); 178 if (!stats) { 179 psError(PS_ERR_UNKNOWN, false, "failure to measure zero point by edge"); 180 return false; 181 } 179 182 } 180 183 fprintf (stderr, "zero point %f +/- %f using %ld stars; transparency %f\n", stats->clippedMean, stats->clippedStdev, dMag->n, zeropt - stats->clippedMean); … … 243 246 // search for the 'blue' edge of the dMag distribution: 244 247 // the distribution is not a normal population, but instead has a broad range with fairly hard edges. 245 // construct a histogram and look for the 248 // construct a histogram and look for the 246 249 247 250 bool status; … … 256 259 float min = NAN, max = NAN; // Mimimum and maximum values 257 260 258 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 261 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 259 262 260 263 // Get the minimum and maximum values … … 267 270 // If all data points have the same value, then we set the appropriate members of stats and return. 268 271 if (fabs(max - min) <= FLT_EPSILON) { 269 stats->clippedMean = min;270 stats->clippedStdev = NAN;271 stats->results |= PS_STAT_CLIPPED_MEAN;272 stats->results |= PS_STAT_CLIPPED_STDEV;273 return stats;274 } 275 276 // Define the histogram bin size. 272 stats->clippedMean = min; 273 stats->clippedStdev = NAN; 274 stats->results |= PS_STAT_CLIPPED_MEAN; 275 stats->results |= PS_STAT_CLIPPED_STDEV; 276 return stats; 277 } 278 279 // Define the histogram bin size. 277 280 float binSize = MAG_RESOLUTION; 278 281 long numBins = (max - min) / binSize; // Number of bins … … 293 296 float S2 = 0.0; 294 297 for (int i = 0; i < edgeSample; i++) { 295 296 // generate the subset vector297 for (long i = 0; i < nSubset; i++) {298 double frnd = psRandomUniform(rng);299 int entry = PS_MIN(myVector->n - 1, PS_MAX(0, myVector->n * frnd));300 301 subset->data.F32[i] = myVector->data.F32[entry];302 }303 304 float value = psastroStatsPercentileValue (histogram, cumulative, subset, edgeFraction);305 306 Sum += value;307 S2 += value*value;298 299 // generate the subset vector 300 for (long i = 0; i < nSubset; i++) { 301 double frnd = psRandomUniform(rng); 302 int entry = PS_MIN(myVector->n - 1, PS_MAX(0, myVector->n * frnd)); 303 304 subset->data.F32[i] = myVector->data.F32[entry]; 305 } 306 307 float value = psastroStatsPercentileValue (histogram, cumulative, subset, edgeFraction); 308 309 Sum += value; 310 S2 += value*value; 308 311 } 309 312 psTrace("psastro", 6, "subset stats: Sum: %f, S2: %f, Npts: %d\n", Sum, S2, edgeSample); … … 345 348 psVectorInit (histogram->nums, 0); 346 349 if (!psVectorHistogram(histogram, myVector, NULL, NULL, 0)) { 347 // if psVectorHistogram returns false, we have a programming error348 psAbort ("Unable to generate histogram for psastroZeroPointAnalysis");350 // if psVectorHistogram returns false, we have a programming error 351 psAbort ("Unable to generate histogram for psastroZeroPointAnalysis"); 349 352 } 350 353 if (psTraceGetLevel("psastro") >= 8) { 351 PS_VECTOR_PRINT_F32(histogram->bounds);352 PS_VECTOR_PRINT_F32(histogram->nums);354 PS_VECTOR_PRINT_F32(histogram->bounds); 355 PS_VECTOR_PRINT_F32(histogram->nums); 353 356 } 354 357 … … 357 360 cumulative->nums->data.F32[0] = histogram->nums->data.F32[0]; 358 361 for (long i = 1; i < histogram->nums->n; i++) { 359 cumulative->nums->data.F32[i] = cumulative->nums->data.F32[i-1] + histogram->nums->data.F32[i];360 cumulative->bounds->data.F32[i-1] = histogram->bounds->data.F32[i];362 cumulative->nums->data.F32[i] = cumulative->nums->data.F32[i-1] + histogram->nums->data.F32[i]; 363 cumulative->bounds->data.F32[i-1] = histogram->bounds->data.F32[i]; 361 364 } 362 365 if (psTraceGetLevel("psastro") >= 8) { 363 PS_VECTOR_PRINT_F32(cumulative->bounds);364 PS_VECTOR_PRINT_F32(cumulative->nums);366 PS_VECTOR_PRINT_F32(cumulative->bounds); 367 PS_VECTOR_PRINT_F32(cumulative->nums); 365 368 } 366 369 … … 403 406 if (item->type != PS_DATA_METADATA_MULTI) ESCAPE ("PHOTCODE.DATA not a multi"); 404 407 405 // PHOTCODE.DATA is a multi of metadata items 408 // PHOTCODE.DATA is a multi of metadata items 406 409 psListIterator *iter = psListIteratorAlloc(item->data.list, PS_LIST_HEAD, false); 407 410 408 411 psMetadataItem *refItem = NULL; 409 412 while ((refItem = psListGetAndIncrement (iter))) { 410 if (refItem->type != PS_DATA_METADATA) ESCAPE ("PHOTCODE.DATA entry is not a metadata folder");411 412 char *refFilter = psMetadataLookupStr (&status, refItem->data.md, "FILTER");413 if (!status) {414 // psLogMsg ("psastro", PS_LOG_INFO, "a PHOTCODE.DATA recipe folder is missing FILTER");415 continue;416 }417 418 // does this entry match the current filter?419 if (strcmp (refFilter, filter)) continue;420 421 psLogMsg ("psastro", PS_LOG_DETAIL, "PHOTCODE.DATA found for filter %s", filter);422 423 *zeropt = psMetadataLookupF32 (&status, refItem->data.md, "ZEROPT");424 if (!status) {425 psLogMsg ("psastro", PS_LOG_INFO, "a PHOTCODE.DATA recipe folder is missing ZEROPT");426 continue;427 }428 if (ghostMaxMag) {429 *ghostMaxMag = psMetadataLookupF32 (&status, refItem->data.md, "GHOST_MAX_MAG");430 if (!status) {431 psLogMsg ("psastro", PS_LOG_INFO, "a PHOTCODE.DATA recipe folder is missing GHOST_MAX_MAG");432 continue;433 }434 }435 psFree (iter);436 return true;413 if (refItem->type != PS_DATA_METADATA) ESCAPE ("PHOTCODE.DATA entry is not a metadata folder"); 414 415 char *refFilter = psMetadataLookupStr (&status, refItem->data.md, "FILTER"); 416 if (!status) { 417 // psLogMsg ("psastro", PS_LOG_INFO, "a PHOTCODE.DATA recipe folder is missing FILTER"); 418 continue; 419 } 420 421 // does this entry match the current filter? 422 if (strcmp (refFilter, filter)) continue; 423 424 psLogMsg ("psastro", PS_LOG_DETAIL, "PHOTCODE.DATA found for filter %s", filter); 425 426 *zeropt = psMetadataLookupF32 (&status, refItem->data.md, "ZEROPT"); 427 if (!status) { 428 psLogMsg ("psastro", PS_LOG_INFO, "a PHOTCODE.DATA recipe folder is missing ZEROPT"); 429 continue; 430 } 431 if (ghostMaxMag) { 432 *ghostMaxMag = psMetadataLookupF32 (&status, refItem->data.md, "GHOST_MAX_MAG"); 433 if (!status) { 434 psLogMsg ("psastro", PS_LOG_INFO, "a PHOTCODE.DATA recipe folder is missing GHOST_MAX_MAG"); 435 continue; 436 } 437 } 438 psFree (iter); 439 return true; 437 440 } 438 441 psFree (iter); -
trunk/pswarp/src/pswarpLoop.c
r26896 r26964 367 367 } 368 368 369 // Update ZP from the astrometry 370 { 371 psMetadataItem *item = psMetadataLookup(outFPA->concepts, "FPA.ZP"); 372 item->data.F32 = psMetadataLookupF32(NULL, astrom->fpa->concepts, "FPA.ZP"); 373 } 374 369 375 pmHDU *hdu = outFPA->hdu; ///< HDU for the output warped image 370 376
Note:
See TracChangeset
for help on using the changeset viewer.
