Changeset 24244 for branches/cnb_branches/cnb_branch_20090301/psphot/src
- Timestamp:
- May 26, 2009, 1:59:32 PM (17 years ago)
- Location:
- branches/cnb_branches/cnb_branch_20090301
- Files:
-
- 25 edited
- 1 copied
-
. (modified) (1 prop)
-
psphot (modified) (1 prop)
-
psphot/src (modified) (1 prop)
-
psphot/src/Makefile.am (modified) (2 diffs)
-
psphot/src/psphot.c (modified) (2 diffs)
-
psphot/src/psphot.h (modified) (1 diff)
-
psphot/src/psphotApResid.c (modified) (2 diffs)
-
psphot/src/psphotArguments.c (modified) (12 diffs)
-
psphot/src/psphotBlendFit.c (modified) (1 diff)
-
psphot/src/psphotChoosePSF.c (modified) (2 diffs)
-
psphot/src/psphotCleanup.c (modified) (1 diff)
-
psphot/src/psphotDefineFiles.c (modified) (2 diffs)
-
psphot/src/psphotDiagnosticPlots.c (modified) (3 diffs)
-
psphot/src/psphotErrorCodes.h.in (modified) (1 diff)
-
psphot/src/psphotImageLoop.c (modified) (1 diff)
-
psphot/src/psphotImageQuality.c (modified) (1 diff)
-
psphot/src/psphotMakeResiduals.c (modified) (2 diffs)
-
psphot/src/psphotMaskReadout.c (modified) (1 diff)
-
psphot/src/psphotModelBackground.c (modified) (1 diff)
-
psphot/src/psphotReadout.c (modified) (1 diff)
-
psphot/src/psphotReadoutCleanup.c (modified) (4 diffs)
-
psphot/src/psphotRoughClass.c (modified) (1 diff)
-
psphot/src/psphotSourceFits.c (modified) (2 diffs)
-
psphot/src/psphotTest.c (modified) (1 diff)
-
psphot/src/psphotVersion.c (modified) (3 diffs)
-
psphot/src/psphotVersionDefinitions.h.in (copied) (copied from trunk/psphot/src/psphotVersionDefinitions.h.in )
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branches/cnb_branch_20090301
- Property svn:mergeinfo changed
-
branches/cnb_branches/cnb_branch_20090301/psphot
- Property svn:mergeinfo changed
/branches/pap/psphot (added) merged: 23580,23596,23646 /trunk/psphot merged: 23688,23692,23740,23790,23805,23808,23957,23978,23989,24029,24097,24144,24174,24187-24188,24203
- Property svn:mergeinfo changed
-
branches/cnb_branches/cnb_branch_20090301/psphot/src
- Property svn:ignore
-
old new 16 16 polyfitTest 17 17 growthTest 18 psphotVersionDefinitions.h
-
- Property svn:ignore
-
branches/cnb_branches/cnb_branch_20090301/psphot/src/Makefile.am
r23352 r24244 1 1 lib_LTLIBRARIES = libpsphot.la 2 2 3 # PSPHOT_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi` 4 # PSPHOT_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi` 5 # PSPHOT_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi` 6 # 7 # # Force recompilation of psphotVersion.c, since it gets the version information 8 # psphotVersion.c: FORCE 9 # touch psphotVersion.c 10 # FORCE: ; 3 if HAVE_SVNVERSION 4 PSPHOT_VERSION=`$(SVNVERSION) ..` 5 else 6 PSPHOT_VERSION="UNKNOWN" 7 endif 11 8 12 libpsphot_la_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPSPHOT_VERSION=$(PSPHOT_VERSION) -DPSPHOT_BRANCH=$(PSPHOT_BRANCH) -DPSPHOT_SOURCE=$(SVN_SOURCE) 9 if HAVE_SVN 10 PSPHOT_BRANCH=`$(SVN) info .. | $(SED) -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'` 11 PSPHOT_SOURCE=`$(SVN) info | $(SED) -n -e 's/Repository UUID: // p'` 12 else 13 PSPHOT_BRANCH="UNKNOWN" 14 PSPHOT_SOURCE="UNKNOWN" 15 endif 16 17 # Force recompilation of psphotVersion.c, since it gets the version information 18 psphotVersion.c: psphotVersionDefinitions.h 19 psphotVersionDefinitions.h: psphotVersionDefinitions.h.in FORCE 20 -$(RM) psphotVersionDefinitions.h 21 $(SED) -e "s|@PSPHOT_VERSION@|\"$(PSPHOT_VERSION)\"|" -e "s|@PSPHOT_BRANCH@|\"$(PSPHOT_BRANCH)\"|" -e "s|@PSPHOT_SOURCE@|\"$(PSPHOT_SOURCE)\"|" psphotVersionDefinitions.h.in > psphotVersionDefinitions.h 22 FORCE: ; 23 24 libpsphot_la_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) 13 25 libpsphot_la_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 14 26 … … 129 141 130 142 # Error codes. 131 BUILT_SOURCES = psphotErrorCodes.h psphotErrorCodes.c 143 BUILT_SOURCES = psphotErrorCodes.h psphotErrorCodes.c psphotVersionDefinitions.h 132 144 CLEANFILES = psphotErrorCodes.h psphotErrorCodes.c 133 145 EXTRA_DIST = psphotErrorCodes.dat psphotErrorCodes.c.in psphotErrorCodes.h.in \ -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphot.c
r23352 r24244 1 1 # include "psphotStandAlone.h" 2 3 static void usage (void) {4 fprintf (stderr, "USAGE: psphot [-file image(s)] [-list imagelist] (output)\n");5 exit (PS_EXIT_CONFIG_ERROR);6 }7 2 8 3 int main (int argc, char **argv) { … … 14 9 // load command-line arguments, options, and system config data 15 10 pmConfig *config = psphotArguments (argc, argv); 16 if (!config) { 17 psErrorStackPrint(stderr, "Error reading arguments\n"); 18 usage (); 19 } 11 assert(config); 20 12 21 13 psphotVersionPrint(); -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphot.h
r23594 r24244 31 31 bool psphotReadoutCleanup (pmConfig *config, pmReadout *readout, psMetadata *recipe, pmDetections *detections, pmPSF *psf, psArray *sources); 32 32 bool psphotDefineFiles (pmConfig *config, pmFPAfile *input); 33 void psphotFilesActivate(pmConfig *config, bool state); 34 33 35 bool psphotSetMaskBits (pmConfig *config); 34 36 bool psphotSetMaskRecipe (pmConfig *config, psImageMaskType maskValue, psImageMaskType markValue); -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotApResid.c
r21519 r24244 355 355 356 356 if (j > 2) { 357 bool status = true; 358 status &= psVectorStats (statsS, dASubset, NULL, mkSubset, 0xff); 359 status &= psVectorStats (statsM, dMSubset, NULL, mkSubset, 0xff); 360 if (!status) { psErrorClear (); } 357 if (!psVectorStats (statsS, dASubset, NULL, mkSubset, 0xff)) { 358 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 359 return false; 360 } 361 if (!psVectorStats (statsM, dMSubset, NULL, mkSubset, 0xff)) { 362 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 363 return false; 364 } 361 365 dSo->data.F32[i] = statsS->robustStdev; 362 366 dMo->data.F32[i] = statsM->sampleMean; 363 367 dRo->data.F32[i] = statsS->robustStdev / statsM->sampleMean; 364 // fprintf (stderr, "%d (%d) : sys: %f, phot: %f, rat: %f\n", i, j, dSo->data.F32[i], dMo->data.F32[i], dRo->data.F32[i]);365 368 } else { 366 369 dSo->data.F32[i] = NAN; … … 375 378 psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN); 376 379 if (!psVectorStats (stats, dRo, NULL, NULL, 0)) { 377 // XXX better testing of raised error 378 psErrorClear();380 psError(PS_ERR_UNKNOWN, false, "failure to measure stats"); 381 return false; 379 382 } 380 383 -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotArguments.c
r23352 r24244 1 1 # include "psphotStandAlone.h" 2 3 static void writeHelpInfo(const char* program, pmConfig* config, FILE* ofile) 4 { 5 fprintf(ofile, 6 "Usage: one of the following\n" 7 "%s -file fname1[,fname2,...] -mask maskfile1[,maskfile2,...]\n" 8 " -variance varfile1[,varfile2,...] OutFileBaseName\n" 9 "\n" 10 "%s -list FileNameList [-masklist MaskFileNameList] \n" 11 " -variancelist VarFileNameList OutFileBaseName\n" 12 "\n" 13 "%s -help\n" 14 "\n" 15 "%s -version\n" 16 "\n" 17 "where:\n" 18 " FileNameList is a text file containing filenames, one per line\n" 19 " MaskFileNameList is a text file of mask filenames, one per line\n" 20 " VarFileNameList is a text file of variance filenames, one per line\n" 21 " OutFileBaseName is the 'root name' for output files\n" 22 "\n" 23 "additional options:\n" 24 " -modeltest xObj yObj [-model DEFAULT|ModelName] \n" 25 " [-fitmode DEFAULT|PSF|CONV] [-fitset FitFileName]\n" 26 " Test fit for object at the given coordinates. ModelName\n" 27 " is one of PS_MODEL_GAUSS, PS_MODEL_PGAUSS, PS_MODEL_QGAUSS,\n" 28 " PS_MODEL_RGAUSS, PS_MODEL_PS1_V1, or PS_MODEL_SERSIC.\n" 29 " FitFileName is a file of x,y,Io triples.\n" 30 " -psf PsfFile1[,PsfFile2,...] or -psflist PsfFileNameList\n" 31 " specify PSF rather than letting %s estimate it\n" 32 " -src SrcFile1[,SrcFile2,...] or -srclist SrcFileNameList\n" 33 " specify additional sources for PSF generation\n" 34 " -chip nn[,nn,...]\n" 35 " select detector chips to process; default is all.\n" 36 " Indices correspond to zero-based offset in the FPA metadata table.\n" 37 " -photcode PhotoCodeName\n" 38 " specify photocode\n" 39 " -region RegionString\n" 40 " specify analysis region. String is of form '[x0:x1,y0:y1]'\n" 41 " To use this option you must define a default in psphot.config\n" 42 " -visual\n" 43 " turns on interactive display mode\n" 44 " -dumpconfig CfgFileName\n" 45 " causes config info to be dumped to the named file.\n" 46 " -break NOTHING|BACKMDL|PEAKS|MOMENTS|PSFMODEL|ENSEMBLE|PASS1\n" 47 " choose a point at which to exit processing early\n" 48 " -nthreads n\n" 49 " set number of parallel threads of execution\n" 50 " -F OldFileRule ReplacementFileRule\n" 51 " change file naming rule; e.g. '-F PSPHOT.OUTPUT PSPHOT.OUT.CMF.MEF'\n" 52 " -D name stringval\n" 53 " set a string-valued config parameter\n" 54 " -Di name intval\n" 55 " set an integer-valued config parameter\n" 56 " -Df name fval\n" 57 " set a float-valued config parameter\n" 58 " -Db name boolval\n" 59 " set a boolean-valued config parameter\n" 60 " -v, -vv, -vvv\n" 61 " set increasing levels of verbosity\n" 62 " -logfmt FormatString\n" 63 " set format string used for log messages\n" 64 " -trace Fac Lvl\n" 65 " set tracing for facility Fac to integer Lvl, e.g. '-trace err 10'\n" 66 " -trace-levels\n" 67 " print current trace levels\n", 68 program,program,program,program,program); 69 psFree(config); 70 pmConfigDone(); 71 psLibFinalize(); 72 exit(PS_EXIT_SUCCESS); 73 } 74 75 static void usage(const char *program, // Name of the program 76 psMetadata *arguments, // Command-line arguments 77 pmConfig *config, // Configuration 78 int exitCode 79 ) 80 { 81 fprintf(stderr, 82 "Usage: one of the following\n" 83 "%s -file fname1[,fname2,...] -mask maskfile1[,maskfile2,...]\n" 84 " -variance varfile1[,varfile2,...] OutFileBaseName\n" 85 "\n" 86 "%s -list FileNameList [-masklist MaskFileNameList] \n" 87 " -variancelist VarFileNameList OutFileBaseName\n" 88 "\n" 89 "Try '%s -help' for more options and explanation\n", 90 program,program,program); 91 if (exitCode != PS_EXIT_SUCCESS) 92 psErrorStackPrint(stderr, "Error reading arguments\n"); 93 psFree(config); 94 pmConfigDone(); 95 psLibFinalize(); 96 exit(exitCode); 97 } 2 98 3 99 pmConfig *psphotArguments(int argc, char **argv) { … … 5 101 int N; 6 102 bool status; 7 8 if (argc == 1) {9 psError(PSPHOT_ERR_ARGUMENTS, true, "Too few arguments: %d", argc);10 return NULL;11 }12 13 if ((N = psArgumentGet (argc, argv, "-version"))) {14 psString version;15 version = psphotVersionLong(); fprintf (stdout, "%s\n", version); psFree (version);16 version = psModulesVersionLong(); fprintf (stdout, "%s\n", version); psFree (version);17 version = psLibVersionLong(); fprintf (stdout, "%s\n", version); psFree (version);18 exit (0);19 }20 103 21 104 // load config data from default locations … … 23 106 if (config == NULL) { 24 107 psError(PSPHOT_ERR_CONFIG, false, "Can't read site configuration"); 25 return NULL; 26 } 108 exit(PS_EXIT_CONFIG_ERROR); 109 } 110 111 PSARGUMENTS_INSTANTIATE_GENERICS( psphot, config, argc, argv ); 27 112 28 113 // save the following additional recipe values based on command-line options … … 30 115 psMetadata *options = pmConfigRecipeOptions (config, PSPHOT_RECIPE); 31 116 32 // Number of threads 33 if ((N = psArgumentGet(argc, argv, "-threads"))) { 34 psArgumentRemove(N, &argc, argv); 35 int nThreads = atoi(argv[N]); 36 psMetadataAddS32(config->arguments, PS_LIST_TAIL, "NTHREADS", 0, "number of psphot threads", nThreads); 37 psArgumentRemove(N, &argc, argv); 38 39 // create the thread pool with number of desired threads, supplying our thread launcher function 40 psThreadPoolInit (nThreads); 41 } 42 psphotSetThreads(); 117 // Number of threads is handled 118 PSARGUMENTS_INSTANTIATE_THREADSARG( psphot, config, argc, argv ) 43 119 44 120 // run the test model (requires X,Y coordinate) 45 121 if ((N = psArgumentGet (argc, argv, "-modeltest"))) { 122 if (argc<=N+2) { 123 psError(PSPHOT_ERR_ARGUMENTS, true, 124 "Expected to see 2 more arguments; saw %d", argc - 1); 125 exit(PS_EXIT_CONFIG_ERROR); 126 } 127 46 128 psMetadataAddBool (options, PS_LIST_TAIL, "TEST_FIT", 0, "", true); 47 129 psMetadataAddF32 (options, PS_LIST_TAIL, "TEST_FIT_X", 0, "", atof(argv[N+1])); … … 54 136 // specify the modeltest model 55 137 if ((N = psArgumentGet (argc, argv, "-model"))) { 138 if (argc<=N+1) { 139 psError(PSPHOT_ERR_ARGUMENTS, true, 140 "Expected to see 1 more argument; saw %d", argc - 1); 141 exit(PS_EXIT_CONFIG_ERROR); 142 } 56 143 psArgumentRemove (N, &argc, argv); 57 144 psMetadataAddStr (options, PS_LIST_TAIL, "TEST_FIT_MODEL", 0, "", argv[N]); … … 61 148 // specify the test fit mode 62 149 if ((N = psArgumentGet (argc, argv, "-fitmode"))) { 150 if (argc<=N+1) { 151 psError(PSPHOT_ERR_ARGUMENTS, true, 152 "Expected to see 1 more argument; saw %d", argc - 1); 153 exit(PS_EXIT_CONFIG_ERROR); 154 } 63 155 psArgumentRemove (N, &argc, argv); 64 156 psMetadataAddStr (options, PS_LIST_TAIL, "TEST_FIT_MODE", 0, "", argv[N]); … … 66 158 } 67 159 if ((N = psArgumentGet (argc, argv, "-fitset"))) { 160 if (argc<=N+1) { 161 psError(PSPHOT_ERR_ARGUMENTS, true, 162 "Expected to see 1 more argument; saw %d", argc - 1); 163 exit(PS_EXIT_CONFIG_ERROR); 164 } 68 165 psArgumentRemove (N, &argc, argv); 69 166 psMetadataAddStr (options, PS_LIST_TAIL, "TEST_FIT_SET", 0, "", argv[N]); … … 74 171 // photcode : used in output to supplement header data (argument or recipe?) 75 172 if ((N = psArgumentGet (argc, argv, "-photcode"))) { 173 if (argc<=N+1) { 174 psError(PSPHOT_ERR_ARGUMENTS, true, 175 "Expected to see 1 more argument; saw %d", argc - 1); 176 exit(PS_EXIT_CONFIG_ERROR); 177 } 76 178 psArgumentRemove (N, &argc, argv); 77 179 psMetadataAddStr (options, PS_LIST_TAIL, "PHOTCODE", PS_META_REPLACE, "", argv[N]); … … 87 189 // break : used from recipe throughout psphotReadout 88 190 if ((N = psArgumentGet (argc, argv, "-break"))) { 191 if (argc<=N+1) { 192 psError(PSPHOT_ERR_ARGUMENTS, true, 193 "Expected to see 1 more argument; saw %d", argc - 1); 194 exit(PS_EXIT_CONFIG_ERROR); 195 } 89 196 psArgumentRemove (N, &argc, argv); 90 197 psMetadataAddStr (options, PS_LIST_TAIL, "BREAK_POINT", PS_META_REPLACE, "", argv[N]); 91 psArgumentRemove (N, &argc, argv);92 }93 94 // fitmode : used from recipe throughout psphotReadout95 if ((N = psArgumentGet (argc, argv, "-fitmode"))) {96 psArgumentRemove (N, &argc, argv);97 psMetadataAddStr (options, PS_LIST_TAIL, "FITMODE", PS_META_REPLACE, "", argv[N]);98 198 psArgumentRemove (N, &argc, argv); 99 199 } … … 101 201 // analysis region : overrides recipe value, used in psphotReadout/psphotEnsemblePSF 102 202 if ((N = psArgumentGet (argc, argv, "-region"))) { 203 if (argc<=N+1) { 204 psError(PSPHOT_ERR_ARGUMENTS, true, 205 "Expected to see 1 more argument; saw %d", argc - 1); 206 exit(PS_EXIT_CONFIG_ERROR); 207 } 103 208 psArgumentRemove (N, &argc, argv); 104 209 psMetadataAddStr (options, PS_LIST_TAIL, "ANALYSIS_REGION", 0, "", argv[N]); … … 108 213 // chip selection is used to limit chips to be processed 109 214 if ((N = psArgumentGet (argc, argv, "-chip"))) { 215 if (argc<=N+1) { 216 psError(PSPHOT_ERR_ARGUMENTS, true, 217 "Expected to see 1 more argument; saw %d", argc - 1); 218 exit(PS_EXIT_CONFIG_ERROR); 219 } 110 220 psArgumentRemove (N, &argc, argv); 111 221 psMetadataAddStr (config->arguments, PS_LIST_TAIL, "CHIP_SELECTIONS", PS_DATA_STRING, "", argv[N]); … … 121 231 pmConfigFileSetsMD (config->arguments, &argc, argv, "SRC", "-src", "-srclist"); 122 232 233 if (argc == 1) { 234 psError(PSPHOT_ERR_ARGUMENTS, true, "Too few arguments: %d", argc); 235 usage(argv[0], config->arguments, config, PS_EXIT_CONFIG_ERROR); 236 } 237 238 if (psArgumentGet(argc, argv, "-help") 239 || psArgumentGet(argc, argv, "-h")) 240 writeHelpInfo(argv[0], config, stdout); 241 123 242 // the input file is a required argument; if not found, we will exit 124 243 status = pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list"); 125 244 if (!status) { 126 245 psError(PSPHOT_ERR_ARGUMENTS, false, "pmConfigFileSetsMD failed to parse arguments"); 127 return NULL;246 usage(argv[0], config->arguments, config, PS_EXIT_CONFIG_ERROR); 128 247 } 129 248 130 249 if (argc != 2) { 131 250 psError(PSPHOT_ERR_ARGUMENTS, true, "Expected to see one more argument; saw %d", argc - 1); 132 return NULL;251 usage(argv[0], config->arguments, config, PS_EXIT_CONFIG_ERROR); 133 252 } 134 253 -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotBlendFit.c
r21519 r24244 197 197 if (source->type == PM_SOURCE_TYPE_SATURATED) continue; 198 198 199 // skip DBL second sources (ie, added by psphotFitBlob )199 // skip DBL second sources (ie, added by psphotFitBlob 200 200 if (source->mode & PM_SOURCE_MODE_PAIR) continue; 201 201 -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotChoosePSF.c
r21183 r24244 361 361 362 362 psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV | PS_STAT_SAMPLE_QUARTILE); 363 psVectorStats (stats, fwhmMajor, NULL, NULL, 0); 363 if (!psVectorStats (stats, fwhmMajor, NULL, NULL, 0)) { 364 psError(PS_ERR_UNKNOWN, false, "failure to measure stats for FWHM MAJOR"); 365 return false; 366 } 367 364 368 psMetadataAddF32 (recipe, PS_LIST_TAIL, "FWHM_MAJ", PS_META_REPLACE, "PSF FWHM Major axis (mean)", stats->sampleMean); 365 369 psMetadataAddF32 (recipe, PS_LIST_TAIL, "FW_MJ_SG", PS_META_REPLACE, "PSF FWHM Major axis (sigma)", stats->sampleStdev); … … 367 371 psMetadataAddF32 (recipe, PS_LIST_TAIL, "FW_MJ_UQ", PS_META_REPLACE, "PSF FWHM Major axis (upper quartile)", stats->sampleUQ); 368 372 369 psVectorStats (stats, fwhmMinor, NULL, NULL, 0); 373 if (!psVectorStats (stats, fwhmMinor, NULL, NULL, 0)) { 374 psError(PS_ERR_UNKNOWN, false, "failure to measure stats for FWHM MINOR"); 375 return false; 376 } 370 377 psMetadataAddF32 (recipe, PS_LIST_TAIL, "FWHM_MIN", PS_META_REPLACE, "PSF FWHM Minor axis (mean)", stats->sampleMean); 371 378 psMetadataAddF32 (recipe, PS_LIST_TAIL, "FW_MN_SG", PS_META_REPLACE, "PSF FWHM Minor axis (sigma)", stats->sampleStdev); -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotCleanup.c
r23594 r24244 2 2 3 3 void psphotCleanup (pmConfig *config) { 4 5 // Dump configuration if requested 6 bool status; 7 psString dump_file = psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG"); 8 if (dump_file) { 9 (void)pmConfigCamerasCull(config,NULL); 10 (void)pmConfigRecipesCull(config,NULL); 11 pmConfigDump(config, dump_file); 12 } 4 13 5 14 psFree (config); -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotDefineFiles.c
r14892 r24244 1 1 # include "psphotInternal.h" 2 3 // List of output files 4 static const char *outputFiles[] = { "PSPHOT.OUTPUT", "PSPHOT.RESID", "PSPHOT.BACKMDL", 5 "PSPHOT.BACKMDL.STDEV", "PSPHOT.BACKGND", "PSPHOT.BACKSUB", 6 "PSPHOT.PSF.SAVE", "SOURCE.PLOT.MOMENTS", "SOURCE.PLOT.PSFMODEL", 7 "SOURCE.PLOT.APRESID", NULL }; 2 8 3 9 // XXX we need to be able to distinguish several cases: … … 133 139 return true; 134 140 } 141 142 void psphotFilesActivate(pmConfig *config, bool state) 143 { 144 for (int i = 0; outputFiles[i]; i++) { 145 if (!pmFPAfileActivate(config->files, state, outputFiles[i])) { 146 psErrorClear(); 147 } 148 } 149 150 return; 151 } -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotDiagnosticPlots.c
r21108 r24244 40 40 41 41 psStats *stats = psStatsAlloc (PS_STAT_MAX | PS_STAT_MIN); 42 psVectorStats (stats, values, NULL, NULL, 0); 42 if (!psVectorStats (stats, values, NULL, NULL, 0)) { 43 psError(PS_ERR_UNKNOWN, false, "failure to measure stats for histogram"); 44 return false; 45 } 43 46 44 47 psHistogram *histogram = psHistogramAlloc (stats->min, stats->max, 1000); … … 63 66 psStatsInit (stats); 64 67 stats->options = PS_STAT_MAX | PS_STAT_MIN; 65 psVectorStats (stats, histogram->nums, NULL, NULL, 0); 68 if (!psVectorStats (stats, histogram->nums, NULL, NULL, 0)) { 69 psError(PS_ERR_UNKNOWN, false, "failure to measure stats for histogram"); 70 return false; 71 } 66 72 67 73 // scale the plot to hold the histogram … … 100 106 psStatsInit (stats); 101 107 stats->options = PS_STAT_MAX | PS_STAT_MIN; 102 psVectorStats (stats, histogram->nums, NULL, NULL, 0); 108 if (!psVectorStats (stats, histogram->nums, NULL, NULL, 0)) { 109 psError(PS_ERR_UNKNOWN, false, "failure to measure stats for histogram"); 110 return false; 111 } 103 112 104 113 // scale the plot to hold the histogram -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotErrorCodes.h.in
r11308 r24244 9 9 */ 10 10 typedef enum { 11 PSPHOT_ERR_BASE = 1300,11 PSPHOT_ERR_BASE = 3000, 12 12 PSPHOT_ERR_${ErrorCode}, 13 13 PSPHOT_ERR_NERROR -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotImageLoop.c
r23352 r24244 75 75 } 76 76 77 psImageMaskType maskSat = pmConfigMaskGet("SAT", config); // Mask value for saturated pixels 78 if (!pmReadoutMaskNonfinite(readout, maskSat)) { 79 psError(psErrorCodeLast(), false, "Unable to mask non-finite pixels."); 80 psFree(view); 81 return false; 82 } 83 77 84 // run the actual photometry analysis on this chip/cell/readout 78 85 if (!psphotReadout (config, view)) { -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotImageQuality.c
r20471 r24244 88 88 "Number of stars used for IQ measurements", M2->n); 89 89 90 // XXX make this a recipe option 90 91 #if (USE_SAMPLE) 91 92 psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV | PS_STAT_SAMPLE_QUARTILE); -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotMakeResiduals.c
r21366 r24244 200 200 // measure the robust median to determine a baseline reference value 201 201 *fluxClip = *fluxClipDef; 202 psVectorStats (fluxClip, fluxes, NULL, fmasks, fmaskVal); 203 psErrorClear(); // clear (ignore) any outstanding errors 202 if (!psVectorStats (fluxClip, fluxes, NULL, fmasks, fmaskVal)) { 203 psError(PSPHOT_ERR_CONFIG, false, "Error calculating residual stats"); 204 return false; 205 } 206 if (isnan(fluxClip->robustMedian)) { 207 resid->Ro->data.F32[oy][ox] = 0.0; 208 resid->Rx->data.F32[oy][ox] = 0.0; 209 resid->Ry->data.F32[oy][ox] = 0.0; 210 resid->mask->data.PM_TYPE_RESID_MASK_DATA[oy][ox] = badMask; 211 continue; 212 } 204 213 205 214 // mark input pixels which are more than N sigma from the median … … 220 229 // measure the desired statistic on the unclipped pixels 221 230 *fluxStats = *fluxStatsDef; 222 psVectorStats (fluxStats, fluxes, NULL, fmasks, fmaskVal); 223 psErrorClear(); // clear (ignore) any outstanding errors 231 if (!psVectorStats (fluxStats, fluxes, NULL, fmasks, fmaskVal)) { 232 psError(PSPHOT_ERR_CONFIG, false, "Error calculating residual stats"); 233 return false; 234 } 224 235 225 236 resid->Ro->data.F32[oy][ox] = psStatsGetValue(fluxStats, statOption); 226 237 resid->Rx->data.F32[oy][ox] = resid->Ry->data.F32[oy][ox] = 0.0; 227 //resid->variance->data.F32[oy][ox] = fluxStats->sampleStdev; 238 239 if (isnan(resid->Ro->data.F32[oy][ox])) { 240 resid->Ro->data.F32[oy][ox] = 0.0; 241 resid->Rx->data.F32[oy][ox] = 0.0; 242 resid->Ry->data.F32[oy][ox] = 0.0; 243 resid->mask->data.PM_TYPE_RESID_MASK_DATA[oy][ox] = badMask; 244 continue; 245 } 228 246 229 247 if (fabs(resid->Ro->data.F32[oy][ox]) < pixelSN*fluxStats->sampleStdev/sqrt(nKeep)) { -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotMaskReadout.c
r23594 r24244 39 39 psImage *mk = readout->mask; 40 40 for (int j = 0; j < im->numRows; j++) { 41 for (int i = 0; i < im->numCols; i++) {42 if (isfinite(im->data.F32[j][i]) && isfinite(wt->data.F32[j][i])) continue;43 mk->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskBad;44 }41 for (int i = 0; i < im->numCols; i++) { 42 if (isfinite(im->data.F32[j][i]) && isfinite(wt->data.F32[j][i])) continue; 43 mk->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskBad; 44 } 45 45 } 46 46 } -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotModelBackground.c
r23352 r24244 189 189 190 190 if (gotX && gotY) { 191 psTraceSetLevel ("psLib.math.vectorFittedStats_v4", 6);192 psTraceSetLevel ("psLib.math.vectorRobustStats", 6);191 (void) psTraceSetLevel ("psLib.math.vectorFittedStats_v4", 6); 192 (void) psTraceSetLevel ("psLib.math.vectorRobustStats", 6); 193 193 } else { 194 psTraceSetLevel ("psLib.math.vectorFittedStats_v4", 0);195 psTraceSetLevel ("psLib.math.vectorRobustStats", 0);194 (void) psTraceSetLevel ("psLib.math.vectorFittedStats_v4", 0); 195 (void) psTraceSetLevel ("psLib.math.vectorRobustStats", 0); 196 196 } 197 197 # endif -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotReadout.c
r23594 r24244 61 61 // display the backsub and backgnd images 62 62 psphotVisualShowBackground (config, view, readout); 63 63 64 64 // run a single-model test if desired (exits from here if test is run) 65 65 psphotModelTest (config, view, recipe); -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotReadoutCleanup.c
r20769 r24244 9 9 if (psErrorCodeLast() == PSPHOT_ERR_DATA) { 10 10 psErrorStackPrint(stderr, "Error in the psphot readout analysis"); 11 psErrorClear();12 } 13 if (psErrorCodeLast() != PS_ERR_NONE) { 14 psFree (psf);15 psFree (sources);16 psFree (detections);17 return false;11 psErrorClear(); 12 } 13 if (psErrorCodeLast() != PS_ERR_NONE) { 14 psFree (psf); 15 psFree (sources); 16 psFree (detections); 17 return false; 18 18 } 19 19 … … 22 22 if (!psphotPSFstats (readout, recipe, psf)) { 23 23 psError(PSPHOT_ERR_PROG, false, "Failed to measure PSF shape parameters"); 24 psFree (psf);25 psFree (sources);26 psFree (detections);24 psFree (psf); 25 psFree (sources); 26 psFree (detections); 27 27 return false; 28 28 } … … 32 32 if (!psphotMomentsStats (readout, recipe, sources)) { 33 33 psError(PSPHOT_ERR_PROG, false, "Failed to measure Moment shape parameters"); 34 psFree (psf);35 psFree (sources);36 psFree (detections);34 psFree (psf); 35 psFree (sources); 36 psFree (detections); 37 37 return false; 38 38 } 39 39 } 40 41 // Check to see if the image quality was measured 42 if (!psf) { 43 bool mdok; // Status of MD lookup 44 int nIQ = psMetadataLookupS32(&mdok, recipe, "IQ_NSTAR"); // Number of stars for IQ measurement 45 if (!mdok || nIQ <= 0) { 46 psError(PSPHOT_ERR_DATA, false, "Unable to measure image quality"); 47 psFree (psf); 48 psFree (sources); 49 psFree (detections); 50 return false; 51 } 52 } 53 40 54 41 55 // write NSTARS to the image header … … 48 62 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.HEADER", PS_DATA_METADATA, "header stats", header); 49 63 if (sources) { 50 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "psphot sources", sources);64 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "psphot sources", sources); 51 65 } 52 66 if (psf) { 53 // save the psf for possible output. if there was already an entry, it was loaded from external sources54 // the new one may have been updated or modified, so replace the existing entry. We55 // are required to save it on the chip, but this will cause problems if we ever want to56 // run psphot on an unmosaiced image57 pmCell *cell = readout->parent;58 pmChip *chip = cell->parent;59 psMetadataAdd (chip->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_DATA_UNKNOWN | PS_META_REPLACE, "psphot psf", psf);67 // save the psf for possible output. if there was already an entry, it was loaded from external sources 68 // the new one may have been updated or modified, so replace the existing entry. We 69 // are required to save it on the chip, but this will cause problems if we ever want to 70 // run psphot on an unmosaiced image 71 pmCell *cell = readout->parent; 72 pmChip *chip = cell->parent; 73 psMetadataAdd (chip->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_DATA_UNKNOWN | PS_META_REPLACE, "psphot psf", psf); 60 74 } 61 75 62 76 if (psErrorCodeLast() != PS_ERR_NONE) { 63 77 psErrorStackPrint(stderr, "unexpected remaining errors"); 64 abort();78 abort(); 65 79 } 66 80 -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotRoughClass.c
r21183 r24244 91 91 return false; 92 92 } 93 if (!psfClump.X || !psfClump.Y ) {93 if (!psfClump.X || !psfClump.Y || isnan(psfClump.X) || isnan(psfClump.Y)) { 94 94 psLogMsg ("psphot", 4, "Failed to find a valid PSF clump for region %f,%f - %f,%f\n", region->x0, region->y0, region->x1, region->y1); 95 95 return false; -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotSourceFits.c
r21519 r24244 234 234 pmSource *tmpSrc = pmSourceAlloc (); 235 235 236 // XXX need to handle failures better here 236 237 pmModel *EXT = psphotFitEXT (readout, source, modelTypeEXT, maskVal, markVal); 237 238 okEXT = psphotEvalEXT (tmpSrc, EXT); 238 chiEXT = EXT->chisq / EXT->nDOF; 239 239 chiEXT = EXT ? EXT->chisq / EXT->nDOF : NAN; 240 241 // DBL will always be defined, but DBL->data[n] might not 240 242 psArray *DBL = psphotFitDBL (readout, source, maskVal, markVal); 241 243 okDBL = psphotEvalDBL (tmpSrc, DBL->data[0]); … … 244 246 245 247 // correct first model chisqs for flux trend 248 chiDBL = NAN; 246 249 ONE = DBL->data[0]; 247 chiTrend = psPolynomial1DEval (psf->ChiTrend, ONE->params->data.F32[1]);248 ONE->chisqNorm = ONE->chisq / chiTrend;249 250 // save chisq for double-star/galaxy comparison251 chiDBL = ONE->chisq / ONE->nDOF;250 if (ONE) { 251 chiTrend = psPolynomial1DEval (psf->ChiTrend, ONE->params->data.F32[1]); 252 ONE->chisqNorm = ONE->chisq / chiTrend; 253 chiDBL = ONE->chisq / ONE->nDOF; // save chisq for double-star/galaxy comparison 254 } 252 255 253 256 // correct second model chisqs for flux trend 254 257 ONE = DBL->data[1]; 255 chiTrend = psPolynomial1DEval (psf->ChiTrend, ONE->params->data.F32[1]); 256 ONE->chisqNorm = ONE->chisq / chiTrend; 258 if (ONE) { 259 chiTrend = psPolynomial1DEval (psf->ChiTrend, ONE->params->data.F32[1]); 260 ONE->chisqNorm = ONE->chisq / chiTrend; 261 } 257 262 258 263 psFree (tmpSrc); 259 264 260 // psTraceSetLevel("psModules.objects.pmSourceFitSet", 0);265 // (void) psTraceSetLevel("psModules.objects.pmSourceFitSet", 0); 261 266 262 267 if (okEXT && okDBL) { -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotTest.c
r21355 r24244 50 50 } 51 51 52 psTraceSetLevel ("psLib.sys.mutex", 3);52 (void) psTraceSetLevel ("psLib.sys.mutex", 3); 53 53 54 54 int nThreads = atoi (argv[2]); -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotVersion.c
r23352 r24244 1 1 #include "psphotInternal.h" 2 #include "psphotVersionDefinitions.h" 2 3 3 4 #ifdef HAVE_KAPA … … 15 16 #endif 16 17 17 #define xstr(s) str(s)18 #define str(s) #s19 20 18 psString psphotVersion(void) 21 19 { 22 20 char *value = NULL; 23 psStringAppend(&value, "%s@%s", xstr(PSPHOT_BRANCH), xstr(PSPHOT_VERSION));21 psStringAppend(&value, "%s@%s", PSPHOT_BRANCH, PSPHOT_VERSION); 24 22 return value; 25 23 } … … 27 25 psString psphotSource(void) 28 26 { 29 return psStringCopy( xstr(PSPHOT_SOURCE));27 return psStringCopy(PSPHOT_SOURCE); 30 28 } 31 29
Note:
See TracChangeset
for help on using the changeset viewer.
