Changeset 23352 for branches/cnb_branches/cnb_branch_20090301/psphot
- Timestamp:
- Mar 17, 2009, 12:08:50 PM (17 years ago)
- Location:
- branches/cnb_branches/cnb_branch_20090301
- Files:
-
- 15 edited
-
. (modified) (1 prop)
-
psphot (modified) (1 prop)
-
psphot/src/Makefile.am (modified) (1 diff)
-
psphot/src/psphot.c (modified) (2 diffs)
-
psphot/src/psphot.h (modified) (2 diffs)
-
psphot/src/psphotArguments.c (modified) (1 diff)
-
psphot/src/psphotImageLoop.c (modified) (2 diffs)
-
psphot/src/psphotMagnitudes.c (modified) (8 diffs)
-
psphot/src/psphotMaskReadout.c (modified) (1 diff)
-
psphot/src/psphotModelBackground.c (modified) (6 diffs)
-
psphot/src/psphotSetThreads.c (modified) (1 diff)
-
psphot/src/psphotSourceStats.c (modified) (14 diffs)
-
psphot/src/psphotSubtractBackground.c (modified) (2 diffs)
-
psphot/src/psphotVersion.c (modified) (1 diff)
-
psphot/src/psphotVisual.c (modified) (32 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branches/cnb_branch_20090301
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk merged eligible /branches/eam_branches/eam_branch_20090303 23158-23228
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/cnb_branches/cnb_branch_20090301/psphot
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/cnb_branches/cnb_branch_20090215/psphot merged eligible /trunk/psphot merged eligible /branches/cnb_branch_20090215/psphot 21495-22685 /branches/eam_branches/eam_branch_20090303/psphot 23158-23228
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/cnb_branches/cnb_branch_20090301/psphot/src/Makefile.am
r21392 r23352 1 1 lib_LTLIBRARIES = libpsphot.la 2 libpsphot_la_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) 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: ; 11 12 libpsphot_la_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPSPHOT_VERSION=$(PSPHOT_VERSION) -DPSPHOT_BRANCH=$(PSPHOT_BRANCH) -DPSPHOT_SOURCE=$(SVN_SOURCE) 3 13 libpsphot_la_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 4 14 -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphot.c
r20411 r23352 9 9 10 10 psTimerStart ("complete"); 11 pmErrorRegister(); // register psModule's error codes/messages11 pmErrorRegister(); // register psModule's error codes/messages 12 12 psphotInit(); 13 13 … … 15 15 pmConfig *config = psphotArguments (argc, argv); 16 16 if (!config) { 17 psErrorStackPrint(stderr, "Error reading arguments\n");18 usage ();17 psErrorStackPrint(stderr, "Error reading arguments\n"); 18 usage (); 19 19 } 20 21 psphotVersionPrint(); 20 22 21 23 // load input data (config and images (signal, noise, mask) -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphot.h
r21392 r23352 16 16 const char *psphotCVSName(void); 17 17 psString psphotVersion(void); 18 psString psphotSource(void); 18 19 psString psphotVersionLong(void); 20 bool psphotVersionHeader(psMetadata *header); 21 bool psphotVersionHeaderFull(psMetadata *header); 22 void psphotVersionPrint(void); 19 23 20 24 bool psphotModelTest (pmConfig *config, const pmFPAview *view, psMetadata *recipe); … … 167 171 168 172 // psphotVisual functions 169 bool psphotSetVisual (bool mode);170 173 bool psphotVisualShowImage (pmReadout *readout); 171 174 bool psphotVisualShowBackground (pmConfig *config, const pmFPAview *view, pmReadout *readout); -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotArguments.c
r21458 r23352 82 82 if ((N = psArgumentGet (argc, argv, "-visual"))) { 83 83 psArgumentRemove (N, &argc, argv); 84 psphotSetVisual (true); 85 // pmSourceSetVisual (true); 84 pmVisualSetVisual(true); 86 85 } 87 86 -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotImageLoop.c
r21458 r23352 26 26 27 27 pmFPAview *view = pmFPAviewAlloc (0); 28 pmHDU *lastHDU = NULL; // Last HDU updated 28 29 29 30 // files associated with the science image … … 64 65 psLogMsg ("psphot", 6, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); 65 66 if (! readout->data_exists) { continue; } 67 68 // Update the header 69 { 70 pmHDU *hdu = pmHDUGetHighest(input->fpa, chip, cell); 71 if (hdu && hdu != lastHDU) { 72 psphotVersionHeaderFull(hdu->header); 73 lastHDU = hdu; 74 } 75 } 66 76 67 77 // run the actual photometry analysis on this chip/cell/readout -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotMagnitudes.c
r21519 r23352 15 15 int nThreads = psMetadataLookupS32(&status, config->arguments, "NTHREADS"); // Number of threads 16 16 if (!status) { 17 nThreads = 0;17 nThreads = 0; 18 18 } 19 19 … … 36 36 37 37 // the binning details are saved on the analysis metadata 38 psImageBinning *binning = psMetadataLookupPtr(&status, recipe, "PSPHOT.BACKGROUND.BINNING"); 38 psImageBinning *binning = NULL; 39 if (backModel) { 40 binning = psMetadataLookupPtr(&status, backModel->analysis, "PSPHOT.BACKGROUND.BINNING"); 41 } 39 42 40 43 bool IGNORE_GROWTH = psMetadataLookupBool (&status, recipe, "IGNORE_GROWTH"); … … 53 56 for (int i = 0; i < cellGroups->n; i++) { 54 57 55 psArray *cells = cellGroups->data[i];56 57 for (int j = 0; j < cells->n; j++) {58 59 // allocate a job -- if threads are not defined, this just runs the job60 psThreadJob *job = psThreadJobAlloc ("PSPHOT_MAGNITUDES");61 62 psArrayAdd(job->args, 1, cells->data[j]); // sources63 psArrayAdd(job->args, 1, psf);64 psArrayAdd(job->args, 1, binning);65 psArrayAdd(job->args, 1, backModel);66 psArrayAdd(job->args, 1, backStdev);67 68 PS_ARRAY_ADD_SCALAR(job->args, photMode, PS_TYPE_S32);69 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK);70 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for nAp71 72 if (!psThreadJobAddPending(job)) {73 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");74 psFree (job);75 return false;76 }77 psFree(job);58 psArray *cells = cellGroups->data[i]; 59 60 for (int j = 0; j < cells->n; j++) { 61 62 // allocate a job -- if threads are not defined, this just runs the job 63 psThreadJob *job = psThreadJobAlloc ("PSPHOT_MAGNITUDES"); 64 65 psArrayAdd(job->args, 1, cells->data[j]); // sources 66 psArrayAdd(job->args, 1, psf); 67 psArrayAdd(job->args, 1, binning); 68 psArrayAdd(job->args, 1, backModel); 69 psArrayAdd(job->args, 1, backStdev); 70 71 PS_ARRAY_ADD_SCALAR(job->args, photMode, PS_TYPE_S32); 72 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 73 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for nAp 74 75 if (!psThreadJobAddPending(job)) { 76 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 77 psFree (job); 78 return false; 79 } 80 psFree(job); 78 81 79 82 # if (0) 80 int nap = 0;81 if (!psphotMagnitudes_Unthreaded (&nap, cells->data[j], psf, binning, backModel, backStdev, photMode, maskVal)) {82 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");83 return false;84 }85 Nap += nap;83 int nap = 0; 84 if (!psphotMagnitudes_Unthreaded (&nap, cells->data[j], psf, binning, backModel, backStdev, photMode, maskVal)) { 85 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 86 return false; 87 } 88 Nap += nap; 86 89 # endif 87 }88 89 // wait for the threads to finish and manage results90 if (!psThreadPoolWait (false)) {91 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");92 return false;93 }94 95 // we have only supplied one type of job, so we can assume the types here96 psThreadJob *job = NULL;97 while ((job = psThreadJobGetDone()) != NULL) {98 if (job->args->n < 1) {99 fprintf (stderr, "error with job\n");100 } else {101 psScalar *scalar = job->args->data[7];102 Nap += scalar->data.S32;103 }104 psFree(job);105 }90 } 91 92 // wait for the threads to finish and manage results 93 if (!psThreadPoolWait (false)) { 94 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 95 return false; 96 } 97 98 // we have only supplied one type of job, so we can assume the types here 99 psThreadJob *job = NULL; 100 while ((job = psThreadJobGetDone()) != NULL) { 101 if (job->args->n < 1) { 102 fprintf (stderr, "error with job\n"); 103 } else { 104 psScalar *scalar = job->args->data[7]; 105 Nap += scalar->data.S32; 106 } 107 psFree(job); 108 } 106 109 } 107 110 … … 130 133 if (status && isfinite(source->apMag)) Nap ++; 131 134 132 if (backModel) {133 psAssert (binning, "if backModel is defined, so should binning be");134 source->sky = psImageUnbinPixel(source->peak->x, source->peak->y, backModel->image, binning);135 if (isnan(source->sky) && false) {136 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.sky");137 }138 } else {139 source->sky = NAN;140 }141 142 if (backStdev) {143 psAssert (binning, "if backStdev is defined, so should binning be");144 source->skyErr = psImageUnbinPixel(source->peak->x, source->peak->y, backStdev->image, binning);145 if (isnan(source->skyErr) && false) {146 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.skyErr");147 }148 } else {149 source->skyErr = NAN;150 }135 if (backModel) { 136 psAssert (binning, "if backModel is defined, so should binning be"); 137 source->sky = psImageUnbinPixel(source->peak->x, source->peak->y, backModel->image, binning); 138 if (isnan(source->sky) && false) { 139 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.sky"); 140 } 141 } else { 142 source->sky = NAN; 143 } 144 145 if (backStdev) { 146 psAssert (binning, "if backStdev is defined, so should binning be"); 147 source->skyErr = psImageUnbinPixel(source->peak->x, source->peak->y, backStdev->image, binning); 148 if (isnan(source->skyErr) && false) { 149 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.skyErr"); 150 } 151 } else { 152 source->skyErr = NAN; 153 } 151 154 } 152 155 … … 169 172 if (status && isfinite(source->apMag)) Nap ++; 170 173 171 if (backModel) {172 psAssert (binning, "if backModel is defined, so should binning be");173 source->sky = psImageUnbinPixel(source->peak->x, source->peak->y, backModel->image, binning);174 if (isnan(source->sky) && false) {175 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.sky");176 }177 } else {178 source->sky = NAN;179 }180 181 if (backStdev) {182 psAssert (binning, "if backStdev is defined, so should binning be");183 source->skyErr = psImageUnbinPixel(source->peak->x, source->peak->y, backStdev->image, binning);184 if (isnan(source->skyErr) && false) {185 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.skyErr");186 }187 } else {188 source->skyErr = NAN;189 }174 if (backModel) { 175 psAssert (binning, "if backModel is defined, so should binning be"); 176 source->sky = psImageUnbinPixel(source->peak->x, source->peak->y, backModel->image, binning); 177 if (isnan(source->sky) && false) { 178 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.sky"); 179 } 180 } else { 181 source->sky = NAN; 182 } 183 184 if (backStdev) { 185 psAssert (binning, "if backStdev is defined, so should binning be"); 186 source->skyErr = psImageUnbinPixel(source->peak->x, source->peak->y, backStdev->image, binning); 187 if (isnan(source->skyErr) && false) { 188 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.skyErr"); 189 } 190 } else { 191 source->skyErr = NAN; 192 } 190 193 } 191 194 … … 210 213 int nThreads = psMetadataLookupS32(&status, config->arguments, "NTHREADS"); // Number of threads 211 214 if (!status) { 212 nThreads = 0;215 nThreads = 0; 213 216 } 214 217 nThreads = 0; // XXX until testing is complete, do not thread this function … … 233 236 for (int i = 0; i < cellGroups->n; i++) { 234 237 235 psArray *cells = cellGroups->data[i];236 237 for (int j = 0; j < cells->n; j++) {238 239 // allocate a job -- if threads are not defined, this just runs the job240 psThreadJob *job = psThreadJobAlloc ("PSPHOT_PSF_WEIGHTS");241 242 psArrayAdd(job->args, 1, cells->data[j]); // sources243 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK);244 245 if (!psThreadJobAddPending(job)) {246 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");247 psFree (job);248 return false;249 }250 psFree(job);251 252 }253 254 // wait for the threads to finish and manage results255 if (!psThreadPoolWait (false)) {256 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");257 return false;258 }259 260 // we have only supplied one type of job, so we can assume the types here261 psThreadJob *job = NULL;262 while ((job = psThreadJobGetDone()) != NULL) {263 if (job->args->n < 1) {264 fprintf (stderr, "error with job\n");265 } 266 psFree(job);267 }238 psArray *cells = cellGroups->data[i]; 239 240 for (int j = 0; j < cells->n; j++) { 241 242 // allocate a job -- if threads are not defined, this just runs the job 243 psThreadJob *job = psThreadJobAlloc ("PSPHOT_PSF_WEIGHTS"); 244 245 psArrayAdd(job->args, 1, cells->data[j]); // sources 246 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 247 248 if (!psThreadJobAddPending(job)) { 249 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 250 psFree (job); 251 return false; 252 } 253 psFree(job); 254 255 } 256 257 // wait for the threads to finish and manage results 258 if (!psThreadPoolWait (false)) { 259 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 260 return false; 261 } 262 263 // we have only supplied one type of job, so we can assume the types here 264 psThreadJob *job = NULL; 265 while ((job = psThreadJobGetDone()) != NULL) { 266 if (job->args->n < 1) { 267 fprintf (stderr, "error with job\n"); 268 } 269 psFree(job); 270 } 268 271 } 269 272 … … 285 288 pmSource *source = (pmSource *) sources->data[i]; 286 289 287 // we must have a valid model288 pmModel *model = pmSourceGetModel (&isPSF, source);289 if (model == NULL) {290 psTrace ("psphot", 3, "fail mag : no valid model");291 source->pixWeight = NAN;292 continue;293 }290 // we must have a valid model 291 pmModel *model = pmSourceGetModel (&isPSF, source); 292 if (model == NULL) { 293 psTrace ("psphot", 3, "fail mag : no valid model"); 294 source->pixWeight = NAN; 295 continue; 296 } 294 297 295 298 status = pmSourcePixelWeight (&source->pixWeight, model, source->maskObj, maskVal); 296 if (!status) {297 psTrace ("psphot", 3, "fail to measure pixel weight");298 source->pixWeight = NAN;299 continue;300 }301 302 } 303 304 return true; 305 } 299 if (!status) { 300 psTrace ("psphot", 3, "fail to measure pixel weight"); 301 source->pixWeight = NAN; 302 continue; 303 } 304 305 } 306 307 return true; 308 } -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotMaskReadout.c
r21366 r23352 29 29 } 30 30 31 // make this an option via the recipe 32 if (0) { 33 psImage *im = readout->image; 34 psImage *wt = readout->variance; 35 psImage *mk = readout->mask; 36 for (int j = 0; j < im->numRows; j++) { 37 for (int i = 0; i < im->numCols; i++) { 38 if (isfinite(im->data.F32[j][i]) && isfinite(wt->data.F32[j][i])) continue; 39 mk->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskBad; 40 } 41 } 42 } 43 31 44 // mask the excluded outer pixels 32 45 // these coordinates refer to the parent image -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotModelBackground.c
r21183 r23352 31 31 static bool backgroundModel(psImage *model, // Model image 32 32 psImage *modelStdev, // Model stdev image 33 ps Image *image, // Image for which to generate a background model34 p sImage *mask, // Mask for image33 psMetadata *analysis, // Analysis metadata for outputs 34 pmReadout *readout, // Readout for which to generate a background model 35 35 psImageBinning *binning, // Binning parameters 36 36 const pmConfig *config // Configuration … … 41 41 bool status = true; 42 42 43 psImage *image = readout->image, *mask = readout->mask; // Image and mask for readout 44 43 45 // select the appropriate recipe information 44 46 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); … … 49 51 assert (maskVal); 50 52 51 // user supplied seed, if available 52 unsigned long seed = psMetadataLookupS32 (&status, recipe, "IMSTATS_SEED"); 53 if (!status) { 54 seed = 0; 55 } 56 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, seed); 53 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 57 54 58 55 // subtract this amount extra from the sky … … 140 137 141 138 // we save the binning structure for use in psphotMagnitudes 142 status = psMetadataAddPtr(recipe, PS_LIST_TAIL, "PSPHOT.BACKGROUND.BINNING", PS_DATA_UNKNOWN | PS_META_REPLACE, "Background binning", binning); 143 PS_ASSERT (status, false); 144 139 psMetadataAddPtr(analysis, PS_LIST_TAIL, "PSPHOT.BACKGROUND.BINNING", 140 PS_DATA_UNKNOWN | PS_META_REPLACE, "Background binning", binning); 145 141 146 142 psF32 **modelData = model->data.F32; … … 343 339 psImage *modelStdev = psImageAlloc(binning->nXruff, binning->nYruff, PS_TYPE_F32); // Standard deviation 344 340 345 if (!backgroundModel(model, modelStdev, ro-> image, ro->mask, binning, config)) {341 if (!backgroundModel(model, modelStdev, ro->analysis, ro, binning, config)) { 346 342 psFree(model); 347 343 psFree(modelStdev); … … 365 361 pmFPAfile *file = psMetadataLookupPtr (&status, config->files, filename); 366 362 pmFPA *inFPA = file->fpa; 367 pmReadout *readout = pmFPAviewThisReadout (view, inFPA); 368 psImage *image = readout->image; 369 psImage *mask = readout->mask; 370 371 psImageBinning *binning = backgroundBinning(image, config); // Image binning parameters 363 pmReadout *readout = pmFPAviewThisReadout(view, inFPA); 364 365 psImageBinning *binning = backgroundBinning(readout->image, config); // Image binning parameters 372 366 pmReadout *model = pmFPAGenerateReadout(config, view, "PSPHOT.BACKMDL", inFPA, binning); 373 367 pmReadout *modelStdev = pmFPAGenerateReadout(config, view, "PSPHOT.BACKMDL.STDEV", inFPA, binning); 374 368 375 if (!backgroundModel(model->image, modelStdev->image, image, mask, binning, config)) {369 if (!backgroundModel(model->image, modelStdev->image, model->analysis, readout, binning, config)) { 376 370 psError(PS_ERR_UNKNOWN, false, "Unable to generate background model"); 377 371 return false; -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotSetThreads.c
r21392 r23352 25 25 psFree(task); 26 26 27 task = psThreadTaskAlloc("PSPHOT_SOURCE_STATS", 4);27 task = psThreadTaskAlloc("PSPHOT_SOURCE_STATS", 5); 28 28 task->function = &psphotSourceStats_Threaded; 29 29 psThreadTaskAdd(task); -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotSourceStats.c
r21519 r23352 15 15 int nThreads = psMetadataLookupS32(&status, config->arguments, "NTHREADS"); // Number of threads 16 16 if (!status) { 17 nThreads = 0;17 nThreads = 0; 18 18 } 19 19 … … 41 41 pmSource *source = pmSourceAlloc(); 42 42 43 // add the peak43 // add the peak 44 44 source->peak = psMemIncrRefCounter(peak); 45 45 46 // allocate space for moments46 // allocate space for moments 47 47 source->moments = pmMomentsAlloc(); 48 48 … … 50 50 pmSourceDefinePixels (source, readout, source->peak->x, source->peak->y, OUTER); 51 51 52 peak->assigned = true;53 psArrayAdd (sources, 100, source);54 psFree (source);52 peak->assigned = true; 53 psArrayAdd (sources, 100, source); 54 psFree (source); 55 55 } 56 56 57 57 if (!strcasecmp (breakPt, "PEAKS")) { 58 psLogMsg ("psphot", PS_LOG_INFO, "%ld sources : %f sec\n", sources->n, psTimerMark ("psphot.stats"));59 psLogMsg ("psphot", PS_LOG_INFO, "break point PEAKS, skipping MOMENTS\n");60 psphotVisualShowMoments (sources);61 return sources;58 psLogMsg ("psphot", PS_LOG_INFO, "%ld sources : %f sec\n", sources->n, psTimerMark ("psphot.stats")); 59 psLogMsg ("psphot", PS_LOG_INFO, "break point PEAKS, skipping MOMENTS\n"); 60 psphotVisualShowMoments (sources); 61 return sources; 62 62 } 63 63 … … 65 65 int Nfail = 0; 66 66 int Nmoments = 0; 67 int Nfaint = 0; 67 68 68 69 // choose Cx, Cy (see psphotThreadTools.c for overview of the concepts) … … 74 75 for (int i = 0; i < cellGroups->n; i++) { 75 76 76 psArray *cells = cellGroups->data[i]; 77 78 for (int j = 0; j < cells->n; j++) { 79 80 // allocate a job -- if threads are not defined, this just runs the job 81 psThreadJob *job = psThreadJobAlloc ("PSPHOT_SOURCE_STATS"); 82 83 psArrayAdd(job->args, 1, cells->data[j]); // sources 84 psArrayAdd(job->args, 1, recipe); 85 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nmoments 86 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail 87 88 if (!psThreadJobAddPending(job)) { 89 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 90 psFree (job); 91 return NULL; 92 } 93 psFree(job); 77 psArray *cells = cellGroups->data[i]; 78 79 for (int j = 0; j < cells->n; j++) { 80 81 // allocate a job -- if threads are not defined, this just runs the job 82 psThreadJob *job = psThreadJobAlloc ("PSPHOT_SOURCE_STATS"); 83 84 psArrayAdd(job->args, 1, cells->data[j]); // sources 85 psArrayAdd(job->args, 1, recipe); 86 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nmoments 87 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail 88 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfaint 89 90 if (!psThreadJobAddPending(job)) { 91 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 92 psFree (job); 93 return NULL; 94 } 95 psFree(job); 94 96 95 97 # if (0) 96 int nfail = 0;97 int nmoments = 0;98 if (!psphotSourceStats_Unthreaded (&nfail, &nmoments, cells->data[j], recipe)) {99 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");100 return NULL;101 }102 Nfail += nfail;103 Nmoments += nmoments;98 int nfail = 0; 99 int nmoments = 0; 100 if (!psphotSourceStats_Unthreaded (&nfail, &nmoments, cells->data[j], recipe)) { 101 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 102 return NULL; 103 } 104 Nfail += nfail; 105 Nmoments += nmoments; 104 106 # endif 105 } 106 107 // wait for the threads to finish and manage results 108 if (!psThreadPoolWait (false)) { 109 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 110 return NULL; 111 } 112 113 // we have only supplied one type of job, so we can assume the types here 114 psThreadJob *job = NULL; 115 while ((job = psThreadJobGetDone()) != NULL) { 116 if (job->args->n < 1) { 117 fprintf (stderr, "error with job\n"); 118 } else { 119 psScalar *scalar = NULL; 120 scalar = job->args->data[2]; 121 Nmoments += scalar->data.S32; 122 scalar = job->args->data[3]; 123 Nfail += scalar->data.S32; 124 } 125 psFree(job); 126 } 107 } 108 109 // wait for the threads to finish and manage results 110 if (!psThreadPoolWait (false)) { 111 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 112 return NULL; 113 } 114 115 // we have only supplied one type of job, so we can assume the types here 116 psThreadJob *job = NULL; 117 while ((job = psThreadJobGetDone()) != NULL) { 118 if (job->args->n < 1) { 119 fprintf (stderr, "error with job\n"); 120 } else { 121 psScalar *scalar = NULL; 122 scalar = job->args->data[2]; 123 Nmoments += scalar->data.S32; 124 scalar = job->args->data[3]; 125 Nfail += scalar->data.S32; 126 scalar = job->args->data[4]; 127 Nfaint += scalar->data.S32; 128 } 129 psFree(job); 130 } 127 131 } 128 132 129 133 psFree (cellGroups); 130 134 131 psLogMsg ("psphot", PS_LOG_INFO, "%ld sources, %d moments, %d fai led: %f sec\n", sources->n, Nmoments, Nfail, psTimerMark ("psphot.stats"));135 psLogMsg ("psphot", PS_LOG_INFO, "%ld sources, %d moments, %d faint, %d failed: %f sec\n", sources->n, Nmoments, Nfaint, Nfail, psTimerMark ("psphot.stats")); 132 136 133 137 psphotVisualShowMoments (sources); … … 166 170 int Nfail = 0; 167 171 int Nmoments = 0; 172 int Nfaint = 0; 168 173 for (int i = 0; i < sources->n; i++) { 169 174 pmSource *source = sources->data[i]; … … 171 176 // skip faint sources for moments measurement 172 177 if (source->peak->SN < MIN_SN) { 173 source->mode |= PM_SOURCE_MODE_BELOW_MOMENTS_SN; 178 source->mode |= PM_SOURCE_MODE_BELOW_MOMENTS_SN; 179 Nfaint++; 174 180 continue; 175 181 } … … 179 185 status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal); 180 186 if (!status) { 181 source->mode |= PM_SOURCE_MODE_SKY_FAILURE;182 psErrorClear(); // XXX re-consider the errors raised here183 Nfail ++;184 continue;187 source->mode |= PM_SOURCE_MODE_SKY_FAILURE; 188 psErrorClear(); // XXX re-consider the errors raised here 189 Nfail ++; 190 continue; 185 191 } 186 192 … … 189 195 status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal); 190 196 if (!status) { 191 source->mode |= PM_SOURCE_MODE_SKYVAR_FAILURE;192 Nfail ++;193 psErrorClear();194 continue;197 source->mode |= PM_SOURCE_MODE_SKYVAR_FAILURE; 198 Nfail ++; 199 psErrorClear(); 200 continue; 195 201 } 196 202 … … 208 214 status = pmSourceMoments (source, BIG_RADIUS); 209 215 if (status) { 210 source->mode |= PM_SOURCE_MODE_BIG_RADIUS;216 source->mode |= PM_SOURCE_MODE_BIG_RADIUS; 211 217 Nmoments ++; 212 218 continue; 213 219 } 214 220 215 source->mode |= PM_SOURCE_MODE_MOMENTS_FAILURE;221 source->mode |= PM_SOURCE_MODE_MOMENTS_FAILURE; 216 222 Nfail ++; 217 223 psErrorClear(); … … 225 231 scalar = job->args->data[3]; 226 232 scalar->data.S32 = Nfail; 227 233 234 scalar = job->args->data[4]; 235 scalar->data.S32 = Nfaint; 236 228 237 return true; 229 238 } … … 268 277 status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal); 269 278 if (!status) { 270 psErrorClear(); // XXX re-consider the errors raised here271 Nfail ++;272 continue;279 psErrorClear(); // XXX re-consider the errors raised here 280 Nfail ++; 281 continue; 273 282 } 274 283 … … 277 286 status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal); 278 287 if (!status) { 279 Nfail ++;280 psErrorClear();281 continue;288 Nfail ++; 289 psErrorClear(); 290 continue; 282 291 } 283 292 … … 307 316 *nmoments = Nmoments; 308 317 *nfail = Nfail; 309 318 310 319 return true; 311 320 } 312 # endif 321 # endif -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotSubtractBackground.c
r21183 r23352 4 4 // generate the median in NxN boxes, clipping heavily 5 5 // linear interpolation to generate full-scale model 6 bool psphotSubtractBackground (pmConfig *config, const pmFPAview *view, const char *filename) 6 bool psphotSubtractBackground (pmConfig *config, const pmFPAview *view, const char *filename) 7 7 { 8 8 bool status = true; … … 31 31 assert (maskVal); 32 32 33 psImageBinning *binning = psMetadataLookupPtr(&status, recipe, "PSPHOT.BACKGROUND.BINNING");33 psImageBinning *binning = psMetadataLookupPtr(&status, model->analysis, "PSPHOT.BACKGROUND.BINNING"); 34 34 assert (binning); 35 35 -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotVersion.c
r12805 r23352 1 # include "psphotInternal.h"1 #include "psphotInternal.h" 2 2 3 # if (HAVE_KAPA)4 # include <kapa.h>5 # endif3 #ifdef HAVE_KAPA 4 #include <kapa.h> 5 #endif 6 6 7 static const char *cvsTag = "$Name: not supported by cvs2svn $";// CVS tag name 7 #ifndef PSPHOT_VERSION 8 #error "PSPHOT_VERSION is not set" 9 #endif 10 #ifndef PSPHOT_BRANCH 11 #error "PSPHOT_BRANCH is not set" 12 #endif 13 #ifndef PSPHOT_SOURCE 14 #error "PSPHOT_SOURCE is not set" 15 #endif 16 17 #define xstr(s) str(s) 18 #define str(s) #s 8 19 9 20 psString psphotVersion(void) 10 21 { 11 psString version = NULL; // Version, to return 12 psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION); 13 return version; 22 char *value = NULL; 23 psStringAppend(&value, "%s@%s", xstr(PSPHOT_BRANCH), xstr(PSPHOT_VERSION)); 24 return value; 25 } 26 27 psString psphotSource(void) 28 { 29 return psStringCopy(xstr(PSPHOT_SOURCE)); 14 30 } 15 31 16 32 psString psphotVersionLong(void) 17 33 { 18 psString version = psphotVersion(); // Version, to return 19 psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag 20 psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__); 34 psString version = psLibVersion(); // Version, to return 35 psString source = psLibSource(); // Source 21 36 22 # if (HAVE_KAPA) 23 psString ohanaVersion = psStringStripCVS (ohana_version(), "Name");24 ps String libdvoVersion = psStringStripCVS (libdvo_version(), "Name");37 psStringPrepend(&version, "psphot "); 38 psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__); 39 psFree(source); 25 40 26 psStringAppend (&version, " with libkapa (ohana %s, libdvo: %s)", ohanaVersion, libdvoVersion); 27 psFree (ohanaVersion); 28 psFree (libdvoVersion); 29 # else 30 psStringAppend (&version, " WITHOUT libkapa"); 31 # endif 41 #ifdef __OPTIMIZE__ 42 psStringAppend(&version, " optimised"); 43 #else 44 psStringAppend(&version, " unoptimised"); 45 #endif 32 46 33 psFree(tag); 47 #ifdef HAVE_KAPA 48 #if 0 49 // XXX Need to get ohana and libdvo versions 50 psString ohanaVersion = psStringStripCVS(ohana_version(), "Name"); 51 psString libdvoVersion = psStringStripCVS(libdvo_version(), "Name"); 52 psStringAppend(&version, " with libkapa (ohana %s, libdvo: %s)", ohanaVersion, libdvoVersion); 53 psFree(ohanaVersion); 54 psFree(libdvoVersion); 55 #else 56 psStringAppend(&version, " with libkapa"); 57 #endif 58 59 #else 60 psStringAppend (&version, " without libkapa"); 61 #endif 62 34 63 return version; 35 64 } 36 65 37 // Defined by RHL; leaving for backwards compatibility. 38 const char *psphotCVSName(void) { 39 return cvsTag; 66 bool psphotVersionHeader(psMetadata *header) 67 { 68 PS_ASSERT_METADATA_NON_NULL(header, false); 69 70 psString version = psphotVersion(); // Software version 71 psString source = psphotSource(); // Software source 72 73 psStringPrepend(&version, "psphot version: "); 74 psStringPrepend(&source, "psphot source: "); 75 76 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, version); 77 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, source); 78 79 psFree(version); 80 psFree(source); 81 82 return true; 40 83 } 84 85 86 bool psphotVersionHeaderFull(psMetadata *header) 87 { 88 PS_ASSERT_METADATA_NON_NULL(header, false); 89 90 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 91 psString timeString = psTimeToISO(time); // The time in an ISO string 92 psFree(time); 93 psString history = NULL; // History string 94 psStringAppend(&history, "psphot at %s", timeString); 95 psFree(timeString); 96 psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history); 97 psFree(history); 98 99 psLibVersionHeader(header); 100 psModulesVersionHeader(header); 101 psphotVersionHeader(header); 102 103 return true; 104 } 105 106 107 void psphotVersionPrint(void) 108 { 109 psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now 110 psString timeString = psTimeToISO(time); // The time in an ISO string 111 psFree(time); 112 psLogMsg("psphot", PS_LOG_INFO, "psphot at %s", timeString); 113 psFree(timeString); 114 115 psString pslib = psLibVersionLong();// psLib version 116 psString psmodules = psModulesVersionLong(); // psModules version 117 psString psphot = psphotVersionLong(); // psphot version 118 119 psLogMsg("psphot", PS_LOG_INFO, "%s", pslib); 120 psLogMsg("psphot", PS_LOG_INFO, "%s", psmodules); 121 psLogMsg("psphot", PS_LOG_INFO, "%s", psphot); 122 123 psFree(pslib); 124 psFree(psmodules); 125 psFree(psphot); 126 127 return; 128 } -
branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotVisual.c
r21519 r23352 18 18 // these are invoked by the -visual options 19 19 20 static bool isVisual = false;21 20 static int kapa = -1; 22 21 static int kapa2 = -1; 23 22 static int kapa3 = -1; 24 23 25 bool psphotSetVisual (bool mode) {26 27 isVisual = mode;28 return true;29 }30 24 31 25 bool psphotVisualShowMask (int kapaFD, psImage *inImage, const char *name, int channel) { … … 38 32 39 33 psStats *stats = psStatsAlloc (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); 40 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0);34 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 41 35 if (!psImageBackground(stats, NULL, inImage, NULL, 0, rng)) { 42 36 fprintf (stderr, "failed to get background values\n"); … … 84 78 85 79 psStats *stats = psStatsAlloc (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); 86 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS , 0);80 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 87 81 if (!psImageBackground(stats, NULL, inImage, NULL, 0, rng)) { 88 82 fprintf (stderr, "failed to get background values\n"); … … 135 129 bool psphotVisualShowImage (pmReadout *readout) { 136 130 137 if (! isVisual) return true;131 if (!pmVisualIsVisual()) return true; 138 132 139 133 if (kapa == -1) { … … 141 135 if (kapa == -1) { 142 136 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 143 isVisual = false;137 pmVisualSetVisual(false); 144 138 return false; 145 139 } … … 164 158 pmReadout *backgnd; 165 159 166 if (! isVisual) return true;160 if (!pmVisualIsVisual()) return true; 167 161 168 162 if (kapa == -1) { … … 170 164 if (kapa == -1) { 171 165 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 172 isVisual = false;166 pmVisualSetVisual(false); 173 167 return false; 174 168 } … … 199 193 bool psphotVisualShowSignificance (psImage *image) { 200 194 201 if (! isVisual) return true;195 if (!pmVisualIsVisual()) return true; 202 196 203 197 if (kapa == -1) { … … 205 199 if (kapa == -1) { 206 200 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 207 isVisual = false;201 pmVisualSetVisual(false); 208 202 return false; 209 203 } … … 228 222 KiiOverlay *overlay; 229 223 230 if (! isVisual) return true;224 if (!pmVisualIsVisual()) return true; 231 225 232 226 if (kapa == -1) { … … 306 300 KiiOverlay *overlay; 307 301 308 if (! isVisual) return true;302 if (!pmVisualIsVisual()) return true; 309 303 310 304 if (kapa == -1) { … … 423 417 psEllipseAxes axes; 424 418 425 if (! isVisual) return true;419 if (!pmVisualIsVisual()) return true; 426 420 427 421 if (kapa == -1) { … … 478 472 Graphdata graphdata; 479 473 480 if (! isVisual) return true;474 if (!pmVisualIsVisual()) return true; 481 475 482 476 if (kapa3 == -1) { … … 484 478 if (kapa3 == -1) { 485 479 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 486 isVisual = false;480 pmVisualSetVisual(false); 487 481 return false; 488 482 } … … 694 688 bool psphotVisualShowRoughClass (psArray *sources) { 695 689 696 if (! isVisual) return true;690 if (!pmVisualIsVisual()) return true; 697 691 698 692 if (kapa == -1) { … … 723 717 bool psphotVisualShowPSFModel (pmReadout *readout, pmPSF *psf) { 724 718 725 if (! isVisual) return true;719 if (!pmVisualIsVisual()) return true; 726 720 727 721 if (kapa2 == -1) { … … 729 723 if (kapa2 == -1) { 730 724 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 731 isVisual = false;725 pmVisualSetVisual(false); 732 726 return false; 733 727 } … … 801 795 bool status; 802 796 803 if (! isVisual) return true;797 if (!pmVisualIsVisual()) return true; 804 798 805 799 if (kapa2 == -1) { … … 807 801 if (kapa2 == -1) { 808 802 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 809 isVisual = false;803 pmVisualSetVisual(false); 810 804 return false; 811 805 } … … 961 955 bool status; 962 956 963 if (! isVisual) return true;957 if (!pmVisualIsVisual()) return true; 964 958 965 959 if (kapa2 == -1) { … … 967 961 if (kapa2 == -1) { 968 962 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 969 isVisual = false;963 pmVisualSetVisual(false); 970 964 return false; 971 965 } … … 1214 1208 KapaSection section; // put the positive profile in one and the residuals in another? 1215 1209 1216 if (! isVisual) return true;1210 if (!pmVisualIsVisual()) return true; 1217 1211 1218 1212 if (kapa3 == -1) { … … 1220 1214 if (kapa3 == -1) { 1221 1215 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 1222 isVisual = false;1216 pmVisualSetVisual(false); 1223 1217 return false; 1224 1218 } … … 1286 1280 psEllipseAxes axes; 1287 1281 1288 if (! isVisual) return true;1282 if (!pmVisualIsVisual()) return true; 1289 1283 1290 1284 if (kapa == -1) { … … 1387 1381 KiiOverlay *overlay; 1388 1382 1389 if (! isVisual) return true;1383 if (!pmVisualIsVisual()) return true; 1390 1384 1391 1385 if (kapa == -1) { … … 1464 1458 KapaSection section; 1465 1459 1466 if (! isVisual) return true;1460 if (!pmVisualIsVisual()) return true; 1467 1461 1468 1462 if (kapa3 == -1) { … … 1470 1464 if (kapa3 == -1) { 1471 1465 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 1472 isVisual = false;1466 pmVisualSetVisual(false); 1473 1467 return false; 1474 1468 } … … 1604 1598 bool psphotVisualShowResidualImage (pmReadout *readout) { 1605 1599 1606 if (! isVisual) return true;1600 if (!pmVisualIsVisual()) return true; 1607 1601 1608 1602 if (kapa == -1) { … … 1610 1604 if (kapa == -1) { 1611 1605 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 1612 isVisual = false;1606 pmVisualSetVisual(false); 1613 1607 return false; 1614 1608 } … … 1631 1625 Graphdata graphdata; 1632 1626 1633 if (! isVisual) return true;1627 if (!pmVisualIsVisual()) return true; 1634 1628 1635 1629 if (kapa3 == -1) { … … 1637 1631 if (kapa3 == -1) { 1638 1632 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 1639 isVisual = false;1633 pmVisualSetVisual(false); 1640 1634 return false; 1641 1635 } … … 1712 1706 # else 1713 1707 1714 bool psphotSetVisual (bool mode){}1715 1708 bool psphotVisualShowImage (pmConfig *config, pmReadout *readout) { return true; } 1716 1709 bool psphotVisualShowBackground (pmConfig *config, const pmFPAview *view, pmReadout *readout) { return true; }
Note:
See TracChangeset
for help on using the changeset viewer.
