IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 24, 2006, 3:56:53 PM (20 years ago)
Author:
eugene
Message:

finished up the mosaic astrometry code

File:
1 edited

Legend:

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

    r10613 r10830  
    11# include "psastro.h"
    22# define RENORM 0
     3
     4// fix this to look up the value in the chip concepts
     5static double getChipPixelScale (pmChip *chip) {
     6    return 10.0;
     7}
     8
     9// I have an FPA structure with multiple chips.  we have loaded or measured astrometry for each
     10// chip with independent pixel/degree scaling values.  These will naturally compensate locally
     11// somewhat for the telescope distortion.  to measure the telescope distortion, we need to
     12// force the chips to have the same pixel scale and measure the difference from that solution.
     13// Convert an FPA with disparate pixel scales to a common pixel scale (perhaps depending on the
     14// chip -- eg, TC3)
     15
     16bool psastroMosaicCommonScale (pmFPA *fpa, psMetadata *recipe) {
     17
     18    // options : use the MIN or MAX chip as global reference or supplied pixel scales
     19    // (microns/pixel), which may depend on the chip
     20
     21    float pixelScaleUse, pixelScale1,  pixelScale2,  pixelScale;
     22
     23    char *option = psMetadataLookupStr (NULL, recipe, "PSASTRO.COMMON.SCALE.OPTION");
     24    if (option == NULL) {
     25        psError(PSASTRO_ERR_DATA, false, "no choice set for common scale option\n");
     26        return false;
     27    }
     28
     29    bool useExternal = true;
     30
     31    // find the min or max scale chip
     32    if (!strcasecmp (option, "MIN") || !strcasecmp (option, "MAX")) {
     33
     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           
     40            pixelScale1 = hypot (chip->toFPA->x->coeff[1][0], chip->toFPA->x->coeff[0][1]);
     41            pixelScale2 = hypot (chip->toFPA->y->coeff[1][0], chip->toFPA->y->coeff[0][1]);
     42            pixelScale = 0.5*(pixelScale1 + pixelScale2);
     43           
     44            pixelScaleUse = (useMax) ? PS_MAX (pixelScale, pixelScaleUse) : PS_MIN (pixelScale, pixelScaleUse);
     45        }
     46        useExternal = false;
     47    }
     48
     49    // rescale each chip by the reference scale
     50    for (int i = 0; i < fpa->chips->n; i++) {
     51        pmChip *chip = fpa->chips->data[i];
     52
     53        psPlaneTransform *toFPA = chip->toFPA;
     54        psPlaneTransform *fromFPA = chip->fromFPA;
     55           
     56        pixelScale1 = hypot (toFPA->x->coeff[1][0], toFPA->x->coeff[0][1]);
     57        pixelScale2 = hypot (toFPA->y->coeff[1][0], toFPA->y->coeff[0][1]);
     58
     59        if (useExternal) {
     60            pixelScaleUse = getChipPixelScale (chip);
     61        }
     62
     63        for (int i = 0; i <= toFPA->x->nX; i++) {
     64            for (int j = 0; j <= toFPA->x->nX; j++) {
     65                toFPA->x->coeff[i][j] *= pixelScaleUse/pixelScale1;
     66                toFPA->y->coeff[i][j] *= pixelScaleUse/pixelScale2;
     67                fromFPA->x->coeff[i][j] *= pixelScale1/pixelScaleUse;
     68                fromFPA->y->coeff[i][j] *= pixelScale2/pixelScaleUse;
     69            }
     70        }
     71
     72    }
     73    return true;
     74}
    375
    476bool psastroUpdateChipToFPA (pmFPA *fpa, pmChip *chip, psArray *rawstars, psArray *refstars) {
     
    1385
    1486        psPlaneTransformApply (raw->FP, chip->toFPA, raw->chip);
    15         psPlaneDistortApply (raw->TP, fpa->toTPA, raw->FP, 0.0, 0.0);
     87        psPlaneTransformApply (raw->TP, fpa->toTPA, raw->FP);
    1688        psDeproject (raw->sky, raw->TP, fpa->toSky);
    1789    }
Note: See TracChangeset for help on using the changeset viewer.