Changeset 42365
- Timestamp:
- Feb 4, 2023, 12:07:32 PM (3 years ago)
- Location:
- branches/eam_branches/ipp-20220316/ppViz/src/ppCoord
- Files:
-
- 4 edited
-
ppCoord.h (modified) (1 diff)
-
ppCoordArguments.c (modified) (3 diffs)
-
ppCoordData.c (modified) (2 diffs)
-
ppCoordLoop.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20220316/ppViz/src/ppCoord/ppCoord.h
r42166 r42365 14 14 psString rawName; // Filename with raw image (or NULL) 15 15 psString pixelsName; // Filename with pixel coordinates 16 psString fpaName; // Filename with FPA coordinates17 16 psString chipName; // Name of chip of interest 18 17 psString radecName; // Filename with sky coordinates -
branches/eam_branches/ipp-20220316/ppViz/src/ppCoord/ppCoordArguments.c
r42166 r42365 49 49 psMetadataAddStr(arguments, PS_LIST_TAIL, "-raw", 0, "Filename with raw data", NULL); 50 50 psMetadataAddStr(arguments, PS_LIST_TAIL, "-pixels", 0, "Filename with pixel coordinates", NULL); 51 psMetadataAddStr(arguments, PS_LIST_TAIL, "-fpa", 0, "Filename with FPA coordinates", NULL);52 51 psMetadataAddStr(arguments, PS_LIST_TAIL, "-chip", 0, "Chip for pixel coordinates", NULL); 53 52 psMetadataAddStr(arguments, PS_LIST_TAIL, "-radec", 0, "Filename with RA,Dec (default decimal degrees)", NULL); … … 67 66 data->rawName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-raw")); 68 67 data->pixelsName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-pixels")); 69 data->fpaName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-fpa"));70 68 data->chipName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-chip")); 71 69 data->radecName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-radec")); … … 98 96 } 99 97 100 if (!data->pixelsName && !data->radecName && !data-> fpaName && !data->streaksName && !data->clustersName) {101 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Neither -pixels nor -radec nor -fpaprovided.");98 if (!data->pixelsName && !data->radecName && !data->streaksName && !data->clustersName) { 99 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Neither -pixels nor -radec provided."); 102 100 return false; 103 101 } -
branches/eam_branches/ipp-20220316/ppViz/src/ppCoord/ppCoordData.c
r42166 r42365 16 16 psFree(data->rawName); 17 17 psFree(data->pixelsName); 18 psFree(data->fpaName);19 18 psFree(data->chipName); 20 19 psFree(data->radecName); … … 38 37 data->rawName = NULL; 39 38 data->pixelsName = NULL; 40 data->fpaName = NULL;41 39 data->chipName = NULL; 42 40 data->radecName = NULL; -
branches/eam_branches/ipp-20220316/ppViz/src/ppCoord/ppCoordLoop.c
r42166 r42365 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.
