IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 2, 2007, 3:26:52 PM (20 years ago)
Author:
eugene
Message:

fixed mosaic analysis; cleaned up test code (some in traces, some removed), general output cleanups

File:
1 edited

Legend:

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

    r10864 r10880  
    44// XXX require this fpa to have multiple chip extensions and a PHU?
    55bool psastroMosaicAstrom (pmConfig *config, psArray *refs) {
    6 
    7     bool status;
    8     psArray *gradients = NULL;
    96
    107    // select the current recipe
     
    2926
    3027    // given the existing per-chip astrometry, determine matches between raw and ref stars
     28    // is this needed? yes, if we didn't do SingleChip astrometry first
    3129    psastroMosaicSetMatch (fpa, recipe, 0);
     30    if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.0.dat"); }
    3231
    3332    // fitted chips will follow the local plate-scale, hiding the distortion
     
    3534    // then recalculate raw and ref positions
    3635    psastroMosaicCommonScale (fpa, recipe);
    37     psastroMosaicSetAstrom (fpa);
     36    if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.1.dat"); }
    3837
    39     gradients = psastroMosaicGradients (fpa, recipe);
     38    // fit the distortion by fitting its gradient
     39    // apply the new distortion terms up and down
     40    // refit the per-chip terms with linear fits only
     41    psastroMosaicGradients (fpa, recipe);
     42    if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.2.dat"); }
    4043
    41     // allocate mosaic-level polynomial transformation and set masks needed by DVO
    42     int order = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.ORDER");
    43     if (!status) {
    44         psError(PSASTRO_ERR_UNKNOWN, false, "failed to find single-chip fit order\n");
    45         return false;
    46     }
    47     psFree (fpa->toTPA);
    48     fpa->toTPA = psPlaneTransformAlloc (order, order);
    49     for (int i = 0; i <= fpa->toTPA->x->nX; i++) {
    50         for (int j = 0; j <= fpa->toTPA->x->nY; j++) {
    51             if (i + j > order) {
    52                 fpa->toTPA->x->mask[i][j] = 1;
    53                 fpa->toTPA->y->mask[i][j] = 1;
    54             }
    55         }
    56     }
     44    psastroMosaicChipAstrom (fpa, recipe, false);
     45    if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.3.dat"); }
    5746
    58     // fit the measured gradients with the telescope distortion model (polynomial order based on toTPA)
    59     pmAstromFitDistortion (fpa, gradients, recipe);
    60     psFree (gradients);
    61 
    62     // apply the new distortion terms up and down
    6347    // re-perform the match with a slightly tighter circle
    64     // XXX modify match radius
    65     // XXX set chip.order to 1
    66     psastroMosaicSetAstrom_tmp (fpa);
    6748    psastroMosaicSetMatch (fpa, recipe, 1);
    68     psastroMosaicChipAstrom (fpa, recipe, 1);
    6949
    7050    // do a second pass on the distortion with improved chip positions and rotations
    71     // XXX do we need to iterate with this step until the distortions don't change?
    7251    psastroMosaicCommonScale (fpa, recipe);
    73     gradients = psastroMosaicGradients (fpa, recipe);
    74     pmAstromFitDistortion (fpa, gradients, recipe);
    75     psFree (gradients);
     52    psastroMosaicGradients (fpa, recipe);
     53    psastroMosaicChipAstrom (fpa, recipe, false);
     54    psastroMosaicSetMatch (fpa, recipe, 1);
    7655   
    7756    // now fit the chips under the common distortion with higher-order terms
    78     // XXX modify match radius
    79     // XXX set chip.order to NORDER
    80     psastroMosaicSetAstrom (fpa);
    81     psastroMosaicSetMatch (fpa, recipe, 2);
    82     psastroMosaicChipAstrom (fpa, recipe, 2);
     57    // first, re-perform the match with a slightly tighter circle
     58    psastroMosaicChipAstrom (fpa, recipe, true);
    8359
    8460    // save WCS and analysis metadata in update header
    85     // XXX need to add global summary statistics
    8661    psMetadata *updates = psMetadataAlloc();
    8762    pmAstromWriteBilevelMosaic (updates, fpa, NONLIN_TOL);
    88     psMetadataAdd (fpa->analysis, PS_LIST_TAIL, "PSASTRO.HEADER",  PS_DATA_METADATA, "psastro header stats", updates);
     63    psMetadataAddMetadata (fpa->analysis, PS_LIST_TAIL, "PSASTRO.HEADER",  PS_META_REPLACE, "psastro header stats", updates);
    8964    psFree (updates);
    9065
    9166    // update the headers based on the results
     67    // XXX need to add global summary statistics
    9268    // psastroMosaicHeaders (config);
    9369
Note: See TracChangeset for help on using the changeset viewer.