IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 23, 2006, 6:16:11 PM (20 years ago)
Author:
eugene
Message:

fixed some errors with double sources, added second-pass linear PSF fit, multiple-depths

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotOutput.c

    r6379 r6481  
    1111static char *extNameKey = NULL;
    1212static char *extRoot    = NULL;
     13static char *psfFile    = NULL;
     14static char *psfSample  = NULL;
    1315
    1416void psphotOutputCleanup () {
     
    2123    psFree (extNameKey);
    2224    psFree (extRoot);
     25    psFree (psfFile);
     26    psFree (psfSample);
    2327    return;
    2428}
     
    3438    outputMode      = psMetadataLookupStr (&status, config->recipe, "OUTPUT_MODE");
    3539    outputFormat    = psMetadataLookupStr (&status, config->recipe, "OUTPUT_FORMAT");
     40
     41    psfFile         = psMetadataLookupStr (&status, config->recipe, "PSF_OUTPUT_FILE");
     42    psfSample       = psMetadataLookupStr (&status, config->recipe, "PSF_SAMPLE_FILE");
    3643
    3744    // rules to construct output names
     
    7582    }
    7683
     84    // register background image-file names
     85    psphotBackgroundNames (config->arguments);
     86
    7787    // save so freeing config will not drop these references
    7888    psMemCopy (outputRoot);
     
    8393    psMemCopy (extNameKey);
    8494    psMemCopy (extRoot);
     95    psMemCopy (psfFile);
     96    psMemCopy (psfSample);
    8597
    8698    return;
     
    165177    char *outputFile;
    166178
    167     psTimerStart ("psphot");
    168 
    169179    psMetadata *header = pmReadoutGetHeader (readout);
    170180
     
    180190    }
    181191
    182     char *psfFile    = psMetadataLookupStr (&status, arguments, "PSF_OUTPUT_FILE");
    183     char *psfSample  = psMetadataLookupStr (&status, arguments, "PSF_SAMPLE_FILE");
    184192    char *residImage = psMetadataLookupStr (&status, arguments, "RESID_IMAGE");
    185193
     
    236244    psF32 *PAR, *dPAR;
    237245    float dmag, apResid;
     246
     247    psTimerStart ("string");
    238248
    239249    psLine *line = psLineAlloc (104);  // 104 is dophot-defined line length
     
    274284    }
    275285    fclose (f);
     286    psFree (line);
     287    fprintf (stderr, "%f seconds for %d objects with psLine\n", psTimerMark ("string"), (int)sources->n);
     288
     289    psTimerStart ("string");
     290
     291    f = fopen ("test.obj", "w");
     292    if (f == NULL) {
     293        psLogMsg ("WriteSourceOBJ", 3, "can't open output file for output %s\n", "test.obj");
     294        return false;
     295    }
     296
     297    char *string;
     298    // write sources with models
     299    for (int i = 0; i < sources->n; i++) {
     300        pmSource *source = (pmSource *) sources->data[i];
     301        pmModel *model = pmModelSelect (source);
     302        if (model == NULL) continue;
     303
     304        PAR = model->params->data.F32;
     305        dPAR = model->dparams->data.F32;
     306
     307        dmag = dPAR[1] / PAR[1];
     308        type = pmSourceDophotType (source);
     309        apResid = source->apMag - source->fitMag;
     310
     311        string = NULL;
     312        psStringAppend (&string, "%3d",   type);
     313        psStringAppend (&string, "%8.2f", PAR[2]);
     314        psStringAppend (&string, "%8.2f", PAR[3]);
     315        psStringAppend (&string, "%8.3f", source->fitMag);
     316        psStringAppend (&string, "%6.3f", dmag);
     317        psStringAppend (&string, "%9.2f", PAR[0]);
     318        psStringAppend (&string, "%9.3f", PAR[4]);
     319        psStringAppend (&string, "%9.3f", PAR[5]);
     320        psStringAppend (&string, "%7.2f", PAR[6]);
     321        psStringAppend (&string, "%8.3f", 99.999);
     322        psStringAppend (&string, "%8.3f", source->apMag);
     323        psStringAppend (&string, "%8.2f\n", apResid);
     324        fwrite (string, 1, strlen(string), f);
     325        psFree (string);
     326    }
     327    fclose (f);
     328    fprintf (stderr, "%f seconds for %d objects with psString\n", psTimerMark ("string"), (int)sources->n);
     329
    276330    return true;
    277331}
     
    501555    }
    502556
    503    // write sources with models first
     557    // write sources with models first
    504558    for (i = 0; i < sources->n; i++) {
    505559        pmSource *source = (pmSource *) sources->data[i];
     
    525579            fprintf (f, "%9.6f ", dPAR[j]);
    526580        }
    527         fprintf (f, ": %7.4f %2d %#5x %7.3f %7.1f %7.2f %4d %2d\n",
     581        fprintf (f, ": %8.4f %2d %#5x %7.3f %7.1f %7.2f %4d %2d\n",
    528582                 source[0].apMag, source[0].type, source[0].mode,
    529583                 log10(model[0].chisq/model[0].nDOF),
     
    617671           
    618672        if (source->moments == NULL) {
    619           moment = empty;
     673            moment = empty;
    620674        } else {
    621           moment = source->moments;
     675            moment = source->moments;
    622676        }
    623677
Note: See TracChangeset for help on using the changeset viewer.