IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19386


Ignore:
Timestamp:
Sep 5, 2008, 7:46:30 AM (18 years ago)
Author:
eugene
Message:

write dump files to OUTPUT.N.dat

Location:
trunk/psastro/src
Files:
2 edited

Legend:

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

    r19309 r19386  
    1414    pmFPAfile *output = psMetadataLookupPtr (&status, config->files, "PSASTRO.OUT.MODEL");
    1515    if (!status) psAbort ("Can't find output pmFPAfile PSASTRO.OUT.MODEL");
     16
     17    char *outroot = psMetadataLookupStr (&status, config->arguments, "OUTPUT");
     18    if (!status || !outroot) psAbort ("Can't find outroot on config->arguments");
    1619
    1720    // physical pixel scale in microns per pixel
     
    5861    output->fpa = NULL;
    5962
     63    char filename[256];
     64    snprintf (filename, 256, "%s.bore", outroot);
     65    FILE *outfile = fopen (filename, "w");
     66    if (!outfile) {
     67        psError(PSASTRO_ERR_ARGUMENTS, true, "cannot open %s for output", filename);
     68        return false;
     69    }
     70
     71    float posBoundary = 0.0;
     72
    6073    // extract the relevant measured and reported values from the reference chip
    6174    for (int i = 0; i < files->n; i++) {
     
    8093
    8194        // we have two measurements of the posangle (may be parity flipped to different quadrants)
     95        // atan2 returns values in the range 0-2pi
     96        // all posZero values should be clustered in some region, but we need to flip over the 0,360 boundary correctly.
     97        // push all to one side or the other
    8298        float posangle = PM_DEG_RAD * atan2 (chip->toFPA->y->coeff[1][0], chip->toFPA->x->coeff[1][0]);
    8399        posZero->data.F32[n] = POSANGLE - posangle;
    84         while (posZero->data.F32[n] > 360.0) posZero->data.F32[n] -= 360.0;
    85         while (posZero->data.F32[n] <   0.0) posZero->data.F32[n] += 360.0;
     100        if (n == 0) {
     101            posBoundary = posZero->data.F32[n] + 180.0;
     102        } else {
     103            while (posZero->data.F32[n] > posBoundary) posZero->data.F32[n] -= 360.0;
     104            while (posZero->data.F32[n] < posBoundary - 360.0) posZero->data.F32[n] += 360.0;
     105        }
    86106
    87107        Po->data.F32[n] = POSANGLE * PM_RAD_DEG; // reported position angle
    88108        Xo->data.F32[n] = chip->fromFPA->x->coeff[0][0]; // reported boresite x position in ref chip coordinates
    89109        Yo->data.F32[n] = chip->fromFPA->y->coeff[0][0]; // reported boresite y position in ref chip coordinates
    90         fprintf (stderr, "%d : %f %f : %f = %f - %f\n", i, Xo->data.F32[n], Yo->data.F32[n], posZero->data.F32[n], POSANGLE, posangle);
     110        fprintf (outfile, "%d : %f %f : %f = %f - %f\n", i, Xo->data.F32[n], Yo->data.F32[n], posZero->data.F32[n], POSANGLE, posangle);
    91111        n ++;
    92112    }
     
    100120    psVectorStats (stats, posZero, NULL, NULL, 0);
    101121
    102     fprintf (stderr, "pos zero %f +/- %f\n", stats->sampleMedian, stats->sampleStdev);
     122    fprintf (outfile, "# pos zero %f +/- %f\n", stats->sampleMedian, stats->sampleStdev);
    103123    psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.POS_ZERO", PS_META_REPLACE, "offset between obs and meas posangle", stats->sampleMedian);
     124    fclose (outfile);
    104125
    105     psVector *params = psastroModelFitBoresite (Xo, Yo, Po);
     126    psVector *params = psastroModelFitBoresite (Xo, Yo, Po, outroot);
    106127    if (params->n != 6) psAbort ("error");
     128
    107129
    108130    psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.X0", PS_META_REPLACE, "boresite parameter", params->data.F32[PAR_X0]);
  • trunk/psastro/src/psastroMosaicAstrom.c

    r19310 r19386  
    22# define NONLIN_TOL 0.001 /* tolerance in pixels */
    33
    4 bool psastroMosaicFit (pmFPA *fpa, psMetadata *recipe, int pass);
     4bool psastroMosaicFit (pmFPA *fpa, psMetadata *recipe, const char *rootname, int pass);
    55
    66// XXX require this fpa to have multiple chip extensions and a PHU?
    77bool psastroMosaicAstrom (pmConfig *config) {
    88
     9    bool status;
     10    char filename[256];
     11
    912    // select the current recipe
    10     psMetadata *recipe  = psMetadataLookupPtr (NULL, config->recipes, PSASTRO_RECIPE);
     13    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSASTRO_RECIPE);
    1114    if (!recipe) {
    1215        psError(PSASTRO_ERR_CONFIG, false, "Can't find PSASTRO recipe!\n");
     
    3639    # endif
    3740
    38     if (!psastroMosaicFit (fpa, recipe, 0)) return false;
    39     if (!psastroMosaicFit (fpa, recipe, 1)) return false;
    40     if (!psastroMosaicFit (fpa, recipe, 2)) return false;
    41     if (!psastroMosaicFit (fpa, recipe, 3)) return false;
     41    char *outroot = psMetadataLookupStr (&status, config->arguments, "OUTPUT");
     42    if (!status || !outroot) psAbort ("Can't find outroot on config->arguments");
     43
     44    if (!psastroMosaicFit (fpa, recipe, outroot, 0)) return false;
     45    if (!psastroMosaicFit (fpa, recipe, outroot, 1)) return false;
     46    if (!psastroMosaicFit (fpa, recipe, outroot, 2)) return false;
     47    if (!psastroMosaicFit (fpa, recipe, outroot, 3)) return false;
    4248
    4349    // now fit the chips under the common distortion with higher-order terms
     
    5157        return false;
    5258    }
    53     if (psTraceGetLevel("psastro.dump") > 0) { psastroDumpMatches (fpa, "match.10.dat"); }
     59    if (psTraceGetLevel("psastro.dump") > 0) {
     60        snprintf (filename, 256, "%s.10.dat", outroot);
     61        psastroDumpMatches (fpa, filename);
     62    }
    5463
    5564    // save WCS and analysis metadata in update header.
     
    8493// 2: match 6,7
    8594// 3: match 8,9
    86 bool psastroMosaicFit (pmFPA *fpa, psMetadata *recipe, int pass) {
     95bool psastroMosaicFit (pmFPA *fpa, psMetadata *recipe, const char *rootname, int pass) {
    8796
    88     char filename[16];
     97    char filename[256];
    8998
    9099    // given the existing per-chip astrometry, determine matches between raw and ref stars
     
    95104    }
    96105
    97     if ((pass == 0) && (psTraceGetLevel("psastro.dump.psastroMosaicAstrom") > 0)) { psastroDumpMatches (fpa, "match.0.dat"); }
     106    if ((pass == 0) && (psTraceGetLevel("psastro.dump.psastroMosaicAstrom") > 0)) {
     107        snprintf (filename, 256, "%s.0.dat", rootname);
     108        psastroDumpMatches (fpa, filename);
     109    }
    98110
    99111    // fitted chips will follow the local plate-scale, hiding the distortion
     
    105117    }
    106118
    107     if ((pass == 0) && (psTraceGetLevel("psastro.dump.psastroMosaicAstrom") > 0)) { psastroDumpMatches (fpa, "match.1.dat"); }
     119    if ((pass == 0) && (psTraceGetLevel("psastro.dump.psastroMosaicAstrom") > 0)) {
     120        snprintf (filename, 256, "%s.1.dat", rootname);
     121        psastroDumpMatches (fpa, filename);
     122    }
    108123
    109124    // fit the distortion by fitting its gradient
     
    115130    }
    116131
    117     snprintf (filename, 16, "match.%d.dat", 2*pass + 2);
     132    snprintf (filename, 256, "%s.%d.dat", rootname, 2*pass + 2);
    118133    if (psTraceGetLevel("psastro.dump.psastroMosaicAstrom") > 0) { psastroDumpMatches (fpa, filename); }
    119134   
     
    124139    }
    125140
    126     snprintf (filename, 16, "match.%d.dat", 2*pass + 3);
     141    snprintf (filename, 256, "%s.%d.dat", rootname, 2*pass + 3);
    127142    if (psTraceGetLevel("psastro.dump.psastroMosaicAstrom") > 0) { psastroDumpMatches (fpa, filename); }
    128143
Note: See TracChangeset for help on using the changeset viewer.