Changeset 24557 for branches/eam_branches/20090522/psModules
- Timestamp:
- Jun 25, 2009, 2:00:56 PM (17 years ago)
- Location:
- branches/eam_branches/20090522
- Files:
-
- 26 edited
- 1 copied
-
. (modified) (1 prop)
-
psModules (modified) (1 prop)
-
psModules/src/camera/pmFPABin.c (modified) (1 diff)
-
psModules/src/camera/pmFPACopy.c (modified) (3 diffs)
-
psModules/src/camera/pmFPAMaskWeight.c (modified) (7 diffs)
-
psModules/src/camera/pmFPAMaskWeight.h (modified) (4 diffs)
-
psModules/src/camera/pmHDU.c (modified) (1 diff)
-
psModules/src/concepts/pmConceptsStandard.c (modified) (4 diffs)
-
psModules/src/config/pmConfig.c (modified) (2 diffs)
-
psModules/src/config/pmErrorCodes.dat (modified) (1 diff)
-
psModules/src/detrend/pmDetrendDB.c (modified) (1 diff)
-
psModules/src/detrend/pmDetrendDB.h (modified) (1 diff)
-
psModules/src/detrend/pmDetrendThreads.c (modified) (1 diff)
-
psModules/src/imcombine/pmSubtraction.c (modified) (7 diffs)
-
psModules/src/imcombine/pmSubtractionEquation.c (modified) (7 diffs)
-
psModules/src/imcombine/pmSubtractionKernels.c (modified) (2 diffs)
-
psModules/src/imcombine/pmSubtractionMask.c (modified) (2 diffs)
-
psModules/src/imcombine/pmSubtractionMatch.c (modified) (3 diffs)
-
psModules/src/objects/Makefile.am (modified) (1 diff)
-
psModules/src/objects/pmFootprintArraysMerge.c (modified) (3 diffs)
-
psModules/src/objects/pmMoments.c (modified) (1 diff)
-
psModules/src/objects/pmSource.c (modified) (6 diffs)
-
psModules/src/objects/pmSourceIO.c (modified) (4 diffs)
-
psModules/src/objects/pmSourceIO.h (modified) (2 diffs)
-
psModules/src/objects/pmSourceIO_CMF_PS1_V2.c (copied) (copied from trunk/psModules/src/objects/pmSourceIO_CMF_PS1_V2.c )
-
psModules/src/objects/pmSourceIO_MatchedRefs.c (modified) (4 diffs)
-
psModules/src/objects/pmSourceMatch.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090522
- Property svn:mergeinfo changed
-
branches/eam_branches/20090522/psModules
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/eam_branches/20090522/psModules/src/camera/pmFPABin.c
r24003 r24557 65 65 } 66 66 67 float imageValue, maskValue;// Values to set 67 // Values to set 68 float imageValue; 69 psImageMaskType maskValue; 68 70 if (numPix > 0) { 69 71 imageValue = sum / numPix; -
branches/eam_branches/20090522/psModules/src/camera/pmFPACopy.c
r23761 r24557 70 70 psImageBinningSetRuffSize(binning, PS_IMAGE_BINNING_CENTER); 71 71 *target = psImageAlloc(binning->nXruff, binning->nYruff, source->type.type); 72 psImageInit (*target, 0.0); 72 73 return; 73 74 } … … 221 222 psTrace("psModules.camera", 3, "xFlip: %d; yFlip: %d\n", xFlip, yFlip); 222 223 224 // Blow away extant readouts 225 for (int i = 0; i < target->readouts->n; i++) { 226 psFree(target->readouts->data[i]); 227 target->readouts->data[i] = NULL; 228 } 229 target->readouts->n = 0; 230 223 231 // Perform deep copy of the images. I would prefer *not* to do a deep copy, in the interests of speed (we 224 232 // still need to do another deep copy into the HDU for when we write out), but this is the only way I can … … 242 250 readoutCopyComponent(&targetReadout->variance, sourceReadout->variance, binning, xFlip, yFlip, 243 251 pixels); 252 // Copy covariance matrix: doesn't care about flips, etc. 253 if (sourceReadout->covariance) { 254 if (targetReadout->covariance) { 255 psFree(targetReadout->covariance); 256 } 257 targetReadout->covariance = psKernelCopy(sourceReadout->covariance); 258 #if 0 259 if (binning) { 260 // XXX This isn't strictly correct, but we don't have a function that bins covariance matrices 261 // with unequal binning factors. 262 psKernel *covar = psImageCovarianceBin(PS_MAX(binning->nXbin, binning->nYbin), 263 targetReadout->covariance); 264 psFree(targetReadout->covariance); 265 targetReadout->covariance = covar; 266 } 267 #endif 268 } 244 269 245 270 // Copy bias -
branches/eam_branches/20090522/psModules/src/camera/pmFPAMaskWeight.c
r23989 r24557 199 199 } 200 200 201 bool pmReadoutSetVariance(pmReadout *readout, bool poisson)201 bool pmReadoutSetVariance(pmReadout *readout, const psImage *noiseMap, bool poisson) 202 202 { 203 203 PS_ASSERT_PTR_NON_NULL(readout, false); 204 // check that the noiseMap (if it exists) matches the readout variance size) 204 205 205 206 pmCell *cell = readout->parent; // The parent cell … … 228 229 229 230 // a negative variance is non-sensical. if the image value drops below 1, the variance must be 1. 231 // XXX this calculation is wrong: limit is 1 e-, but this is in DN 230 232 readout->variance = (psImage*)psUnaryOp(readout->variance, readout->variance, "abs"); 231 233 readout->variance = (psImage*)psBinaryOp(readout->variance, readout->variance, "max", … … 239 241 } 240 242 241 readout->variance = (psImage*)psBinaryOp(readout->variance, readout->variance, "+", 242 psScalarAlloc(readnoise*readnoise/gain/gain, PS_TYPE_F32)); 243 // apply a supplied readnoise map (NOTE: in DN, not electrons): 244 if (noiseMap) { 245 psImage *rdVar = (psImage*)psBinaryOp(NULL, (const psPtr) noiseMap, "*", (const psPtr) noiseMap); 246 readout->variance = (psImage*)psBinaryOp(readout->variance, readout->variance, "+", rdVar); 247 psFree (rdVar); 248 } else { 249 readout->variance = (psImage*)psBinaryOp(readout->variance, readout->variance, "+", psScalarAlloc(readnoise*readnoise/gain/gain, PS_TYPE_F32)); 250 } 243 251 244 252 return true; … … 247 255 // this function creates the variance pixels, or uses the existing variance pixels. it will set 248 256 // the noise pixel values only if the variance image is not supplied 249 bool pmReadoutGenerateVariance(pmReadout *readout, bool poisson)257 bool pmReadoutGenerateVariance(pmReadout *readout, const psImage *noiseMap, bool poisson) 250 258 { 251 259 PS_ASSERT_PTR_NON_NULL(readout, false); … … 291 299 readout->variance = variance; 292 300 293 return pmReadoutSetVariance(readout, poisson);294 } 295 296 bool pmReadoutGenerateMaskVariance(pmReadout *readout, psImageMaskType satMask, psImageMaskType badMask, bool poisson)301 return pmReadoutSetVariance(readout, noiseMap, poisson); 302 } 303 304 bool pmReadoutGenerateMaskVariance(pmReadout *readout, psImageMaskType satMask, psImageMaskType badMask, const psImage *noiseMap, bool poisson) 297 305 { 298 306 PS_ASSERT_PTR_NON_NULL(readout, false); … … 301 309 302 310 success &= pmReadoutGenerateMask(readout, satMask, badMask); 303 success &= pmReadoutGenerateVariance(readout, poisson);311 success &= pmReadoutGenerateVariance(readout, noiseMap, poisson); 304 312 305 313 return success; 306 314 } 307 315 308 bool pmCellGenerateMaskVariance(pmCell *cell, psImageMaskType satMask, psImageMaskType badMask, bool poisson)316 bool pmCellGenerateMaskVariance(pmCell *cell, psImageMaskType satMask, psImageMaskType badMask, const psImage *noiseMap, bool poisson) 309 317 { 310 318 PS_ASSERT_PTR_NON_NULL(cell, false); … … 314 322 for (int i = 0; i < readouts->n; i++) { 315 323 pmReadout *readout = readouts->data[i]; // The readout 316 success &= pmReadoutGenerateMaskVariance(readout, poisson, satMask, badMask);324 success &= pmReadoutGenerateMaskVariance(readout, satMask, badMask, noiseMap, poisson); 317 325 } 318 326 -
branches/eam_branches/20090522/psModules/src/camera/pmFPAMaskWeight.h
r21363 r24557 54 54 /// can't be generated. 55 55 bool pmReadoutSetVariance(pmReadout *readout, ///< Readout for which to set variance 56 const psImage *noiseMap, ///< 2D image of the read noise in DN 56 57 bool poisson ///< Include poisson variance (in addition to read noise)? 57 58 ); … … 72 73 /// with HDU entry). This is intended for most operations. 73 74 bool pmReadoutGenerateVariance(pmReadout *readout, ///< Readout for which to generate variance 75 const psImage *noiseMap, ///< 2D image of the read noise in DN 74 76 bool poisson ///< Include poisson variance (in addition to read noise)? 75 77 ); … … 81 83 psImageMaskType sat, ///< Mask value to give saturated pixels 82 84 psImageMaskType bad, ///< Mask value to give bad (low) pixels 85 const psImage *noiseMap, ///< 2D image of the read noise in DN 83 86 bool poisson ///< Include poisson variance (in addition to read noise)? 84 87 ); … … 90 93 psImageMaskType sat, ///< Mask value to give saturated pixels 91 94 psImageMaskType bad, ///< Mask value to give bad (low) pixels 95 const psImage *noiseMap, ///< 2D image of the read noise in DN 92 96 bool poisson ///< Include poisson variance (in addition to read noise)? 93 97 ); -
branches/eam_branches/20090522/psModules/src/camera/pmHDU.c
r21363 r24557 93 93 } 94 94 95 psTrace("psModules.camera", 5, "Reading the header...\n"); 96 97 // The header may already exist (e.g., from doing concept writing at the PHU level) so we need to be 98 // careful. We read into a separate container and copy that over the top of anything that's already read. 99 psMetadata *header = psFitsReadHeader(NULL, fits); 100 if (!header) { 101 psError(PS_ERR_IO, false, "Unable to read header for extension %s\n", hdu->extname); 102 return false; 103 } 104 95 105 if (!hdu->header) { 96 psTrace("psModules.camera", 5, "Reading the header...\n"); 97 hdu->header = psFitsReadHeader(hdu->header, fits); 98 if (! hdu->header) { 99 psError(PS_ERR_IO, false, "Unable to read header for extension %s\n", hdu->extname); 100 return false; 101 } 102 } 106 hdu->header = header; 107 return true; 108 } 109 110 psMetadataIterator *iter = psMetadataIteratorAlloc(header, PS_LIST_HEAD, NULL); // Iterator 111 psMetadataItem *item; // Item from iteration 112 while ((item = psMetadataGetAndIncrement(iter))) { 113 const char *name = item->name; // Name of item 114 if (psMetadataLookup(hdu->header, name)) { 115 // It exists; clobber 116 psMetadataRemoveKey(hdu->header, name); 117 } 118 psMetadataAddItem(hdu->header, item, PS_LIST_TAIL, 0); 119 } 120 psFree(iter); 121 psFree(header); 103 122 104 123 return true; -
branches/eam_branches/20090522/psModules/src/concepts/pmConceptsStandard.c
r23819 r24557 36 36 // Format type for time 37 37 typedef enum { 38 TIME_FORMAT_YYYYMMDD, // Date stored in YYYY-MM-DD order (ISO-standard)39 TIME_FORMAT_DDMMYYYY, // Date stored in DD-MM-YYYY order40 TIME_FORMAT_MMDDYYYY, // Date stored in MM-DD-YYYY order41 TIME_FORMAT_JD, // Date stored as JD42 TIME_FORMAT_MJD, // Date stored as MJD38 TIME_FORMAT_YYYYMMDD, // Date stored in YYYY-MM-DD order (ISO-standard) 39 TIME_FORMAT_DDMMYYYY, // Date stored in DD-MM-YYYY order 40 TIME_FORMAT_MMDDYYYY, // Date stored in MM-DD-YYYY order 41 TIME_FORMAT_JD, // Date stored as JD 42 TIME_FORMAT_MJD, // Date stored as MJD 43 43 } conceptTimeFormatType; 44 44 … … 391 391 } 392 392 393 393 394 // FPA.RA and FPA.DEC 394 395 psMetadataItem *p_pmConceptFormat_FPA_Coords(const psMetadataItem *concept, … … 410 411 // How to interpret the coordinates 411 412 bool mdok = true; // Status of MD lookup 412 psMetadata *formats = psMetadataLookupMetadata(&mdok, 413 cameraFormat, 414 "FORMATS"); 413 psMetadata *formats = psMetadataLookupMetadata(&mdok, cameraFormat, "FORMATS"); 414 bool sexagesimal = false; // Write sexagesimal format? 415 415 if (mdok && formats) { 416 psString format = psMetadataLookupStr(&mdok, formats, concept->name);416 psString format = psMetadataLookupStr(&mdok, formats, concept->name); 417 417 if (mdok && strlen(format) > 0) { 418 418 if (strcasecmp(format, "HOURS") == 0) { … … 428 428 coords /= defaultCoordScaling(concept); 429 429 } 430 431 psString ra = psMetadataLookupStr(&mdok, formats, "FPA.RA"); // Format for RA 432 psString dec = psMetadataLookupStr(&mdok, formats, "FPA.DEC"); // Format for Dec 433 if (ra && strcasecmp(ra, "HOURS") == 0 && dec && strcasecmp(dec, "DEGREES") == 0) { 434 sexagesimal = true; 435 } 430 436 } else { 431 437 coords /= defaultCoordScaling(concept); 432 438 } 433 439 434 // We choose to write sexagesimal format 435 int big, medium; // Degrees and minutes 436 float small; // Seconds 437 bool negative = (coords < 0); // Are we working below zero? 438 coords = fabs(coords); 439 big = (int)abs(coords); 440 coords -= big; 441 medium = 60.0 * coords; 442 coords -= medium / 60.0; 443 small = 3600.0 * coords; 444 small = (float)((int)(small * 1000.0)) / 1000.0; 445 if (negative) { 446 big *= -1; 447 } 448 psString coordString = NULL; // String with the coordinates in sexagesimal format 449 psStringAppend(&coordString, "%d:%02d:%06.3f", big, medium, small); 450 psMetadataItem *coordItem = psMetadataItemAllocStr(concept->name, concept->comment, coordString); 451 psFree(coordString); 440 psMetadataItem *coordItem = NULL; // Item with coordinates, to return 441 if (sexagesimal) { 442 int big, medium; // Degrees and minutes 443 float small; // Seconds 444 bool negative = (coords < 0); // Are we working below zero? 445 coords = fabs(coords); 446 big = (int)abs(coords); 447 coords -= big; 448 medium = 60.0 * coords; 449 coords -= medium / 60.0; 450 small = 3600.0 * coords; 451 small = (float)((int)(small * 1000.0)) / 1000.0; 452 if (negative) { 453 big *= -1; 454 } 455 psString coordString = NULL; // String with the coordinates in sexagesimal format 456 psStringAppend(&coordString, "%d:%02d:%06.3f", big, medium, small); 457 coordItem = psMetadataItemAllocStr(concept->name, concept->comment, coordString); 458 psFree(coordString); 459 } else { 460 coordItem = psMetadataItemAllocF64(concept->name, concept->comment, coords); 461 } 452 462 453 463 return coordItem; -
branches/eam_branches/20090522/psModules/src/config/pmConfig.c
r23748 r24557 243 243 unsigned int numBadLines = 0; 244 244 struct stat filestat; 245 246 pmErrorRegister(); 245 247 246 248 psTrace("psModules.config", 3, "Loading %s configuration from file %s\n", … … 1496 1498 } 1497 1499 } 1500 globfree(&globList); 1498 1501 } 1499 1502 psFree (words); -
branches/eam_branches/20090522/psModules/src/config/pmErrorCodes.dat
r23688 r24557 12 12 SKY Problem in sky 13 13 STAMPS Unable to select stamps for PSF-matching 14 SMALL_AREA Small area for PSF-matching 14 15 # these errors correspond to standard exit conditions 15 16 ARGUMENTS Incorrect arguments -
branches/eam_branches/20090522/psModules/src/detrend/pmDetrendDB.c
r23600 r24557 105 105 DETREND_STRING_CASE(FRINGE); 106 106 DETREND_STRING_CASE(ASTROM); 107 DETREND_STRING_CASE(NOISEMAP); 107 108 default: 108 109 return NULL; -
branches/eam_branches/20090522/psModules/src/detrend/pmDetrendDB.h
r23487 r24557 35 35 PM_DETREND_TYPE_BACKGROUND, 36 36 PM_DETREND_TYPE_ASTROM, 37 PM_DETREND_TYPE_NOISEMAP, 37 38 } pmDetrendType; 38 39 -
branches/eam_branches/20090522/psModules/src/detrend/pmDetrendThreads.c
r21457 r24557 60 60 } 61 61 62 // NOISEMAP : for now, not applied in the threaded loop 63 62 64 return true; 63 65 } -
branches/eam_branches/20090522/psModules/src/imcombine/pmSubtraction.c
r23989 r24557 196 196 { 197 197 psKernel *convolved = psKernelAlloc(-footprint, footprint, -footprint, footprint); // Convolved image 198 int numBytes = (2 * footprint + 1) * PSELEMTYPE_SIZEOF(PS_TYPE_F32); // Number of bytes to copy199 198 for (int y = -footprint; y <= footprint; y++) { 200 // Convolution with a delta function is just the value specified by the offset 201 memcpy(&convolved->kernel[y][-footprint], &image->kernel[y - v][-footprint - u], numBytes); 199 for (int x = -footprint; x <= footprint; x++) { 200 convolved->kernel[y][x] = image->kernel[y - v][x - u]; 201 } 202 202 } 203 203 return convolved; 204 204 } 205 205 206 // Take a subset of an image207 static inline psImage *convolveSubsetAlloc(psImage *image, // Image to be convolved208 psRegion region, // Region of interest (with border)209 bool threaded // Are we running threaded?210 )211 {212 if (!image) {213 return NULL;214 }215 // XXX if (threaded) {216 // XXX psMutexLock(image);217 // XXX }218 psImage *subset = psImageSubset(image, region); // Subset image, to return219 // XXX if (threaded) {220 // XXX psMutexUnlock(image);221 // XXX }222 return subset;223 }224 225 // Free the subset of an image226 static inline void convolveSubsetFree(psImage *parent, // Parent image227 psImage *child, // Child (subset) image228 bool threaded // Are we running threaded?229 )230 {231 if (!child || !parent) {232 return;233 }234 // XXX if (threaded) {235 // XXX psMutexLock(parent);236 // XXX }237 psFree(child);238 // XXX if (threaded) {239 // XXX psMutexUnlock(parent);240 // XXX }241 return;242 }243 206 244 207 // Convolve an image using FFT … … 256 219 region.y0 - size, region.y1 + size); // Add a border 257 220 258 bool threaded = pmSubtractionThreaded(); // Are we running threaded? 259 260 psImage *subImage = convolveSubsetAlloc(image, border, threaded); // Subimage to convolve 261 psImage *subMask = convolveSubsetAlloc(mask, border, threaded); // Subimage mask 221 psImage *subImage = image ? psImageSubset(image, border) : NULL; // Subimage to convolve 222 psImage *subMask = mask ? psImageSubset(mask, border) : NULL; // Subimage mask 262 223 263 224 psImage *convolved = psImageConvolveFFT(NULL, subImage, subMask, maskVal, kernel); // Convolution 264 225 265 convolveSubsetFree(image, subImage, threaded);266 convolveSubsetFree(mask, subMask, threaded);226 psFree(subImage); 227 psFree(subMask); 267 228 268 229 // Now, we have to stick it in where it belongs … … 300 261 region.y0 - size, region.y1 + size); // Add a border 301 262 302 bool threaded = pmSubtractionThreaded(); // Are we running threaded? 303 304 psImage *subVariance = convolveSubsetAlloc(variance, border, threaded); // Variance map 305 psImage *subSys = convolveSubsetAlloc(sys, border, threaded); // Systematic error image 306 psImage *subMask = convolveSubsetAlloc(mask, border, threaded); // Mask 263 psImage *subVariance = variance ? psImageSubset(variance, border) : NULL; // Variance map 264 psImage *subSys = sys ? psImageSubset(sys, border) : NULL; // Systematic error image 265 psImage *subMask = mask ? psImageSubset(mask, border) : NULL; // Mask 307 266 308 267 // XXX Can trim this a little by combining the convolution: only have to take the FFT of the kernel once … … 310 269 psImage *convSys = subSys ? psImageConvolveFFT(NULL, subSys, subMask, maskVal, kernel) : NULL; // Conv sys 311 270 312 convolveSubsetFree(variance, subVariance, threaded);313 convolveSubsetFree(sys, subSys, threaded);314 convolveSubsetFree(mask, subMask, threaded);271 psFree(subVariance); 272 psFree(subSys); 273 psFree(subMask); 315 274 316 275 // Now, we have to stick it in where it belongs … … 420 379 if (box > 0) { 421 380 int colMin = region.x0, colMax = region.x1, rowMin = region.y0, rowMax = region.y1; // Bounds 422 bool threaded = pmSubtractionThreaded(); // Are we running threaded?423 424 381 psRegion region = psRegionSet(colMin - box, colMax + box, 425 382 rowMin - box, rowMax + box); // Region to convolve 426 383 427 psImage *image = convolveSubsetAlloc(subMask, region, threaded); // Mask to convolve384 psImage *image = subMask ? psImageSubset(subMask, region) : NULL; // Mask to convolve 428 385 429 386 psImage *convolved = psImageConvolveMask(NULL, image, subBad, subConvBad, 430 387 -box, box, -box, box); // Convolved subtraction mask 431 388 432 convolveSubsetFree(subMask, image, threaded);389 psFree(image); 433 390 434 391 psAssert(convolved->numCols - 2 * box == colMax - colMin, "Bad number of columns"); … … 653 610 float value = 0.0; // Value of convolved pixel 654 611 int uMin = x - size, uMax = x + size; // Range for u 655 psF32 *xKernelData = xKernel->data.F32; // Kernel values612 psF32 *xKernelData = &xKernel->data.F32[xKernel->n - 1]; // Kernel values 656 613 psF32 *imageData = &image->kernel[y][uMin]; // Image values 657 for (int u = uMin; u <= uMax; u++, xKernelData ++, imageData++) {614 for (int u = uMin; u <= uMax; u++, xKernelData--, imageData++) { 658 615 value += *xKernelData * *imageData; 659 616 } … … 668 625 float value = 0.0; // Value of convolved pixel 669 626 int vMin = y - size, vMax = y + size; // Range for v 670 psF32 *yKernelData = yKernel->data.F32; // Kernel values627 psF32 *yKernelData = &yKernel->data.F32[yKernel->n - 1]; // Kernel values 671 628 psF32 *imageData = &temp->kernel[x][vMin]; // Image values; NOTE: wrong way! 672 for (int v = vMin; v <= vMax; v++, yKernelData ++, imageData++) {629 for (int v = vMin; v <= vMax; v++, yKernelData--, imageData++) { 673 630 value += *yKernelData * *imageData; 674 631 } -
branches/eam_branches/20090522/psModules/src/imcombine/pmSubtractionEquation.c
r24093 r24557 15 15 #include "pmSubtractionVisual.h" 16 16 17 //#define TESTING 17 //#define TESTING // TESTING output for debugging; may not work with threads! 18 19 #define USE_VARIANCE // Include variance in equation? 18 20 19 21 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// … … 31 33 for (int y = - footprint; y <= footprint; y++) { 32 34 for (int x = - footprint; x <= footprint; x++) { 33 sum += image1->kernel[y][x] * image2->kernel[y][x] / 1.0; // variance->kernel[y][x]; 35 double value = image1->kernel[y][x] * image2->kernel[y][x]; 36 #ifdef USE_VARIANCE 37 value /= variance->kernel[y][x]; 38 #endif 39 sum += value; 34 40 } 35 41 } … … 195 201 for (int y = - footprint; y <= footprint; y++) { 196 202 for (int x = - footprint; x <= footprint; x++) { 197 sumC += conv->kernel[y][x] / 1.0; // variance->kernel[y][x]; 203 double value = conv->kernel[y][x]; 204 #ifdef USE_VARIANCE 205 value /= variance->kernel[y][x]; 206 #endif 207 sumC += value; 198 208 } 199 209 } … … 218 228 for (int y = - footprint; y <= footprint; y++) { 219 229 for (int x = - footprint; x <= footprint; x++) { 220 double invNoise2 = 1.0 / 1.0; // variance->kernel[y][x]; 230 double invNoise2 = 1.0; 231 #ifdef USE_VARIANCE 232 invNoise2 /= variance->kernel[y][x]; 233 #endif 221 234 double value = input->kernel[y][x] * invNoise2; 222 235 sumI += value; … … 277 290 for (int y = - footprint; y <= footprint; y++) { 278 291 for (int x = - footprint; x <= footprint; x++) { 279 sumTC += target->kernel[y][x] * conv->kernel[y][x] / 1.0; // variance->kernel[y][x]; 292 double value = target->kernel[y][x] * conv->kernel[y][x]; 293 #ifdef USE_VARIANCE 294 value /= variance->kernel[y][x]; 295 #endif 296 sumTC += value; 280 297 } 281 298 } … … 297 314 for (int y = - footprint; y <= footprint; y++) { 298 315 for (int x = - footprint; x <= footprint; x++) { 299 float value = target->kernel[y][x] / 1.0; // variance->kernel[y][x]; 316 double value = target->kernel[y][x]; 317 #ifdef USE_VARIANCE 318 value /= variance->kernel[y][x]; 319 #endif 300 320 sumIT += value * input->kernel[y][x]; 301 321 sumT += value; … … 366 386 for (int y = - footprint; y <= footprint; y++) { 367 387 for (int x = - footprint; x <= footprint; x++) { 368 sumC += conv->kernel[y][x] / 1.0; // variance->kernel[y][x]; 388 double value = conv->kernel[y][x]; 389 #ifdef USE_VARIANCE 390 value /= variance->kernel[y][x]; 391 #endif 392 sumC += value; 369 393 } 370 394 } -
branches/eam_branches/20090522/psModules/src/imcombine/pmSubtractionKernels.c
r20421 r24557 145 145 146 146 // Calculate moments 147 double sum = 0.0; // Sum of kernel component, for normalisation148 147 double moment = 0.0; // Moment, for penalty 149 148 for (int v = -size, y = 0; v <= size; v++, y++) { 150 149 for (int u = -size, x = 0; u <= size; u++, x++) { 151 150 double value = xKernel->data.F32[x] * yKernel->data.F32[y]; // Value of kernel 152 sum += value;153 151 moment += value * (PS_SQR(u) + PS_SQR(v)); 154 152 } … … 163 161 } 164 162 } 165 sum = 1.0 / s um;163 sum = 1.0 / sqrt(sum); 166 164 psBinaryOp(xKernel, xKernel, "*", psScalarAlloc(sum, PS_TYPE_F32)); 167 165 psBinaryOp(yKernel, yKernel, "*", psScalarAlloc(sum, PS_TYPE_F32)); 168 moment *= sum;166 moment *= PS_SQR(sum); 169 167 } 170 168 -
branches/eam_branches/20090522/psModules/src/imcombine/pmSubtractionMask.c
r23851 r24557 6 6 #include <pslib.h> 7 7 8 #include "pmErrorCodes.h" 8 9 #include "pmSubtraction.h" 9 10 #include "pmSubtractionKernels.h" … … 78 79 } 79 80 if (numBad > badFrac * numCols * numRows) { 80 psError(P S_ERR_BAD_PARAMETER_VALUE, true,81 psError(PM_ERR_SMALL_AREA, true, 81 82 "Fraction of bad pixels (%d/%d=%f) exceeds limit (%f)\n", 82 83 numBad, numCols * numRows, (float)numBad/(float)(numCols * numRows), badFrac); -
branches/eam_branches/20090522/psModules/src/imcombine/pmSubtractionMatch.c
r24181 r24557 246 246 badFrac, mode); // Subtraction mask 247 247 if (!subMask) { 248 psError( PS_ERR_UNKNOWN, false, "Unable to generate subtraction mask.");248 psError(psErrorCodeLast(), false, "Unable to generate subtraction mask."); 249 249 psFree(kernels); 250 250 psFree(regions); … … 337 337 PS_ASSERT_FLOAT_LESS_THAN_OR_EQUAL(optThreshold, 1.0, false); 338 338 } 339 PS_ASSERT_INT_ POSITIVE(iter, false);339 PS_ASSERT_INT_NONNEGATIVE(iter, false); 340 340 PS_ASSERT_FLOAT_LARGER_THAN(rej, 0.0, false); 341 341 … … 379 379 badFrac, subMode); 380 380 if (!subMask) { 381 psError( PS_ERR_UNKNOWN, false, "Unable to generate subtraction mask.");381 psError(psErrorCodeLast(), false, "Unable to generate subtraction mask."); 382 382 goto MATCH_ERROR; 383 383 } -
branches/eam_branches/20090522/psModules/src/objects/Makefile.am
r23990 r24557 38 38 pmSourceIO_PS1_CAL_0.c \ 39 39 pmSourceIO_CMF_PS1_V1.c \ 40 pmSourceIO_CMF_PS1_V2.c \ 40 41 pmSourceIO_MatchedRefs.c \ 41 42 pmSourcePlots.c \ -
branches/eam_branches/20090522/psModules/src/objects/pmFootprintArraysMerge.c
r20937 r24557 28 28 */ 29 29 psArray *pmFootprintArraysMerge(const psArray *footprints1, // one set of footprints 30 const psArray *footprints2, // the other set 31 const int includePeaks) { // which peaks to set? 0x1 => footprints1, 0x2 => 2 32 assert (footprints1->n == 0 || pmFootprintTest(footprints1->data[0])); 33 assert (footprints2->n == 0 || pmFootprintTest(footprints2->data[0])); 30 const psArray *footprints2, // the other set 31 const int includePeaks // which peaks to set? 0x1 => footprints1, 0x2 => 2 32 ) 33 { 34 if (!footprints1 && !footprints2) { 35 // No footprints in merged array 36 return psArrayAllocEmpty(0); 37 } 34 38 35 if (footprints1->n == 0 || footprints2->n == 0) { // nothing to do but put copies on merged36 const psArray *old = (footprints1->n == 0) ? footprints2 : footprints1;39 assert(!footprints1 || footprints1->n == 0 || pmFootprintTest(footprints1->data[0])); 40 assert(!footprints2 || footprints2->n == 0 || pmFootprintTest(footprints2->data[0])); 37 41 38 psArray *merged = psArrayAllocEmpty(old->n); 39 for (int i = 0; i < old->n; i++) { 40 psArrayAdd(merged, 1, old->data[i]); 41 } 42 43 return merged; 42 if (!footprints1 || footprints1->n == 0 || !footprints2 || footprints2->n == 0) { 43 // nothing to do but put copies on merged 44 const psArray *old = (!footprints1 || footprints1->n == 0) ? footprints2 : footprints1; 45 46 psArray *merged = psArrayAllocEmpty(old->n); 47 for (int i = 0; i < old->n; i++) { 48 psArrayAdd(merged, 1, old->data[i]); 49 } 50 51 return merged; 44 52 } 45 53 /* … … 48 56 */ 49 57 { 50 pmFootprint *fp1 = footprints1->data[0];51 pmFootprint *fp2 = footprints2->data[0];52 if (fp1->region.x0 != fp2->region.x0 ||53 fp1->region.x1 != fp2->region.x1 ||54 fp1->region.y0 != fp2->region.y0 ||55 fp1->region.y1 != fp2->region.y1) {56 psError(PS_ERR_BAD_PARAMETER_SIZE, true,57 "The two pmFootprint arrays correspnond to different-sized regions");58 return NULL;59 }58 pmFootprint *fp1 = footprints1->data[0]; 59 pmFootprint *fp2 = footprints2->data[0]; 60 if (fp1->region.x0 != fp2->region.x0 || 61 fp1->region.x1 != fp2->region.x1 || 62 fp1->region.y0 != fp2->region.y0 || 63 fp1->region.y1 != fp2->region.y1) { 64 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 65 "The two pmFootprint arrays correspnond to different-sized regions"); 66 return NULL; 67 } 60 68 } 61 69 /* … … 72 80 * Now assign the peaks appropriately. We could do this more efficiently 73 81 * using idImage (which we just freed), but this is easy and probably fast enough 74 */ 82 */ 75 83 if (includePeaks & 0x1) { 76 psArray *peaks = pmFootprintArrayToPeaks(footprints1);77 pmFootprintsAssignPeaks(merged, peaks);78 psFree(peaks);84 psArray *peaks = pmFootprintArrayToPeaks(footprints1); 85 pmFootprintsAssignPeaks(merged, peaks); 86 psFree(peaks); 79 87 } 80 88 81 89 if (includePeaks & 0x2) { 82 psArray *peaks = pmFootprintArrayToPeaks(footprints2);83 pmFootprintsAssignPeaks(merged, peaks);84 psFree(peaks);90 psArray *peaks = pmFootprintArrayToPeaks(footprints2); 91 pmFootprintsAssignPeaks(merged, peaks); 92 psFree(peaks); 85 93 } 86 94 87 95 return merged; 88 96 } -
branches/eam_branches/20090522/psModules/src/objects/pmMoments.c
r23487 r24557 51 51 tmp->Sky = 0.0; 52 52 tmp->nPixels = 0; 53 tmp->SN = 0; 53 54 54 55 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__); -
branches/eam_branches/20090522/psModules/src/objects/pmSource.c
r24529 r24557 480 480 481 481 if (!psVectorStats (stats, tmpSx, NULL, NULL, 0)) { 482 psError(PS_ERR_UNKNOWN, false, "failed to measure Sx stats");482 psError(PS_ERR_UNKNOWN, false, "failed to measure Sx stats"); 483 483 return (emptyClump); 484 }484 } 485 485 psfClump.X = stats->clippedMean; 486 486 psfClump.dX = stats->clippedStdev; 487 487 488 488 if (!psVectorStats (stats, tmpSy, NULL, NULL, 0)) { 489 psError(PS_ERR_UNKNOWN, false, "failed to measure Sy stats");489 psError(PS_ERR_UNKNOWN, false, "failed to measure Sy stats"); 490 490 return (emptyClump); 491 }491 } 492 492 psfClump.Y = stats->clippedMean; 493 493 psfClump.dY = stats->clippedStdev; … … 548 548 pmSource *source = (pmSource *) sources->data[i]; 549 549 550 // psf clumps are found for image subregions:551 // skip sources not in this region 550 // psf clumps are found for image subregions: 551 // skip sources not in this region 552 552 if (source->peak->x < region->x0) continue; 553 553 if (source->peak->x >= region->x1) continue; 554 554 if (source->peak->y < region->y0) continue; 555 if (source->peak->y >= region->y1) continue;556 557 // should be set by pmSourceAlloc555 if (source->peak->y >= region->y1) continue; 556 557 // should be set by pmSourceAlloc 558 558 psAssert (source->type == PM_SOURCE_TYPE_UNKNOWN, "source type was not init-ed?"); 559 559 … … 561 561 if (!source->moments) { 562 562 source->type = PM_SOURCE_TYPE_STAR; 563 psAssert (source->mode & noMoments, "why is this source missing moments?");563 psAssert (source->mode & noMoments, "why is this source missing moments?"); 564 564 Nstar++; 565 565 continue; … … 596 596 } 597 597 598 // likely defect (too small to be stellar) (push out to 3 sigma) 599 // low S/N objects which are small are probably stellar 600 // only set candidate defects if 601 // XXX these limits are quite arbitrary 602 if ((sigX < 0.05) || (sigY < 0.05)) { 603 source->type = PM_SOURCE_TYPE_DEFECT; 604 source->mode |= PM_SOURCE_MODE_DEFECT; 605 Ncr ++; 606 continue; 607 } 608 609 // likely unsaturated extended source (too large to be stellar) 610 if ((sigX > (clump.X + 3*clump.dX)) || (sigY > (clump.Y + 3*clump.dY))) { 611 source->type = PM_SOURCE_TYPE_EXTENDED; 612 Next ++; 613 continue; 614 } 615 616 // the rest are probable stellar objects 617 starsn_moments->data.F32[starsn_moments->n] = source->moments->SN; 618 starsn_moments->n ++; 619 starsn_peaks->data.F32[starsn_peaks->n] = source->peak->SN; 620 starsn_peaks->n ++; 621 Nstar ++; 622 623 // PSF star (within 1.5 sigma of clump center, S/N > limit) 624 psF32 radius = hypot ((sigX-clump.X)/clump.dX, (sigY-clump.Y)/clump.dY); 625 if ((source->moments->SN > PSF_SN_LIM) && (radius < PSF_CLUMP_NSIGMA)) { 626 source->type = PM_SOURCE_TYPE_STAR; 627 source->mode |= PM_SOURCE_MODE_PSFSTAR; 628 Npsf ++; 629 continue; 598 // The following determinations require the use of moments 599 if (!(source->mode & noMoments)) { 600 // likely defect (too small to be stellar) (push out to 3 sigma) 601 // low S/N objects which are small are probably stellar 602 // XXX these limits are quite arbitrary 603 if (sigX < 0.05 || sigY < 0.05) { 604 source->type = PM_SOURCE_TYPE_DEFECT; 605 source->mode |= PM_SOURCE_MODE_DEFECT; 606 Ncr ++; 607 continue; 608 } 609 610 // likely unsaturated extended source (too large to be stellar) 611 if (sigX > clump.X + 3*clump.dX || sigY > clump.Y + 3*clump.dY) { 612 source->type = PM_SOURCE_TYPE_EXTENDED; 613 Next ++; 614 continue; 615 } 616 617 // the rest are probable stellar objects 618 starsn_moments->data.F32[starsn_moments->n] = source->moments->SN; 619 starsn_moments->n ++; 620 starsn_peaks->data.F32[starsn_peaks->n] = source->peak->SN; 621 starsn_peaks->n ++; 622 Nstar ++; 623 624 // PSF star (within 1.5 sigma of clump center, S/N > limit) 625 psF32 radius = hypot ((sigX-clump.X)/clump.dX, (sigY-clump.Y)/clump.dY); 626 if ((source->moments->SN > PSF_SN_LIM) && (radius < PSF_CLUMP_NSIGMA)) { 627 source->type = PM_SOURCE_TYPE_STAR; 628 source->mode |= PM_SOURCE_MODE_PSFSTAR; 629 Npsf ++; 630 continue; 631 } 630 632 } 631 633 … … 642 644 643 645 if (!psVectorStats (stats, starsn_moments, NULL, NULL, 0)) { 644 psError(PS_ERR_UNKNOWN, false, "failed to measure SN / moments stats");645 psFree (stats);646 psFree (starsn_peaks);647 return false;646 psError(PS_ERR_UNKNOWN, false, "failed to measure SN / moments stats"); 647 psFree (stats); 648 psFree (starsn_peaks); 649 return false; 648 650 } 649 651 psLogMsg ("pmObjects", 3, "SN range (moments): %f - %f\n", stats->min, stats->max); … … 656 658 stats = psStatsAlloc (PS_STAT_MIN | PS_STAT_MAX); 657 659 if (!psVectorStats (stats, starsn_peaks, NULL, NULL, 0)) { 658 psError(PS_ERR_UNKNOWN, false, "failed to measure SN / moments stats");659 psFree (stats);660 psFree (starsn_peaks);661 return false;660 psError(PS_ERR_UNKNOWN, false, "failed to measure SN / moments stats"); 661 psFree (stats); 662 psFree (starsn_peaks); 663 return false; 662 664 } 663 665 psLogMsg ("psModules.objects", 3, "SN range (peaks) : %f - %f (%ld)\n", -
branches/eam_branches/20090522/psModules/src/objects/pmSourceIO.c
r23990 r24557 496 496 status = pmSourcesWrite_CMF_PS1_V1 (file->fits, readout, sources, file->header, outhead, dataname); 497 497 } 498 if (!strcmp (exttype, "PS1_V2")) { 499 status = pmSourcesWrite_CMF_PS1_V2 (file->fits, readout, sources, file->header, outhead, dataname); 500 } 498 501 if (xsrcname) { 499 502 if (!strcmp (exttype, "PS1_DEV_1")) { … … 506 509 status = pmSourcesWrite_CMF_PS1_V1_XSRC (file->fits, sources, xsrcname, recipe); 507 510 } 511 if (!strcmp (exttype, "PS1_V2")) { 512 status = pmSourcesWrite_CMF_PS1_V2_XSRC (file->fits, sources, xsrcname, recipe); 513 } 508 514 } 509 515 if (xfitname) { … … 517 523 status = pmSourcesWrite_CMF_PS1_V1_XFIT (file->fits, sources, xfitname); 518 524 } 525 if (!strcmp (exttype, "PS1_V2")) { 526 status = pmSourcesWrite_CMF_PS1_V2_XFIT (file->fits, sources, xfitname); 527 } 519 528 } 520 529 if (!status) { … … 944 953 sources = pmSourcesRead_CMF_PS1_V1 (file->fits, hdu->header); 945 954 } 955 if (!strcmp (exttype, "PS1_V2")) { 956 sources = pmSourcesRead_CMF_PS1_V2 (file->fits, hdu->header); 957 } 946 958 } 947 959 -
branches/eam_branches/20090522/psModules/src/objects/pmSourceIO.h
r23990 r24557 39 39 bool pmSourcesWrite_CMF_PS1_V1_XFIT (psFits *fits, psArray *sources, char *extname); 40 40 41 bool pmSourcesWrite_CMF_PS1_V2 (psFits *fits, pmReadout *readout, psArray *sources, psMetadata *imageHeader, psMetadata *tableHeader, char *extname); 42 bool pmSourcesWrite_CMF_PS1_V2_XSRC (psFits *fits, psArray *sources, char *extname, psMetadata *recipe); 43 bool pmSourcesWrite_CMF_PS1_V2_XFIT (psFits *fits, psArray *sources, char *extname); 44 41 45 bool pmSource_CMF_WritePHU (const pmFPAview *view, pmFPAfile *file, pmConfig *config); 42 46 … … 48 52 psArray *pmSourcesRead_PS1_CAL_0 (psFits *fits, psMetadata *header); 49 53 psArray *pmSourcesRead_CMF_PS1_V1 (psFits *fits, psMetadata *header); 54 psArray *pmSourcesRead_CMF_PS1_V2 (psFits *fits, psMetadata *header); 50 55 51 56 bool pmSourcesWritePSFs (psArray *sources, char *filename); -
branches/eam_branches/20090522/psModules/src/objects/pmSourceIO_MatchedRefs.c
r24025 r24557 49 49 pmCell *cell = NULL; 50 50 pmReadout *readout = NULL; 51 pmFPAview *view = pmFPAviewAlloc (0);52 51 53 52 // first, check if there are any matches to be written … … 57 56 psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, "PSASTRO"); 58 57 if (!status) { 59 psError(PS_ERR_UNKNOWN, true, "missing recipe PSASTRO in config data");60 return false;58 psError(PS_ERR_UNKNOWN, true, "missing recipe PSASTRO in config data"); 59 return false; 61 60 } 62 61 … … 65 64 66 65 psArray *table = psArrayAllocEmpty (0x1000); 66 pmFPAview *view = pmFPAviewAlloc (0); 67 67 68 68 // this loop selects the matched stars for all chips … … 70 70 psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process); 71 71 if (!chip->process || !chip->file_exists) continue; 72 73 char *chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME");74 72 75 while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) { 73 char *chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME"); 74 75 while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) { 76 76 psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); 77 77 if (!cell->process || !cell->file_exists) continue; 78 78 79 // process each of the readouts80 // XXX there can only be one readout per chip, right?81 while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) {82 if (! readout->data_exists) continue;79 // process each of the readouts 80 // XXX there can only be one readout per chip, right? 81 while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) { 82 if (! readout->data_exists) continue; 83 83 84 // select the raw objects for this readout85 psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS");86 if (rawstars == NULL) continue;84 // select the raw objects for this readout 85 psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS"); 86 if (rawstars == NULL) continue; 87 87 88 // select the raw objects for this readout89 psArray *refstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.REFSTARS");90 if (refstars == NULL) continue;91 psTrace ("psastro", 4, "Trying %ld refstars\n", refstars->n);88 // select the raw objects for this readout 89 psArray *refstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.REFSTARS"); 90 if (refstars == NULL) continue; 91 psTrace ("psastro", 4, "Trying %ld refstars\n", refstars->n); 92 92 93 psArray *matches = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.MATCH");94 if (matches == NULL) continue;93 psArray *matches = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.MATCH"); 94 if (matches == NULL) continue; 95 95 96 for (int i = 0; i < matches->n; i++) {97 pmAstromMatch *match = matches->data[i];96 for (int i = 0; i < matches->n; i++) { 97 pmAstromMatch *match = matches->data[i]; 98 98 99 pmAstromObj *raw = rawstars->data[match->raw];100 pmAstromObj *ref = refstars->data[match->ref];99 pmAstromObj *raw = rawstars->data[match->raw]; 100 pmAstromObj *ref = refstars->data[match->ref]; 101 101 102 psMetadata *row = psMetadataAlloc ();103 psMetadataAdd (row, PS_LIST_TAIL, "RA", PS_DATA_F64, "right ascension (deg, J2000)", PM_DEG_RAD*ref->sky->r);104 psMetadataAdd (row, PS_LIST_TAIL, "DEC", PS_DATA_F64, "declination (deg, J2000)", PM_DEG_RAD*ref->sky->d);105 psMetadataAdd (row, PS_LIST_TAIL, "X_CHIP", PS_DATA_F32, "x coord on chip",raw->chip->x);106 psMetadataAdd (row, PS_LIST_TAIL, "Y_CHIP", PS_DATA_F32, "y coord on chip", raw->chip->y); 107 psMetadataAdd (row, PS_LIST_TAIL, "X_FPA", PS_DATA_F32, "x coord on focal plane", raw->FP->x);108 psMetadataAdd (row, PS_LIST_TAIL, "Y_FPA", PS_DATA_F32, "y coord on focal plane", raw->FP->y);109 psMetadataAdd (row, PS_LIST_TAIL, "MAG_INST", PS_DATA_F32, "instrumental magnitude", raw->Mag);110 psMetadataAdd (row, PS_LIST_TAIL, "MAG_REF", PS_DATA_F32, "reference star magnitude", ref->Mag);111 psMetadataAdd (row, PS_LIST_TAIL, "COLOR_REF",PS_DATA_F32, "reference star color", ref->Color);112 psMetadataAdd (row, PS_LIST_TAIL, "CHIP_ID", PS_DATA_STRING, "chip identifier", chipName);113 // XXX need to add the reference color, but this needs getstar / dvo.photcodes for the reference to be refined.102 psMetadata *row = psMetadataAlloc (); 103 psMetadataAdd (row, PS_LIST_TAIL, "RA", PS_DATA_F64, "right ascension (deg, J2000)", PM_DEG_RAD*ref->sky->r); 104 psMetadataAdd (row, PS_LIST_TAIL, "DEC", PS_DATA_F64, "declination (deg, J2000)", PM_DEG_RAD*ref->sky->d); 105 psMetadataAdd (row, PS_LIST_TAIL, "X_CHIP", PS_DATA_F32, "x coord on chip", raw->chip->x); 106 psMetadataAdd (row, PS_LIST_TAIL, "Y_CHIP", PS_DATA_F32, "y coord on chip", raw->chip->y); 107 psMetadataAdd (row, PS_LIST_TAIL, "X_FPA", PS_DATA_F32, "x coord on focal plane", raw->FP->x); 108 psMetadataAdd (row, PS_LIST_TAIL, "Y_FPA", PS_DATA_F32, "y coord on focal plane", raw->FP->y); 109 psMetadataAdd (row, PS_LIST_TAIL, "MAG_INST", PS_DATA_F32, "instrumental magnitude", raw->Mag); 110 psMetadataAdd (row, PS_LIST_TAIL, "MAG_REF", PS_DATA_F32, "reference star magnitude", ref->Mag); 111 psMetadataAdd (row, PS_LIST_TAIL, "COLOR_REF",PS_DATA_F32, "reference star color", ref->Color); 112 psMetadataAdd (row, PS_LIST_TAIL, "CHIP_ID", PS_DATA_STRING, "chip identifier", chipName); 113 // XXX need to add the reference color, but this needs getstar / dvo.photcodes for the reference to be refined. 114 114 115 psArrayAdd (table, 100, row);116 psFree (row);117 }118 }119 }115 psArrayAdd (table, 100, row); 116 psFree (row); 117 } 118 } 119 } 120 120 } 121 121 psFree (view); 122 122 123 123 if (table->n == 0) { 124 psFree(table);125 return true;124 psFree(table); 125 return true; 126 126 } 127 127 -
branches/eam_branches/20090522/psModules/src/objects/pmSourceMatch.c
r23989 r24557 45 45 psVector **x, psVector **y, // Coordinate vectors to return 46 46 psVector **mag, psVector **magErr, // Magnitude and error vectors to return 47 psVector **indices, // Indices for sources 47 48 const psArray *sources // Input sources 48 49 ) … … 58 59 *mag = psVectorRecycle(*mag, numSources, PS_TYPE_F32); 59 60 *magErr = psVectorRecycle(*magErr, numSources, PS_TYPE_F32); 61 *indices = psVectorRecycle(*indices, numSources, PS_TYPE_S32); 60 62 float xMin = INFINITY, xMax = -INFINITY, yMin = INFINITY, yMax = -INFINITY; // Bounds of sources 61 63 long num = 0; // Number of valid sources 62 64 for (long i = 0; i < numSources; i++) { 63 65 pmSource *source = sources->data[i]; // Source of interest 64 if (!source) continue; 65 if (source->mode & SOURCE_MASK) continue; 66 if (!isfinite(source->psfMag)) continue; 67 if (!isfinite(source->errMag)) continue; 68 if (source->psfMag > SOURCE_FAINTEST) continue; 66 if (!source || (source->mode & SOURCE_MASK) || !isfinite(source->psfMag) || 67 !isfinite(source->errMag) || source->psfMag > SOURCE_FAINTEST) { 68 continue; 69 } 69 70 70 71 float xSrc, ySrc; // Coordinates of source … … 78 79 (*y)->data.F32[num] = ySrc; 79 80 (*mag)->data.F32[num] = source->psfMag; 80 (*magErr)->data.F32[num] = source->errMag ; 81 (*magErr)->data.F32[num] = source->errMag; 82 (*indices)->data.S32[num] = i; 81 83 num++; 82 84 } … … 85 87 (*mag)->n = num; 86 88 (*magErr)->n = num; 89 (*indices)->n = num; 87 90 88 91 if (*bounds) { … … 175 178 psVector *xImage = NULL, *yImage = NULL; // Coordinates of sources 176 179 psVector *magImage = NULL, *magErrImage = NULL; // Magnitude and mag 177 178 int numSources = sourcesParse(&boundsImage, &xImage, &yImage, &magImage, &magErrImage, 180 psVector *indices = NULL; // Indices for sources 181 182 int numSources = sourcesParse(&boundsImage, &xImage, &yImage, &magImage, &magErrImage, &indices, 179 183 sources); // Number of sources 180 184 … … 187 191 for (int j = 0; j < numSources; j++) { 188 192 pmSourceMatch *match = pmSourceMatchAlloc(); // Match data 189 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j); 193 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], 194 i, indices->data.S32[j]); 190 195 matches->data[j] = match; 191 196 } … … 206 211 for (int j = 0, k = numMaster; j < numSources; j++, k++) { 207 212 pmSourceMatch *match = pmSourceMatchAlloc(); // Match data 208 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j); 213 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], 214 i, indices->data.S32[j]); 209 215 matches->data[k] = match; 210 216 } … … 231 237 // Record the match 232 238 pmSourceMatch *match = matches->data[index]; // Match data 233 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j); 239 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], 240 i, indices->data.S32[j]); 234 241 numMatch++; 235 242 } else { 236 243 // Add to the master list 237 244 pmSourceMatch *match = pmSourceMatchAlloc(); // Match data 238 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j); 245 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], 246 i, indices->data.S32[j]); 239 247 xMaster->data.F32[numMaster] = xImage->data.F32[j]; 240 248 yMaster->data.F32[numMaster] = yImage->data.F32[j];
Note:
See TracChangeset
for help on using the changeset viewer.
