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/psastroMosaicAstrom.c

    r10815 r10830  
    11# include "psastro.h"
     2# define NONLIN_TOL 0.001 /* tolerance in pixels */
    23
     4// XXX require this fpa to have multiple chip extensions and a PHU?
    35bool psastroMosaicAstrom (pmConfig *config, psArray *refs) {
    46
    57    bool status;
    6     psArray *grads = NULL;
     8    psArray *gradients = NULL;
    79
    810    // select the current recipe
     
    2022    }
    2123
    22     int order = psMetadataLookupF32 (&status, recipe, "PSASTRO.DISTORTION.ORDER");
    23     if (!status) order = 3.0;
    24 
    2524    pmFPA *fpa = input->fpa;
    2625
    27     psastroMosaicSetMatch (fpa, recipe);
     26    // XXX before we do object matches, we need to fix failed chips
     27    // compare chips with supplied mosaic model
     28    // adjust significant outliers to match model
    2829
    29     // XXX no input distortion model yet; existing fpa distortion is identity: replace it
    30     // XXX make this a test if these are NULL; the load step can NULL them if nothing is loaded
    31     // XXX if we have an input distortion model, the gradient is measuring the error rel to that model
    32     // XXX how does this couple to the individual chip fits?
     30    // given the existing per-chip astrometry, determine matches between raw and ref stars
     31    psastroMosaicSetMatch (fpa, recipe, 0);
     32
     33    // fitted chips will follow the local plate-scale, hiding the distortion
     34    // modify the chip->toFPA scaling to match knowledge about pixel scale
     35    psastroMosaicCommonScale (fpa, recipe);
     36
     37    gradients = psastroMosaicGradients (fpa, recipe);
     38
     39    // allocate mosaic-level polynomial transformation and set masks needed by DVO
     40    int order = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.ORDER");
     41    if (!status) {
     42        psError(PSASTRO_ERR_UNKNOWN, false, "failed to find single-chip fit order\n");
     43        return false;
     44    }
    3345    psFree (fpa->toTPA);
    34     psFree (fpa->fromTPA);
    35     fpa->toTPA   = psPlaneDistortIdentity (order);
    36     fpa->fromTPA = psPlaneDistortIdentity (order);
     46    fpa->toTPA = psPlaneTransformAlloc (order, order);
     47    for (int i = 0; i <= fpa->toTPA->x->nX; i++) {
     48        for (int j = 0; j <= fpa->toTPA->x->nY; j++) {
     49            if (i + j > order) {
     50                fpa->toTPA->x->mask[i][j] = 1;
     51                fpa->toTPA->y->mask[i][j] = 1;
     52            }
     53        }
     54    }
    3755
    38     grads = psastroMosaicGetGrads (fpa, recipe);
    39 
    40     // fit the measured gradients with the telescope distortion model (3rd order polynomial)
    41     pmAstromFitDistortion (fpa, grads, recipe);
    42     psastroMosaicRescaleChips (fpa);
     56    // fit the measured gradients with the telescope distortion model (polynomial order based on toTPA)
     57    pmAstromFitDistortion (fpa, gradients, recipe);
     58    psFree (gradients);
    4359
    4460    // apply the new distortion terms up and down
    4561    // re-perform the match with a slightly tighter circle
     62    // XXX modify match radius
     63    // XXX set chip.order to 1
    4664    psastroMosaicSetAstrom (fpa);
    47     psastroMosaicSetMatch (fpa, recipe);
     65    psastroMosaicSetMatch (fpa, recipe, 1);
     66    psastroMosaicChipAstrom (fpa, recipe, 1);
    4867
    49     // fit the chips with linear fits
    50     // re-match
    51     psastroMosaicChipAstrom (fpa, recipe);
    52     psastroMosaicSetMatch (fpa, recipe);
     68    // do a second pass on the distortion with improved chip positions and rotations
     69    // XXX do we need to iterate with this step until the distortions don't change?
     70    psastroMosaicCommonScale (fpa, recipe);
     71    gradients = psastroMosaicGradients (fpa, recipe);
     72    pmAstromFitDistortion (fpa, gradients, recipe);
     73    psFree (gradients);
     74   
     75    // now fit the chips under the common distortion with higher-order terms
     76    // XXX modify match radius
     77    // XXX set chip.order to NORDER
     78    psastroMosaicSetAstrom (fpa);
     79    psastroMosaicSetMatch (fpa, recipe, 2);
     80    psastroMosaicChipAstrom (fpa, recipe, 2);
    5381
    54     // re-fit the chips with higher-order fits
    55     // re-match
    56     psastroMosaicChipAstrom (fpa, recipe);
    57     psastroMosaicSetMatch (fpa, recipe);
     82    // save WCS and analysis metadata in update header
     83    // XXX need to add global summary statistics
     84    psMetadata *updates = psMetadataAlloc();
     85    pmAstromWriteBilevelMosaic (updates, fpa, NONLIN_TOL);
     86    psMetadataAdd (fpa->analysis, PS_LIST_TAIL, "PSASTRO.HEADER",  PS_DATA_METADATA, "psastro header stats", updates);
     87    psFree (updates);
    5888
    59     // re-fit the chips with higher-order fits
    60     psastroMosaicChipAstrom (fpa, recipe);
    61     psastroMosaicHeaders (config);
     89    // update the headers based on the results
     90    // psastroMosaicHeaders (config);
    6291
    6392    return true;
     
    6594
    6695/* coordinate frame hierachy
    67    pixels (on a given readout)
    68    cell
    69    chip
    70    FP (focal plane)
    71    TP (tangent plane)
    72    sky (ra, dec)
    73 */
     96 * pixels (on a given readout)
     97 * cell
     98 * chip
     99 * FP (focal plane)
     100 * TP (tangent plane)
     101 * sky (ra, dec)
     102 */
Note: See TracChangeset for help on using the changeset viewer.