Changeset 26649
- Timestamp:
- Jan 20, 2010, 5:20:00 PM (16 years ago)
- Location:
- branches/eam_branches/20091201/ppSub/src
- Files:
-
- 4 edited
-
ppSubCamera.c (modified) (2 diffs)
-
ppSubMakePSF.c (modified) (4 diffs)
-
ppSubMatchPSFs.c (modified) (3 diffs)
-
ppSubReadoutPhotometry.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20091201/ppSub/src/ppSubCamera.c
r26597 r26649 317 317 318 318 // psPhot input 319 if (data->photometry ) {319 if (data->photometry || 1) { 320 320 psphotModelClassInit(); // load implementation-specific models 321 321 … … 329 329 return false; 330 330 } 331 // specify the number of psphot input images332 psMetadataAddS32 (config->arguments, PS_LIST_TAIL, "PSPHOT.INPUT.NUM", PS_META_REPLACE, "number of inputs", 1);331 // specify the number of psphot input images 332 psMetadataAddS32 (config->arguments, PS_LIST_TAIL, "PSPHOT.INPUT.NUM", PS_META_REPLACE, "number of inputs", 1); 333 333 pmFPAfileActivate(config->files, false, "PSPHOT.INPUT"); 334 334 -
branches/eam_branches/20091201/ppSub/src/ppSubMakePSF.c
r26612 r26649 70 70 psMetadataRemoveKey(photRO->analysis, "PSPHOT.SOURCES"); 71 71 } 72 if (psMetadataLookup(photRO->parent->parent->analysis, "PSPHOT.PSF")) { 73 psMetadataRemoveKey(photRO->parent->parent->analysis, "PSPHOT.PSF"); 74 } 72 75 73 76 # ifdef TESTING … … 101 104 psErrorStackPrint(stderr, "PSF was not generated"); 102 105 psWarning("PSF was not generated --- suspect bad data quality."); 103 ppSubDataQuality(data, psErrorCodeLast(), PPSUB_FILES_PHOT_SUB | PPSUB_FILES_PHOT_INV);106 ppSubDataQuality(data, psErrorCodeLast(), PPSUB_FILES_PHOT_SUB | PPSUB_FILES_PHOT_INV); 104 107 } 105 108 … … 124 127 125 128 if (!outputRO) { 126 pmCell *outputCell = pmFPAviewThisCell(view, output->fpa); 127 outputRO = pmReadoutAlloc(outputCell);128 outputRO->image = psMemIncrRefCounter (inputRO->image);129 pmCell *outputCell = pmFPAviewThisCell(view, output->fpa); 130 outputRO = pmReadoutAlloc(outputCell); 131 outputRO->image = psMemIncrRefCounter (inputRO->image); 129 132 } 130 133 … … 135 138 if (!nRegions) { 136 139 psErrorStackPrint(stderr, "No PSF available"); 137 return false;140 return false; 138 141 } 139 142 psMetadataAddS32 (psfRegions, PS_LIST_TAIL, "PSF.CLUMP.NREGIONS", PS_META_REPLACE, "psf clump regions", nRegions); 140 143 141 144 for (int i = 0; i < nRegions; i++) { 142 char fieldName[80];143 snprintf (fieldName, 80, "PSF.CLUMP.REGION.%03d", i);145 char fieldName[80]; 146 snprintf (fieldName, 80, "PSF.CLUMP.REGION.%03d", i); 144 147 psMetadata *regionMD = psMetadataLookupPtr (&mdok, inputRO->analysis, fieldName); 145 148 if (!regionMD) { 146 psWarning ("missing psf clump region metadata for entry %d", i);147 continue;148 }149 psMetadataAddMetadata (psfRegions, PS_LIST_TAIL, fieldName, PS_META_REPLACE, "psf clump region", regionMD);149 psWarning ("missing psf clump region metadata for entry %d", i); 150 continue; 151 } 152 psMetadataAddMetadata (psfRegions, PS_LIST_TAIL, fieldName, PS_META_REPLACE, "psf clump region", regionMD); 150 153 } 151 154 -
branches/eam_branches/20091201/ppSub/src/ppSubMatchPSFs.c
r26581 r26649 36 36 psFree(subImage); 37 37 return; 38 } 39 40 // Measure the PSF for an image 41 static float subImagePSF(ppSubData *data, // Processing data 42 const pmReadout *ro, // Readout for which to measure PSF 43 psArray *sources // Sources with positions at which to measure PSF 44 ) 45 { 46 psAssert(data, "Require processing data"); 47 pmConfig *config = data->config; // Configuration 48 psAssert(config, "Require configuration"); 49 50 psAssert(ro, "Need readout"); 51 psAssert(sources, "Need sources."); 52 53 pmFPAfile *photFile = psMetadataLookupPtr(NULL, config->files, "PSPHOT.INPUT"); // Photometry file 54 psAssert(photFile, "Need photometry file."); 55 if (!pmFPACopy(photFile->fpa, ro->parent->parent->parent)) { 56 psError(PS_ERR_UNKNOWN, false, "Unable to copy FPA for photometry"); 57 return false; 58 } 59 60 pmFPAview *view = ppSubViewReadout(); // View to readout 61 pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout to photometer 62 63 if (psMetadataLookup(photRO->analysis, "PSPHOT.SOURCES")) { 64 psMetadataRemoveKey(photRO->analysis, "PSPHOT.SOURCES"); 65 } 66 if (psMetadataLookup(photRO->parent->parent->analysis, "PSPHOT.PSF")) { 67 psMetadataRemoveKey(photRO->parent->parent->analysis, "PSPHOT.PSF"); 68 } 69 70 // Extract the loaded sources from the associated readout, and generate PSF 71 // Here, we assume the image is background-subtracted 72 if (!psphotReadoutFindPSF(config, view, sources)) { 73 psErrorStackPrint(stderr, "Unable to determine PSF"); 74 psWarning("Unable to determine PSF."); 75 psFree(view); 76 return true; 77 } 78 79 psFree(view); 80 81 psMetadata *header = psMetadataLookupMetadata(NULL, photRO->analysis, "PSPHOT.HEADER"); 82 psAssert(header, "Require header."); 83 float fwhm = psMetadataLookupF32(NULL, header, "FWHM_MAJ"); 84 85 return fwhm; 86 } 87 88 // Scale the kernel parameters according to the PSFs 89 static bool subScaleKernel(ppSubData *data, // Processing data 90 psVector *kernelWidths, // Widths for kernel 91 int *kernelSize, // Size of kernel 92 int *stampSize // Size of stamps (footprint) 93 ) 94 { 95 psAssert(data, "Require processing data"); 96 pmConfig *config = data->config; // Configuration 97 psAssert(config, "Require configuration"); 98 99 // Nothing to do if pre-calculated kernel exists 100 pmFPAview *view = ppSubViewReadout(); // View to readout 101 pmReadout *kernelRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT.KERNELS"); // RO with kernel 102 if (kernelRO) { 103 psFree(view); 104 return true; 105 } 106 107 // Look up recipe values 108 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim 109 psAssert(recipe, "We checked this earlier, so it should be here."); 110 if (!psMetadataLookupBool(NULL, recipe, "SCALE")) { 111 // No scaling requested 112 psFree(view); 113 return true; 114 } 115 116 // Input images 117 pmReadout *inRO = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT"); // Input readout 118 pmReadout *refRO = pmFPAfileThisReadout(config->files, view, "PPSUB.REF"); // Reference readout 119 120 // Input sources 121 pmReadout *inSourceRO = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.SOURCES"); 122 pmReadout *refSourceRO = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.SOURCES"); 123 psArray *inSources = psMetadataLookupPtr(NULL, inSourceRO->analysis, "PSPHOT.SOURCES"); // Input sources 124 psArray *refSources = psMetadataLookupPtr(NULL, refSourceRO->analysis, "PSPHOT.SOURCES"); // Ref sources 125 126 psFree(view); 127 128 if (!inSources || !refSources) { 129 psWarning("Unable to scale kernel, since no sources were provided."); 130 return true; 131 } 132 133 134 float inFWHM = subImagePSF(data, inRO, inSources); // FWHM for input 135 float refFWHM = subImagePSF(data, refRO, refSources); // FWHM for reference 136 psLogMsg("ppSub", PS_LOG_INFO, "Input FWHM: %f\nReference FWHM: %f\n", inFWHM, refFWHM); 137 if (!isfinite(inFWHM) || !isfinite(refFWHM)) { 138 psWarning("Unable to scale kernel, since unable to measure PSFs."); 139 return true; 140 } 141 142 // float diff = sqrtf(PS_SQR(PS_MAX(inFWHM, refFWHM)) - PS_SQR(PS_MIN(inFWHM, refFWHM))); // Difference 143 float diff = PS_MAX(inFWHM, refFWHM); 144 145 float scaleRef = psMetadataLookupF32(NULL, recipe, "SCALE.REF"); // Reference for scaling 146 float scaleMin = psMetadataLookupF32(NULL, recipe, "SCALE.MIN"); // Minimum for scaling 147 float scaleMax = psMetadataLookupF32(NULL, recipe, "SCALE.MAX"); // Maximum for scaling 148 if (!isfinite(scaleRef) || !isfinite(scaleMin) || !isfinite(scaleMax)) { 149 psError(PPSUB_ERR_ARGUMENTS, false, 150 "Scale parameters (SCALE.REF=%f, SCALE.MIN=%f, SCALE.MAX=%f) not set in recipe.", 151 scaleRef, scaleMin, scaleMax); 152 return false; 153 } 154 155 float scale = diff / scaleRef; // Scaling factor 156 if (scale < scaleMin) { 157 scale = scaleMin; 158 } 159 if (scale > scaleMax) { 160 scale = scaleMax; 161 } 162 163 for (int i = 0; i < kernelWidths->n; i++) { 164 kernelWidths->data.F32[i] *= scale; 165 } 166 *kernelSize = *kernelSize * scale + 0.5; 167 *stampSize = *stampSize * scale + 0.5; 168 169 psLogMsg("ppSub", PS_LOG_INFO, "Scaled kernel parameters by %f: %d %d", scale, *kernelSize, *stampSize); 170 171 return true; 38 172 } 39 173 … … 133 267 float kernelErr = psMetadataLookupF32(NULL, recipe, "KERNEL.ERR"); // Relative systematic error in kernel 134 268 float sysErr = psMetadataLookupF32(NULL, recipe, "SYS.ERR"); // Relative systematic error in images 135 float skyErr = psMetadataLookupF32(NULL, recipe, "SKY.ERR"); // Relative systematic error in images269 float skyErr = psMetadataLookupF32(NULL, recipe, "SKY.ERR"); // Additional error in sky 136 270 137 271 float badFrac = psMetadataLookupF32(NULL, recipe, "BADFRAC"); // Maximum bad fraction … … 171 305 break; 172 306 default: 173 psError StackPrint(stderr, "Invalid value for -convolve");307 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Invalid value for -convolve"); 174 308 return false; 175 309 } 310 } 311 312 if (!subScaleKernel(data, widths, &size, &footprint)) { 313 psError(PS_ERR_UNKNOWN, false, "Unable to scale kernel parameters"); 314 return false; 176 315 } 177 316 -
branches/eam_branches/20091201/ppSub/src/ppSubReadoutPhotometry.c
r26432 r26649 78 78 // erase the overlays from a previous psphot-related step 79 79 if (pmVisualIsVisual()) { 80 psphotVisualEraseOverlays (1, "all");80 // psphotVisualEraseOverlays (1, "all"); 81 81 } 82 82
Note:
See TracChangeset
for help on using the changeset viewer.
