IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7732


Ignore:
Timestamp:
Jun 28, 2006, 9:33:41 AM (20 years ago)
Author:
eugene
Message:

fixed handing of creating depended output images

File:
1 edited

Legend:

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

    r7582 r7732  
    66{
    77    bool status;
     8    pmFPA *inFPA;
     9    pmFPAfile *file;
    810    psRegion region;
    911    int MAX_SAMPLE_PIXELS;
     12
     13    pmReadout *model = NULL;
     14    pmReadout *readout = NULL;
     15    pmReadout *background = NULL;
     16    pmReadout *backSub = NULL;
    1017
    1118    psTimerStart ("psphot");
     
    3138
    3239    // find the currently selected readout
    33     pmReadout  *readout = pmFPAfileThisReadout (config->files, view, "PSPHOT.INPUT");
     40    file = psMetadataLookupPtr (&status, config->files, "PSPHOT.INPUT");
     41    inFPA = file->fpa;
     42    readout = pmFPAviewThisReadout (view, inFPA);
    3443
    3544    psImage *image = readout->image;
     
    5362
    5463    // select model pixels (from output background model file, or create internal file)
    55     pmReadout *model = pmFPAfileThisReadout (config->files, view, "PSPHOT.BACKMDL");
    56     if (model == NULL) {
    57         // select model pixels, from output background model file, or create
     64    file = psMetadataLookupPtr (&status, config->files, "PSPHOT.BACKMDL");
     65    if (file == NULL) {
     66        // we are not using PSPHOT.BACKMDL as an I/O file: define an internal version
    5867        model = pmFPAfileDefineInternal (config->files, "PSPHOT.BACKMDL", nx, ny, PS_TYPE_F32);
    5968    } else {
    60         // replace the supplied image data with an image of the desired size
    61         psImageRecycle (model->image, nx, ny, PS_TYPE_F32);
     69        // we are using PSPHOT.BACKMDL as an I/O file: select readout or create
     70        model = pmFPAviewThisReadout (view, file->fpa);
     71        if (model == NULL) {
     72            // readout does not yet exist: create from input
     73            pmFPAfileCopyStructureView (file->fpa, inFPA, DX, DY, view);
     74            model = pmFPAviewThisReadout (view, file->fpa);
     75            if (nx != model->image->numCols) psAbort ("psphot", "inconsistent size");
     76            if (ny != model->image->numRows) psAbort ("psphot", "inconsistent size");
     77        }
    6278    }
    6379    psF32 **modelData = model->image->data.F32;
     
    107123
    108124    // select background pixels, from output background file, or create
    109     pmReadout *background = pmFPAfileThisReadout (config->files, view, "PSPHOT.BACKGND");
    110     if (background == NULL) {
     125    file = psMetadataLookupPtr (&status, config->files, "PSPHOT.BACKGND");
     126    if (file) {
     127        // we are using PSPHOT.BACKMDL as an I/O file: select readout or create
     128        background = pmFPAviewThisReadout (view, file->fpa);
     129        if (background == NULL) {
     130            // readout does not yet exist: create from input
     131            pmFPAfileCopyStructureView (file->fpa, inFPA, 1, 1, view);
     132            background = pmFPAviewThisReadout (view, file->fpa);
     133            if (Nx != background->image->numCols) psAbort ("psphot", "inconsistent size");
     134            if (Ny != background->image->numRows) psAbort ("psphot", "inconsistent size");
     135        }
     136    } else {
    111137        background = pmFPAfileDefineInternal (config->files, "PSPHOT.BACKGND", Nx, Ny, PS_TYPE_F32);
    112138    }
     
    118144
    119145    // back-sub image pixels, from output background file (don't create if not requested)
    120     pmReadout *backSub = pmFPAfileThisReadout (config->files, view, "PSPHOT.BACKSUB");
     146    file = psMetadataLookupPtr (&status, config->files, "PSPHOT.BACKSUB");
     147    if (file) {
     148        // we are using PSPHOT.BACKMDL as an I/O file: select readout or create
     149        backSub = pmFPAviewThisReadout (view, file->fpa);
     150        if (backSub == NULL) {
     151            // readout does not yet exist: create from input
     152            pmFPAfileCopyStructureView (file->fpa, inFPA, 1, 1, view);
     153            backSub = pmFPAviewThisReadout (view, file->fpa);
     154        }
     155    }
    121156
    122     // psphotSaveImage (NULL, image, "image.fits");
    123     // psphotSaveImage (NULL, background->image, "back.fits");
    124     // psphotSaveImage (NULL, mask, "mask.fits");
     157# ifdef TESTSAVE
     158    psphotSaveImage (NULL, image, "image.fits");
     159    psphotSaveImage (NULL, background->image, "back.fits");
     160    psphotSaveImage (NULL, mask, "mask.fits");
     161    psphotSaveImage (NULL, model->image, "backmdl.fits");
     162# endif
    125163
    126164    // subtract the background model (save in backSub, if requested)
     
    136174    }
    137175
    138     // if (backSub) psphotSaveImage (NULL, backSub->image, "backsub.fits");
    139     // psphotSaveImage (NULL, model->image, "backmdl.fits");
    140     // psphotSaveImage (NULL, background->image, "backgnd.fits");
     176# ifdef TESTSAVE
     177    psphotSaveImage (NULL, image, "backsub.fits");
     178# endif
    141179
    142180    psLogMsg ("psphot", 3, "subtracted background model: %f sec\n", psTimerMark ("psphot"));
Note: See TracChangeset for help on using the changeset viewer.