Changeset 42254 for trunk/ppViz/src/ppCoord/ppCoordLoop.c
- Timestamp:
- Jul 14, 2022, 3:01:13 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
r42253 r42254 79 79 NULL; // File with raw image 80 80 81 psArray *pixels = NULL, *radec = NULL, * fpas = NULL, *streaks = NULL, *clusters = NULL; // Array of coordinate vectors82 psArray *radecOut = NULL, *fpaOut = NULL,*streaksOut = NULL, *clustersOut = NULL; // Output for sky coordinates81 psArray *pixels = NULL, *radec = NULL, *streaks = NULL, *clusters = NULL; // Array of coordinate vectors 82 psArray *radecOut = 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 coordinates118 long num = fpa_x->n; // Number of coordinates119 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);130 109 } 131 110 … … 415 394 yTP->data.F32[i] = src.tp.y; 416 395 } 417 }418 419 if (fpas) {420 psVector *fpa_x = fpas->data[0], *fpa_y = fpas->data[1]; // FPA coordinates421 long num = fpa_x->n; // Number of coordinates422 423 int numCols = psMetadataLookupS32(NULL, hdu->header, "IMNAXIS1"); // Number of columns424 int numRows = psMetadataLookupS32(NULL, hdu->header, "IMNAXIS2"); // Number of rows425 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 pixels431 psVector *xPix = fpaOut->data[1]; // x coordinate for pixels432 psVector *yPix = fpaOut->data[2]; // y coordinate for pixels433 psArray *cellPix = fpaOut->data[3]; // Cell for pixels434 psVector *xCell = fpaOut->data[4]; // x coordinate for cell435 psVector *yCell = fpaOut->data[5]; // y coordinate for cell436 437 psPlane *pix = psPlaneAlloc(); // Pixel coordinates on chip438 psPlane *fp = psPlaneAlloc(); // Focal plane coordinates439 440 for (long i = 0; i < num; i++) {441 float x, y; // Pixel coordinates442 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 chip453 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 cell462 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);472 396 } 473 397 … … 632 556 } 633 557 634 if (fpaOut) {635 psArray *chipPix = fpaOut->data[0]; // Chip for pixels636 psVector *xPix = fpaOut->data[1]; // x coordinate for pixels637 psVector *yPix = fpaOut->data[2]; // y coordinate for pixels638 psArray *cellPix = fpaOut->data[3]; // Cell for pixels639 psVector *xCell = fpaOut->data[4]; // x coordinate for pixels640 psVector *yCell = fpaOut->data[5]; // y coordinate for pixels641 psVector *fpa_x = fpas->data[0]; // FPA x coordinate642 psVector *fpa_y = fpas->data[1]; // FPA y coordinate643 644 for (long i = 0; i < chipPix->n; i++) {645 const char *chipName = chipPix->data[i]; // Name of chip646 const char *cellName = cellPix->data[i]; // Name of cell, or NULL647 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 coordinates653 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 669 558 if (streaksOut) { 670 559 psArray *chipPix1 = streaksOut->data[0]; // Chip for point 1
Note:
See TracChangeset
for help on using the changeset viewer.
