Changeset 21366 for trunk/psphot/src/psphotVisual.c
- Timestamp:
- Feb 5, 2009, 5:03:33 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotVisual.c (modified) (73 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotVisual.c
r21183 r21366 2 2 3 3 // this function displays representative images as the psphot analysis progresses: 4 // 0 : image, 1 : weight5 // 0 : backsub, 1 : weight, 2 : backgnd6 // 0 : backsub, 1 : weight, 2 : signif4 // 0 : image, 1 : variance 5 // 0 : backsub, 1 : variance, 2 : backgnd 6 // 0 : backsub, 1 : variance, 2 : signif 7 7 // (overlay peaks on images) 8 8 // (overlay footprints on images) 9 9 // (overlay moments on images) 10 // (overlay rough class on images) 10 // (overlay rough class on images) 11 11 // 0 : backsub, 1 : psfpos, 2: psfsub 12 12 // 0 : backsub, 1 : lin_resid, 2: psfsub … … 40 40 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0); 41 41 if (!psImageBackground(stats, NULL, inImage, NULL, 0, rng)) { 42 fprintf (stderr, "failed to get background values\n");43 return false;42 fprintf (stderr, "failed to get background values\n"); 43 return false; 44 44 } 45 45 … … 49 49 ALLOCATE (image.data2d, float *, image.Ny); 50 50 for (int iy = 0; iy < image.Ny; iy++) { 51 ALLOCATE (image.data2d[iy], float, image.Nx);52 for (int ix = 0; ix < image.Nx; ix++) {53 image.data2d[iy][ix] = inImage->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix];54 }51 ALLOCATE (image.data2d[iy], float, image.Nx); 52 for (int ix = 0; ix < image.Nx; ix++) { 53 image.data2d[iy][ix] = inImage->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix]; 54 } 55 55 } 56 56 … … 60 60 data.range = 32; 61 61 data.logflux = 0; 62 62 63 63 KiiSetChannel (kapaFD, channel); 64 64 KiiNewPicture2D (kapaFD, &image, &data, &coords); 65 65 66 66 for (int iy = 0; iy < image.Ny; iy++) { 67 free (image.data2d[iy]);67 free (image.data2d[iy]); 68 68 } 69 69 free (image.data2d); … … 86 86 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0); 87 87 if (!psImageBackground(stats, NULL, inImage, NULL, 0, rng)) { 88 fprintf (stderr, "failed to get background values\n");89 return false;88 fprintf (stderr, "failed to get background values\n"); 89 return false; 90 90 } 91 91 … … 99 99 data.range = 5*stats->robustStdev; 100 100 data.logflux = 0; 101 101 102 102 KiiSetChannel (kapaFD, channel); 103 103 KiiNewPicture2D (kapaFD, &image, &data, &coords); … … 126 126 data.range = max - min; 127 127 data.logflux = 0; 128 128 129 129 KiiSetChannel (kapaFD, channel); 130 130 KiiNewPicture2D (kapaFD, &image, &data, &coords); … … 139 139 if (kapa == -1) { 140 140 kapa = KapaOpenNamedSocket ("kapa", "psphot:images"); 141 if (kapa == -1) {142 fprintf (stderr, "failure to open kapa; visual mode disabled\n");143 isVisual = false;144 return false;145 }146 } 141 if (kapa == -1) { 142 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 143 isVisual = false; 144 return false; 145 } 146 } 147 147 148 148 // psphotVisualShowMask (kapa, readout->mask, "mask", 2); 149 psphotVisualScaleImage (kapa, readout-> weight, "weight", 1);149 psphotVisualScaleImage (kapa, readout->variance, "variance", 1); 150 150 psphotVisualScaleImage (kapa, readout->image, "image", 0); 151 151 … … 155 155 fprintf (stdout, "[c]ontinue? "); 156 156 if (!fgets(key, 8, stdin)) { 157 psWarning("Unable to read option");157 psWarning("Unable to read option"); 158 158 } 159 159 return true; … … 168 168 if (kapa == -1) { 169 169 kapa = KapaOpenNamedSocket ("kapa", "psphot:images"); 170 if (kapa == -1) {171 fprintf (stderr, "failure to open kapa; visual mode disabled\n");172 isVisual = false;173 return false;174 }175 } 170 if (kapa == -1) { 171 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 172 isVisual = false; 173 return false; 174 } 175 } 176 176 177 177 bool status = false; … … 179 179 180 180 if (file->mode == PM_FPA_MODE_INTERNAL) { 181 backgnd = file->readout;181 backgnd = file->readout; 182 182 } else { 183 backgnd = pmFPAviewThisReadout (view, file->fpa);183 backgnd = pmFPAviewThisReadout (view, file->fpa); 184 184 } 185 185 … … 192 192 fprintf (stdout, "[c]ontinue? "); 193 193 if (!fgets(key, 8, stdin)) { 194 psWarning("Unable to read option");194 psWarning("Unable to read option"); 195 195 } 196 196 return true; … … 203 203 if (kapa == -1) { 204 204 kapa = KapaOpenNamedSocket ("kapa", "psphot:images"); 205 if (kapa == -1) {206 fprintf (stderr, "failure to open kapa; visual mode disabled\n");207 isVisual = false;208 return false;209 }210 } 205 if (kapa == -1) { 206 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 207 isVisual = false; 208 return false; 209 } 210 } 211 211 212 212 // XXX test: image->data.F32[10][10] = 10000; … … 218 218 fprintf (stdout, "[c]ontinue? "); 219 219 if (!fgets(key, 8, stdin)) { 220 psWarning("Unable to read option");220 psWarning("Unable to read option"); 221 221 } 222 222 return true; … … 227 227 int Noverlay; 228 228 KiiOverlay *overlay; 229 229 230 230 if (!isVisual) return true; 231 231 232 232 if (kapa == -1) { 233 fprintf (stderr, "kapa not opened, skipping\n");234 return false;233 fprintf (stderr, "kapa not opened, skipping\n"); 234 return false; 235 235 } 236 236 … … 244 244 for (int i = 0; i < peaks->n; i++) { 245 245 246 pmPeak *peak = peaks->data[i];247 if (peak == NULL) continue;248 249 overlay[Noverlay].type = KII_OVERLAY_BOX;250 overlay[Noverlay].x = peak->xf;251 overlay[Noverlay].y = peak->yf;252 overlay[Noverlay].dx = 2.0;253 overlay[Noverlay].dy = 2.0;254 overlay[Noverlay].angle = 0.0;255 overlay[Noverlay].text = NULL;256 Noverlay ++;246 pmPeak *peak = peaks->data[i]; 247 if (peak == NULL) continue; 248 249 overlay[Noverlay].type = KII_OVERLAY_BOX; 250 overlay[Noverlay].x = peak->xf; 251 overlay[Noverlay].y = peak->yf; 252 overlay[Noverlay].dx = 2.0; 253 overlay[Noverlay].dy = 2.0; 254 overlay[Noverlay].angle = 0.0; 255 overlay[Noverlay].text = NULL; 256 Noverlay ++; 257 257 258 258 # if (0) 259 overlay[Noverlay].type = KII_OVERLAY_BOX;260 overlay[Noverlay].x = peak->x;261 overlay[Noverlay].y = peak->y;262 overlay[Noverlay].dx = 1.0;263 overlay[Noverlay].dy = 1.0;264 overlay[Noverlay].angle = 0.0;265 overlay[Noverlay].text = NULL;266 Noverlay ++;267 268 overlay[Noverlay].type = KII_OVERLAY_CIRCLE;269 overlay[Noverlay].x = peak->xf;270 overlay[Noverlay].y = peak->yf;271 overlay[Noverlay].dx = 2.0;272 overlay[Noverlay].dy = 2.0;273 overlay[Noverlay].angle = 0.0;274 overlay[Noverlay].text = NULL;275 Noverlay ++;259 overlay[Noverlay].type = KII_OVERLAY_BOX; 260 overlay[Noverlay].x = peak->x; 261 overlay[Noverlay].y = peak->y; 262 overlay[Noverlay].dx = 1.0; 263 overlay[Noverlay].dy = 1.0; 264 overlay[Noverlay].angle = 0.0; 265 overlay[Noverlay].text = NULL; 266 Noverlay ++; 267 268 overlay[Noverlay].type = KII_OVERLAY_CIRCLE; 269 overlay[Noverlay].x = peak->xf; 270 overlay[Noverlay].y = peak->yf; 271 overlay[Noverlay].dx = 2.0; 272 overlay[Noverlay].dy = 2.0; 273 overlay[Noverlay].angle = 0.0; 274 overlay[Noverlay].text = NULL; 275 Noverlay ++; 276 276 # endif 277 277 } … … 296 296 fprintf (stdout, "[c]ontinue? "); 297 297 if (!fgets(key, 8, stdin)) { 298 psWarning("Unable to read option");298 psWarning("Unable to read option"); 299 299 } 300 300 return true; … … 305 305 int Noverlay; 306 306 KiiOverlay *overlay; 307 307 308 308 if (!isVisual) return true; 309 309 310 310 if (kapa == -1) { 311 fprintf (stderr, "kapa not opened, skipping\n");312 return false;311 fprintf (stderr, "kapa not opened, skipping\n"); 312 return false; 313 313 } 314 314 … … 323 323 for (int i = 0; i < footprints->n; i++) { 324 324 325 pmSpan *span = NULL;326 327 pmFootprint *footprint = footprints->data[i];328 if (footprint == NULL) continue;329 if (footprint->spans == NULL) continue;330 if (footprint->spans->n < 1) continue;331 332 // draw the top333 span = footprint->spans->data[0];334 overlay[Noverlay].type = KII_OVERLAY_LINE;335 overlay[Noverlay].x = span->x0;336 overlay[Noverlay].y = span->y;337 overlay[Noverlay].dx = span->x1 - span->x0;338 overlay[Noverlay].dy = 0;339 overlay[Noverlay].angle = 0.0;340 overlay[Noverlay].text = NULL;341 Noverlay ++;342 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 100);343 344 int ys = span->y;345 int x0s = span->x0;346 int x1s = span->x1;347 348 // draw the outer span edges349 for (int j = 1; j < footprint->spans->n; j++) {350 pmSpan *span1 = footprint->spans->data[j];351 352 int ye = span1->y;353 int x0e = span1->x0;354 int x1e = span1->x1;355 356 // we cannot have two discontinuous spans on the top or bottom, right? (no, probably not right)357 // find all of the spans in this row and generate x0e, x01:358 for (int k = j + 1; k < footprint->spans->n; k++) {359 pmSpan *span2 = footprint->spans->data[k];360 if (span2->y > span1->y) break;361 x0e = PS_MIN (x0e, span2->x0);362 x1e = PS_MAX (x1e, span2->x1);363 j++;364 }365 366 overlay[Noverlay].type = KII_OVERLAY_LINE;367 overlay[Noverlay].x = x0s;368 overlay[Noverlay].y = ys;369 overlay[Noverlay].dx = x0e - x0s;370 overlay[Noverlay].dy = ye - ys;371 overlay[Noverlay].angle = 0.0;372 overlay[Noverlay].text = NULL;373 Noverlay ++;374 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 100);375 376 overlay[Noverlay].type = KII_OVERLAY_LINE;377 overlay[Noverlay].x = x1s;378 overlay[Noverlay].y = ys;379 overlay[Noverlay].dx = x1e - x1s;380 overlay[Noverlay].dy = ye - ys;381 overlay[Noverlay].angle = 0.0;382 overlay[Noverlay].text = NULL;383 Noverlay ++;384 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 100);385 386 ys = ye;387 x0s = x0e;388 x1s = x1e;389 }390 391 // draw the bottom392 span = footprint->spans->data[footprint->spans->n - 1];393 overlay[Noverlay].type = KII_OVERLAY_LINE;394 overlay[Noverlay].x = span->x0;395 overlay[Noverlay].y = span->y;396 overlay[Noverlay].dx = span->x1 - span->x0;397 overlay[Noverlay].dy = 0;398 overlay[Noverlay].angle = 0.0;399 overlay[Noverlay].text = NULL;400 Noverlay ++;401 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 100);325 pmSpan *span = NULL; 326 327 pmFootprint *footprint = footprints->data[i]; 328 if (footprint == NULL) continue; 329 if (footprint->spans == NULL) continue; 330 if (footprint->spans->n < 1) continue; 331 332 // draw the top 333 span = footprint->spans->data[0]; 334 overlay[Noverlay].type = KII_OVERLAY_LINE; 335 overlay[Noverlay].x = span->x0; 336 overlay[Noverlay].y = span->y; 337 overlay[Noverlay].dx = span->x1 - span->x0; 338 overlay[Noverlay].dy = 0; 339 overlay[Noverlay].angle = 0.0; 340 overlay[Noverlay].text = NULL; 341 Noverlay ++; 342 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 100); 343 344 int ys = span->y; 345 int x0s = span->x0; 346 int x1s = span->x1; 347 348 // draw the outer span edges 349 for (int j = 1; j < footprint->spans->n; j++) { 350 pmSpan *span1 = footprint->spans->data[j]; 351 352 int ye = span1->y; 353 int x0e = span1->x0; 354 int x1e = span1->x1; 355 356 // we cannot have two discontinuous spans on the top or bottom, right? (no, probably not right) 357 // find all of the spans in this row and generate x0e, x01: 358 for (int k = j + 1; k < footprint->spans->n; k++) { 359 pmSpan *span2 = footprint->spans->data[k]; 360 if (span2->y > span1->y) break; 361 x0e = PS_MIN (x0e, span2->x0); 362 x1e = PS_MAX (x1e, span2->x1); 363 j++; 364 } 365 366 overlay[Noverlay].type = KII_OVERLAY_LINE; 367 overlay[Noverlay].x = x0s; 368 overlay[Noverlay].y = ys; 369 overlay[Noverlay].dx = x0e - x0s; 370 overlay[Noverlay].dy = ye - ys; 371 overlay[Noverlay].angle = 0.0; 372 overlay[Noverlay].text = NULL; 373 Noverlay ++; 374 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 100); 375 376 overlay[Noverlay].type = KII_OVERLAY_LINE; 377 overlay[Noverlay].x = x1s; 378 overlay[Noverlay].y = ys; 379 overlay[Noverlay].dx = x1e - x1s; 380 overlay[Noverlay].dy = ye - ys; 381 overlay[Noverlay].angle = 0.0; 382 overlay[Noverlay].text = NULL; 383 Noverlay ++; 384 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 100); 385 386 ys = ye; 387 x0s = x0e; 388 x1s = x1e; 389 } 390 391 // draw the bottom 392 span = footprint->spans->data[footprint->spans->n - 1]; 393 overlay[Noverlay].type = KII_OVERLAY_LINE; 394 overlay[Noverlay].x = span->x0; 395 overlay[Noverlay].y = span->y; 396 overlay[Noverlay].dx = span->x1 - span->x0; 397 overlay[Noverlay].dy = 0; 398 overlay[Noverlay].angle = 0.0; 399 overlay[Noverlay].text = NULL; 400 Noverlay ++; 401 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 100); 402 402 } 403 403 … … 410 410 fprintf (stdout, "[c]ontinue? "); 411 411 if (!fgets(key, 8, stdin)) { 412 psWarning("Unable to read option");412 psWarning("Unable to read option"); 413 413 } 414 414 return true; … … 419 419 int Noverlay; 420 420 KiiOverlay *overlay; 421 421 422 422 psEllipseMoments emoments; 423 423 psEllipseAxes axes; … … 426 426 427 427 if (kapa == -1) { 428 fprintf (stderr, "kapa not opened, skipping\n");429 return false;428 fprintf (stderr, "kapa not opened, skipping\n"); 429 return false; 430 430 } 431 431 … … 436 436 for (int i = 0; i < sources->n; i++) { 437 437 438 pmSource *source = sources->data[i];439 if (source == NULL) continue;440 441 pmMoments *moments = source->moments;442 if (moments == NULL) continue;443 444 overlay[Noverlay].type = KII_OVERLAY_CIRCLE;445 overlay[Noverlay].x = moments->Mx;446 overlay[Noverlay].y = moments->My;447 448 emoments.x2 = moments->Mxx;449 emoments.xy = moments->Mxy;450 emoments.y2 = moments->Myy;451 452 axes = psEllipseMomentsToAxes (emoments, 20.0);453 454 overlay[Noverlay].dx = 2.0*axes.major;455 overlay[Noverlay].dy = 2.0*axes.minor;456 overlay[Noverlay].angle = -axes.theta * PS_DEG_RAD; // XXXXXXXX the axes angle is negative to display of object on kapa457 overlay[Noverlay].text = NULL;458 Noverlay ++;438 pmSource *source = sources->data[i]; 439 if (source == NULL) continue; 440 441 pmMoments *moments = source->moments; 442 if (moments == NULL) continue; 443 444 overlay[Noverlay].type = KII_OVERLAY_CIRCLE; 445 overlay[Noverlay].x = moments->Mx; 446 overlay[Noverlay].y = moments->My; 447 448 emoments.x2 = moments->Mxx; 449 emoments.xy = moments->Mxy; 450 emoments.y2 = moments->Myy; 451 452 axes = psEllipseMomentsToAxes (emoments, 20.0); 453 454 overlay[Noverlay].dx = 2.0*axes.major; 455 overlay[Noverlay].dy = 2.0*axes.minor; 456 overlay[Noverlay].angle = -axes.theta * PS_DEG_RAD; // XXXXXXXX the axes angle is negative to display of object on kapa 457 overlay[Noverlay].text = NULL; 458 Noverlay ++; 459 459 } 460 460 … … 467 467 fprintf (stdout, "[c]ontinue? "); 468 468 if (!fgets(key, 8, stdin)) { 469 psWarning("Unable to read option");469 psWarning("Unable to read option"); 470 470 } 471 471 … … 482 482 if (kapa3 == -1) { 483 483 kapa3 = KapaOpenNamedSocket ("kapa", "psphot:plots"); 484 if (kapa3 == -1) {485 fprintf (stderr, "failure to open kapa; visual mode disabled\n");486 isVisual = false;487 return false;488 }489 } 484 if (kapa3 == -1) { 485 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 486 isVisual = false; 487 return false; 488 } 489 } 490 490 491 491 KapaClearPlots (kapa3); … … 494 494 // there are N regions: use the first (guaranteed to exist) to get the overall limits 495 495 psMetadata *regionMD = psMetadataLookupPtr (&status, recipe, "PSF.CLUMP.REGION.000"); 496 496 497 497 float psfX = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.X"); 498 498 float psfY = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.Y"); … … 558 558 559 559 // XXX draw N circles to outline the clumps 560 { 561 // draw a circle centered on psfX,Y with size of the psf limit562 psVector *xLimit = psVectorAlloc (120, PS_TYPE_F32);563 psVector *yLimit = psVectorAlloc (120, PS_TYPE_F32);564 565 int nRegions = psMetadataLookupS32 (&status, recipe, "PSF.CLUMP.NREGIONS");566 float PSF_CLUMP_NSIGMA = psMetadataLookupF32 (&status, recipe, "PSF_CLUMP_NSIGMA");567 568 graphdata.color = KapaColorByName ("blue");569 graphdata.style = 0;570 571 for (int n = 0; n < nRegions; n++) {572 573 char regionName[64];574 snprintf (regionName, 64, "PSF.CLUMP.REGION.%03d", n);575 psMetadata *regionMD = psMetadataLookupPtr (&status, recipe, regionName);576 577 float psfX = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.X");578 float psfY = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.Y");579 float psfdX = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.DX");580 float psfdY = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.DY");581 float Rx = psfdX * PSF_CLUMP_NSIGMA;582 float Ry = psfdY * PSF_CLUMP_NSIGMA;583 584 for (int i = 0; i < xLimit->n; i++) {585 xLimit->data.F32[i] = Rx*cos(i*2.0*M_PI/120.0) + psfX;586 yLimit->data.F32[i] = Ry*sin(i*2.0*M_PI/120.0) + psfY;587 }588 KapaPrepPlot (kapa3, xLimit->n, &graphdata);589 KapaPlotVector (kapa3, xLimit->n, xLimit->data.F32, "x");590 KapaPlotVector (kapa3, yLimit->n, yLimit->data.F32, "y");591 }592 psFree (xLimit);593 psFree (yLimit);560 { 561 // draw a circle centered on psfX,Y with size of the psf limit 562 psVector *xLimit = psVectorAlloc (120, PS_TYPE_F32); 563 psVector *yLimit = psVectorAlloc (120, PS_TYPE_F32); 564 565 int nRegions = psMetadataLookupS32 (&status, recipe, "PSF.CLUMP.NREGIONS"); 566 float PSF_CLUMP_NSIGMA = psMetadataLookupF32 (&status, recipe, "PSF_CLUMP_NSIGMA"); 567 568 graphdata.color = KapaColorByName ("blue"); 569 graphdata.style = 0; 570 571 for (int n = 0; n < nRegions; n++) { 572 573 char regionName[64]; 574 snprintf (regionName, 64, "PSF.CLUMP.REGION.%03d", n); 575 psMetadata *regionMD = psMetadataLookupPtr (&status, recipe, regionName); 576 577 float psfX = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.X"); 578 float psfY = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.Y"); 579 float psfdX = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.DX"); 580 float psfdY = psMetadataLookupF32 (&status, regionMD, "PSF.CLUMP.DY"); 581 float Rx = psfdX * PSF_CLUMP_NSIGMA; 582 float Ry = psfdY * PSF_CLUMP_NSIGMA; 583 584 for (int i = 0; i < xLimit->n; i++) { 585 xLimit->data.F32[i] = Rx*cos(i*2.0*M_PI/120.0) + psfX; 586 yLimit->data.F32[i] = Ry*sin(i*2.0*M_PI/120.0) + psfY; 587 } 588 KapaPrepPlot (kapa3, xLimit->n, &graphdata); 589 KapaPlotVector (kapa3, xLimit->n, xLimit->data.F32, "x"); 590 KapaPlotVector (kapa3, yLimit->n, yLimit->data.F32, "y"); 591 } 592 psFree (xLimit); 593 psFree (yLimit); 594 594 } 595 595 596 596 # if (0) 597 // *** make a histogram of the source counts in the x and y directions 597 // *** make a histogram of the source counts in the x and y directions 598 598 psHistogram *nX = psHistogramAlloc (graphdata.xmin, graphdata.xmax, 50.0); 599 599 psHistogram *nY = psHistogramAlloc (graphdata.ymin, graphdata.ymax, 50.0); … … 605 605 psVector *vY = psVectorAlloc (nY->nums->n, PS_TYPE_F32); 606 606 for (int i = 0; i < nX->nums->n; i++) { 607 dX->data.F32[i] = nX->nums->data.S32[i];608 vX->data.F32[i] = 0.5*(nX->bounds->data.F32[i] + nX->bounds->data.F32[i+1]);607 dX->data.F32[i] = nX->nums->data.S32[i]; 608 vX->data.F32[i] = 0.5*(nX->bounds->data.F32[i] + nX->bounds->data.F32[i+1]); 609 609 } 610 610 for (int i = 0; i < nY->nums->n; i++) { 611 dY->data.F32[i] = nY->nums->data.S32[i];612 vY->data.F32[i] = 0.5*(nY->bounds->data.F32[i] + nY->bounds->data.F32[i+1]);611 dY->data.F32[i] = nY->nums->data.S32[i]; 612 vY->data.F32[i] = 0.5*(nY->bounds->data.F32[i] + nY->bounds->data.F32[i+1]); 613 613 } 614 614 … … 640 640 fprintf (stdout, "[c]ontinue? "); 641 641 if (!fgets(key, 8, stdin)) { 642 psWarning("Unable to read option");642 psWarning("Unable to read option"); 643 643 } 644 644 return true; … … 650 650 int Noverlay; 651 651 KiiOverlay *overlay; 652 652 653 653 psEllipseMoments emoments; 654 654 psEllipseAxes axes; … … 660 660 for (int i = 0; i < sources->n; i++) { 661 661 662 pmSource *source = sources->data[i];663 if (source == NULL) continue;664 665 if (source->type != type) continue;666 if (mode && !(source->mode & mode)) continue;667 668 pmMoments *moments = source->moments;669 if (moments == NULL) continue;670 671 overlay[Noverlay].type = KII_OVERLAY_CIRCLE;672 overlay[Noverlay].x = moments->Mx;673 overlay[Noverlay].y = moments->My;674 675 emoments.x2 = moments->Mxx;676 emoments.y2 = moments->Myy;677 emoments.xy = moments->Mxy;678 679 axes = psEllipseMomentsToAxes (emoments, 20.0);680 681 overlay[Noverlay].dx = 2.0*axes.major;682 overlay[Noverlay].dy = 2.0*axes.minor;683 overlay[Noverlay].angle = -axes.theta * PS_DEG_RAD;684 overlay[Noverlay].text = NULL;685 Noverlay ++;662 pmSource *source = sources->data[i]; 663 if (source == NULL) continue; 664 665 if (source->type != type) continue; 666 if (mode && !(source->mode & mode)) continue; 667 668 pmMoments *moments = source->moments; 669 if (moments == NULL) continue; 670 671 overlay[Noverlay].type = KII_OVERLAY_CIRCLE; 672 overlay[Noverlay].x = moments->Mx; 673 overlay[Noverlay].y = moments->My; 674 675 emoments.x2 = moments->Mxx; 676 emoments.y2 = moments->Myy; 677 emoments.xy = moments->Mxy; 678 679 axes = psEllipseMomentsToAxes (emoments, 20.0); 680 681 overlay[Noverlay].dx = 2.0*axes.major; 682 overlay[Noverlay].dy = 2.0*axes.minor; 683 overlay[Noverlay].angle = -axes.theta * PS_DEG_RAD; 684 overlay[Noverlay].text = NULL; 685 Noverlay ++; 686 686 } 687 687 … … 697 697 698 698 if (kapa == -1) { 699 fprintf (stderr, "kapa not opened, skipping\n");700 return false;699 fprintf (stderr, "kapa not opened, skipping\n"); 700 return false; 701 701 } 702 702 … … 716 716 fprintf (stdout, "[c]ontinue? "); 717 717 if (!fgets(key, 8, stdin)) { 718 psWarning("Unable to read option");718 psWarning("Unable to read option"); 719 719 } 720 720 return true; … … 727 727 if (kapa2 == -1) { 728 728 kapa2 = KapaOpenNamedSocket ("kapa", "psphot:psfstars"); 729 if (kapa2 == -1) {730 fprintf (stderr, "failure to open kapa; visual mode disabled\n");731 isVisual = false;732 return false;733 }734 } 729 if (kapa2 == -1) { 730 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 731 isVisual = false; 732 return false; 733 } 734 } 735 735 736 736 int DX = 64; … … 739 739 psImage *psfMosaic = psImageAlloc (5*DX, 5*DY, PS_TYPE_F32); 740 740 psImageInit (psfMosaic, 0.0); 741 741 742 742 psImage *funMosaic = psImageAlloc (5*DX, 5*DY, PS_TYPE_F32); 743 743 psImageInit (funMosaic, 0.0); … … 750 750 // generate a fake model at each of the 3x3 image grid positions 751 751 for (int x = -2; x <= +2; x ++) { 752 for (int y = -2; y <= +2; y ++) {753 // use the center of the center pixel of the image754 float xc = (int)((0.5 + 0.225*x)*readout->image->numCols) + readout->image->col0 + 0.5;755 float yc = (int)((0.5 + 0.225*y)*readout->image->numRows) + readout->image->row0 + 0.5;756 757 // assign the x and y coords to the image center758 // create an object with center intensity of 1000759 modelRef->params->data.F32[PM_PAR_SKY] = 0;760 modelRef->params->data.F32[PM_PAR_I0] = 1000;761 modelRef->params->data.F32[PM_PAR_XPOS] = xc;762 modelRef->params->data.F32[PM_PAR_YPOS] = yc;763 764 // create modelPSF from this model765 pmModel *model = pmModelFromPSF (modelRef, psf);766 if (!model) continue;767 768 // place the reference object in the image center769 // no need to mask the source here770 // XXX should we measure this for the analytical model only or the full model?771 pmModelAddWithOffset (psfMosaic, NULL, model, PM_MODEL_OP_FULL | PM_MODEL_OP_CENTER, 0, x*DX, y*DY);772 pmModelAddWithOffset (funMosaic, NULL, model, PM_MODEL_OP_FUNC | PM_MODEL_OP_CENTER, 0, x*DX, y*DY);773 pmModelAddWithOffset (resMosaic, NULL, model, PM_MODEL_OP_RES0 | PM_MODEL_OP_RES1 | PM_MODEL_OP_CENTER, 0, x*DX, y*DY);774 psFree (model);775 }752 for (int y = -2; y <= +2; y ++) { 753 // use the center of the center pixel of the image 754 float xc = (int)((0.5 + 0.225*x)*readout->image->numCols) + readout->image->col0 + 0.5; 755 float yc = (int)((0.5 + 0.225*y)*readout->image->numRows) + readout->image->row0 + 0.5; 756 757 // assign the x and y coords to the image center 758 // create an object with center intensity of 1000 759 modelRef->params->data.F32[PM_PAR_SKY] = 0; 760 modelRef->params->data.F32[PM_PAR_I0] = 1000; 761 modelRef->params->data.F32[PM_PAR_XPOS] = xc; 762 modelRef->params->data.F32[PM_PAR_YPOS] = yc; 763 764 // create modelPSF from this model 765 pmModel *model = pmModelFromPSF (modelRef, psf); 766 if (!model) continue; 767 768 // place the reference object in the image center 769 // no need to mask the source here 770 // XXX should we measure this for the analytical model only or the full model? 771 pmModelAddWithOffset (psfMosaic, NULL, model, PM_MODEL_OP_FULL | PM_MODEL_OP_CENTER, 0, x*DX, y*DY); 772 pmModelAddWithOffset (funMosaic, NULL, model, PM_MODEL_OP_FUNC | PM_MODEL_OP_CENTER, 0, x*DX, y*DY); 773 pmModelAddWithOffset (resMosaic, NULL, model, PM_MODEL_OP_RES0 | PM_MODEL_OP_RES1 | PM_MODEL_OP_CENTER, 0, x*DX, y*DY); 774 psFree (model); 775 } 776 776 } 777 777 … … 792 792 fprintf (stdout, "[c]ontinue? "); 793 793 if (!fgets(key, 8, stdin)) { 794 psWarning("Unable to read option");794 psWarning("Unable to read option"); 795 795 } 796 796 return true; … … 805 805 if (kapa2 == -1) { 806 806 kapa2 = KapaOpenNamedSocket ("kapa", "psphot:psfstars"); 807 if (kapa2 == -1) {808 fprintf (stderr, "failure to open kapa; visual mode disabled\n");809 isVisual = false;810 return false;811 }812 } 807 if (kapa2 == -1) { 808 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 809 isVisual = false; 810 return false; 811 } 812 } 813 813 814 814 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) … … 827 827 828 828 // counters to track the size of the image and area used in a row 829 int dX = 0; // starting corner of next box830 int dY = 0; // height of row so far831 int NX = 20*DX; // full width of output image832 int NY = 0; // total height of output image829 int dX = 0; // starting corner of next box 830 int dY = 0; // height of row so far 831 int NX = 20*DX; // full width of output image 832 int NY = 0; // total height of output image 833 833 834 834 // first, examine the PSF stars: … … 838 838 pmSource *source = sources->data[i]; 839 839 840 bool keep = false;840 bool keep = false; 841 841 keep |= (source->mode & PM_SOURCE_MODE_PSFSTAR); 842 if (!keep) continue;843 844 // how does this subimage get placed into the output image?845 // DX = source->pixels->numCols846 // DY = source->pixels->numRows847 848 if (dX + DX > NX) {849 // too wide for the rest of this row850 if (dX == 0) {851 // alone on this row852 NY += DY;853 dX = 0;854 dY = 0;855 } else {856 // start the next row857 NY += dY;858 dX = DX;859 dY = DY;860 }861 } else {862 // extend this row863 dX += DX;864 dY = PS_MAX (dY, DY);865 }842 if (!keep) continue; 843 844 // how does this subimage get placed into the output image? 845 // DX = source->pixels->numCols 846 // DY = source->pixels->numRows 847 848 if (dX + DX > NX) { 849 // too wide for the rest of this row 850 if (dX == 0) { 851 // alone on this row 852 NY += DY; 853 dX = 0; 854 dY = 0; 855 } else { 856 // start the next row 857 NY += dY; 858 dX = DX; 859 dY = DY; 860 } 861 } else { 862 // extend this row 863 dX += DX; 864 dY = PS_MAX (dY, DY); 865 } 866 866 } 867 867 NY += DY; … … 873 873 psImageInit (outsub, 0.0); 874 874 875 int Xo = 0; // starting corner of next box876 int Yo = 0; // starting corner of next box877 dY = 0; // height of row so far875 int Xo = 0; // starting corner of next box 876 int Yo = 0; // starting corner of next box 877 dY = 0; // height of row so far 878 878 879 879 int nPSF = 0; … … 885 885 pmSource *source = sources->data[i]; 886 886 887 bool keep = false;887 bool keep = false; 888 888 if (source->mode & PM_SOURCE_MODE_PSFSTAR) { 889 nPSF ++;890 keep = true;891 }892 if (!keep) continue;893 894 if (Xo + DX > NX) {895 // too wide for the rest of this row896 if (Xo == 0) {897 // place source alone on this row898 psphotAddWithTest (source, true, maskVal); // replace source if subtracted899 psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY, true);900 901 psphotSubWithTest (source, false, maskVal); // remove source (force)902 psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY, true);903 psphotSetState (source, false, maskVal); // reset source Add/Sub state to recorded904 905 Yo += DY;906 Xo = 0;907 dY = 0;908 } else {909 // start the next row910 Yo += dY;911 Xo = 0;912 913 psphotAddWithTest (source, true, maskVal); // replace source if subtracted914 psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY, true);915 916 psphotSubWithTest (source, false, maskVal); // remove source (force)917 psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY, true);918 psphotSetState (source, false, maskVal); // replace source (has been subtracted)919 920 Xo = DX;921 dY = DY;922 }923 } else {924 // extend this row925 psphotAddWithTest (source, true, maskVal); // replace source if subtracted926 psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY, true);927 928 psphotSubWithTest (source, false, maskVal); // remove source (force)929 psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY, true);930 psphotSetState (source, false, maskVal); // replace source (has been subtracted)931 932 Xo += DX;933 dY = PS_MAX (dY, DY);934 }889 nPSF ++; 890 keep = true; 891 } 892 if (!keep) continue; 893 894 if (Xo + DX > NX) { 895 // too wide for the rest of this row 896 if (Xo == 0) { 897 // place source alone on this row 898 psphotAddWithTest (source, true, maskVal); // replace source if subtracted 899 psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY, true); 900 901 psphotSubWithTest (source, false, maskVal); // remove source (force) 902 psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY, true); 903 psphotSetState (source, false, maskVal); // reset source Add/Sub state to recorded 904 905 Yo += DY; 906 Xo = 0; 907 dY = 0; 908 } else { 909 // start the next row 910 Yo += dY; 911 Xo = 0; 912 913 psphotAddWithTest (source, true, maskVal); // replace source if subtracted 914 psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY, true); 915 916 psphotSubWithTest (source, false, maskVal); // remove source (force) 917 psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY, true); 918 psphotSetState (source, false, maskVal); // replace source (has been subtracted) 919 920 Xo = DX; 921 dY = DY; 922 } 923 } else { 924 // extend this row 925 psphotAddWithTest (source, true, maskVal); // replace source if subtracted 926 psphotMosaicSubimage (outpos, source, Xo, Yo, DX, DY, true); 927 928 psphotSubWithTest (source, false, maskVal); // remove source (force) 929 psphotMosaicSubimage (outsub, source, Xo, Yo, DX, DY, true); 930 psphotSetState (source, false, maskVal); // replace source (has been subtracted) 931 932 Xo += DX; 933 dY = PS_MAX (dY, DY); 934 } 935 935 } 936 936 … … 943 943 fprintf (stdout, "[c]ontinue? "); 944 944 if (!fgets(key, 8, stdin)) { 945 psWarning("Unable to read option");945 psWarning("Unable to read option"); 946 946 } 947 947 … … 965 965 if (kapa2 == -1) { 966 966 kapa2 = KapaOpenNamedSocket ("kapa", "psphot:images"); 967 if (kapa2 == -1) {968 fprintf (stderr, "failure to open kapa; visual mode disabled\n");969 isVisual = false;970 return false;971 }972 } 967 if (kapa2 == -1) { 968 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 969 isVisual = false; 970 return false; 971 } 972 } 973 973 974 974 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) … … 987 987 988 988 // counters to track the size of the image and area used in a row 989 int dX = 0; // starting corner of next box990 int dY = 0; // height of row so far991 int NX = 10*DX; // full width of output image992 int NY = 0; // total height of output image989 int dX = 0; // starting corner of next box 990 int dY = 0; // height of row so far 991 int NX = 10*DX; // full width of output image 992 int NY = 0; // total height of output image 993 993 994 994 // first, examine the PSF and SAT stars: … … 998 998 pmSource *source = sources->data[i]; 999 999 1000 bool keep = false;1000 bool keep = false; 1001 1001 keep |= (source->mode & PM_SOURCE_MODE_SATSTAR); 1002 if (!keep) continue;1003 1004 // how does this subimage get placed into the output image?1005 // DX = source->pixels->numCols1006 // DY = source->pixels->numRows1007 1008 if (dX + DX > NX) {1009 // too wide for the rest of this row1010 if (dX == 0) {1011 // alone on this row1012 NY += DY;1013 dX = 0;1014 dY = 0;1015 } else {1016 // start the next row1017 NY += dY;1018 dX = DX;1019 dY = DY;1020 }1021 } else {1022 // extend this row1023 dX += DX;1024 dY = PS_MAX (dY, DY);1025 }1002 if (!keep) continue; 1003 1004 // how does this subimage get placed into the output image? 1005 // DX = source->pixels->numCols 1006 // DY = source->pixels->numRows 1007 1008 if (dX + DX > NX) { 1009 // too wide for the rest of this row 1010 if (dX == 0) { 1011 // alone on this row 1012 NY += DY; 1013 dX = 0; 1014 dY = 0; 1015 } else { 1016 // start the next row 1017 NY += dY; 1018 dX = DX; 1019 dY = DY; 1020 } 1021 } else { 1022 // extend this row 1023 dX += DX; 1024 dY = PS_MAX (dY, DY); 1025 } 1026 1026 } 1027 1027 NY += DY; … … 1031 1031 psImageInit (outsat, 0.0); 1032 1032 1033 int Xo = 0; // starting corner of next box1034 int Yo = 0; // starting corner of next box1035 dY = 0; // height of row so far1033 int Xo = 0; // starting corner of next box 1034 int Yo = 0; // starting corner of next box 1035 dY = 0; // height of row so far 1036 1036 1037 1037 int nSAT = 0; … … 1043 1043 pmSource *source = sources->data[i]; 1044 1044 1045 bool keep = false;1045 bool keep = false; 1046 1046 if (source->mode & PM_SOURCE_MODE_SATSTAR) { 1047 nSAT ++;1048 keep = true;1049 } 1050 if (!keep) continue;1051 1052 if (Xo + DX > NX) {1053 // too wide for the rest of this row1054 if (Xo == 0) {1055 // place source alone on this row1056 psphotAddWithTest (source, true, maskVal); // replace source if subtracted1057 psphotMosaicSubimage (outsat, source, Xo, Yo, DX, DY, false);1058 psphotSetState (source, true, maskVal); // reset source Add/Sub state to recorded1059 1060 Yo += DY;1061 Xo = 0;1062 dY = 0;1063 } else {1064 // start the next row1065 Yo += dY;1066 Xo = 0;1067 psphotAddWithTest (source, true, maskVal); // replace source if subtracted1068 psphotMosaicSubimage (outsat, source, Xo, Yo, DX, DY, false);1069 psphotSetState (source, true, maskVal); // replace source (has been subtracted)1070 1071 Xo = DX;1072 dY = DY;1073 }1074 } else {1075 // extend this row1076 psphotAddWithTest (source, true, maskVal); // replace source if subtracted1077 psphotMosaicSubimage (outsat, source, Xo, Yo, DX, DY, false);1078 psphotSetState (source, true, maskVal); // replace source (has been subtracted)1079 1080 Xo += DX;1081 dY = PS_MAX (dY, DY);1082 }1047 nSAT ++; 1048 keep = true; 1049 } 1050 if (!keep) continue; 1051 1052 if (Xo + DX > NX) { 1053 // too wide for the rest of this row 1054 if (Xo == 0) { 1055 // place source alone on this row 1056 psphotAddWithTest (source, true, maskVal); // replace source if subtracted 1057 psphotMosaicSubimage (outsat, source, Xo, Yo, DX, DY, false); 1058 psphotSetState (source, true, maskVal); // reset source Add/Sub state to recorded 1059 1060 Yo += DY; 1061 Xo = 0; 1062 dY = 0; 1063 } else { 1064 // start the next row 1065 Yo += dY; 1066 Xo = 0; 1067 psphotAddWithTest (source, true, maskVal); // replace source if subtracted 1068 psphotMosaicSubimage (outsat, source, Xo, Yo, DX, DY, false); 1069 psphotSetState (source, true, maskVal); // replace source (has been subtracted) 1070 1071 Xo = DX; 1072 dY = DY; 1073 } 1074 } else { 1075 // extend this row 1076 psphotAddWithTest (source, true, maskVal); // replace source if subtracted 1077 psphotMosaicSubimage (outsat, source, Xo, Yo, DX, DY, false); 1078 psphotSetState (source, true, maskVal); // replace source (has been subtracted) 1079 1080 Xo += DX; 1081 dY = PS_MAX (dY, DY); 1082 } 1083 1083 } 1084 1084 … … 1090 1090 fprintf (stdout, "[c]ontinue? "); 1091 1091 if (!fgets(key, 8, stdin)) { 1092 psWarning("Unable to read option");1092 psWarning("Unable to read option"); 1093 1093 } 1094 1094 … … 1117 1117 float Yo = source->modelPSF->params->data.F32[PM_PAR_YPOS] - source->pixels->row0; 1118 1118 for (int iy = 0; iy < source->pixels->numRows; iy++) { 1119 for (int ix = 0; ix < source->pixels->numCols; ix++) {1120 if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix]) {1121 // rb->data.F32[nb] = hypot (ix + 0.5 - Xo, iy + 0.5 - Yo) ;1122 rb->data.F32[nb] = hypot (ix - Xo, iy - Yo) ;1123 Rb->data.F32[nb] = log10(rb->data.F32[nb]);1124 fb->data.F32[nb] = log10(source->pixels->data.F32[iy][ix]);1125 nb++;1126 } else {1127 // rg->data.F32[ng] = hypot (ix + 0.5 - Xo, iy + 0.5 - Yo) ;1128 rg->data.F32[ng] = hypot (ix - Xo, iy - Yo) ;1129 Rg->data.F32[ng] = log10(rg->data.F32[ng]);1130 fg->data.F32[ng] = log10(source->pixels->data.F32[iy][ix]);1131 ng++;1132 }1133 }1134 } 1135 1119 for (int ix = 0; ix < source->pixels->numCols; ix++) { 1120 if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix]) { 1121 // rb->data.F32[nb] = hypot (ix + 0.5 - Xo, iy + 0.5 - Yo) ; 1122 rb->data.F32[nb] = hypot (ix - Xo, iy - Yo) ; 1123 Rb->data.F32[nb] = log10(rb->data.F32[nb]); 1124 fb->data.F32[nb] = log10(source->pixels->data.F32[iy][ix]); 1125 nb++; 1126 } else { 1127 // rg->data.F32[ng] = hypot (ix + 0.5 - Xo, iy + 0.5 - Yo) ; 1128 rg->data.F32[ng] = hypot (ix - Xo, iy - Yo) ; 1129 Rg->data.F32[ng] = log10(rg->data.F32[ng]); 1130 fg->data.F32[ng] = log10(source->pixels->data.F32[iy][ix]); 1131 ng++; 1132 } 1133 } 1134 } 1135 1136 1136 // reset source Add/Sub state to recorded 1137 psphotSetState (source, state, maskVal); 1137 psphotSetState (source, state, maskVal); 1138 1138 1139 1139 KapaInitGraph (&graphdata); … … 1148 1148 graphdata.ymax = +5.05; 1149 1149 KapaSetLimits (myKapa, &graphdata); 1150 1150 1151 1151 KapaSetFont (myKapa, "helvetica", 14); 1152 1152 KapaBox (myKapa, &graphdata); 1153 1153 KapaSendLabel (myKapa, "radius (pixels)", KAPA_LABEL_XM); 1154 1154 KapaSendLabel (myKapa, "log flux (counts)", KAPA_LABEL_YM); 1155 1155 1156 1156 graphdata.color = KapaColorByName ("black"); 1157 1157 graphdata.ptype = 2; … … 1169 1169 KapaPlotVector (myKapa, nb, rb->data.F32, "x"); 1170 1170 KapaPlotVector (myKapa, nb, fb->data.F32, "y"); 1171 1171 1172 1172 // ** loglog ** 1173 1173 KapaSelectSection (myKapa, "loglog"); … … 1179 1179 graphdata.ymax = +5.05; 1180 1180 KapaSetLimits (myKapa, &graphdata); 1181 1181 1182 1182 KapaSetFont (myKapa, "helvetica", 14); 1183 1183 KapaBox (myKapa, &graphdata); 1184 1184 KapaSendLabel (myKapa, "log radius (pixels)", KAPA_LABEL_XM); 1185 1185 KapaSendLabel (myKapa, "log flux (counts)", KAPA_LABEL_YM); 1186 1186 1187 1187 graphdata.color = KapaColorByName ("black"); 1188 1188 graphdata.ptype = 2; … … 1212 1212 bool psphotVisualPlotRadialProfiles (psMetadata *recipe, psArray *sources) { 1213 1213 1214 KapaSection section; // put the positive profile in one and the residuals in another? 1214 KapaSection section; // put the positive profile in one and the residuals in another? 1215 1215 1216 1216 if (!isVisual) return true; … … 1218 1218 if (kapa3 == -1) { 1219 1219 kapa3 = KapaOpenNamedSocket ("kapa", "psphot:plots"); 1220 if (kapa3 == -1) {1221 fprintf (stderr, "failure to open kapa; visual mode disabled\n");1222 isVisual = false;1223 return false;1224 }1225 } 1220 if (kapa3 == -1) { 1221 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 1222 isVisual = false; 1223 return false; 1224 } 1225 } 1226 1226 1227 1227 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) … … 1257 1257 if (!(source->mode & PM_SOURCE_MODE_PSFSTAR)) continue; 1258 1258 1259 psphotVisualPlotRadialProfile (kapa3, source, maskVal);1260 1261 // pause and wait for user input:1262 // continue, save (provide name), ??1263 char key[10];1264 fprintf (stdout, "[e]rase and continue? [o]verplot and continue? [s]kip rest of stars? : ");1265 if (!fgets(key, 8, stdin)) {1266 psWarning("Unable to read option");1267 }1268 if (key[0] == 'e') {1269 KapaClearPlots (kapa3);1270 }1271 if (key[0] == 's') {1272 break;1273 }1274 } 1259 psphotVisualPlotRadialProfile (kapa3, source, maskVal); 1260 1261 // pause and wait for user input: 1262 // continue, save (provide name), ?? 1263 char key[10]; 1264 fprintf (stdout, "[e]rase and continue? [o]verplot and continue? [s]kip rest of stars? : "); 1265 if (!fgets(key, 8, stdin)) { 1266 psWarning("Unable to read option"); 1267 } 1268 if (key[0] == 'e') { 1269 KapaClearPlots (kapa3); 1270 } 1271 if (key[0] == 's') { 1272 break; 1273 } 1274 } 1275 1275 1276 1276 return true; … … 1282 1282 int NoverlayO, NOVERLAYO; 1283 1283 KiiOverlay *overlayE, *overlayO; 1284 1284 1285 1285 psEllipseMoments emoments; 1286 1286 psEllipseAxes axes; … … 1289 1289 1290 1290 if (kapa == -1) { 1291 fprintf (stderr, "kapa not opened, skipping\n");1292 return false;1291 fprintf (stderr, "kapa not opened, skipping\n"); 1292 return false; 1293 1293 } 1294 1294 … … 1304 1304 for (int i = 0; i < sources->n; i++) { 1305 1305 1306 float Xo, Yo, Rmaj, Rmin, cs, sn;1307 1308 pmSource *source = sources->data[i];1309 if (source == NULL) continue;1310 1311 pmMoments *moments = source->moments;1312 if (0) { 1313 emoments.x2 = moments->Mxx;1314 emoments.y2 = moments->Myy;1315 emoments.xy = moments->Mxy;1316 Xo = moments->Mx;1317 Yo = moments->My;1318 1319 axes = psEllipseMomentsToAxes (emoments, 20.0);1320 Rmaj = 2.0*axes.major;1321 Rmin = 2.0*axes.minor;1322 cs = cos(axes.theta);1323 sn = sin(axes.theta);1324 } else {1325 Rmaj = Rmin = 5.0;1326 cs = 1.0;1327 sn = 0.0;1328 Xo = source->peak->xf;1329 Yo = source->peak->yf;1330 }1331 1332 unsigned short int flagMask = 0x01;1333 for (int j = 0; j < 8; j++) {1334 if (source->mode & flagMask) {1335 overlayE[NoverlayE].type = KII_OVERLAY_LINE;1336 overlayE[NoverlayE].x = Xo;1337 overlayE[NoverlayE].y = Yo;1338 1339 float phi = j*M_PI/4.0;1340 overlayE[NoverlayE].dx = +Rmaj*cos(phi)*cs - Rmin*sin(phi)*sn;1341 overlayE[NoverlayE].dy = +Rmaj*cos(phi)*sn + Rmin*sin(phi)*cs;1342 overlayE[NoverlayE].angle = 0;1343 overlayE[NoverlayE].text = NULL;1344 NoverlayE ++;1345 CHECK_REALLOCATE (overlayE, KiiOverlay, NOVERLAYE, NoverlayE, 100);1346 }1347 flagMask <<= 1;1348 1349 if (source->mode & flagMask) {1350 overlayO[NoverlayO].type = KII_OVERLAY_LINE;1351 overlayO[NoverlayO].x = Xo + 1;1352 overlayO[NoverlayO].y = Yo;1353 1354 float phi = j*M_PI/4.0;1355 overlayO[NoverlayO].dx = +Rmaj*cos(phi)*cs - Rmin*sin(phi)*sn;1356 overlayO[NoverlayO].dy = +Rmaj*cos(phi)*sn + Rmin*sin(phi)*cs;1357 overlayO[NoverlayO].angle = 0;1358 overlayO[NoverlayO].text = NULL;1359 NoverlayO ++;1360 CHECK_REALLOCATE (overlayO, KiiOverlay, NOVERLAYO, NoverlayO, 100);1361 }1362 flagMask <<= 1;1363 }1306 float Xo, Yo, Rmaj, Rmin, cs, sn; 1307 1308 pmSource *source = sources->data[i]; 1309 if (source == NULL) continue; 1310 1311 pmMoments *moments = source->moments; 1312 if (0) { 1313 emoments.x2 = moments->Mxx; 1314 emoments.y2 = moments->Myy; 1315 emoments.xy = moments->Mxy; 1316 Xo = moments->Mx; 1317 Yo = moments->My; 1318 1319 axes = psEllipseMomentsToAxes (emoments, 20.0); 1320 Rmaj = 2.0*axes.major; 1321 Rmin = 2.0*axes.minor; 1322 cs = cos(axes.theta); 1323 sn = sin(axes.theta); 1324 } else { 1325 Rmaj = Rmin = 5.0; 1326 cs = 1.0; 1327 sn = 0.0; 1328 Xo = source->peak->xf; 1329 Yo = source->peak->yf; 1330 } 1331 1332 unsigned short int flagMask = 0x01; 1333 for (int j = 0; j < 8; j++) { 1334 if (source->mode & flagMask) { 1335 overlayE[NoverlayE].type = KII_OVERLAY_LINE; 1336 overlayE[NoverlayE].x = Xo; 1337 overlayE[NoverlayE].y = Yo; 1338 1339 float phi = j*M_PI/4.0; 1340 overlayE[NoverlayE].dx = +Rmaj*cos(phi)*cs - Rmin*sin(phi)*sn; 1341 overlayE[NoverlayE].dy = +Rmaj*cos(phi)*sn + Rmin*sin(phi)*cs; 1342 overlayE[NoverlayE].angle = 0; 1343 overlayE[NoverlayE].text = NULL; 1344 NoverlayE ++; 1345 CHECK_REALLOCATE (overlayE, KiiOverlay, NOVERLAYE, NoverlayE, 100); 1346 } 1347 flagMask <<= 1; 1348 1349 if (source->mode & flagMask) { 1350 overlayO[NoverlayO].type = KII_OVERLAY_LINE; 1351 overlayO[NoverlayO].x = Xo + 1; 1352 overlayO[NoverlayO].y = Yo; 1353 1354 float phi = j*M_PI/4.0; 1355 overlayO[NoverlayO].dx = +Rmaj*cos(phi)*cs - Rmin*sin(phi)*sn; 1356 overlayO[NoverlayO].dy = +Rmaj*cos(phi)*sn + Rmin*sin(phi)*cs; 1357 overlayO[NoverlayO].angle = 0; 1358 overlayO[NoverlayO].text = NULL; 1359 NoverlayO ++; 1360 CHECK_REALLOCATE (overlayO, KiiOverlay, NOVERLAYO, NoverlayO, 100); 1361 } 1362 flagMask <<= 1; 1363 } 1364 1364 } 1365 1365 … … 1376 1376 fprintf (stdout, "[c]ontinue? "); 1377 1377 if (!fgets(key, 8, stdin)) { 1378 psWarning("Unable to read option");1378 psWarning("Unable to read option"); 1379 1379 } 1380 1380 … … 1390 1390 1391 1391 if (kapa == -1) { 1392 fprintf (stderr, "kapa not opened, skipping\n");1393 return false;1392 fprintf (stderr, "kapa not opened, skipping\n"); 1393 return false; 1394 1394 } 1395 1395 … … 1402 1402 for (int i = 0; i < sources->n; i++) { 1403 1403 1404 pmSource *source = sources->data[i];1405 if (source == NULL) continue;1406 1407 if (!(source->mode & PM_SOURCE_MODE_CR_LIMIT)) continue;1408 1409 overlay[Noverlay].type = KII_OVERLAY_BOX;1410 overlay[Noverlay].x = source->peak->xf;1411 overlay[Noverlay].y = source->peak->yf;1412 1413 overlay[Noverlay].dx = 4;1414 overlay[Noverlay].dy = 4;1415 overlay[Noverlay].angle = 0;1416 overlay[Noverlay].text = NULL;1417 Noverlay ++;1418 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 100);1404 pmSource *source = sources->data[i]; 1405 if (source == NULL) continue; 1406 1407 if (!(source->mode & PM_SOURCE_MODE_CR_LIMIT)) continue; 1408 1409 overlay[Noverlay].type = KII_OVERLAY_BOX; 1410 overlay[Noverlay].x = source->peak->xf; 1411 overlay[Noverlay].y = source->peak->yf; 1412 1413 overlay[Noverlay].dx = 4; 1414 overlay[Noverlay].dy = 4; 1415 overlay[Noverlay].angle = 0; 1416 overlay[Noverlay].text = NULL; 1417 Noverlay ++; 1418 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 100); 1419 1419 } 1420 1420 KiiLoadOverlay (kapa, overlay, Noverlay, "red"); … … 1424 1424 for (int i = 0; i < sources->n; i++) { 1425 1425 1426 pmSource *source = sources->data[i];1427 if (source == NULL) continue;1428 1429 // mark EXTs with yellow circles1430 if (!(source->mode & PM_SOURCE_MODE_EXT_LIMIT)) continue;1431 1432 overlay[Noverlay].type = KII_OVERLAY_CIRCLE;1433 overlay[Noverlay].x = source->peak->xf;1434 overlay[Noverlay].y = source->peak->yf;1435 1436 overlay[Noverlay].dx = 10;1437 overlay[Noverlay].dy = 10;1438 overlay[Noverlay].angle = 0;1439 overlay[Noverlay].text = NULL;1440 Noverlay ++;1441 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 100);1426 pmSource *source = sources->data[i]; 1427 if (source == NULL) continue; 1428 1429 // mark EXTs with yellow circles 1430 if (!(source->mode & PM_SOURCE_MODE_EXT_LIMIT)) continue; 1431 1432 overlay[Noverlay].type = KII_OVERLAY_CIRCLE; 1433 overlay[Noverlay].x = source->peak->xf; 1434 overlay[Noverlay].y = source->peak->yf; 1435 1436 overlay[Noverlay].dx = 10; 1437 overlay[Noverlay].dy = 10; 1438 overlay[Noverlay].angle = 0; 1439 overlay[Noverlay].text = NULL; 1440 Noverlay ++; 1441 CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 100); 1442 1442 } 1443 1443 … … 1453 1453 fprintf (stdout, "[c]ontinue? "); 1454 1454 if (!fgets(key, 8, stdin)) { 1455 psWarning("Unable to read option");1455 psWarning("Unable to read option"); 1456 1456 } 1457 1457 … … 1468 1468 if (kapa3 == -1) { 1469 1469 kapa3 = KapaOpenNamedSocket ("kapa", "psphot:plots"); 1470 if (kapa3 == -1) {1471 fprintf (stderr, "failure to open kapa; visual mode disabled\n");1472 isVisual = false;1473 return false;1474 }1475 } 1470 if (kapa3 == -1) { 1471 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 1472 isVisual = false; 1473 return false; 1474 } 1475 } 1476 1476 1477 1477 KapaClearPlots (kapa3); … … 1500 1500 for (int i = 0; i < sources->n; i++) { 1501 1501 pmSource *source = sources->data[i]; 1502 if (!source) continue;1502 if (!source) continue; 1503 1503 if (source->type != PM_SOURCE_TYPE_STAR) continue; 1504 if (!isfinite (source->crNsigma)) continue;1504 if (!isfinite (source->crNsigma)) continue; 1505 1505 1506 1506 x->data.F32[n] = -2.5*log10(source->peak->flux); … … 1555 1555 for (int i = 0; i < sources->n; i++) { 1556 1556 pmSource *source = sources->data[i]; 1557 if (!source) continue;1557 if (!source) continue; 1558 1558 if (source->type != PM_SOURCE_TYPE_STAR) continue; 1559 if (!isfinite (source->extNsigma)) continue;1559 if (!isfinite (source->extNsigma)) continue; 1560 1560 1561 1561 x->data.F32[n] = -2.5*log10(source->peak->flux); … … 1597 1597 fprintf (stdout, "[c]ontinue? "); 1598 1598 if (!fgets(key, 8, stdin)) { 1599 psWarning("Unable to read option");1599 psWarning("Unable to read option"); 1600 1600 } 1601 1601 return true; … … 1608 1608 if (kapa == -1) { 1609 1609 kapa = KapaOpenNamedSocket ("kapa", "psphot:images"); 1610 if (kapa == -1) {1611 fprintf (stderr, "failure to open kapa; visual mode disabled\n");1612 isVisual = false;1613 return false;1614 }1615 } 1610 if (kapa == -1) { 1611 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 1612 isVisual = false; 1613 return false; 1614 } 1615 } 1616 1616 1617 1617 psphotVisualScaleImage (kapa, readout->image, "resid", 1); … … 1622 1622 fprintf (stdout, "[c]ontinue? "); 1623 1623 if (!fgets(key, 8, stdin)) { 1624 psWarning("Unable to read option");1624 psWarning("Unable to read option"); 1625 1625 } 1626 1626 return true; … … 1635 1635 if (kapa3 == -1) { 1636 1636 kapa3 = KapaOpenNamedSocket ("kapa", "psphot:plots"); 1637 if (kapa3 == -1) {1638 fprintf (stderr, "failure to open kapa; visual mode disabled\n");1639 isVisual = false;1640 return false;1641 }1642 } 1637 if (kapa3 == -1) { 1638 fprintf (stderr, "failure to open kapa; visual mode disabled\n"); 1639 isVisual = false; 1640 return false; 1641 } 1642 } 1643 1643 1644 1644 KapaClearPlots (kapa3); … … 1657 1657 for (int i = 0; i < sources->n; i++) { 1658 1658 pmSource *source = sources->data[i]; 1659 if (!source) continue;1659 if (!source) continue; 1660 1660 if (source->type != PM_SOURCE_TYPE_STAR) continue; 1661 if (!isfinite (source->apMag)) continue;1662 if (!isfinite (source->psfMag)) continue;1661 if (!isfinite (source->apMag)) continue; 1662 if (!isfinite (source->psfMag)) continue; 1663 1663 1664 1664 x->data.F32[n] = source->psfMag; … … 1705 1705 fprintf (stdout, "[c]ontinue? "); 1706 1706 if (!fgets(key, 8, stdin)) { 1707 psWarning("Unable to read option");1707 psWarning("Unable to read option"); 1708 1708 } 1709 1709 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
