IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12587


Ignore:
Timestamp:
Mar 24, 2007, 8:01:21 AM (19 years ago)
Author:
eugene
Message:

psphot image loop now performs the mosaicing function first

Location:
trunk/psphot/src
Files:
1 added
5 edited

Legend:

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

    r11554 r12587  
    1616        psphotArguments.c       \
    1717        psphotParseCamera.c     \
     18        psphotMosaicChip.c      \
    1819        psphotImageLoop.c       \
    1920        psphotMaskReadout.c     \
  • trunk/psphot/src/psphot.h

    r11583 r12587  
    2424bool            psphotParseCamera (pmConfig *config);
    2525bool            psphotImageLoop (pmConfig *config);
     26bool            psphotMosaicChip(pmConfig *config, const pmFPAview *view, char *outFile, char *inFile);
    2627
    2728bool            psphotModelTest (pmReadout *readout, psMetadata *recipe);
  • trunk/psphot/src/psphotImageLoop.c

    r11310 r12587  
    11# include "psphot.h"
    22
    3 // XXX the errors in the pmFPAfileIOChecks could also be due to a programming or config error
    4 // XXX we need to either handle those errors or handle the error in pmFPAfileIOChecks and exit
    53bool psphotImageLoop (pmConfig *config) {
    64
     
    108    pmReadout *readout;
    119
     10    pmFPAfile *load = psMetadataLookupPtr (&status, config->files, "PSPHOT.LOAD");
     11    if (!status) {
     12        psError(PSPHOT_ERR_PROG, false, "Can't find input data!");
     13        return false;
     14    }
    1215    pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PSPHOT.INPUT");
    1316    if (!status) {
     
    2528    }
    2629
    27     while ((chip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) {
     30    // for psphot, we force data to be read at the chip level
     31    while ((chip = pmFPAviewNextChip (view, load->fpa, 1)) != NULL) {
    2832        psLogMsg ("psphot", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
    2933        if (! chip->process || ! chip->file_exists) { continue; }
     34
     35        // load just the input image data (image, mask, weight)
     36        pmFPAfileActivate (config->files, false, NULL);
     37        pmFPAfileActivate (config->files, true, "PSPHOT.LOAD");
     38        pmFPAfileActivate (config->files, true, "PSPHOT.MASK");
     39        pmFPAfileActivate (config->files, true, "PSPHOT.WEIGHT");
    3040        if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
    3141            psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d in psphot\n", view->chip);
     
    3343            return false;
    3444        }
     45        pmFPAfileActivate (config->files, true, NULL);
    3546       
     47        // mosaic the cells of a chip into a single contiguous chip.
     48        // this probably needs to return a new fpa?
     49        if (!psphotMosaicChip(config, view, "PSPHOT.INPUT", "PSPHOT.LOAD")) {
     50            psError(PS_ERR_UNKNOWN, false, "Unable to mosaic chip.\n");
     51            return false;
     52        }
     53
     54        // try to load the data
     55        if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
     56            psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d in psphot\n", view->chip);
     57            psFree (view);
     58            return false;
     59        }
     60
     61        // there is now only a single chip (multiple readouts?). loop over it and process
     62        // XXX activate / de-activate files? no I/O here?
    3663        while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
    3764            psLogMsg ("psphot", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    38             if (! cell->process || ! cell->file_exists) { continue; }
    39             if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
    40                 psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d in psphot\n", view->chip, view->cell);
    41                 psFree (view);
    42                 return false;
    43             }
     65            // if (! cell->process || ! cell->file_exists) { continue; }
     66            if (! cell->process) { continue; }
    4467           
    4568            // process each of the readouts
    4669            while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
    47                 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
    48                     psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d, readout %d in psphot\n", view->chip, view->cell, view->readout);
    49                     psFree (view);
    50                     return false;
    51                 }
    52                
     70                psLogMsg ("psphot", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    5371                if (! readout->data_exists) { continue; }
    54                
     72
    5573                // run the actual photometry analysis
     74                // XXX calling psphotReadout here will operate on the mosaic'ed chips (for each readout)
    5675                if (!psphotReadout (config, view)) {
    5776                    psError(psErrorCodeLast(), false, "failure in psphotReadout for chip %d, cell %d, readout %d\n", view->chip, view->cell, view->readout);
     
    5978                    return false;
    6079                }
    61 
    62                 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
    63                     psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d, readout %d in psphot\n", view->chip, view->cell, view->readout);
    64                     psFree (view);
    65                     return false;
    66                 }
    67             }
    68             if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
    69                 psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d in psphot\n", view->chip, view->cell);
    70                 psFree (view);
    71                 return false;
    7280            }
    7381        }
     82
     83        // save output which is saved at the chip level
    7484        if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
    7585            psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d in psphot\n", view->chip);
     
    7888        }
    7989    }
     90    // save output which is saved at the fpa level
    8091    if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
    8192        psError(PSPHOT_ERR_DATA, false, "failed IO for fpa in psphot\n");
     
    101112// PSPHOT.PSF     : sample PSF images
    102113
     114// PSPHOT.MASK
     115// PSPHOT.WEIGHT
     116//
  • trunk/psphot/src/psphotImageMedian.c

    r12451 r12587  
    122122    } else {
    123123        if (file->mode == PM_FPA_MODE_INTERNAL) {
     124            // we are not using PSPHOT.BACKMDL as an I/O file: already defined above
    124125            model = file->readout;
    125126        } else {
     
    128129            if (model == NULL) {
    129130                // readout does not yet exist: create from input
     131                // XXX we have an inconsistency in this calculation here and in pmFPACopy
    130132                pmFPAfileCopyStructureView (file->fpa, inFPA, DX, DY, view);
    131133                model = pmFPAviewThisReadout (view, file->fpa);
  • trunk/psphot/src/psphotParseCamera.c

    r12545 r12587  
    66    bool status = false;
    77
    8     // the input image defines the camera
    9     pmFPAfile *input = pmFPAfileDefineFromArgs (&status, config, "PSPHOT.INPUT", "INPUT");
     8    // the file to be loaded may have subdivisions at the cell and readout level
     9    // we load into pmFPAfile *load, then reformat into pmFPAfile *input
     10    pmFPAfile *load = pmFPAfileDefineFromArgs (&status, config, "PSPHOT.LOAD", "INPUT");
    1011    if (!status) {
    11         psError(PSPHOT_ERR_CONFIG, false, "Failed to build FPA from PSPHOT.INPUT");
     12        psError(PSPHOT_ERR_CONFIG, false, "Failed to build FPA from PSPHOT.LOAD");
    1213        return status;
     14    }
     15    load->dataLevel = PM_FPA_LEVEL_CHIP; // force load at the CHIP level
     16
     17    // the psphot analysis is performed on chips
     18    pmFPAfile *input = pmFPAfileDefineChipMosaic(config, input->fpa, "PSPHOT.INPUT");
     19    if (!input) {
     20        psError(PSPHOT_ERR_CONFIG, false, _("Unable to generate new file from PSPHOT.INPUT"));
     21        return NULL;
    1322    }
    1423
    1524    // if we have requested PSPHOT.SRC, attempt to resolve it
     25    // this is a list of input sources, stored in a psphot output format file
     26# if (0)   
    1627    if (psMetadataLookupPtr(NULL, config->arguments, "SRC")) {
    1728        pmFPAfileDefineFromArgs (&status, config, "PSPHOT.SRC", "SRC");
     
    2132        }
    2233    }
     34# endif
    2335
    2436    // select recipe options supplied on command line
    2537    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
    2638
     39    // these values are used below to define the background subtraction images.
     40
    2741    // if MASK or WEIGHT was supplied on command line, bind files to input fpa
    2842    // XXX these do not quite yet work: pmFPAAddSourceFromHeader is not appropriate
    29     pmFPAfileBindFromArgs (NULL, input, config, "PSPHOT.MASK", "MASK");
    30     pmFPAfileBindFromArgs (NULL, input, config, "PSPHOT.WEIGHT", "WEIGHT");
     43    // the mask and weight will be mosaic'ed with the image
     44    pmFPAfileBindFromArgs (NULL, load, config, "PSPHOT.MASK",   "MASK");
     45    pmFPAfileBindFromArgs (NULL, load, config, "PSPHOT.WEIGHT", "WEIGHT");
    3146
    3247    // optionally load the PSF Model and/or fixed stars
    33     pmFPAfileBindFromArgs (NULL, input, config, "PSPHOT.PSF", "PSF");
    34 
    35     // set default recipe values here
    36     // XXX drop this?  we put this in the default recipe?
    37     psMetadataAddStr (recipe, PS_LIST_TAIL, "FITMODE",         PS_META_NO_REPLACE, "default fitting mode", "NONE");
    38     psMetadataAddStr (recipe, PS_LIST_TAIL, "BREAK_POINT",     PS_META_NO_REPLACE, "default break point",  "NONE");
    39     psMetadataAddF32 (recipe, PS_LIST_TAIL, "ZERO_PT",         PS_META_NO_REPLACE, "default zero point",    25.00);
    40     psMetadataAddS32 (recipe, PS_LIST_TAIL, "BACKGROUND.XBIN", PS_META_NO_REPLACE, "default binning",          64);
    41     psMetadataAddS32 (recipe, PS_LIST_TAIL, "BACKGROUND.YBIN", PS_META_NO_REPLACE, "default binning",          64);
    42     psMetadataAddStr (recipe, PS_LIST_TAIL, "PHOTCODE",        PS_META_NO_REPLACE, "default photcode",     "NONE");
    43     // photcode will be added in psphotReadout
     48    // XXX bind this to the input or the load file?
     49    // if the readout->analysis entries are copied, we can bind to the load file
     50    // XXX add this back in later
     51    // pmFPAfileBindFromArgs (NULL, input, config, "PSPHOT.PSF", "PSF");
    4452
    4553    // XXX we need to be able to distinguish several cases:
     
    4957    // 4) the particular output data was requested but was not generated (surprising failure)
    5058
    51     // these calls bind the I/O handle to the specified fpa
    52     bool saveOutput = psMetadataLookupBool (NULL, recipe, "SAVE.OUTPUT");
    53     if (saveOutput) {
     59    // the output sources are carried on the input->fpa structures
     60    if (psMetadataLookupBool (NULL, recipe, "SAVE.OUTPUT")) {
    5461        if (!pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.OUTPUT")) {
    5562            psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.OUTPUT");
     
    5764        }
    5865    }
    59 
    6066    // optionally save the residual image
    6167    if (psMetadataLookupBool(NULL, recipe, "SAVE.RESID")) {
     
    6571        }
    6672    }
    67 
    68     int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND.XBIN");
    69     int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND.YBIN");
    70 
    71     // these calls construct a new fpa for the I/O handle
    72 
    7373    // optionally save the background model (small FITS image)
    7474    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKMDL")) {
     75        int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND.XBIN");
     76        int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND.YBIN");
    7577        if (!pmFPAfileDefineFromFPA (config, input->fpa, DX, DY, "PSPHOT.BACKMDL")) {
    7678            psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKMDL");
Note: See TracChangeset for help on using the changeset viewer.