Changeset 21374 for trunk/ppSub/src/ppSubReadoutPhotometry.c
- Timestamp:
- Feb 5, 2009, 5:20:02 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ppSub/src/ppSubReadoutPhotometry.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSub/src/ppSubReadoutPhotometry.c
r21360 r21374 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02-06 0 1:37:17$8 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-06 03:20:02 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ … … 25 25 26 26 if (!psMetadataLookupBool(NULL, recipe, "PHOTOMETRY")) { 27 pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL");28 pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL.STDEV");29 return true;27 pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL"); 28 pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL.STDEV"); 29 return true; 30 30 } 31 31 … … 40 40 pmPSF *psf = psMetadataLookupPtr(NULL, psfInputChip->analysis, "PSPHOT.PSF"); 41 41 if (!psf) { 42 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find PSF from psphot");43 return false;42 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find PSF from psphot"); 43 return false; 44 44 } 45 45 psMetadataAddPtr(psfLoadChip->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_DATA_UNKNOWN | PS_META_REPLACE, "PSF from matched addition", psf); … … 55 55 pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout with the sources 56 56 if (!photRO) { 57 pmCell *cell = pmFPAfileThisCell(config->files, view, "PSPHOT.RESID"); // Output cell58 photRO = pmReadoutAlloc(cell); // Output readout: subtraction57 pmCell *cell = pmFPAfileThisCell(config->files, view, "PSPHOT.RESID"); // Output cell 58 photRO = pmReadoutAlloc(cell); // Output readout: subtraction 59 59 } 60 60 photRO->image = psImageCopy(photRO->image, outRO->image, PS_TYPE_F32); 61 if (outRO-> weight) {62 photRO->weight = psImageCopy(photRO->weight, outRO->weight, PS_TYPE_F32);61 if (outRO->variance) { 62 photRO->variance = psImageCopy(photRO->variance, outRO->variance, PS_TYPE_F32); 63 63 } else { 64 psFree (photRO->weight);65 photRO->weight= NULL;64 psFree (photRO->variance); 65 photRO->variance = NULL; 66 66 } 67 67 if (outRO->mask) { 68 photRO->mask = psImageCopy(photRO->mask, outRO->mask, PS_TYPE_IMAGE_MASK);68 photRO->mask = psImageCopy(photRO->mask, outRO->mask, PS_TYPE_IMAGE_MASK); 69 69 } else { 70 psFree (photRO->mask);71 photRO->mask = NULL;70 psFree (photRO->mask); 71 photRO->mask = NULL; 72 72 } 73 73 … … 77 77 // old-style variance renormalization 78 78 if (!ppSubReadoutRenormPhot (config, recipe, photRO)) { 79 psError(PS_ERR_UNKNOWN, false, "failure in renormalization");80 return false;79 psError(PS_ERR_UNKNOWN, false, "failure in renormalization"); 80 return false; 81 81 } 82 82 83 83 if (!psphotReadoutMinimal(config, view)) { 84 psWarning("Unable to perform photometry on subtracted image.");85 psErrorStackPrint(stderr, "Error stack from photometry:");86 psErrorClear();84 psWarning("Unable to perform photometry on subtracted image."); 85 psErrorStackPrint(stderr, "Error stack from photometry:"); 86 psErrorClear(); 87 87 } 88 88 89 89 if (stats) { 90 psArray *sources = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.SOURCES"); // Sources91 psMetadataAddS32(stats, PS_LIST_TAIL, "NUM_SOURCES", 0, "Number of sources detected",92 sources ? sources->n : 0);93 psMetadataAddF32(stats, PS_LIST_TAIL, "TIME_PHOT", 0, "Time to do photometry",94 psTimerClear("PPSUB_PHOT"));90 psArray *sources = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.SOURCES"); // Sources 91 psMetadataAddS32(stats, PS_LIST_TAIL, "NUM_SOURCES", 0, "Number of sources detected", 92 sources ? sources->n : 0); 93 psMetadataAddF32(stats, PS_LIST_TAIL, "TIME_PHOT", 0, "Time to do photometry", 94 psTimerClear("PPSUB_PHOT")); 95 95 } 96 96 … … 103 103 // XXX not sure that this is still needed (only if psphotReadoutMinimal measures the background) 104 104 // if (!pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL") || 105 // !pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL.STDEV") ||106 // !pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND")) {107 // psError(PS_ERR_UNKNOWN, false, "Unable to drop PSPHOT internal files.");108 // return false;105 // !pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL.STDEV") || 106 // !pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND")) { 107 // psError(PS_ERR_UNKNOWN, false, "Unable to drop PSPHOT internal files."); 108 // return false; 109 109 // } 110 110 … … 116 116 // Record data about sources: not everything gets into the output CMF files 117 117 { 118 pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout with the sources119 psArray *sources = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.SOURCES"); // Sources120 FILE *sourceFile = fopen("sources.dat", "w"); // File for sources121 fprintf(sourceFile,122 "# x y mag mag_err psf_chisq cr_nsigma ext_nsigma psf_qf flags m_x m_y m_xx m_xy m_yy\n");123 for (int i = 0; i < sources->n; i++) {124 pmSource *source = sources->data[i];125 if (!source) {126 continue;127 }118 pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout with the sources 119 psArray *sources = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.SOURCES"); // Sources 120 FILE *sourceFile = fopen("sources.dat", "w"); // File for sources 121 fprintf(sourceFile, 122 "# x y mag mag_err psf_chisq cr_nsigma ext_nsigma psf_qf flags m_x m_y m_xx m_xy m_yy\n"); 123 for (int i = 0; i < sources->n; i++) { 124 pmSource *source = sources->data[i]; 125 if (!source) { 126 continue; 127 } 128 128 129 float x, y; // Position of source130 float chi2; // chi^2 for source131 if (source->modelPSF) {132 x = source->modelPSF->params->data.F32[PM_PAR_XPOS];133 y = source->modelPSF->params->data.F32[PM_PAR_YPOS];134 chi2 = source->modelPSF->chisq;135 } else if (source->peak) {136 x = source->peak->xf;137 y = source->peak->yf;138 chi2 = NAN;139 } else {140 psWarning("No position available for source.");141 continue;142 }129 float x, y; // Position of source 130 float chi2; // chi^2 for source 131 if (source->modelPSF) { 132 x = source->modelPSF->params->data.F32[PM_PAR_XPOS]; 133 y = source->modelPSF->params->data.F32[PM_PAR_YPOS]; 134 chi2 = source->modelPSF->chisq; 135 } else if (source->peak) { 136 x = source->peak->xf; 137 y = source->peak->yf; 138 chi2 = NAN; 139 } else { 140 psWarning("No position available for source."); 141 continue; 142 } 143 143 144 float xMoment = NAN, yMoment = NAN, xxMoment = NAN, xyMoment = NAN, yyMoment = NAN;145 if (source->moments) {146 xMoment = source->moments->Mx;147 yMoment = source->moments->My;148 xxMoment = source->moments->Mxx;149 xyMoment = source->moments->Mxy;150 yyMoment = source->moments->Myy;151 }144 float xMoment = NAN, yMoment = NAN, xxMoment = NAN, xyMoment = NAN, yyMoment = NAN; 145 if (source->moments) { 146 xMoment = source->moments->Mx; 147 yMoment = source->moments->My; 148 xxMoment = source->moments->Mxx; 149 xyMoment = source->moments->Mxy; 150 yyMoment = source->moments->Myy; 151 } 152 152 153 fprintf(sourceFile, "%f %f %f %f %f %f %f %f %d %f %f %f %f %f\n",154 x, y, source->psfMag, source->errMag, chi2, source->crNsigma, source->extNsigma,155 source->pixWeight, source->mode, xMoment, yMoment, xxMoment, xyMoment, yyMoment);156 }157 fclose(sourceFile);153 fprintf(sourceFile, "%f %f %f %f %f %f %f %f %d %f %f %f %f %f\n", 154 x, y, source->psfMag, source->errMag, chi2, source->crNsigma, source->extNsigma, 155 source->pixWeight, source->mode, xMoment, yMoment, xxMoment, xyMoment, yyMoment); 156 } 157 fclose(sourceFile); 158 158 } 159 159 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
