IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20443


Ignore:
Timestamp:
Oct 28, 2008, 1:20:29 PM (18 years ago)
Author:
beaumont
Message:

New plots for fixChips and CommonScale

Location:
branches/cnb_branch_20081011
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/cnb_branch_20081011/psModules/src/astrom/pmAstrometryObjects.c

    r20415 r20443  
    88*  @author EAM, IfA
    99*
    10 *  @version $Revision: 1.41.4.2 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2008-10-27 22:50:07 $
     10*  @version $Revision: 1.41.4.3 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2008-10-28 23:20:29 $
    1212*
    1313*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    871871    tweak->offset.y += yPeak;
    872872
    873     pmAstromVisualPlotTweak (xHist, yHist, xHistNew, yHistNew, xBin, yBin);
     873    pmAstromVisualPlotTweak (xHistNew, yHistNew, xBin, yBin);
    874874
    875875    psFree (rot);
  • branches/cnb_branch_20081011/psModules/src/astrom/pmAstrometryVisual.c

    r20415 r20443  
    259259
    260260
    261 /** Plot the refinements that pmAstromGridTweak makes to the offset between raw and ref stars */
    262 bool pmAstromVisualPlotTweak (psVector *xHist, psVector *yHist, psVector *xHistNew, psVector *yHistNew, int xBin, int yBin)
     261/** Plot the refinements made within pmAstromGridTweak.
     262 * After pmAstromGridMatch finds the best rotaion/scale/offset between raw and reference stars
     263 * within a coarse grid of rotations/scales, pmAstromGridTweak computes a higher precision
     264 * estimate of the offset. It computes the 2 point correlation function between raw and ref
     265 * stars along horizontal and vertical cuts through the first-guess offset. It finds the peak
     266 * of these two profiles and adjusts the offset accordingly. This procedure plots the profiles.
     267 */
     268bool pmAstromVisualPlotTweak (psVector *xHist, psVector *yHist, int xBin, int yBin)
    263269{
    264270    //make sure we want to plot this
     
    274280    psVector *xIndices = psVectorAlloc (xHist->n, PS_TYPE_F32);
    275281    psVector *yIndices = psVectorAlloc (yHist->n, PS_TYPE_F32);
    276 
    277282
    278283    //populate the Indices vectors
     
    298303    KapaSendLabel (kapa, "Horizontal Profile",
    299304                   KAPA_LABEL_XP);
    300     graphdata.style = 2;
     305    graphdata.style = 1;
    301306    graphdata.ptype = 0;
    302307    graphdata.size = 0.4;
     
    307312    KapaPlotVector (kapa, xHist->n, xHist->data.F32, "y");
    308313
    309     //overplot smoothed line
    310     graphdata.style = 1;
    311     graphdata.color = KapaColorByName ("red");
    312     KapaPrepPlot (kapa, xHist->n, &graphdata);
    313     KapaPlotVector (kapa, xHist->n, xIndices->data.F32, "x");
    314     KapaPlotVector (kapa, xHist->n, xHistNew->data.F32, "y");
    315 
    316314    //overplot the peak
    317315    float x[2] = {xBin, xBin};
    318316    float y[2] = {-500, 500};
    319     graphdata.color = KapaColorByName ("black");
     317    graphdata.color = KapaColorByName ("red");
    320318    KapaPrepPlot (kapa, 2, &graphdata);
    321319    KapaPlotVector (kapa, 2, x, "x");
     
    328326    KapaSetFont(kapa, "helvetica", 14);
    329327    KapaBox(kapa, &graphdata);
    330     KapaSendLabel (kapa, "X offset Bin", KAPA_LABEL_XM);
     328    KapaSendLabel (kapa, "Y offset Bin", KAPA_LABEL_XM);
    331329    KapaSendLabel (kapa, "Number of Sources", KAPA_LABEL_YM);
    332330    KapaSendLabel (kapa, "Vertical Profile",
    333331                   KAPA_LABEL_XP);
    334     graphdata.style = 2;
     332    graphdata.style = 1;
    335333    graphdata.ptype = 0;
    336334    graphdata.size = 0.4;
     
    341339    KapaPlotVector (kapa, yHist->n, yHist->data.F32, "y");
    342340
    343     //overplot smoothed line
    344     graphdata.style = 1;
    345     graphdata.color = KapaColorByName ("red");
    346     KapaPrepPlot (kapa, yHist->n, &graphdata);
    347     KapaPlotVector (kapa, yHist->n, yIndices->data.F32, "x");
    348     KapaPlotVector (kapa, yHist->n, yHistNew->data.F32, "y");
    349 
    350341    //overplot the peak
    351342    x[0] = x[1] = yBin;
    352     graphdata.color = KapaColorByName ("black");
     343    graphdata.color = KapaColorByName ("red");
    353344    KapaPrepPlot (kapa, 2, &graphdata);
    354345    KapaPlotVector (kapa, 2, x, "x");
     
    356347
    357348    //plot title
     349    graphdata.color = KapaColorByName("black");
    358350    KapaSection section3 = {"s3", 0, 0, 1, 1};
    359351    KapaSetSection( kapa, &section3);
     
    366358    psFree(yIndices);
    367359    return true;
    368 }
    369 
    370 
    371 /** psastroVisualScaleGraphdata
     360} //end of pmAstromPlotTweak
     361
     362
     363/** pmAstromScaleGraphdata
    372364 * Scale the graphdata structure based on x and y coordinates. Use sigma clipping to
    373365 * prevent outliers from making te plot region too big.
     
    441433
    442434
    443 
    444435# else
    445436
     
    449440bool pmAstromVisualClose() { return true; }
    450441bool pmAstromVisualPlotGridMatch (const psArray *raw, const psArray *ref, psImage *gridNP, double offsetX, double offsetY, double maxOffpix, double Scale, double Offset) { return true; }
     442bool pmAstromVisualPlotTweak (psVector *xHist, psVector *yHist, int xBin, int yBin) {return true;}
    451443
    452444# endif
  • branches/cnb_branch_20081011/psModules/src/astrom/pmAstrometryVisual.h

    r20415 r20443  
    44bool pmAstromVisualClose();
    55bool pmAstromVisualPlotGridMatch (const psArray *raw, const psArray *ref, psImage *gridNP, double offsetX, double offsetY, double maxOffpix, double Scale, double Offset);
    6 bool pmAstromVisualPlotTweak (psVector *xHist, psVector *yHist, psVector *xHistNew, psVector *yHistNew, int xBin, int yBin);
     6bool pmAstromVisualPlotTweak (psVector *xHist, psVector *yHist, int xBin, int yBin);
  • branches/cnb_branch_20081011/psastro/src/psastro.h

    r20335 r20443  
    8383bool psastroVisualPlotRefStars (psArray *refstars, psMetadata *recipe);
    8484bool psastroVisualPlotRemoveClumps (psArray *input, psImage *count, int scale, float limit);
     85bool psastroVisualPlotFixChips (pmFPAfile *input, psVector *xOld, psVector *yOld);
    8586bool psastroVisualPlotOneChipFit (psArray *rawstars, psArray *refstars, psArray *match, psMetadata *recipe);
    8687bool psastroVisualPlotAstromGuessCheck (psVector *cornerPo, psVector *cornerQo, psVector *cornerPn, psVector *cornerQn, psVector *cornerPd, psVector *cornerQd);
    8788bool psastroVisualPlotMosaicOneChip (psArray *rawstars, psArray *refstars, psArray *match, psMetadata *recipe);
     89bool psastroVisualPlotCommonScale (pmFPA *fpa, psVector *oldScale);
    8890bool psastroVisualPlotMosaicMatches (psArray *rawstars, psArray *refstars, psArray *match, int iteration, psMetadata *recipe);
    8991
  • branches/cnb_branch_20081011/psastro/src/psastroFixChips.c

    r16077 r20443  
    109109  }
    110110  xObs->n = yObs->n = xRef->n = yRef->n = nPts;
    111        
     111
    112112  psPlaneTransform *map = psPlaneTransformAlloc (1, 1);
    113  
     113
    114114  psVector *mask = psVectorAlloc (nPts, PS_TYPE_U8);
    115115  psVectorInit (mask, 0);
     
    127127
    128128  // loop over all chips, select the outliers, and replace the measured astrometry with the model
    129   // the measured transformation above must be applied to make the comparison, and also then applied to the 
     129  // the measured transformation above must be applied to make the comparison, and also then applied to the
    130130  // model transformation
    131131
    132   psFree (xObs);
    133   psFree (yObs);
    134132  psFree (xRef);
    135133  psFree (yRef);
     
    159157    psPlaneTransformApply (&tmpCoord, refChip->toFPA, &refPixel);
    160158    psPlaneTransformApply (&refCoord, map, &tmpCoord);
    161    
     159
    162160    psPlane offPixel = {100.0, 0.0, 100.0, 0.0};
    163161    psPlane obsOffPt, refOffPt;
     
    169167    psPlaneTransformApply (&tmpCoord, refChip->toFPA, &offPixel);
    170168    psPlaneTransformApply (&refOffPt, map, &tmpCoord);
    171    
     169
    172170    double obsAngle = PM_DEG_RAD*atan2 (obsOffPt.y - obsCoord.y, obsOffPt.x - obsCoord.x);
    173171    double refAngle = PM_DEG_RAD*atan2 (refOffPt.y - refCoord.y, refOffPt.x - refCoord.x);
     
    183181
    184182    psLogMsg ("psastro", PS_LOG_INFO, "fixing chip %d, angle: %f, pixel: %f,%f\n",
    185               view->chip, obsAngle - refAngle, obsCoord.x - refCoord.x, obsCoord.y - refCoord.y);
     183              view->chip, obsAngle - refAngle, obsCoord.x - refCoord.x, obsCoord.y - refCoord.y);
    186184
    187185    psFree (obsChip->toFPA);
     
    192190    psPlaneTransform *toFPA = psPlaneTransformAlloc(refChip->toFPA->x->nX, refChip->toFPA->x->nY);
    193191    for (int i = 0; i <= refChip->toFPA->x->nX; i++) {
    194         for (int j = 0; j <= refChip->toFPA->x->nY; j++) {
    195             double f1 = refChip->toFPA->x->coeffMask[i][j] ? 0.0 : map->x->coeff[1][0]*refChip->toFPA->x->coeff[i][j];
    196             double f2 = refChip->toFPA->y->coeffMask[i][j] ? 0.0 : map->x->coeff[0][1]*refChip->toFPA->y->coeff[i][j];
    197             toFPA->x->coeff[i][j] = f1 + f2;
    198 
    199             double g1 = refChip->toFPA->x->coeffMask[i][j] ? 0.0 : map->y->coeff[1][0]*refChip->toFPA->x->coeff[i][j];
    200             double g2 = refChip->toFPA->y->coeffMask[i][j] ? 0.0 : map->y->coeff[0][1]*refChip->toFPA->y->coeff[i][j];
    201             toFPA->y->coeff[i][j] = g1 + g2;
    202         }
     192        for (int j = 0; j <= refChip->toFPA->x->nY; j++) {
     193            double f1 = refChip->toFPA->x->coeffMask[i][j] ? 0.0 : map->x->coeff[1][0]*refChip->toFPA->x->coeff[i][j];
     194            double f2 = refChip->toFPA->y->coeffMask[i][j] ? 0.0 : map->x->coeff[0][1]*refChip->toFPA->y->coeff[i][j];
     195            toFPA->x->coeff[i][j] = f1 + f2;
     196
     197            double g1 = refChip->toFPA->x->coeffMask[i][j] ? 0.0 : map->y->coeff[1][0]*refChip->toFPA->x->coeff[i][j];
     198            double g2 = refChip->toFPA->y->coeffMask[i][j] ? 0.0 : map->y->coeff[0][1]*refChip->toFPA->y->coeff[i][j];
     199            toFPA->y->coeff[i][j] = g1 + g2;
     200        }
    203201    }
    204202    toFPA->x->coeff[0][0] += map->x->coeff[0][0];
     
    209207    obsChip->fromFPA = psPlaneTransformInvert(NULL, obsChip->toFPA, *region, 50);
    210208    psFree (region);
    211    
     209
    212210    // XXX this stuff below should be applied to each readout...
    213211    // XXX for now, just use first readout
     
    226224    // the absolute minimum number of stars is 4 (for order = 1)
    227225    if ((rawstars->n < 4) || (refstars->n < 4)) {
    228         readout->data_exists = false;
    229         psLogMsg ("psastro", 3, "insufficient rawstars (%ld) or refstars (%ld)",
    230                   rawstars->n, refstars->n);
    231         continue;
    232     } 
     226        readout->data_exists = false;
     227        psLogMsg ("psastro", 3, "insufficient rawstars (%ld) or refstars (%ld)",
     228                  rawstars->n, refstars->n);
     229        continue;
     230    }
    233231
    234232    psastroUpdateChipToFPA (input->fpa, obsChip, rawstars, refstars);
     
    237235    psMetadata *updates = psMemIncrRefCounter (psMetadataLookupMetadata (&status, readout->analysis, "PSASTRO.HEADER"));
    238236    if (!updates) {
    239         updates = psMetadataAlloc ();
     237        updates = psMetadataAlloc ();
    240238    }
    241239
    242240    // XXX update the header with info to reflect the failure
    243241    if (!psastroOneChipFit (input->fpa, obsChip, refstars, rawstars, recipe, updates)) {
    244         readout->data_exists = false;
    245         psLogMsg ("psastro", 3, "failed to find a solution\n");
    246         psFree (updates);
    247         continue;
     242        readout->data_exists = false;
     243        psLogMsg ("psastro", 3, "failed to find a solution\n");
     244        psFree (updates);
     245        continue;
    248246    }
    249247
     
    253251  }
    254252
     253  psastroVisualPlotFixChips (input, xObs, yObs);
     254  psFree (xObs);
     255  psFree (yObs);
    255256  psFree (map);
    256257  psFree (view);
  • branches/cnb_branch_20081011/psastro/src/psastroUtils.c

    r12806 r20443  
    2020
    2121    float pixelScaleUse = 1.0, pixelScale1 = 1.0,  pixelScale2 = 1.0,  pixelScale = 1.0;
     22    psVector *oldScale = psVectorAllocEmpty (fpa->chips->n, PS_TYPE_F32);
    2223
    2324    char *option = psMetadataLookupStr (NULL, recipe, "PSASTRO.COMMON.SCALE.OPTION");
    2425    if (option == NULL) {
    25         psError(PSASTRO_ERR_DATA, false, "no choice set for common scale option\n");
    26         return false;
     26        psError(PSASTRO_ERR_DATA, false, "no choice set for common scale option\n");
     27        return false;
    2728    }
    2829
    2930    bool useExternal = true;
     31    int nobj = 0;
    3032
    3133    // find the min or max scale chip
    3234    if (!strcasecmp (option, "MIN") || !strcasecmp (option, "MAX")) {
    3335
    34         bool useMax = !strcasecmp (option, "MAX");
    35         pixelScaleUse = (useMax) ? FLT_MIN : FLT_MAX;
    36 
    37         for (int i = 0; i < fpa->chips->n; i++) {
    38             pmChip *chip = fpa->chips->data[i];
    39             if (!chip->process || !chip->file_exists) { continue; }
    40             if (!chip->toFPA) { continue; }
    41 
    42             pixelScale1 = hypot (chip->toFPA->x->coeff[1][0], chip->toFPA->x->coeff[0][1]);
    43             pixelScale2 = hypot (chip->toFPA->y->coeff[1][0], chip->toFPA->y->coeff[0][1]);
    44             pixelScale = 0.5*(pixelScale1 + pixelScale2);
    45            
    46             pixelScaleUse = (useMax) ? PS_MAX (pixelScale, pixelScaleUse) : PS_MIN (pixelScale, pixelScaleUse);
    47         }
    48         useExternal = false;
    49     }
     36        bool useMax = !strcasecmp (option, "MAX");
     37        pixelScaleUse = (useMax) ? FLT_MIN : FLT_MAX;
     38
     39        for (int i = 0; i < fpa->chips->n; i++) {
     40            pmChip *chip = fpa->chips->data[i];
     41            if (!chip->process || !chip->file_exists) { continue; }
     42            if (!chip->toFPA) { continue; }
     43
     44            pixelScale1 = hypot (chip->toFPA->x->coeff[1][0], chip->toFPA->x->coeff[0][1]);
     45            pixelScale2 = hypot (chip->toFPA->y->coeff[1][0], chip->toFPA->y->coeff[0][1]);
     46            pixelScale = 0.5*(pixelScale1 + pixelScale2);
     47            oldScale->data.F32[nobj++] = pixelScale;
     48            pixelScaleUse = (useMax) ? PS_MAX (pixelScale, pixelScaleUse) : PS_MIN (pixelScale, pixelScaleUse);
     49        }
     50        useExternal = false;
     51        oldScale->n = nobj;
     52    }
     53
    5054
    5155    // rescale each chip by the reference scale
    5256    for (int i = 0; i < fpa->chips->n; i++) {
    53         pmChip *chip = fpa->chips->data[i];
    54         if (!chip->process || !chip->file_exists) { continue; }
    55         if (!chip->toFPA) { continue; }
    56 
    57         psPlaneTransform *toFPA = chip->toFPA;
    58         psPlaneTransform *fromFPA = chip->fromFPA;
    59            
    60         pixelScale1 = hypot (toFPA->x->coeff[1][0], toFPA->x->coeff[0][1]);
    61         pixelScale2 = hypot (toFPA->y->coeff[1][0], toFPA->y->coeff[0][1]);
    62 
    63         if (useExternal) {
    64             pixelScaleUse = getChipPixelScale (chip);
    65         }
    66 
    67         for (int i = 0; i <= toFPA->x->nX; i++) {
    68             for (int j = 0; j <= toFPA->x->nX; j++) {
    69                 toFPA->x->coeff[i][j] *= pixelScaleUse/pixelScale1;
    70                 toFPA->y->coeff[i][j] *= pixelScaleUse/pixelScale2;
    71                 fromFPA->x->coeff[i][j] *= pixelScale1/pixelScaleUse;
    72                 fromFPA->y->coeff[i][j] *= pixelScale2/pixelScaleUse;
    73             }
    74         }
     57        pmChip *chip = fpa->chips->data[i];
     58        if (!chip->process || !chip->file_exists) { continue; }
     59        if (!chip->toFPA) { continue; }
     60
     61        psPlaneTransform *toFPA = chip->toFPA;
     62        psPlaneTransform *fromFPA = chip->fromFPA;
     63
     64        pixelScale1 = hypot (toFPA->x->coeff[1][0], toFPA->x->coeff[0][1]);
     65        pixelScale2 = hypot (toFPA->y->coeff[1][0], toFPA->y->coeff[0][1]);
     66
     67        if (useExternal) {
     68            pixelScaleUse = getChipPixelScale (chip);
     69        }
     70
     71        for (int i = 0; i <= toFPA->x->nX; i++) {
     72            for (int j = 0; j <= toFPA->x->nX; j++) {
     73                toFPA->x->coeff[i][j] *= pixelScaleUse/pixelScale1;
     74                toFPA->y->coeff[i][j] *= pixelScaleUse/pixelScale2;
     75                fromFPA->x->coeff[i][j] *= pixelScale1/pixelScaleUse;
     76                fromFPA->y->coeff[i][j] *= pixelScale2/pixelScaleUse;
     77            }
     78        }
    7579
    7680    }
    7781    psastroMosaicSetAstrom (fpa);
     82    if (!useExternal) {
     83        psastroVisualPlotCommonScale (fpa, oldScale);
     84    }
     85    psFree (oldScale);
    7886    return true;
    7987}
  • branches/cnb_branch_20081011/psastro/src/psastroVisual.c

    r20416 r20443  
    22/***Diagnostic plots for psastro****/
    33/***********************************/
     4#ifdef HAVE_CONFIG_H
     5#include <config.h>
     6#endif
     7
    48# include "psastroInternal.h"
    59# include <string.h>
     
    2024static bool plotRemoveClumps     = false;
    2125static bool plotOneChipFit       = false;
     26static bool plotFixChips         = true;
    2227static bool plotAstromGuessCheck = false;
    2328static bool plotMosaicMatches    = false;
     29static bool plotCommonScale      = true;
    2430static bool plotMosaicOneChip    = false;
    2531
     
    2935
    3036// helper routine prototypes
     37bool psastroVisualInitGraph (int kapa, KapaSection *section, Graphdata *graphdata);
    3138bool psastroVisualTriplePlot (int kapa, Graphdata *graphdata, psVector *xVec, psVector *yVec, psVector *zVec, bool increasing);
    3239bool psastroVisualScaleGraphdata(Graphdata *graphdata, psVector *xVec, psVector *yVec);
     
    538545
    539546
     547/** Plots the chip corners in the FP before and after chips with inconsistent solutions have been fixed.
     548 * Invoked during psastroFixChips
     549 */
     550bool psastroVisualPlotFixChips (pmFPAfile *input, ///< focal plane array file
     551                            psVector *xOld, ///< old X location of chip cornerss
     552                            psVector *yOld ///< old Y location of chip corners
     553    )
     554{
     555    //make sure we want to plot this
     556    if(!isVisual || !plotFixChips) return true;
     557
     558    if(!psastroVisualInitWindow(&kapa, "psastro:plots")) return false;
     559
     560    KapaSection section = {"s1", .05, .05, .9, .9};
     561    Graphdata graphdata;
     562    KapaInitGraph( &graphdata);
     563    KapaClearPlots (kapa);
     564    graphdata.ptype = 2;
     565    graphdata.style = 2;
     566
     567    psVector *xNew = psVectorAllocEmpty (xOld->n, PS_TYPE_F32);
     568    psVector *yNew = psVectorAllocEmpty (yOld->n, PS_TYPE_F32);
     569
     570    // copy of the code in psastroFixChips that generated xOld, yOld, but for xNew, yNew
     571    pmFPAview *view = pmFPAviewAlloc (0);
     572    int nPts = 0;
     573    pmChip *obsChip = NULL;
     574    while ((obsChip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) {
     575        if (!obsChip->process || !obsChip->file_exists || !obsChip->data_exists) { continue; }
     576
     577        psRegion *region = pmChipPixels (obsChip);
     578        psPlane ptCP, ptFP;
     579
     580        ptCP.x = region->x0; ptCP.y = region->y0;
     581        psPlaneTransformApply (&ptFP, obsChip->toFPA, &ptCP);
     582        xNew->data.F32[nPts] = ptFP.x;
     583        yNew->data.F32[nPts] = ptFP.y;
     584        nPts ++;
     585
     586        ptCP.x = region->x0; ptCP.y = region->y1;
     587        psPlaneTransformApply (&ptFP, obsChip->toFPA, &ptCP);
     588        xNew->data.F32[nPts] = ptFP.x;
     589        yNew->data.F32[nPts] = ptFP.y;
     590        nPts ++;
     591
     592        ptCP.x = region->x1; ptCP.y = region->y1;
     593        psPlaneTransformApply (&ptFP, obsChip->toFPA, &ptCP);
     594        xNew->data.F32[nPts] = ptFP.x;
     595        yNew->data.F32[nPts] = ptFP.y;
     596        nPts ++;
     597
     598        ptCP.x = region->x1; ptCP.y = region->y0;
     599        psPlaneTransformApply (&ptFP, obsChip->toFPA, &ptCP);
     600        xNew->data.F32[nPts] = ptFP.x;
     601        yNew->data.F32[nPts] = ptFP.y;
     602        nPts ++;
     603
     604        psFree (region);
     605    }
     606    xNew->n = yNew->n = nPts;
     607
     608    //set up graph
     609    psastroVisualScaleGraphdata(&graphdata, xOld, yOld);
     610    psastroVisualInitGraph(kapa, &section, &graphdata);
     611    KapaSendLabel (kapa, "L (FP)", KAPA_LABEL_XM);
     612    KapaSendLabel (kapa, "M (FP)", KAPA_LABEL_YM);
     613    KapaSendLabel (kapa, "Chip corners before (black) and after (red) FixChips", KAPA_LABEL_XP);
     614    KapaPrepPlot (kapa, xOld->n, &graphdata);
     615    KapaPlotVector (kapa, xOld->n, xOld->data.F32, "x");
     616    KapaPlotVector (kapa, xOld->n, yOld->data.F32, "y");
     617
     618    graphdata.ptype = 1;
     619    graphdata.color = KapaColorByName("red");
     620    KapaPrepPlot (kapa, xNew->n, &graphdata);
     621    KapaPlotVector (kapa, xNew->n, xNew->data.F32, "x");
     622    KapaPlotVector (kapa, xNew->n, yNew->data.F32, "y");
     623
     624    psastroVisualAskUser(&plotFixChips);
     625    psFree(xNew);
     626    psFree(yNew);
     627    psFree(view);
     628    return true;
     629}
     630
     631
    540632/**
    541633 *  Plots the fpa chip corners projected on to the tangential plane before and after
     
    631723}
    632724
     725/** psastroVisualPlotCommonScale (fpa, oldScale, newScale)
     726 * Plots the pixel scales of the fpa before they are
     727 * equalized in psastroMosaicCommonScale
     728 */
     729
     730bool psastroVisualPlotCommonScale (pmFPA *fpa,         ///< the fpa
     731                              psVector *oldScale) ///< the old pixel scale of each chip in the fpa
     732{
     733    //make sure we want to plot this
     734    if (!isVisual || !plotCommonScale) return false;
     735
     736    if (!psastroVisualInitWindow(&kapa, "psastro:plots")) return false;
     737
     738    KapaSection section = {"s1", .05, .05, .9, .9};
     739    Graphdata graphdata;
     740    psPlane ptCH, ptFP;
     741    ptCH.x = 0;
     742    ptCH.y = 0;
     743    psVector *xVec = psVectorAllocEmpty (oldScale->n, PS_TYPE_F32);
     744    psVector *yVec = psVectorAllocEmpty (oldScale->n, PS_TYPE_F32);
     745    int nobj = 0;
     746
     747    //project each chip corner to the Focal Plane
     748    for(int i = 0; i < fpa->chips->n; i++) {
     749        pmChip *chip = fpa->chips->data[i];
     750        if (!chip->process || !chip->file_exists) { continue; }
     751        if (!chip->toFPA) { continue; }
     752
     753        psPlaneTransformApply (&ptFP, chip->toFPA, &ptCH);
     754        xVec->data.F32[nobj] = ptFP.x;
     755        yVec->data.F32[nobj] = ptFP.y;
     756        nobj++;
     757    }
     758
     759    //set up plot window
     760    KapaInitGraph (&graphdata);
     761    KapaClearPlots (kapa);
     762    KapaSetSection (kapa, &section);
     763    psastroVisualInitGraph(kapa, &section, &graphdata);
     764    psastroVisualTriplePlot (kapa, &graphdata, xVec, yVec, oldScale, false);
     765    KapaSendLabel (kapa, "L (FP)", KAPA_LABEL_XM);
     766    KapaSendLabel (kapa, "M (FP)", KAPA_LABEL_YM);
     767    KapaSendLabel (kapa, "Old Pixel Scale of FPA Chips (Not to Scale)", KAPA_LABEL_XP);
     768
     769    psastroVisualAskUser (&plotCommonScale);
     770    return true;
     771}
     772
    633773
    634774/**
     
    663803    //make sure we want to plot this
    664804    if (!isVisual || !plotMosaicMatches) return true;
    665     char *title;
    666     switch(iteration) {
    667       case 0:
    668         title = "Matches found during psastroMosaicSetMatch iteration 0";
    669         break;
    670       case 1 :
    671         title = "Matches found during psastroMosaicSetMatch iteration 1";
    672         break;
    673       case 2:
    674         title = "Matches found during psastroMosaicSetMatch iteration 2";
    675         break;
    676       case 3:
    677         title = "Matches found during psastroMosaicSetMatch iteration 3";
    678         break;
    679       case 4:
    680          title = "Matches found during psastroMosaicSetMatch iteration 4";
    681          break;
    682       default:
    683         title = "Matches found during psastroMosaicSetMatch";
    684         break;
    685     }
     805
     806    char title[60];
     807    sprintf(title, "Matches found during psastroMosaicSetMatch iteration %d", iteration);
    686808
    687809    if (!psastroVisualResidPlot(rawstars, refstars, match, recipe, title))
     
    698820/*********************/
    699821
     822/** psastroVisualInitGraph (kapa, *section, *graphdata)
     823 * Initializes graph, sets the section, sets the font,
     824 * sets the limits, draws the box
     825 */
     826
     827bool psastroVisualInitGraph (int kapa, KapaSection *section, Graphdata *graphdata)
     828{
     829    KapaSetSection (kapa, section);
     830    KapaSetFont (kapa, "helvetica", 14);
     831    KapaSetLimits (kapa, graphdata);
     832    KapaBox (kapa, graphdata);
     833    return true;
     834}
    700835
    701836/** psastroVisualTriplePlot
     
    11251260    return true;
    11261261}
     1262#else
     1263
     1264bool psastroSetVisual (bool mode) {return true};
     1265bool psastroVisualClose() {return true};
     1266bool psastroVisualPlotLuminosityFunction (psVector *lnMag, psVector *Mag, pmLumFunc *lumFunc, pmLumFunc *rawFunc) {return true};
     1267bool psastroVisualPlotRawStars (psArray *rawstars, pmFPA *fpa, pmChip *chip, psMetadata *recipe) {return true};
     1268bool psastroVisualPlotRefStars (psArray *refstars, psMetadata *recipe) {return true};
     1269bool psastroVisualPlotRemoveClumps (psArray *input, psImage *count, int scale, float limit) {return true};
     1270bool psastroVisualPlotFixChips (pmFPAfile *input, psVector *xOld, psVector *yOld) {return true};
     1271bool psastroVisualPlotOneChipFit (psArray *rawstars, psArray *refstars, psArray *match, psMetadata *recipe) {return true};
     1272bool psastroVisualPlotAstromGuessCheck (psVector *cornerPo, psVector *cornerQo, psVector *cornerPn, psVector *cornerQn, psVector *cornerPd, psVector *cornerQd) {return true};
     1273bool psastroVisualPlotMosaicOneChip (psArray *rawstars, psArray *refstars, psArray *match, psMetadata *recipe) {return true};
     1274bool psastroVisualPlotCommonScale (pmFPA *fpa, psVector *oldScale) {return true};
     1275bool psastroVisualPlotMosaicMatches (psArray *rawstars, psArray *refstars, psArray *match, int iteration, psMetadata *recipe) {return true};
    11271276
    11281277# endif
Note: See TracChangeset for help on using the changeset viewer.