IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 1, 2021, 9:50:51 AM (5 years ago)
Author:
eugene
Message:

include TP and FP coords in the outputs of ppCoords; add option to set the extra orders

Location:
branches/eam_branches/ipp-dev-20210817/ppViz/src/ppCoord
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-dev-20210817/ppViz/src/ppCoord/ppCoordArguments.c

    r27979 r41827  
    5858    psMetadataAddF32(arguments, PS_LIST_TAIL, "-ds9-radius", 0, "ds9 region radii", 5.0);
    5959    psMetadataAddStr(arguments, PS_LIST_TAIL, "-ds9-color", 0, "ds9 region color", "red");
     60    psMetadataAddS32(arguments, PS_LIST_TAIL, "-extra-orders", 0, "extra orders for transform inversion", -1);
    6061    if (!psArgumentParse(arguments, &argc, argv) || argc != 1) {
    6162        usage(argv[0], arguments, data);
     
    8485    data->ds9color = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-ds9-color"));
    8586
     87    int ExtraOrders = psMetadataLookupS32(NULL, arguments, "-extra-orders");
     88    if (ExtraOrders >= 0) { pmAstrometrySetExtraOrders(ExtraOrders); }
     89
    8690    psTrace("ppCoord", 1, "Done reading command-line arguments\n");
    8791    psFree(arguments);
  • branches/eam_branches/ipp-dev-20210817/ppViz/src/ppCoord/ppCoordLoop.c

    r32600 r41827  
    99#include "ppCoord.h"
    1010
     11typedef struct {
     12  psPlane pix;
     13  psPlane fp;
     14  psPlane tp;
     15  psSphere sky;
     16} ppCoordSet;
     17
    1118// Convert sky coordinates to chip coordinates
    12 static void coordSky2Chip(float *x, float *y, // Chip coordinates (output)
    13                           double ra, double dec, // Sky coordinates
     19static void coordSky2Chip(ppCoordSet *src, // Sky coordinates
    1420                          bool radians,          // Coordinates are in radians?
    1521                          const pmFPA *astromFPA,  // Astrometry FPA
     
    1723    )
    1824{
    19     psPlane pix;                        // Pixel coordinates on chip
    20     psPlane fp;                         // Focal plane coordinates
    21     psPlane tp;                         // Tangent plane coordinates
    22     psSphere sky;                       // Sky coordinates
    23 
    24     sky.r = ra;
    25     sky.d = dec;
    26 
     25    // convert from src->sky to src->pix
    2726    if (!radians) {
    28         sky.r *= M_PI / 180.0;
    29         sky.d *= M_PI / 180.0;
    30     }
    31 
    32     psProject(&tp, &sky, astromFPA->toSky);
    33     psTrace("ppCoord",2,"sky2pix tr1: %f %f\n",tp.x,tp.y);
    34     psPlaneTransformApply(&fp, astromFPA->fromTPA, &tp);
    35     psTrace("ppCoord",2,"sky2pix tr2: %f %f\n",fp.x,fp.y);
    36     psPlaneTransformApply(&pix, astromChip->fromFPA, &fp);
    37     psTrace("ppCoord",2,"sky2pix tr3: %f %f\n",pix.x,pix.y);
    38 
    39     *x = pix.x;
    40     *y = pix.y;
     27        src->sky.r *= M_PI / 180.0;
     28        src->sky.d *= M_PI / 180.0;
     29    }
     30
     31    psProject(&src->tp, &src->sky, astromFPA->toSky);
     32    psTrace("ppCoord",2,"sky2pix tr1: %f %f\n", src->tp.x, src->tp.y);
     33    psPlaneTransformApply(&src->fp, astromFPA->fromTPA, &src->tp);
     34    psTrace("ppCoord",2,"sky2pix tr2: %f %f\n", src->fp.x, src->fp.y);
     35    psPlaneTransformApply(&src->pix, astromChip->fromFPA, &src->fp);
     36    psTrace("ppCoord",2,"sky2pix tr3: %f %f\n", src->pix.x, src->pix.y);
    4137
    4238    return;
     
    10096        psVector *ra = radec->data[0];  // RA coordinates
    10197        long num = ra->n;               // Number of coordinates
    102         radecOut = psArrayAlloc(4);
     98        radecOut = psArrayAlloc(8);
    10399        radecOut->data[0] = psArrayAlloc(num);
    104100        radecOut->data[1] = psVectorAlloc(num, PS_TYPE_F32);
    105101        radecOut->data[2] = psVectorAlloc(num, PS_TYPE_F32);
    106102        radecOut->data[3] = psArrayAlloc(num);
     103        radecOut->data[4] = psVectorAlloc(num, PS_TYPE_F32); // FP x
     104        radecOut->data[5] = psVectorAlloc(num, PS_TYPE_F32); // FP y
     105        radecOut->data[6] = psVectorAlloc(num, PS_TYPE_F32); // TP x
     106        radecOut->data[7] = psVectorAlloc(num, PS_TYPE_F32); // TP y
    107107        psVectorInit(radecOut->data[1], NAN);
    108108        psVectorInit(radecOut->data[2], NAN);
     
    274274                }
    275275
    276                 fprintf(stdout, "%s %.3f %.3f --> %.10lf %.10lf\n", chipName, pix->x, pix->y, sky->r, sky->d);
     276                fprintf(stdout, "%s %10.3f %10.3f --> %14.10lf %14.10lf : %11.4f %11.4f : %11.4f %11.4f\n", chipName, pix->x, pix->y, sky->r, sky->d, tp->x, tp->y, fp->x, fp->y);
    277277            }
    278278            psFree(pix);
     
    358358            psVector *yPix = radecOut->data[2];   // y coordinate for pixels
    359359            psArray *cellPix = radecOut->data[3]; // Cell for pixels
     360            psVector *xFP = radecOut->data[4];   // x coordinate for FP
     361            psVector *yFP = radecOut->data[5];   // y coordinate for FP
     362            psVector *xTP = radecOut->data[6];   // x coordinate for TP
     363            psVector *yTP = radecOut->data[7];   // y coordinate for TP
    360364
    361365            for (long i = 0; i < num; i++) {
    362                 float x, y;             // Pixel coordinates
    363                 coordSky2Chip(&x, &y, ra->data.F64[i], dec->data.F64[i],
    364                                 data->radians, astromFile->fpa, chip);
    365                 if ((x < 0 || x > numCols || y < 0 || y > numRows)) {
     366                ppCoordSet src;
     367                src.sky.r = ra->data.F64[i];
     368                src.sky.d = dec->data.F64[i];
     369                coordSky2Chip(&src, data->radians, astromFile->fpa, chip);
     370                if ((src.pix.x < 0 || src.pix.x > numCols || src.pix.y < 0 || src.pix.y > numRows)) {
    366371                    // Not on this chip
    367372                    continue;
     
    369374
    370375                if (rawChip) {
     376                    float x, y;
    371377                    psString cellName = NULL; // Name of cell
    372                     coordChip2Cell(&cellName, &x, &y, x, y, cellNames, cellBounds,
     378                    coordChip2Cell(&cellName, &x, &y, src.pix.x, src.pix.y, cellNames, cellBounds,
    373379                                   cellX0, cellY0, cellParityX, cellParityY, cellBinX, cellBinY);
    374380                    cellPix->data[i] = cellName;
    375                 }
    376 
     381                    xPix->data.F32[i] = x;
     382                    yPix->data.F32[i] = y;
     383                } else {
     384                    xPix->data.F32[i] = src.pix.x;
     385                    yPix->data.F32[i] = src.pix.y;
     386                }
    377387                chipPix->data[i] = psStringCopy(chipName);
    378                 xPix->data.F32[i] = x;
    379                 yPix->data.F32[i] = y;
     388                xFP->data.F32[i] = src.fp.x;
     389                yFP->data.F32[i] = src.fp.y;
     390                xTP->data.F32[i] = src.tp.x;
     391                yTP->data.F32[i] = src.tp.y;
    380392            }
    381393        }
     
    406418            for (long i = 0; i < xPix1->n; i++) {
    407419                float x1, y1;   // Coordinates of point 1
    408                 coordSky2Chip(&x1, &y1, ra1->data.F64[i], dec1->data.F64[i],
    409                               true, astromFile->fpa, chip);
     420                ppCoordSet src;
     421                src.sky.r = ra1->data.F64[i];
     422                src.sky.d = dec1->data.F64[i];
     423                coordSky2Chip(&src, true, astromFile->fpa, chip);
     424                x1 = src.pix.x;
     425                y1 = src.pix.y;
    410426                if ((x1 >= 0 && x1 < numCols && y1 >= 0 && y1 < numRows)) {
    411427                    if (rawChip) {
     
    421437
    422438                float x2, y2;   // Coordinates of point 2
    423                 coordSky2Chip(&x2, &y2, ra2->data.F64[i], dec2->data.F64[i],
    424                               true, astromFile->fpa, chip);
     439                src.sky.r = ra2->data.F64[i];
     440                src.sky.d = dec2->data.F64[i];
     441                coordSky2Chip(&src, true, astromFile->fpa, chip);
     442                x2 = src.pix.x;
     443                y2 = src.pix.y;
    425444                if ((x2 >= 0 && x2 < numCols && y2 >= 0 && y2 < numRows)) {
    426445                    if (rawChip) {
     
    455474            for (long i = 0; i < num; i++) {
    456475                float x, y;             // Pixel coordinates
    457                 coordSky2Chip(&x, &y, ra->data.F64[i], dec->data.F64[i],
    458                                 false, astromFile->fpa, chip);
     476                ppCoordSet src;
     477                src.sky.r = ra->data.F64[i];
     478                src.sky.d = dec->data.F64[i];
     479                coordSky2Chip(&src, false, astromFile->fpa, chip);
     480                x = src.pix.x;
     481                y = src.pix.y;
    459482                if ((x < 0 || x > numCols || y < 0 || y > numRows)) {
    460483                    // Not on this chip
     
    503526        psVector *ra = radec->data[0];        // RA coordinate
    504527        psVector *dec = radec->data[1];       // Dec coordinate
     528        psVector *xFP = radecOut->data[4];   // x coordinate for FP
     529        psVector *yFP = radecOut->data[5];   // y coordinate for FP
     530        psVector *xTP = radecOut->data[6];   // x coordinate for TP
     531        psVector *yTP = radecOut->data[7];   // y coordinate for TP
    505532
    506533        for (long i = 0; i < chipPix->n; i++) {
     
    516543                        xPix->data.F32[i], yPix->data.F32[i], data->ds9radius, data->ds9color);
    517544            } else {
    518                 fprintf(stdout, "%.10lf %.10lf --> %.3f %.3f %s%s%s\n",
     545                fprintf(stdout, "%14.10lf %14.10lf --> %10.3f %10.3f %s%s%s : %11.4f %11.4f : %11.4f %11.4f\n",
    519546                        ra->data.F64[i], dec->data.F64[i], xPix->data.F32[i], yPix->data.F32[i],
    520547                        chipName ? chipName : "UNKNOWN",
    521548                        rawFile ? " " : "",
    522                         rawFile && cellName ? cellName : (rawFile ? "UNKNOWN" : ""));
     549                        rawFile && cellName ? cellName : (rawFile ? "UNKNOWN" : ""),
     550                        xFP->data.F32[i], yFP->data.F32[i], xTP->data.F32[i], yTP->data.F32[i] );
    523551            }
    524552        }
Note: See TracChangeset for help on using the changeset viewer.