IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30936


Ignore:
Timestamp:
Mar 16, 2011, 3:42:31 PM (15 years ago)
Author:
eugene
Message:

merge psphotImageLoop, psphotForcedImageLoop, and psphotMakePSFImageLoop

Location:
branches/eam_branches/ipp-20110213/psphot/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110213/psphot/src/Makefile.am

    r30749 r30936  
    6969        psphotForced.c             \
    7070        psphotForcedArguments.c    \
    71         psphotForcedImageLoop.c    \
    72         psphotForcedReadout.c      \
    7371        psphotParseCamera.c        \
     72        psphotImageLoop.c          \
    7473        psphotMosaicChip.c         \
    7574        psphotCleanup.c
     
    7978        psphotMakePSF.c            \
    8079        psphotMakePSFArguments.c   \
    81         psphotMakePSFImageLoop.c   \
    82         psphotMakePSFReadout.c     \
    8380        psphotParseCamera.c        \
     81        psphotImageLoop.c   \
    8482        psphotMosaicChip.c         \
    8583        psphotCleanup.c
     
    128126        psphotReadoutForcedKnownSources.c    \
    129127        psphotReadoutMinimal.c         \
     128        psphotForcedReadout.c          \
     129        psphotMakePSFReadout.c         \
    130130        psphotModelBackground.c        \
    131131        psphotMaskBackground.c         \
  • branches/eam_branches/ipp-20110213/psphot/src/psphot.c

    r24144 r30936  
    11# include "psphotStandAlone.h"
     2# define FORCED_PHOTOMETRY 0
    23
    34int main (int argc, char **argv) {
     
    2021
    2122    // call psphot for each readout
    22     if (!psphotImageLoop (config)) {
     23    if (!psphotImageLoop (config, PSPHOT_SINGLE)) {
    2324        psErrorStackPrint(stderr, "Error in the psphot image loop\n");
    2425        exit (psphotGetExitStatus());
  • branches/eam_branches/ipp-20110213/psphot/src/psphot.h

    r30903 r30936  
    1414
    1515# define READOUT_OR_INTERNAL(VIEW,FILE)((FILE)->mode == PM_FPA_MODE_INTERNAL) ? (FILE)->readout : pmFPAviewThisReadout((VIEW), (FILE)->fpa)
     16
     17typedef enum {
     18    PSPHOT_SINGLE,
     19    PSPHOT_FORCED,
     20    PSPHOT_MAKE_PSF,
     21} psphotImageLoopMode;
    1622
    1723// top-level psphot functions
     
    2329bool            psphotVersionHeaderFull(psMetadata *header);
    2430void            psphotVersionPrint(void);
     31
     32bool            psphotImageLoop (pmConfig *config, psphotImageLoopMode mode);
    2533
    2634bool            psphotModelTest (pmConfig *config, const pmFPAview *view, psMetadata *recipe);
     
    311319
    312320pmConfig *psphotForcedArguments(int argc, char **argv);
    313 bool psphotForcedImageLoop (pmConfig *config);
    314321bool psphotForcedReadout(pmConfig *config, const pmFPAview *view, const char *filerule);
    315322
    316323pmConfig *psphotMakePSFArguments(int argc, char **argv);
    317 bool psphotMakePSFImageLoop (pmConfig *config);
    318324bool psphotMakePSFReadout(pmConfig *config, const pmFPAview *view, const char *filerule);
    319325
  • branches/eam_branches/ipp-20110213/psphot/src/psphotForced.c

    r25981 r30936  
    11# include "psphotStandAlone.h"
     2# define FORCED_PHOTOMETRY 1
    23
    34int main (int argc, char **argv) {
     
    2021
    2122    // call psphot for each readout
    22     if (!psphotForcedImageLoop (config)) {
     23    if (!psphotImageLoop (config, PSPHOT_FORCED)) {
    2324        psErrorStackPrint(stderr, "Error in the psphot image loop\n");
    2425        exit (psphotGetExitStatus());
  • branches/eam_branches/ipp-20110213/psphot/src/psphotForcedImageLoop.c

    r29936 r30936  
    11# include "psphotStandAlone.h"
    22
    3 # define ESCAPE(MESSAGE) { \
    4   psError(PSPHOT_ERR_DATA, false, MESSAGE); \
    5   psFree (view); \
    6   return false; \
    7 }
     3# define ESCAPE(MESSAGE) {                              \
     4        psError(PSPHOT_ERR_DATA, false, MESSAGE);       \
     5        psFree (view);                                  \
     6        return false;                                   \
     7    }
    88
    99bool psphotForcedImageLoop (pmConfig *config) {
     
    3131    if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE ("failed input for fpa in psphot.");
    3232
     33    // select the appropriate recipe information
     34    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
     35    psAssert (recipe, "missing recipe?");
     36
     37    psImageMaskType maskTest = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");
     38
    3339    // for psphot, we force data to be read at the chip level
    3440    while ((chip = pmFPAviewNextChip (view, load->fpa, 1)) != NULL) {
     
    4551        // mosaic the cells of a chip into a single contiguous (trimmed) chip
    4652        if (!psphotMosaicChip(config, view, "PSPHOT.INPUT", "PSPHOT.LOAD")) ESCAPE ("Unable to mosaic chip.");
     53
     54        // Read WCS if easy.
     55        // XXX Since we're mosaicking cells, we ignore the case where the WCS is defined for a cell.
     56        {
     57            pmChip *inChip = pmFPAviewThisChip(view, input->fpa); // Mosaicked chip
     58            pmHDU *hduLow = pmHDUGetLowest(input->fpa, inChip, NULL);
     59            if (hduLow && !pmAstromReadWCS(input->fpa, inChip, hduLow->header, 1.0)) {
     60                psWarning("Unable to read WCS astrometry from header.");
     61                psErrorClear();
     62                pmHDU *hduHigh = pmHDUGetHighest(input->fpa, inChip, NULL);
     63                if (hduHigh && hduHigh != hduLow &&
     64                    !pmAstromReadWCS(input->fpa, chip, hduHigh->header, 1.0)) {
     65                    psWarning("Unable to read WCS astrometry from primary header.");
     66                    psErrorClear();
     67                }
     68            }
     69        }
    4770
    4871        // try to load other supporting data (PSF, SRC, etc).
     
    7699                if (readout->mask) {
    77100                    psImageMaskType maskSat = pmConfigMaskGet("SAT", config); // Mask value for saturated pixels
    78                     if (!pmReadoutMaskNonfinite(readout, maskSat)) {
     101                    if (!pmReadoutMaskInvalid(readout, maskTest, maskSat)) {
    79102                        psError(psErrorCodeLast(), false, "Unable to mask non-finite pixels.");
    80103                        psFree(view);
     
    91114            }
    92115
     116            // drop all versions of the internal files
    93117            status = true;
    94118            status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL");
  • branches/eam_branches/ipp-20110213/psphot/src/psphotImageLoop.c

    r29936 r30936  
    11# include "psphotStandAlone.h"
    22
    3 # define ESCAPE(MESSAGE) { \
    4   psError(PSPHOT_ERR_DATA, false, MESSAGE); \
    5   psFree (view); \
    6   return false; \
    7 }
     3# define ESCAPE(MESSAGE) {                              \
     4        psError(PSPHOT_ERR_DATA, false, MESSAGE);       \
     5        psFree (view);                                  \
     6        return false;                                   \
     7    }
    88
    9 bool psphotImageLoop (pmConfig *config) {
     9bool psphotImageLoop (pmConfig *config, psphotImageLoopMode mode) {
    1010
    1111    bool status;
     
    9090
    9191                // Update the header
    92                 {
    93                     pmHDU *hdu = pmHDUGetHighest(input->fpa, chip, cell);
    94                     if (hdu && hdu != lastHDU) {
    95                         psphotVersionHeaderFull(hdu->header);
    96                         lastHDU = hdu;
    97                     }
     92                pmHDU *hdu = pmHDUGetHighest(input->fpa, chip, cell);
     93                if (hdu && hdu != lastHDU) {
     94                    psphotVersionHeaderFull(hdu->header);
     95                    lastHDU = hdu;
    9896                }
    9997
     
    109107
    110108                // run the actual photometry analysis on this chip/cell/readout
    111                 if (!psphotReadout (config, view, "PSPHOT.INPUT")) {
    112                     psError(psErrorCodeLast(), false, "failure in psphotReadout for chip %d, cell %d, readout %d\n", view->chip, view->cell, view->readout);
    113                     psFree (view);
    114                     return false;
    115                 }
     109                switch (mode) {
     110                  case PSPHOT_SINGLE:
     111                    if (!psphotReadout (config, view, "PSPHOT.INPUT")) {
     112                        psError(psErrorCodeLast(), false, "failure in psphotReadout for chip %d, cell %d, readout %d\n", view->chip, view->cell, view->readout);
     113                        psFree (view);
     114                        return false;
     115                    }
     116                    break;
     117                  case PSPHOT_FORCED:
     118                    if (!psphotForcedReadout (config, view, "PSPHOT.INPUT")) {
     119                        psError(psErrorCodeLast(), false, "failure in psphotReadout for chip %d, cell %d, readout %d\n", view->chip, view->cell, view->readout);
     120                        psFree (view);
     121                        return false;
     122                    }
     123                    break;
     124                  case PSPHOT_MAKE_PSF:
     125                    if (!psphotMakePSFReadout (config, view, "PSPHOT.INPUT")) {
     126                        psError(psErrorCodeLast(), false, "failure in psphotReadout for chip %d, cell %d, readout %d\n", view->chip, view->cell, view->readout);
     127                        psFree (view);
     128                        return false;
     129                    }
     130                    break;
     131                }
    116132            }
    117133
  • branches/eam_branches/ipp-20110213/psphot/src/psphotMakePSF.c

    r25982 r30936  
    2020
    2121    // call psphot for each readout
    22     if (!psphotMakePSFImageLoop (config)) {
     22    if (!psphotImageLoop (config, PSPHOT_MAKE_PSF)) {
    2323        psErrorStackPrint(stderr, "Error in the psphot image loop\n");
    2424        exit (psphotGetExitStatus());
  • branches/eam_branches/ipp-20110213/psphot/src/psphotStandAlone.h

    r23487 r30936  
    1414pmConfig       *psphotArguments (int argc, char **argv);
    1515bool            psphotParseCamera (pmConfig *config);
    16 bool            psphotImageLoop (pmConfig *config);
    1716bool            psphotMosaicChip(pmConfig *config, const pmFPAview *view, char *outFile, char *inFile);
    1817void            psphotCleanup (pmConfig *config);
Note: See TracChangeset for help on using the changeset viewer.