IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 22, 2009, 3:00:47 PM (16 years ago)
Author:
eugene
Message:

various updates from eam_branches/20091113

1) psf model order limits now consistent in poly and map modes
2) added subpix visualization
3) added model fit in MATCHED_REFS
4) handle input smf files with empty extensions (earlier failure)
5) function for generating unique reference matches

Location:
trunk/psModules/src/objects
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects

    • Property svn:mergeinfo deleted
  • trunk/psModules/src/objects/pmPSFtryMetric.c

    r25754 r26260  
    7676
    7777    pmSourceVisualPlotPSFMetric (psfTry);
     78    pmSourceVisualPlotPSFMetricSubpix (psfTry);
    7879
    7980    psFree (stats);
  • trunk/psModules/src/objects/pmPSFtryModel.c

    r25819 r26260  
    7272    }
    7373
    74     // XXX set the min number of needed source more carefully (depends on psfTrendMode?)
    75     int orderMax = PS_MAX (options->psfTrendNx, options->psfTrendNy);
    76     if ((sources->n < 15) && (orderMax >= 3)) orderMax = 2;
    77     if ((sources->n < 11) && (orderMax >= 2)) orderMax = 1;
    78     if ((sources->n <  8) && (orderMax >= 1)) orderMax = 0;
     74    // hard limit on minimum number of stars
    7975    if ((sources->n <  3)) {
    8076        psError (PS_ERR_UNKNOWN, true, "failed to determine PSF parameters");
     
    8278    }
    8379
    84     int orderMin;
     80    // this is a bit tricky, because we have two cases (MAP vs POLY), and they have a different
     81    // definition for 'order' (order_MAP = order_POLY + 1).  in addition, we have a
     82    // user-specified MAX order, which we should respect, regardless of the mode
     83
     84    // set the max order (0 = constant) which the number of psf stars can support:
     85    // rule of thumb: require 3 stars per 'cell' (order+1)^2
     86    int MaxOrderForStars = 0;
     87    if (sources->n >= 12) MaxOrderForStars = 1; // 4 cells
     88    if (sources->n >= 27) MaxOrderForStars = 2; // 9 cells
     89    if (sources->n >= 48) MaxOrderForStars = 3; // 16 cells
     90    if (sources->n >  75) MaxOrderForStars = 4; // 25 cells
     91
     92    int orderMax = PS_MAX (options->psfTrendNx, options->psfTrendNy);
     93    int orderMin = 0;
    8594    if (options->psfTrendMode == PM_TREND_MAP) {
    86         orderMin = 1;
    87         orderMax = PS_MAX(orderMax, 1);
    88     } else {
    89         orderMin = 0;
    90     }
     95        MaxOrderForStars ++;
     96        orderMin ++;
     97    }
     98    orderMax = PS_MIN (orderMax, MaxOrderForStars);
    9199
    92100    // save the raw source mask (generated by pmPSFtryFitEXT)
  • trunk/psModules/src/objects/pmSourceIO.c

    r25907 r26260  
    980980        if (!tableHeader) psAbort("cannot read table header");
    981981
     982        char *xtension = psMetadataLookupStr (NULL, tableHeader, "XTENSION");
     983        if (!xtension) psAbort("cannot read table type");
     984        if (strcmp (xtension, "BINTABLE")) {
     985            psWarning ("no binary table in extension %s, skipping\n", dataname);
     986            return false;
     987        }
     988
    982989        char *exttype = psMetadataLookupStr (NULL, tableHeader, "EXTTYPE");
    983990        if (!exttype) psAbort("cannot read table type");
  • trunk/psModules/src/objects/pmSourceIO_MatchedRefs.c

    r24801 r26260  
    120120                        psMetadataAdd (row, PS_LIST_TAIL, "X_CHIP",   PS_DATA_F32, "x coord on chip",              raw->chip->x);
    121121                        psMetadataAdd (row, PS_LIST_TAIL, "Y_CHIP",   PS_DATA_F32, "y coord on chip",              raw->chip->y);
     122                        psMetadataAdd (row, PS_LIST_TAIL, "X_CHIP_FIT",PS_DATA_F32, "x fitted coord on chip",      ref->chip->x);
     123                        psMetadataAdd (row, PS_LIST_TAIL, "Y_CHIP_FIT",PS_DATA_F32, "y fitted coord on chip",      ref->chip->y);
    122124                        psMetadataAdd (row, PS_LIST_TAIL, "X_FPA",    PS_DATA_F32, "x coord on focal plane",       raw->FP->x);
    123125                        psMetadataAdd (row, PS_LIST_TAIL, "Y_FPA",    PS_DATA_F32, "y coord on focal plane",       raw->FP->y);
  • trunk/psModules/src/objects/pmSourceVisual.c

    r25979 r26260  
    7373
    7474    float range;
     75    range = graphdata.xmax - graphdata.xmin;
     76    graphdata.xmax += 0.05*range;
     77    graphdata.xmin -= 0.05*range;
     78    range = graphdata.ymax - graphdata.ymin;
     79    graphdata.ymax += 0.05*range;
     80    graphdata.ymin -= 0.05*range;
     81
     82    // better choice for range?
     83    // graphdata.xmin = -17.0;
     84    // graphdata.xmax =  -9.0;
     85    graphdata.ymin = -0.51;
     86    graphdata.ymax = +0.51;
     87
     88    KapaSetLimits (kapa1, &graphdata);
     89
     90    KapaSetFont (kapa1, "helvetica", 14);
     91    KapaBox (kapa1, &graphdata);
     92    KapaSendLabel (kapa1, "PSF Mag", KAPA_LABEL_XM);
     93    KapaSendLabel (kapa1, "Ap Mag - PSF Mag", KAPA_LABEL_YM);
     94
     95    graphdata.color = KapaColorByName ("black");
     96    graphdata.ptype = 2;
     97    graphdata.size = 0.5;
     98    graphdata.style = 2;
     99    graphdata.etype |= 0x01;
     100
     101    KapaPrepPlot (kapa1, n, &graphdata);
     102    KapaPlotVector (kapa1, n, x->data.F32, "x");
     103    KapaPlotVector (kapa1, n, y->data.F32, "y");
     104    KapaPlotVector (kapa1, n, dy->data.F32, "dym");
     105    KapaPlotVector (kapa1, n, dy->data.F32, "dyp");
     106
     107    psFree (x);
     108    psFree (y);
     109    psFree (dy);
     110
     111    pmVisualAskUser(NULL);
     112    return true;
     113}
     114
     115bool pmSourceVisualPlotPSFMetricSubpix (pmPSFtry *psfTry) {
     116
     117    KapaSection section;  // put the positive profile in one and the residuals in another?
     118    Graphdata graphdata;
     119
     120    if (!pmVisualIsVisual()) return true;
     121
     122    if (kapa1 == -1) {
     123        kapa1 = KapaOpenNamedSocket ("kapa", "pmSource:plots");
     124        if (kapa1 == -1) {
     125            fprintf (stderr, "failure to open kapa; visual mode disabled\n");
     126            pmVisualSetVisual(false);
     127            return false;
     128        }
     129    }
     130
     131    KapaClearSections (kapa1);
     132    KapaInitGraph (&graphdata);
     133
     134    int n;
     135    float range;
     136    psVector *x = psVectorAllocEmpty (psfTry->sources->n, PS_TYPE_F32);
     137    psVector *y = psVectorAllocEmpty (psfTry->sources->n, PS_TYPE_F32);
     138    psVector *dy = psVectorAllocEmpty(psfTry->sources->n, PS_TYPE_F32);
     139
     140    // section a: fractional-x pixel
     141    section.dx = 1.0;
     142    section.dy = 0.5;
     143    section.x = 0.0;
     144    section.y = 0.0;
     145    section.name = NULL;
     146    psStringAppend (&section.name, "a1");
     147    KapaSetSection (kapa1, &section);
     148    psFree (section.name);
     149
     150    graphdata.xmin = +32.0;
     151    graphdata.xmax = -32.0;
     152    graphdata.ymin = +32.0;
     153    graphdata.ymax = -32.0;
     154
     155    // construct the plot vectors
     156    n = 0;
     157    for (int i = 0; i < psfTry->sources->n; i++) {
     158        if (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL) continue;
     159
     160        pmSource *source = psfTry->sources->data[i];
     161        x->data.F32[n] = source->modelEXT->params->data.F32[PM_PAR_XPOS] - (int)source->modelEXT->params->data.F32[PM_PAR_XPOS];
     162
     163        y->data.F32[n] = psfTry->metric->data.F32[i];
     164        dy->data.F32[n] = psfTry->metricErr->data.F32[i];
     165        graphdata.xmin = PS_MIN(graphdata.xmin, x->data.F32[n]);
     166        graphdata.xmax = PS_MAX(graphdata.xmax, x->data.F32[n]);
     167        graphdata.ymin = PS_MIN(graphdata.ymin, y->data.F32[n]);
     168        graphdata.ymax = PS_MAX(graphdata.ymax, y->data.F32[n]);
     169        n++;
     170    }
     171    x->n = y->n = dy->n = n;
     172
     173    range = graphdata.xmax - graphdata.xmin;
     174    graphdata.xmax += 0.05*range;
     175    graphdata.xmin -= 0.05*range;
     176    range = graphdata.ymax - graphdata.ymin;
     177    graphdata.ymax += 0.05*range;
     178    graphdata.ymin -= 0.05*range;
     179
     180    // better choice for range?
     181    // graphdata.xmin = -17.0;
     182    // graphdata.xmax =  -9.0;
     183    graphdata.ymin = -0.51;
     184    graphdata.ymax = +0.51;
     185
     186    KapaSetLimits (kapa1, &graphdata);
     187
     188    KapaSetFont (kapa1, "helvetica", 14);
     189    KapaBox (kapa1, &graphdata);
     190    KapaSendLabel (kapa1, "PSF Mag", KAPA_LABEL_XM);
     191    KapaSendLabel (kapa1, "Ap Mag - PSF Mag", KAPA_LABEL_YM);
     192
     193    graphdata.color = KapaColorByName ("black");
     194    graphdata.ptype = 2;
     195    graphdata.size = 0.5;
     196    graphdata.style = 2;
     197    graphdata.etype |= 0x01;
     198
     199    KapaPrepPlot (kapa1, n, &graphdata);
     200    KapaPlotVector (kapa1, n, x->data.F32, "x");
     201    KapaPlotVector (kapa1, n, y->data.F32, "y");
     202    KapaPlotVector (kapa1, n, dy->data.F32, "dym");
     203    KapaPlotVector (kapa1, n, dy->data.F32, "dyp");
     204
     205    // *** section b: fractional-x pixel
     206    section.dx = 1.0;
     207    section.dy = 0.5;
     208    section.x = 0.0;
     209    section.y = 0.5;
     210    section.name = NULL;
     211    psStringAppend (&section.name, "a2");
     212    KapaSetSection (kapa1, &section);
     213    psFree (section.name);
     214
     215    graphdata.xmin = +32.0;
     216    graphdata.xmax = -32.0;
     217    graphdata.ymin = +32.0;
     218    graphdata.ymax = -32.0;
     219
     220    // construct the plot vectors
     221    n = 0;
     222    for (int i = 0; i < psfTry->sources->n; i++) {
     223        if (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL) continue;
     224
     225        pmSource *source = psfTry->sources->data[i];
     226        x->data.F32[n] = source->modelEXT->params->data.F32[PM_PAR_YPOS] - (int)source->modelEXT->params->data.F32[PM_PAR_YPOS];
     227
     228        y->data.F32[n] = psfTry->metric->data.F32[i];
     229        dy->data.F32[n] = psfTry->metricErr->data.F32[i];
     230        graphdata.xmin = PS_MIN(graphdata.xmin, x->data.F32[n]);
     231        graphdata.xmax = PS_MAX(graphdata.xmax, x->data.F32[n]);
     232        graphdata.ymin = PS_MIN(graphdata.ymin, y->data.F32[n]);
     233        graphdata.ymax = PS_MAX(graphdata.ymax, y->data.F32[n]);
     234        n++;
     235    }
     236    x->n = y->n = dy->n = n;
     237
    75238    range = graphdata.xmax - graphdata.xmin;
    76239    graphdata.xmax += 0.05*range;
  • trunk/psModules/src/objects/pmSourceVisual.h

    r25754 r26260  
    1919bool pmSourceVisualPSFModelResid (pmTrend2D *trend, psVector *x, psVector *y, psVector *param, psVector *mask);
    2020bool pmSourceVisualPlotPSFMetric (pmPSFtry *try);
     21bool pmSourceVisualPlotPSFMetricSubpix (pmPSFtry *try);
     22
    2123bool pmSourceVisualShowModelFit (pmSource *source);
    2224bool pmSourceVisualShowModelFits (pmPSF *psf, psArray *sources, psImageMaskType maskVal);
Note: See TracChangeset for help on using the changeset viewer.