Changeset 11263
- Timestamp:
- Jan 24, 2007, 11:41:08 AM (19 years ago)
- Location:
- trunk/psphot/src
- Files:
-
- 15 edited
-
psphot.c (modified) (3 diffs)
-
psphot.h (modified) (1 diff)
-
psphotBlendFit.c (modified) (1 diff)
-
psphotChoosePSF.c (modified) (4 diffs)
-
psphotCleanup.c (modified) (1 diff)
-
psphotErrorCodes.dat (modified) (2 diffs)
-
psphotFindPeaks.c (modified) (2 diffs)
-
psphotImageLoop.c (modified) (11 diffs)
-
psphotImageMedian.c (modified) (2 diffs)
-
psphotMergeSources.c (modified) (1 diff)
-
psphotParseCamera.c (modified) (10 diffs)
-
psphotReadout.c (modified) (6 diffs)
-
psphotReadoutCleanup.c (modified) (1 diff)
-
psphotRoughClass.c (modified) (1 diff)
-
psphotSourceStats.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphot.c
r10791 r11263 3 3 static void usage (void) { 4 4 fprintf (stderr, "USAGE: psphot [-file image(s)] [-list imagelist] (output)\n"); 5 exit ( 2);5 exit (PS_EXIT_CONFIG_ERROR); 6 6 } 7 7 … … 9 9 10 10 psTimerStart ("complete"); 11 12 11 psphotErrorRegister(); // register our error codes/messages 13 14 // load implementation-specific models 15 psphotModelGroupInit (); 12 psphotModelGroupInit (); // load implementation-specific models 16 13 17 14 // load command-line arguments, options, and system config data … … 21 18 // load input data (config and images (signal, noise, mask) 22 19 if (!psphotParseCamera (config)) { 23 psErrorStackPrint(stderr, " error setting up the camera");24 exit (1);20 psErrorStackPrint(stderr, "Error setting up the camera"); 21 exit (psphotGetExitStatus()); 25 22 } 26 27 // XXX for test checking of the config system28 // psphotDumpConfig (config);29 23 30 24 // call psphot for each readout 31 25 if (!psphotImageLoop (config)) { 32 psErrorStackPrint(stderr, " ");33 exit (1);26 psErrorStackPrint(stderr, "Error in the psphot image loop"); 27 exit (psphotGetExitStatus()); 34 28 } 35 29 36 30 psLogMsg ("psphot", 3, "complete psphot run: %f sec\n", psTimerMark ("complete")); 37 31 32 psErrorCode exit_status = psphotGetExitStatus(); 38 33 psphotCleanup (config); 39 exit ( EXIT_SUCCESS);34 exit (exit_status); 40 35 } 36 37 // all functions which return to this level must raise one of the top-level error codes if they 38 // exit with an error. these error codes are used to specify the program exit status -
trunk/psphot/src/psphot.h
r11230 r11263 99 99 bool psphotMergeSources (psArray *oldSources, psArray *newSources); 100 100 bool psphotLoadExtSources (pmConfig *config, pmFPAview *view, psArray *sources); 101 psExit psphotGetExitStatus (); -
trunk/psphot/src/psphotBlendFit.c
r11165 r11263 91 91 92 92 psLogMsg ("psphot.psphotBlendFit", PS_LOG_INFO, "fit models: %f sec for %d objects (%d psf, %d ext, %d failed, %ld skipped)\n", psTimerMark ("psphot"), Nfit, Npsf, Next, Nfail, sources->n - Nfit); 93 return (true);93 return true; 94 94 } -
trunk/psphot/src/psphotChoosePSF.c
r11200 r11263 256 256 } 257 257 258 // measure average parameters of the PSF model 258 259 bool psphotPSFstats (pmReadout *readout, psMetadata *recipe, pmPSF *psf) { 259 260 … … 295 296 psF64 FWHM_Y = FWHM_X * (axes.minor / axes.major); 296 297 297 psMetadataAdd (recipe, PS_LIST_TAIL, "FWHM_X", PS_DATA_F32 | PS_META_REPLACE, "PSF FWHM Major axis", FWHM_X); 298 psMetadataAdd (recipe, PS_LIST_TAIL, "FWHM_Y", PS_DATA_F32 | PS_META_REPLACE, "PSF FWHM Minor axis", FWHM_Y); 299 psMetadataAdd (recipe, PS_LIST_TAIL, "ANGLE", PS_DATA_F32 | PS_META_REPLACE, "PSF angle", axes.theta); 300 psMetadataAdd (recipe, PS_LIST_TAIL, "NPSFSTAR", PS_DATA_S32 | PS_META_REPLACE, "number of stars used to make PSF", psf->nPSFstars); 298 psMetadataAddF32 (recipe, PS_LIST_TAIL, "FWHM_X", PS_META_REPLACE, "PSF FWHM Major axis", FWHM_X); 299 psMetadataAddF32 (recipe, PS_LIST_TAIL, "FWHM_Y", PS_META_REPLACE, "PSF FWHM Minor axis", FWHM_Y); 300 psMetadataAddF32 (recipe, PS_LIST_TAIL, "ANGLE", PS_META_REPLACE, "PSF angle", axes.theta); 301 psMetadataAddS32 (recipe, PS_LIST_TAIL, "NPSFSTAR", PS_META_REPLACE, "Number of stars used to make PSF", psf->nPSFstars); 302 psMetadataAddBool(recipe, PS_LIST_TAIL, "PSFMODEL", PS_META_REPLACE, "Valid PSF Model?", true); 301 303 302 304 psFree (modelEXT); … … 306 308 } 307 309 308 // XXX fix this wrt re-definition of PM_PAR_SXX310 // determine approximate PSF shape parameters based on the moments 309 311 bool psphotMomentsStats (pmReadout *readout, psMetadata *recipe, psArray *sources) { 310 312 … … 347 349 FWHM_T /= FWHM_N; 348 350 349 psMetadataAdd (recipe, PS_LIST_TAIL, "FWHM_X", PS_DATA_F32 | PS_META_REPLACE, "PSF FWHM Major axis", FWHM_X); 350 psMetadataAdd (recipe, PS_LIST_TAIL, "FWHM_Y", PS_DATA_F32 | PS_META_REPLACE, "PSF FWHM Minor axis", FWHM_Y); 351 psMetadataAdd (recipe, PS_LIST_TAIL, "ANGLE", PS_DATA_F32 | PS_META_REPLACE, "PSF angle", FWHM_T); 351 psMetadataAddF32 (recipe, PS_LIST_TAIL, "FWHM_X", PS_META_REPLACE, "PSF FWHM Major axis (from moments)", FWHM_X); 352 psMetadataAddF32 (recipe, PS_LIST_TAIL, "FWHM_Y", PS_META_REPLACE, "PSF FWHM Minor axis (from moments)", FWHM_Y); 353 psMetadataAddF32 (recipe, PS_LIST_TAIL, "ANGLE", PS_META_REPLACE, "PSF angle", FWHM_T); 354 psMetadataAddS32 (recipe, PS_LIST_TAIL, "NPSFSTAR", PS_META_REPLACE, "Number of stars used to make PSF", 0); 355 psMetadataAddBool(recipe, PS_LIST_TAIL, "PSFMODEL", PS_META_REPLACE, "Valid PSF Model?", false); 352 356 353 357 return true; -
trunk/psphot/src/psphotCleanup.c
r9270 r11263 15 15 return; 16 16 } 17 18 psExit psphotGetExitStatus () { 19 20 psErrorCode err = psErrorCodeLast (); 21 switch (err) { 22 case PSPHOT_ERR_SYS: 23 return PS_EXIT_SYS_ERROR; 24 case PSPHOT_ERR_CONFIG: 25 return PS_EXIT_CONFIG_ERROR; 26 case PSPHOT_ERR_PROG: 27 return PS_EXIT_PROG_ERROR; 28 case PSPHOT_ERR_DATA: 29 return PS_EXIT_DATA_ERROR; 30 default: 31 return PS_EXIT_UNKNOWN_ERROR; 32 } 33 return PS_EXIT_UNKNOWN_ERROR; 34 } -
trunk/psphot/src/psphotErrorCodes.dat
r10135 r11263 2 2 # This file is used to generate psphotErrorClasses.h 3 3 # 4 BASE = 512First value we use; lower values belong to psLib4 BASE = 200 First value we use; lower values belong to psLib 5 5 UNKNOWN Unknown PM error code 6 6 NOT_IMPLEMENTED Desired feature is not yet implemented 7 ARGUMENTS Incorrect arguments8 CONFIG Problem in configure files9 7 FITS Problem in FITS I/O 10 8 FITS_WCS Error interpreting FITS WCS information … … 13 11 APERTURE Problem with aperture photometry 14 12 SKY Problem in sky determination 13 # these errors correspond to standard exit conditions 14 ARGUMENTS Incorrect arguments 15 SYS System error 16 CONFIG Problem in configure files 17 PROG Programming error 18 DATA invalid data -
trunk/psphot/src/psphotFindPeaks.c
r11186 r11263 17 17 float FWHM_X = psMetadataLookupF32 (&status_x, recipe, "FWHM_X"); 18 18 float FWHM_Y = psMetadataLookupF32 (&status_y, recipe, "FWHM_Y"); 19 if (!status_x | !status_y) psAbort ("psphotFindPeaks", "FWHM_X or FWHM_Y not defined"); 19 if (!status_x | !status_y) { 20 psError(PSPHOT_ERR_CONFIG, false, "FWHM_X or FWHM_Y not defined"); 21 return false; 22 } 20 23 SIGMA_SMTH = 0.5*(FWHM_X + FWHM_Y) / (2.0*sqrt(2.0*log(2.0))); 21 24 NSIGMA_SMTH = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_NSIGMA"); … … 83 86 // find the peaks in the smoothed image 84 87 psArray *peaks = pmFindImagePeaks (smooth_im, threshold); 85 if (peaks == NULL) psAbort ("find peaks", "no peaks found"); 88 if (peaks == NULL) { 89 // XXX this may also be due to a programming or config error 90 // XXX do we need to set something in the readout->analysis to indicate that 91 // we tried and failed to find peaks (something in the header data) 92 psError(PSPHOT_ERR_DATA, false, "no peaks found in this image"); 93 return false; 94 } 86 95 87 96 // correct the peak values to S/N = sqrt(value*effArea) -
trunk/psphot/src/psphotImageLoop.c
r9566 r11263 1 1 # include "psphot.h" 2 2 3 // XXX where do we load optional mask and weight input images? 3 // XXX the errors in the pmFPAfileIOChecks could also be due to a programming or config error 4 // XXX we need to either handle those errors or handle the error in pmFPAfileIOChecks and exit 4 5 bool psphotImageLoop (pmConfig *config) { 5 6 … … 11 12 pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PSPHOT.INPUT"); 12 13 if (!status) { 13 psError(PS _ERR_IO, false, "Can't find input data!");14 psError(PSPHOT_ERR_PROG, false, "Can't find input data!"); 14 15 return false; 15 16 } … … 19 20 // files associated with the science image 20 21 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) { 21 psError(PS _ERR_UNKNOWN, false, "failed IO for fpa in psphot\n");22 psError(PSPHOT_ERR_DATA, false, "failed IO for fpa in psphot\n"); 22 23 psFree(view); 23 24 return false; … … 28 29 if (! chip->process || ! chip->file_exists) { continue; } 29 30 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) { 30 psError(PS _ERR_UNKNOWN, false, "failed IO for chip %d in psphot\n", view->chip);31 psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d in psphot\n", view->chip); 31 32 psFree (view); 32 33 return false; … … 37 38 if (! cell->process || ! cell->file_exists) { continue; } 38 39 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) { 39 psError(PS _ERR_UNKNOWN, false, "failed IO for chip %d, cell %d in psphot\n", view->chip, view->cell);40 psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d in psphot\n", view->chip, view->cell); 40 41 psFree (view); 41 42 return false; … … 45 46 while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) { 46 47 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) { 47 psError(PS _ERR_UNKNOWN, false, "failed IO for chip %d, cell %d, readout %d in psphot\n", view->chip, view->cell, view->readout);48 psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d, readout %d in psphot\n", view->chip, view->cell, view->readout); 48 49 psFree (view); 49 50 return false; … … 54 55 // run the actual photometry analysis 55 56 if (!psphotReadout (config, view)) { 56 psError( PS_ERR_UNKNOWN, false, "failedpsphotReadout for chip %d, cell %d, readout %d\n", view->chip, view->cell, view->readout);57 psError(psErrorCodeLast(), false, "failure in psphotReadout for chip %d, cell %d, readout %d\n", view->chip, view->cell, view->readout); 57 58 psFree (view); 58 59 return false; … … 60 61 61 62 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) { 62 psError(PS _ERR_UNKNOWN, false, "failed IO for chip %d, cell %d, readout %d in psphot\n", view->chip, view->cell, view->readout);63 psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d, readout %d in psphot\n", view->chip, view->cell, view->readout); 63 64 psFree (view); 64 65 return false; … … 66 67 } 67 68 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) { 68 psError(PS _ERR_UNKNOWN, false, "failed IO for chip %d, cell %d in psphot\n", view->chip, view->cell);69 psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d in psphot\n", view->chip, view->cell); 69 70 psFree (view); 70 71 return false; … … 72 73 } 73 74 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) { 74 psError(PS _ERR_UNKNOWN, false, "failed IO for chip %d in psphot\n", view->chip);75 psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d in psphot\n", view->chip); 75 76 psFree (view); 76 77 return false; … … 78 79 } 79 80 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) { 80 psError(PS _ERR_UNKNOWN, false, "failed IO for fpa in psphot\n");81 psError(PSPHOT_ERR_DATA, false, "failed IO for fpa in psphot\n"); 81 82 psFree (view); 82 83 return false; -
trunk/psphot/src/psphotImageMedian.c
r11200 r11263 99 99 pmFPAfileCopyStructureView (file->fpa, inFPA, DX, DY, view); 100 100 model = pmFPAviewThisReadout (view, file->fpa); 101 if (nx != model->image->numCols) psAbort ("psphot", "inconsistent size"); 102 if (ny != model->image->numRows) psAbort ("psphot", "inconsistent size"); 101 if ((nx != model->image->numCols) || (ny != model->image->numRows)) { 102 psError (PSPHOT_ERR_PROG, true, "inconsistent sizes for model dimensions"); 103 return false; 104 } 103 105 } 104 106 } … … 230 232 pmFPAfileCopyStructureView (file->fpa, inFPA, 1, 1, view); 231 233 background = pmFPAviewThisReadout (view, file->fpa); 232 if (Nx != background->image->numCols) psAbort ("psphot", "inconsistent size"); 233 if (Ny != background->image->numRows) psAbort ("psphot", "inconsistent size"); 234 if ((Nx != background->image->numCols) || (Ny != background->image->numRows)) { 235 psError (PSPHOT_ERR_PROG, true, "inconsistent sizes for background dimensions"); 236 return false; 237 } 234 238 } 235 239 } else { -
trunk/psphot/src/psphotMergeSources.c
r11230 r11263 16 16 17 17 // find the currently selected readout 18 pmReadout *readout = pmFPAfileThisReadout (config->files, view, " INPUT.SRC");18 pmReadout *readout = pmFPAfileThisReadout (config->files, view, "PSPHOT.SRC"); 19 19 if (!readout) { 20 20 psLogMsg ("psphot", 3, "no external sources supplied"); -
trunk/psphot/src/psphotParseCamera.c
r11230 r11263 13 13 } 14 14 15 // if we have requested PSPHOT.SRC, attempt to resolve it 16 if (psMetadataLookupPtr(NULL, config->arguments, "SRC")) { 17 pmFPAfileDefineFromArgs (&status, config, "PSPHOT.SRC", "SRC"); 18 if (!status) { 19 psError(PSPHOT_ERR_CONFIG, false, "Failed to find/build PSPHOT.SRC"); 20 return status; 21 } 22 } 23 15 24 // select recipe options supplied on command line 16 25 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); … … 18 27 // if MASK or WEIGHT was supplied on command line, bind files to input fpa 19 28 // XXX these do not quite yet work: pmFPAAddSourceFromHeader is not appropriate 20 pmFPAfileBindFromArgs (NULL, input, config, " INPUT.MASK", "MASK");21 pmFPAfileBindFromArgs (NULL, input, config, " INPUT.WEIGHT", "WEIGHT");29 pmFPAfileBindFromArgs (NULL, input, config, "PSPHOT.MASK", "MASK"); 30 pmFPAfileBindFromArgs (NULL, input, config, "PSPHOT.WEIGHT", "WEIGHT"); 22 31 23 32 // optionally load the PSF Model and/or fixed stars 24 pmFPAfileBindFromArgs (NULL, input, config, "INPUT.PSF", "PSF"); 25 pmFPAfile *srcInput = pmFPAfileDefineFromArgs (NULL, config, "INPUT.SRC", "SRC"); 26 if (!srcInput) { 27 fprintf (stderr, "!"); 28 } 33 pmFPAfileBindFromArgs (NULL, input, config, "PSPHOT.PSF", "PSF"); 29 34 30 35 // set default recipe values here … … 47 52 if (!status || saveOutput) { 48 53 if (!pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.OUTPUT")) { 49 psError(PS _ERR_IO, false, "Cannot find a rule for PSPHOT.OUTPUT");54 psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.OUTPUT"); 50 55 return false; 51 56 } … … 55 60 if (psMetadataLookupBool(NULL, recipe, "SAVE.RESID")) { 56 61 if (!pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.RESID")) { 57 psError(PS _ERR_IO, false, "Cannot find a rule for PSPHOT.BACKMDL");62 psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKMDL"); 58 63 return false; 59 64 } … … 68 73 if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKMDL")) { 69 74 if (!pmFPAfileDefineFromFPA (config, input->fpa, DX, DY, "PSPHOT.BACKMDL")) { 70 psError(PS _ERR_IO, false, "Cannot find a rule for PSPHOT.BACKMDL");75 psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKMDL"); 71 76 return false; 72 77 } … … 75 80 if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKGND")) { 76 81 if (!pmFPAfileDefineFromFPA (config, input->fpa, 1, 1, "PSPHOT.BACKGND")) { 77 psError(PS _ERR_IO, false, "Cannot find a rule for PSPHOT.BACKGND");82 psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKGND"); 78 83 return false; 79 84 } … … 82 87 if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKSUB")) { 83 88 if (!pmFPAfileDefineFromFPA (config, input->fpa, 1, 1, "PSPHOT.BACKSUB")) { 84 psError(PS _ERR_IO, false, "Cannot find a rule for PSPHOT.");89 psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT."); 85 90 return false; 86 91 } … … 89 94 if (psMetadataLookupBool(NULL, recipe, "SAVE.PSF")) { 90 95 if (!pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.PSF.SAVE")) { 91 psError(PS _ERR_IO, false, "Cannot find a rule for PSPHOT.PSF.SAVE");96 psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.PSF.SAVE"); 92 97 return false; 93 98 } … … 115 120 int chipNum = atoi(chips->data[i]); 116 121 if (! pmFPASelectChip(input->fpa, chipNum, false)) { 117 psError(PS _ERR_IO, false, "Chip number %d doesn't exist in camera.\n", chipNum);122 psError(PSPHOT_ERR_CONFIG, false, "Chip number %d doesn't exist in camera.\n", chipNum); 118 123 return false; 119 124 } … … 121 126 } 122 127 psFree (chips); 123 124 128 psTrace("psphot", 1, "Done with psphotParseCamera...\n"); 125 129 126 130 psErrorClear(); // some metadata lookup may have failed 127 128 131 return true; 129 132 } -
trunk/psphot/src/psphotReadout.c
r11230 r11263 5 5 // select the current recipe 6 6 psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSPHOT_RECIPE); 7 if (!recipe) { 8 psError(PSPHOT_ERR_CONFIG, false, "missing recipe %s", PSPHOT_RECIPE); 9 return false; 10 } 7 11 8 12 // find the currently selected readout 9 13 pmReadout *readout = pmFPAfileThisReadout (config->files, view, "PSPHOT.INPUT"); 14 PS_ASSERT_PTR_NON_NULL (readout, false); 10 15 11 16 // optional break-point for processing 12 17 char *breakPt = psMetadataLookupStr (NULL, recipe, "BREAK_POINT"); 18 PS_ASSERT_PTR_NON_NULL (breakPt, false); 13 19 14 20 // generate mask & weight images if they don't already exit 15 21 if (!pmReadoutGenerateMaskWeight (readout, true)) { 22 psError (PSPHOT_ERR_CONFIG, false, "trouble creating mask and/or weight"); 16 23 return false; 17 24 } … … 34 41 35 42 // generate a background model (median, smoothed image) 36 psphotImageMedian (config, view); 43 if (!psphotImageMedian (config, view)) { 44 return psphotReadoutCleanup (config, readout, recipe, NULL, NULL); 45 } 37 46 38 47 if (!strcasecmp (breakPt, "BACKMDL")) { … … 40 49 } 41 50 42 pmReadout *background = psphotSelectBackground (config, view);43 44 51 // find the peaks in the image 45 52 psArray *peaks = psphotFindPeaks (readout, recipe, 1); 53 if (!peaks) { 54 psLogMsg ("psphot", 3, "unable to find peaks in this image"); 55 return psphotReadoutCleanup (config, readout, recipe, NULL, NULL); 56 } 46 57 47 58 // construct sources and measure basic stats 48 // limit moments analysis by S/N?49 59 psArray *sources = psphotSourceStats (readout, recipe, peaks); 60 if (!sources) return false; 50 61 psFree (peaks); 51 62 … … 55 66 56 67 // mark blended peaks PS_SOURCE_BLEND 57 psphotBasicDeblend (sources, recipe); 68 if (!psphotBasicDeblend (sources, recipe)) { 69 psLogMsg ("psphot", 3, "failed on deblend analysis"); 70 return psphotReadoutCleanup (config, readout, recipe, NULL, sources); 71 } 58 72 59 73 // classify sources based on moments, brightness 60 74 if (!psphotRoughClass (sources, recipe)) { 61 psFree (sources); 62 psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image"); 63 pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL"); 64 pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND"); 65 return false; 75 psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image"); 76 return psphotReadoutCleanup (config, readout, recipe, NULL, sources); 66 77 } 67 78 if (!strcasecmp (breakPt, "MOMENTS")) { … … 72 83 pmPSF *psf = psphotChoosePSF (readout, sources, recipe); 73 84 if (psf == NULL) { 74 psError(PSPHOT_ERR_UNKNOWN, false, "failure to construct a psf model");75 return false;85 psLogMsg ("psphot", 3, "failure to construct a psf model"); 86 return psphotReadoutCleanup (config, readout, recipe, psf, sources); 76 87 } 77 88 if (!strcasecmp (breakPt, "PSFMODEL")) { 78 return psphotReadoutCleanup (config, readout, recipe, psf, sources);89 return psphotReadoutCleanup (config, readout, recipe, psf, sources); 79 90 } 80 91 … … 142 153 143 154 // calculate source magnitudes 155 // XXX modify this API to take config, view? 156 pmReadout *background = psphotSelectBackground (config, view); 144 157 psphotMagnitudes(sources, recipe, psf, background); 145 158 -
trunk/psphot/src/psphotReadoutCleanup.c
r11184 r11263 1 1 # include "psphot.h" 2 2 3 // psphotReadoutCleanup is called on exit from psphotReadout if the last raised 4 // error is not a DATA error, then there was a serious problem. only in this 5 // case, or if the fail on the stats measurement, do we return false 3 6 bool psphotReadoutCleanup (pmConfig *config, pmReadout *readout, psMetadata *recipe, pmPSF *psf, psArray *sources) { 7 8 psErrorCode err = psErrorCodeLast(); 9 if (err != PSPHOT_ERR_DATA) { 10 return false; 11 } 4 12 5 13 // use the psf-model to measure FWHM stats 6 14 if (psf) { 15 // don't call psphotPSFstats unless we have a valid pdf 16 // if it fails, there is probably a programming error 7 17 if (!psphotPSFstats (readout, recipe, psf)) { 8 psError(PS _ERR_IO, true, "Failed to measure PSF shape parameters");18 psError(PSPHOT_ERR_PROG, false, "Failed to measure PSF shape parameters"); 9 19 return false; 10 20 } 11 } else if (sources) { 21 } 22 if (!psf && sources) { 12 23 if (!psphotMomentsStats (readout, recipe, sources)) { 13 psError(PS _ERR_IO, true, "Failed to measure Moment shape parameters");24 psError(PSPHOT_ERR_PROG, false, "Failed to measure Moment shape parameters"); 14 25 return false; 15 26 } -
trunk/psphot/src/psphotRoughClass.c
r10803 r11263 9 9 10 10 psfClump = pmSourcePSFClump (sources, recipe); 11 if (psfClump.X < 0) { 12 psError(PSPHOT_ERR_PROG, false, "programming error calling pmSourcePSFClump"); 13 return false; 14 } 15 if (!psfClump.X || !psfClump.Y) { 16 psError(PSPHOT_ERR_DATA, true, "Failed to find a valid PSF clump"); 17 return false; 18 } 11 19 psLogMsg ("psphot", 3, "psf clump X, Y: %f, %f\n", psfClump.X, psfClump.Y); 12 20 psLogMsg ("psphot", 3, "psf clump DX, DY: %f, %f\n", psfClump.dX, psfClump.dY); 13 21 14 // did we find a valid psfClump?15 if (!p sfClump.X || !psfClump.Y) {16 psError(PSPHOT_ERR_P SF, true, "Failed to find a valid PSF clump");22 // group into STAR, COSMIC, EXTENDED, SATURATED, etc. 23 if (!pmSourceRoughClass (sources, recipe, psfClump)) { 24 psError(PSPHOT_ERR_PROG, false, "programming error calling pmSourceRoughClass"); 17 25 return false; 18 26 } 19 20 // group into STAR, COSMIC, EXTENDED, SATURATED, etc.21 pmSourceRoughClass (sources, recipe, psfClump);22 27 23 28 // optional printout of source moments only -
trunk/psphot/src/psphotSourceStats.c
r11177 r11263 11 11 // determine properties (sky, moments) of initial sources 12 12 float INNER = psMetadataLookupF32 (&status, recipe, "SKY_INNER_RADIUS"); 13 if (!status) return NULL; 13 14 float OUTER = psMetadataLookupF32 (&status, recipe, "SKY_OUTER_RADIUS"); 15 if (!status) return NULL; 14 16 float RADIUS = psMetadataLookupF32 (&status, recipe, "PSF_MOMENTS_RADIUS"); 17 if (!status) return NULL; 15 18 float MIN_SN = psMetadataLookupF32 (&status, recipe, "MOMENTS_SN_MIN"); 19 if (!status) return NULL; 16 20 char *breakPt = psMetadataLookupStr (&status, recipe, "BREAK_POINT"); 21 if (!status) return NULL; 17 22 18 23 sources = psArrayAllocEmpty (peaks->n);
Note:
See TracChangeset
for help on using the changeset viewer.
