IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20803


Ignore:
Timestamp:
Nov 19, 2008, 3:27:03 PM (17 years ago)
Author:
eugene
Message:

import visualizations; increase number of stars needed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psastro/src/psastroMosaicOneChip.c

    r19312 r20803  
    55  if (!status) { \
    66   psError(PSASTRO_ERR_CONFIG, false, MESSAGE); \
    7    return false; } 
     7   return false; }
    88
    99bool psastroMosaicOneChip (pmChip *chip, pmReadout *readout, psMetadata *recipe, psMetadata *updates, int iteration) {
     
    2929
    3030    // correct radius to FP units (physical pixel scale in microns per pixel)
    31     REQUIRED_RECIPE_VALUE (double pixelScale, "PSASTRO.PIXEL.SCALE", F32, "Failed to lookup pixel scale"); 
     31    REQUIRED_RECIPE_VALUE (double pixelScale, "PSASTRO.PIXEL.SCALE", F32, "Failed to lookup pixel scale");
    3232
    3333    // allowed limits for valid solutions
     
    4242    int order = psMetadataLookupS32 (&status, recipe, orderWord);
    4343    if (!status || (order == -1)) {
    44         order = defaultOrder;
     44        order = defaultOrder;
    4545    }
    4646
    4747    // modify the order to correspond to the actual number of matched stars:
    48     if ((match->n < 15) && (order >= 3)) order = 2;
    49     if ((match->n < 11) && (order >= 2)) order = 1;
    50     if ((match->n <  8) && (order >= 1)) order = 0;
     48    if ((match->n < 17) && (order >= 3)) order = 2;
     49    if ((match->n < 13) && (order >= 2)) order = 1;
     50    if ((match->n <  9) && (order >= 1)) order = 0;
    5151    if ((match->n <  3) || (order < 0) || (order > 3)) {
    52         psLogMsg ("psastro", 3, "insufficient stars (%ld) or invalid order (%d)", match->n, order);
    53         return false;
    54     } 
     52        psLogMsg ("psastro", 3, "insufficient stars (%ld) or invalid order (%d)", match->n, order);
     53        return false;
     54    }
    5555
    5656    psLogMsg ("psastro", PS_LOG_DETAIL, "mosaic fit chip order %d", order);
     
    6060    // coefficients frozen to the current values
    6161    if (order == 0) {
    62         // set FIT mask for all higher order terms of the existing solution
    63         // any existing SET masks will be retained.
    64         for (int i = 0; i <= chip->toFPA->x->nX; i++) {
    65             for (int j = 0; j <= chip->toFPA->x->nY; j++) {
    66                 if (i + j > 0) {
    67                     chip->toFPA->x->coeffMask[i][j] |= PS_POLY_MASK_FIT;
    68                     chip->toFPA->y->coeffMask[i][j] |= PS_POLY_MASK_FIT;
    69                 }
    70             }
    71         }
     62        // set FIT mask for all higher order terms of the existing solution
     63        // any existing SET masks will be retained.
     64        for (int i = 0; i <= chip->toFPA->x->nX; i++) {
     65            for (int j = 0; j <= chip->toFPA->x->nY; j++) {
     66                if (i + j > 0) {
     67                    chip->toFPA->x->coeffMask[i][j] |= PS_POLY_MASK_FIT;
     68                    chip->toFPA->y->coeffMask[i][j] |= PS_POLY_MASK_FIT;
     69                }
     70            }
     71        }
    7272    } else {
    73         psFree (chip->toFPA);
    74         chip->toFPA = psPlaneTransformAlloc (order, order);
    75         for (int i = 0; i <= chip->toFPA->x->nX; i++) {
    76             for (int j = 0; j <= chip->toFPA->x->nY; j++) {
    77                 if (i + j > order) {
    78                     chip->toFPA->x->coeffMask[i][j] = PS_POLY_MASK_SET;
    79                     chip->toFPA->y->coeffMask[i][j] = PS_POLY_MASK_SET;
    80                 }
    81             }
    82         }
     73        psFree (chip->toFPA);
     74        chip->toFPA = psPlaneTransformAlloc (order, order);
     75        for (int i = 0; i <= chip->toFPA->x->nX; i++) {
     76            for (int j = 0; j <= chip->toFPA->x->nY; j++) {
     77                if (i + j > order) {
     78                    chip->toFPA->x->coeffMask[i][j] = PS_POLY_MASK_SET;
     79                    chip->toFPA->y->coeffMask[i][j] = PS_POLY_MASK_SET;
     80                }
     81            }
     82        }
    8383    }
    8484
     
    8787    psStats *fitStats = NULL;
    8888//    if (order == 0) {
    89 //      fitStats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV);
    90 //      fitStats->clipSigma = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NSIGMA");
    91 //      fitStats->clipIter = psMetadataLookupS32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NITER");
     89//      fitStats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV);
     90//      fitStats->clipSigma = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NSIGMA");
     91//      fitStats->clipIter = psMetadataLookupS32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NITER");
    9292//    } else {
    93         fitStats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV);
    94         fitStats->clipSigma = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NSIGMA");
    95         fitStats->clipIter = psMetadataLookupS32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NITER");
     93        fitStats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV);
     94        fitStats->clipSigma = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NSIGMA");
     95        fitStats->clipIter = psMetadataLookupS32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NITER");
    9696//    }
    9797
     
    9999    pmAstromFitResults *results = pmAstromMatchFit (chip->toFPA, rawstars, refstars, match, fitStats);
    100100    if (!results) {
    101         psError(PSASTRO_ERR_DATA, false, "failed to perform the matched fit\n");
    102         return false;
     101        psError(PSASTRO_ERR_DATA, false, "failed to perform the matched fit\n");
     102        return false;
    103103    }
    104104
     
    124124    psLogMsg ("psastro", PS_LOG_INFO, "astrometry solution: error: %f arcsec, Nstars: %d", astError, astNstar);
    125125    if ((maxError > 0) && (astError > maxError)) {
    126         psLogMsg("psastro", PS_LOG_INFO, "residual error is too large, failed to find a solution: %f > %f", astError, maxError);
    127         validSolution = false;
     126        psLogMsg("psastro", PS_LOG_INFO, "residual error is too large, failed to find a solution: %f > %f", astError, maxError);
     127        validSolution = false;
    128128    }
    129129    if (astNstar < minNstar) {
    130         psLogMsg("psastro", PS_LOG_INFO, "solution uses too few stars: %d < %d", astNstar, minNstar);
    131         validSolution = false;
     130        psLogMsg("psastro", PS_LOG_INFO, "solution uses too few stars: %d < %d", astNstar, minNstar);
     131        validSolution = false;
    132132    }
    133133
     
    136136    psMetadataAddF32 (updates, PS_LIST_TAIL, "CERROR",   PS_META_REPLACE, "astrometry error (arcsec)", astError);
    137137    if (validSolution) {
    138         psMetadataAddF32 (updates, PS_LIST_TAIL, "CPRECISE", PS_META_REPLACE, "astrometry precision (arcsec)", astError/sqrt(astNstar));
    139         psMetadataAddS32 (updates, PS_LIST_TAIL, "NASTRO",   PS_META_REPLACE, "number of astrometry stars", astNstar);
     138        psMetadataAddF32 (updates, PS_LIST_TAIL, "CPRECISE", PS_META_REPLACE, "astrometry precision (arcsec)", astError/sqrt(astNstar));
     139        psMetadataAddS32 (updates, PS_LIST_TAIL, "NASTRO",   PS_META_REPLACE, "number of astrometry stars", astNstar);
    140140    } else {
    141         psMetadataAddF32 (updates, PS_LIST_TAIL, "CPRECISE", PS_META_REPLACE, "astrometry precision (arcsec)", 0.0);
    142         psMetadataAddS32 (updates, PS_LIST_TAIL, "NASTRO",   PS_META_REPLACE, "number of astrometry stars", 0);
     141        psMetadataAddF32 (updates, PS_LIST_TAIL, "CPRECISE", PS_META_REPLACE, "astrometry precision (arcsec)", 0.0);
     142        psMetadataAddS32 (updates, PS_LIST_TAIL, "NASTRO",   PS_META_REPLACE, "number of astrometry stars", 0);
    143143    }
    144144    psMetadataAddF32 (updates, PS_LIST_TAIL, "EQUINOX",  PS_META_REPLACE, "", 2000.0); // XXX this is bogus: should be defined based on equinox of refstars
     
    147147    psastroUpdateChipToFPA (fpa, chip, rawstars, refstars);
    148148
     149    //plot results
     150    psastroVisualPlotMosaicOneChip(rawstars, refstars, match, recipe);
     151
    149152    psFree (fitStats);
    150153    psFree (results);
Note: See TracChangeset for help on using the changeset viewer.