IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6727


Ignore:
Timestamp:
Mar 29, 2006, 11:08:05 AM (20 years ago)
Author:
eugene
Message:

more cleanups, more work on files and views

Location:
trunk/psphot/src
Files:
5 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/Makefile.am

    r6715 r6727  
    3939        psphotGrowthCurve.c     \
    4040        psphotFakeSources.c     \
     41        psphotModelTest.c       \
     42        psphotFitSet.c          \
    4143        psphotCleanup.c         
    42 
    43 junk =  psphotDefinePixels.c    \
    44         pmSourceContour.c       \
    45         pmModelFitSet.c         \
    46         pmSourceFitSet.c        \
    47         psphotModelTest.c       
    4844
    4945noinst_HEADERS =                \
     
    5551tags:
    5652        etags `find . -name \*.[ch] -print`
    57 
    58 #       psphotFullFit.c         
    59 #       psphotApplyPSF.c       
    60 #       psphotFitGalaxies.c
    61 #       psphotLoadPixels.c     
  • trunk/psphot/src/psphot.c

    r6715 r6727  
    2727    exit (0);
    2828}
     29
     30/** I/O test code
     31
     32    psFits *fits = psFitsOpen (argv[1], "r");
     33    psMetadata *header = psFitsReadHeader (NULL, fits);
     34    psFitsClose (fits);
     35
     36    psMetadata *new = psMetadataCopy (NULL, header);
     37    psMetadataConfigWrite (new, "test.cnf");
     38
     39    fits = psFitsOpen ("test.fits", "w");
     40    psFitsWriteHeaderNotImage (fits, new);
     41    psFitsClose (fits);
     42
     43    exit (0);
     44
     45**/
  • trunk/psphot/src/psphot.h

    r6715 r6727  
    4646bool            psphotImageLoop (pmConfig *config);
    4747
    48 bool            psphotModelTest (pmReadout *readout, psMetadata *arguments, psMetadata *recipe);
     48bool            psphotModelTest (pmReadout *readout, psMetadata *recipe);
    4949bool            psphotReadout (pmConfig *config, pmFPAview *view);
    5050void            psphotCleanup (void);
     
    8585// output functions
    8686bool            psphotDumpMoments (psMetadata *config, psArray *sources);
    87 bool            psphotUpdateHeader (psMetadata *header, psMetadata *config);
     87psMetadata     *psphotDefineHeader (psMetadata *config);
    8888
    8989// PSF / DBL / EXT evaluation functions
  • trunk/psphot/src/psphotCleanup.c

    r6715 r6727  
    99    psTimeFinalize ();
    1010    pmConceptsDone ();
    11     fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, stdout, false), "psphot");
     11    fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, NULL, false), "psphot");
     12    // fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, stdout, false), "psphot");
    1213    return;
    1314}
  • trunk/psphot/src/psphotImageLoop.c

    r6715 r6727  
    2828
    2929        while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
    30             continue;
    3130            psLogMsg ("psphot", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    3231            if (! cell->process) { continue; }
     
    3938                if (! readout->data_exists) { continue; }
    4039
    41                 // run a single-model test if desired
    42                 // XXX move this to psphotReadout??
    43                 // psphotModelTest (readout, recipe);
    44 
    4540                // run the actual photometry analysis
    4641                psphotReadout (config, view);
    4742
    4843                pmFPAfileIOChecks (config->files, view, PM_FPA_AFTER);
    49 
    50                 // write out the desired output dataset(s)
    51                 // psphotOutput (view, recipe);
    5244            }
    5345            pmFPAfileIOChecks (config->files, view, PM_FPA_AFTER);
  • trunk/psphot/src/psphotModelTest.c

    r6715 r6727  
    11# include "psphot.h"
    2 # include "psEllipse.h"
    32static char DEFAULT_MODE[] = "EXT";
    43
    5 bool psphotModelTest (pmReadout *readout, recipe) {
     4bool psphotModelTest (pmReadout *readout, psMetadata *recipe) {
    65
    76    bool status;
     
    9796    fprintf (stderr, "sum: %f @ (%f, %f)\n", source->moments->Sum, source->moments->x, source->moments->y);
    9897
    99     EllipseMoments moments;
     98    psEllipseMoments moments;
    10099    moments.x2 = source->moments->Sx;
    101100    moments.y2 = source->moments->Sy;
    102101    moments.xy = source->moments->Sxy;
    103     EllipseAxes axes = EllipseMomentsToAxes (moments);
     102    psEllipseAxes axes = psEllipseMomentsToAxes (moments);
    104103
    105104    fprintf (stderr, "axes: %f @ (%f, %f)\n", axes.theta*180/M_PI, axes.major, axes.minor);
     
    137136
    138137    // list model input shape
    139     EllipseShape shape;
     138    psEllipseShape shape;
    140139    shape.sx  = 1.4 / model->params->data.F32[4];
    141140    shape.sy  = 1.4 / model->params->data.F32[5];
    142141    shape.sxy = model->params->data.F32[6];
    143     axes = EllipseShapeToAxes (shape);
     142    axes = psEllipseShapeToAxes (shape);
    144143
    145144    fprintf (stderr, "guess: %f @ (%f, %f)\n", axes.theta*180/M_PI, axes.major, axes.minor);
     
    152151
    153152    // define the pixels used for the fit
    154     psImageKeepCircle (source->mask, xObj, yObj, RADIUS, "OR", PSPHOT_MASK_MARKED);
     153    psImageKeepCircle (source->mask, xObj, yObj, RADIUS, "OR", PM_SOURCE_MASK_MARKED);
    155154
    156155    char *fitset = psMetadataLookupStr (&status, recipe, "TEST_FIT_SET");
     
    163162
    164163    // measure the source mags
    165     pmSourcePhotometry (&fitMag, &obsMag, model, source->pixels, source->mask);
     164    pmSourcePhotometryModel (&fitMag, model);
     165    pmSourcePhotometryAper  (&obsMag, model, source->pixels, source->mask);
    166166    fprintf (stderr, "ap: %f, fit: %f, apmifit: %f\n", obsMag, fitMag, obsMag - fitMag);
    167167
  • trunk/psphot/src/psphotOutput.c

    r6715 r6727  
    8989}
    9090
    91 bool psphotUpdateHeader (psMetadata *header, psMetadata *config) {
     91// these values are saved in an output header stub - they are added to either the
     92// PHU header (CMP) or the MEF table header (CMF)
     93psMetadata *psphotDefineHeader (psMetadata *recipe) {
     94
     95    psMetadata *header = psMetadataAlloc ();
    9296
    9397    // write necessary information to output header
    94     psMetadataItemTransfer (header, config, "NSTARS");
    95     psMetadataItemTransfer (header, config, "ZERO_PT");
    96     psMetadataItemTransfer (header, config, "APMIFIT");
    97     psMetadataItemTransfer (header, config, "dAPMIFIT");
    98     psMetadataItemTransfer (header, config, "SKYBIAS");
    99     psMetadataItemTransfer (header, config, "PHOTCODE");
     98    psMetadataItemTransfer (header, recipe, "ZERO_PT");
     99    psMetadataItemTransfer (header, recipe, "PHOTCODE");
     100
     101    psMetadataItemTransfer (header, recipe, "APMIFIT");
     102    psMetadataItemTransfer (header, recipe, "DAPMIFIT");
     103    psMetadataItemTransfer (header, recipe, "NAPMIFIT");
     104    psMetadataItemTransfer (header, recipe, "SKYBIAS");
     105    psMetadataItemTransfer (header, recipe, "SKYSAT");
    100106   
    101     // write necessary information to output header
    102     psMetadataItemTransfer (header, config, "NPSFSTAR");
    103     psMetadataItemTransfer (header, config, "SKYBIAS");
    104     psMetadataItemTransfer (header, config, "SKYSAT");
    105     psMetadataItemTransfer (header, config, "APMIFIT");
    106     psMetadataItemTransfer (header, config, "DAPMIFIT");
    107     psMetadataItemTransfer (header, config, "NAPMIFIT");
    108     psMetadataItemTransfer (header, config, "APLOSS");
     107    psMetadataItemTransfer (header, recipe, "NPSFSTAR");
     108    psMetadataItemTransfer (header, recipe, "APLOSS");
    109109
    110110    // XXX these need to be defined from elsewhere
     
    115115    psMetadataAdd (header, PS_LIST_TAIL, "FLIMIT",   PS_DATA_F32 | PS_META_REPLACE, "COMPLETENESS MAG",    0.0);
    116116
    117     return true;
     117    return header;
    118118}
  • trunk/psphot/src/psphotParseCamera.c

    r6715 r6727  
    6262
    6363    pmFPAfileDefine (config->files, format, input, "PSPHOT.OUTPUT");
     64    pmFPAfileDefine (config->files, format, input, "PSPHOT.RESID");
    6465
    65     // pmFPAfileDefine (config->files, format, input, "PSPHOT.RESID");
    6666    // pmFPAfileDefine (config->files, format, input, "PSPHOT.PSF_INPUT");
    6767    // pmFPAfileDefine (config->files, format, input, "PSPHOT.PSF_OUTPUT");
     
    7676
    7777    // psphot is supplied with the output name
     78    // this needs to be better: supply to all output (WRITE) files?
    7879    char *output = psMetadataLookupPtr(&status, config->arguments, "OUTPUT");
     80
    7981    file = psMetadataLookupPtr (&status, config->files, "PSPHOT.OUTPUT");
     82    if (!status) psAbort (__func__, "missing OUTPUT entry");
     83    psMetadataAddStr (file->names, PS_LIST_TAIL, "OUTPUT", 0, "", output);
     84
     85    file = psMetadataLookupPtr (&status, config->files, "PSPHOT.RESID");
    8086    if (!status) psAbort (__func__, "missing OUTPUT entry");
    8187    psMetadataAddStr (file->names, PS_LIST_TAIL, "OUTPUT", 0, "", output);
     
    95101    psMetadataAddStr (recipe, PS_LIST_TAIL, "PHOTCODE", PS_META_NO_REPLACE, "default photcode", "NONE");
    96102    psMetadataAddStr (recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_NO_REPLACE, "default break point", "NONE");
     103    psMetadataAddF32 (recipe, PS_LIST_TAIL, "ZERO_PT", PS_META_NO_REPLACE, "default zero point", 25.00);
    97104
    98105    // Chip selection: if we are using a single chip, select it for each FPA
  • trunk/psphot/src/psphotReadout.c

    r6715 r6727  
    11# include "psphot.h"
    22
    3 // XXX 2006.02.07 : no leaks!
    4 // XXX change 'config' to 'recipe' eventually
     3// XXX 2006.03.28 : no leaks!
    54bool psphotReadout (pmConfig *config, pmFPAview *view) {
    65
     
    1514    pmReadout  *readout = pmFPAviewThisReadout (view, input->fpa);
    1615
    17     sources = psphotFakeSources();
    18     status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES",   PS_DATA_ARRAY,   "psphot sources", sources);
    19     psFree (sources);
    20     return true;
    21 
    2216    // XXX does this need to invoke I/O?
    2317    pmReadoutSetWeights (readout);
     
    2519    // I have a valid mask, now mask in the analysis region of interest
    2620    psphotMaskReadout (readout, recipe);
     21
     22    // run a single-model test if desired
     23    psphotModelTest (readout, recipe);
    2724
    2825    // generate a background model (median, smoothed image)
     
    5552    psphotReplaceUnfit (sources);
    5653
    57     // find remaining peaks after first source subtraction pass
     54    // XXX find remaining peaks after first source subtraction pass
    5855    // psphotFindPeaks ();
    5956
     
    6764    psphotMagnitudes (sources, recipe, psf);
    6865
    69     // update the header with stats results
    70     // XXX need to do this conditionally?
    71     // XXX psMetadata *header = pmReadoutGetHeader (readout);
    72     // XXX psphotUpdateHeader (header, config);
     66    // create an output header with stats results
     67    psMetadata *header = psphotDefineHeader (recipe);
    7368
    74     // XXX make this an option?
    7569    // replace background in residual image
    7670    psphotSkyReplace (config, view);
    7771
    78     // need to do something with the sources, psf, and sky
    79     status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES",   PS_DATA_ARRAY,   "psphot sources", sources);
    80     status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.PSF",       PS_DATA_UNKNOWN, "psphot psf", psf);
    81     // XXX : replace? status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SKY.MEAN",  PS_DATA_F32,     "psphot sky mean", sky->sampleMean);
    82     // XXX : replace? status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SKY.SIGMA", PS_DATA_F32,     "psphot sky stdev", sky->sampleStdev);
     72    // save the results of the analysis
     73    status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY,    "psphot sources", sources);
     74    status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.HEADER",  PS_DATA_METADATA, "header stats", header);
     75    status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.PSF",     PS_DATA_UNKNOWN,  "psphot psf", psf);
    8376
    8477    // free up the local copies of the data
    8578    psFree (psf);
     79    psFree (header);
    8680    psFree (sources);
    8781    psFree (peaks);
     
    8983}
    9084
    91 
    92 // XXX Deprecate or allow these versions?
    93 # if (0)
    94     // select analysis method
    95     char *FITMODE = psMetadataLookupStr (&status, config, "FITMODE");
    96     if (!strcasecmp(FITMODE, "ENSEMBLE")) {
    97         psphotEnsemblePSF (readout, config, sources, psf);
    98     }
    99 
    100     if (!strcasecmp(FITMODE, "FULL")) {
    101         psphotEnsemblePSF (readout, config, sources, psf);
    102         psphotFullFit (readout, config, sources, psf);
    103         psphotReplaceUnfit (sources);
    104         psphotApResid (readout, sources, config, psf);
    105     }
    106 
    107     if (!strcasecmp(FITMODE, "BASIC")) {
    108         psphotApplyPSF (readout, config, sources, psf);
    109         psphotFitExtended (readout, config, sources);
    110     }
    111 
    112 
    113 
    114     psphotSaveImage (NULL, readout->image,  "pixels.fits");
    115     psphotSaveImage (NULL, readout->weight, "weight.fits");
    116     psphotSaveImage (NULL, readout->mask,   "mask.fits");
    117     exit (1);
    118 
    119 # endif
     85    # if (1)
     86    fprintf (stderr, "making fake sources\n");
     87    sources = psphotFakeSources ();
     88    psMetadata *tmp = psMetadataAlloc ();
     89    status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY,    "psphot sources", sources);
     90    status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.HEADER",  PS_DATA_METADATA, "header stats", tmp);
     91    psFree (sources);
     92    psFree (tmp);
     93    return true;
     94    # endif
  • trunk/psphot/src/psphotSkyReplace.c

    r6715 r6727  
    11# include "psphot.h"
    22
     3// XXX make this an option?
    34// in order to  successfully replace the sky, we must define a corresponding file...
    45bool psphotSkyReplace (pmConfig *config, pmFPAview *view) {
Note: See TracChangeset for help on using the changeset viewer.