Changeset 42154 for trunk/ppViz/src/ppCoord/ppCoordLoop.c
- Timestamp:
- Apr 4, 2022, 2:56:53 PM (4 years ago)
- File:
-
- 1 edited
-
trunk/ppViz/src/ppCoord/ppCoordLoop.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppViz/src/ppCoord/ppCoordLoop.c
r41899 r42154 79 79 NULL; // File with raw image 80 80 81 psArray *pixels = NULL, *radec = NULL, * streaks = NULL, *clusters = NULL; // Array of coordinate vectors82 psArray *radecOut = NULL, *streaksOut = NULL, *clustersOut = NULL; // Output for sky coordinates81 psArray *pixels = NULL, *radec = NULL, *fpas = NULL, *streaks = NULL, *clusters = NULL; // Array of coordinate vectors 82 psArray *radecOut = NULL,*fpaOut = NULL, *streaksOut = NULL, *clustersOut = NULL; // Output for sky coordinates 83 83 if (data->pixelsName) { 84 84 pixels = psVectorsReadFromFile(data->pixelsName, "%f %f"); … … 107 107 psVectorInit(radecOut->data[1], NAN); 108 108 psVectorInit(radecOut->data[2], NAN); 109 } 110 111 if (data->fpaName) { 112 fpas = psVectorsReadFromFile(data->fpaName, "%f %f"); 113 if (!fpas || fpas->n != 2) { 114 psError(psErrorCodeLast(), false, "Unable to read FPA coordinates"); 115 return false; 116 } 117 psVector *fpa_x = fpas->data[0]; // FPA x coordinates 118 long num = fpa_x->n; // Number of coordinates 119 fpaOut = psArrayAlloc(6); 120 fpaOut->data[0] = psArrayAlloc(num); 121 fpaOut->data[1] = psVectorAlloc(num, PS_TYPE_F32); 122 fpaOut->data[2] = psVectorAlloc(num, PS_TYPE_F32); 123 fpaOut->data[3] = psArrayAlloc(num); 124 fpaOut->data[4] = psVectorAlloc(num, PS_TYPE_F32); 125 fpaOut->data[5] = psVectorAlloc(num, PS_TYPE_F32); 126 psVectorInit(fpaOut->data[1], NAN); 127 psVectorInit(fpaOut->data[2], NAN); 128 psVectorInit(fpaOut->data[4], NAN); 129 psVectorInit(fpaOut->data[5], NAN); 109 130 } 110 131 … … 394 415 yTP->data.F32[i] = src.tp.y; 395 416 } 417 } 418 419 if (fpas) { 420 psVector *fpa_x = fpas->data[0], *fpa_y = fpas->data[1]; // FPA coordinates 421 long num = fpa_x->n; // Number of coordinates 422 423 int numCols = psMetadataLookupS32(NULL, hdu->header, "IMNAXIS1"); // Number of columns 424 int numRows = psMetadataLookupS32(NULL, hdu->header, "IMNAXIS2"); // Number of rows 425 if (numCols <= 0 || numRows <= 0) { 426 psError(psErrorCodeLast(), false, "Unable to read size of chip."); 427 return false; 428 } 429 430 psArray *chipPix = fpaOut->data[0]; // Chip for pixels 431 psVector *xPix = fpaOut->data[1]; // x coordinate for pixels 432 psVector *yPix = fpaOut->data[2]; // y coordinate for pixels 433 psArray *cellPix = fpaOut->data[3]; // Cell for pixels 434 psVector *xCell = fpaOut->data[4]; // x coordinate for cell 435 psVector *yCell = fpaOut->data[5]; // y coordinate for cell 436 437 psPlane *pix = psPlaneAlloc(); // Pixel coordinates on chip 438 psPlane *fp = psPlaneAlloc(); // Focal plane coordinates 439 440 for (long i = 0; i < num; i++) { 441 float x, y; // Pixel coordinates 442 fp->x = fpa_x->data.F32[i]; 443 fp->y = fpa_y->data.F32[i]; 444 445 psPlaneTransformApply(pix, chip->fromFPA, fp); 446 psTrace("ppCoord",2,"fpa2pix tr1: %f %f\n",pix->x,pix->y); 447 448 x = pix->x; 449 y = pix->y; 450 451 if ((x < 0 || x > numCols || y < 0 || y > numRows)) { 452 // Not on this chip 453 continue; 454 } 455 456 chipPix->data[i] = psStringCopy(chipName); 457 xPix->data.F32[i] = x; 458 yPix->data.F32[i] = y; 459 460 if (rawChip) { 461 psString cellName = NULL; // Name of cell 462 coordChip2Cell(&cellName, &x, &y, x, y, cellNames, cellBounds, 463 cellX0, cellY0, cellParityX, cellParityY, cellBinX, cellBinY); 464 cellPix->data[i] = cellName; 465 xCell->data.F32[i] = x; 466 yCell->data.F32[i] = y; 467 } 468 469 } 470 psFree(pix); 471 psFree(fp); 396 472 } 397 473 … … 556 632 } 557 633 634 if (fpaOut) { 635 psArray *chipPix = fpaOut->data[0]; // Chip for pixels 636 psVector *xPix = fpaOut->data[1]; // x coordinate for pixels 637 psVector *yPix = fpaOut->data[2]; // y coordinate for pixels 638 psArray *cellPix = fpaOut->data[3]; // Cell for pixels 639 psVector *xCell = fpaOut->data[4]; // x coordinate for pixels 640 psVector *yCell = fpaOut->data[5]; // y coordinate for pixels 641 psVector *fpa_x = fpas->data[0]; // FPA x coordinate 642 psVector *fpa_y = fpas->data[1]; // FPA y coordinate 643 644 for (long i = 0; i < chipPix->n; i++) { 645 const char *chipName = chipPix->data[i]; // Name of chip 646 const char *cellName = cellPix->data[i]; // Name of cell, or NULL 647 if (!data->all && (!isfinite(xPix->data.F32[i]) || !isfinite(yPix->data.F32[i]) || 648 !chipName || (rawFile && !cellName))) { 649 continue; 650 } 651 if (!rawFile && data->ds9) { 652 // Region file is only appropriate if we're not mapping all the way back to cell coordinates 653 fprintf(data->ds9, "image;circle(%f,%f,%f) # color=%s\n", 654 xPix->data.F32[i], yPix->data.F32[i], data->ds9radius, data->ds9color); 655 } else if (rawFile) { 656 fprintf(stdout, "%.3f %.3f --> %.3f %.3f %s %.3f %.3f %s\n", 657 fpa_x->data.F32[i], fpa_y->data.F32[i], xPix->data.F32[i], yPix->data.F32[i], 658 chipName ? chipName : "UNKNOWN", 659 xCell->data.F32[i], yCell->data.F32[i], 660 cellName ? cellName : "UNKNOWN"); 661 } else { 662 fprintf(stdout, "%.3f %.3f --> %.3f %.3f %s\n", 663 fpa_x->data.F32[i], fpa_y->data.F32[i], xPix->data.F32[i], yPix->data.F32[i], 664 chipName ? chipName : "UNKNOWN"); 665 } 666 } 667 } 668 558 669 if (streaksOut) { 559 670 psArray *chipPix1 = streaksOut->data[0]; // Chip for point 1
Note:
See TracChangeset
for help on using the changeset viewer.
