IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

New plots for fixChips and CommonScale

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.