IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34666


Ignore:
Timestamp:
Nov 15, 2012, 1:32:57 PM (14 years ago)
Author:
watersc1
Message:

Median code completes now, but is saving in the wrong output format.

Location:
branches/czw_branch/20120906/ppStack/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20120906/ppStack/src/Makefile.am

    r30620 r34666  
    1 bin_PROGRAMS = ppStack
     1bin_PROGRAMS = ppStack ppStackMedian
    22
    33if HAVE_SVNVERSION
     
    2525ppStack_LDFLAGS = $(PSLIB_LIBS)   $(PSMODULE_LIBS)   $(PSPHOT_LIBS)   $(PPSTATS_LIBS)   $(PPSTACK_LIBS)
    2626
     27ppStackMedian_CFLAGS    = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PPSTATS_CFLAGS) $(PPSTACK_CFLAGS)
     28ppStackMedian_LDFLAGS = $(PSLIB_LIBS)   $(PSMODULE_LIBS)   $(PSPHOT_LIBS)   $(PPSTATS_LIBS)   $(PPSTACK_LIBS)
     29
    2730ppStack_SOURCES =               \
    2831        ppStack.c               \
     
    4346        ppStackCombinePrepare.c \
    4447        ppStackCombineInitial.c \
     48        ppStackCombineAlternate.c       \
     49        ppStackReject.c         \
     50        ppStackCombineFinal.c   \
     51        ppStackCleanup.c        \
     52        ppStackPhotometry.c     \
     53        ppStackFinish.c         \
     54        ppStackTarget.c         \
     55        ppStackUpdateHeader.c   \
     56        ppStackJPEGs.c          \
     57        ppStackStats.c          \
     58        ppStackErrorCodes.c
     59
     60ppStackMedian_SOURCES =         \
     61        ppStackMedian.c         \
     62        ppStackArguments.c      \
     63        ppStackCamera.c         \
     64        ppStackFiles.c          \
     65        ppStackMedianLoop.c             \
     66        ppStackPSF.c            \
     67        ppStackReadout.c        \
     68        ppStackVersion.c        \
     69        ppStackMatch.c          \
     70        ppStackSources.c        \
     71        ppStackThread.c         \
     72        ppStackOptions.c        \
     73        ppStackSetup.c          \
     74        ppStackPrepare.c        \
     75        ppStackConvolve.c       \
     76        ppStackCombinePrepare.c \
     77        ppStackCombineInitial.c \
     78        ppStackCombineAlternate.c       \
    4579        ppStackReject.c         \
    4680        ppStackCombineFinal.c   \
  • branches/czw_branch/20120906/ppStack/src/ppStack.h

    r34516 r34666  
    3939    PPSTACK_FILES_UNCONV,               // Unconvolved stack files
    4040    PPSTACK_FILES_PHOT,                 // Files for photometry
    41     PPSTACK_FILES_BKG                   // Files for bkg
     41    PPSTACK_FILES_BKG,                  // Files for bkg
     42    PPSTACK_FILES_MEDIAN,                // Files for median only stacks.
     43    PPSTACK_FILES_MINIMAL                // Files for median only stacks.
    4244} ppStackFileList;
    4345
     
    114116// Perform median stacking for background
    115117bool ppStackCombineBackground(ppStackThreadData *stack, ppStackOptions *options, pmConfig *config);
     118bool ppStackCombineMedian(ppStackThreadData *stack, ppStackOptions *options, pmConfig *config);
    116119
    117120// Return software version
  • branches/czw_branch/20120906/ppStack/src/ppStackArguments.c

    r31422 r34666  
    324324    }
    325325
     326   
    326327    psTrace("ppStack", 1, "Done parsing arguments\n");
    327328
  • branches/czw_branch/20120906/ppStack/src/ppStackCleanup.c

    r34623 r34666  
    2222    options->outRO = NULL;
    2323
    24     options->expRO->data_exists = false;
    25     options->expRO->parent->data_exists = false;
    26     options->expRO->parent->parent->data_exists = false;
    27     psFree(options->expRO);
    28     options->expRO = NULL;
     24    if (options->expRO) {
     25      options->expRO->data_exists = false;
     26      if (options->expRO->parent) {
     27        options->expRO->parent->data_exists = false;
     28        options->expRO->parent->parent->data_exists = false;
     29      }
     30      psFree(options->expRO);
     31      options->expRO = NULL;
     32    }
    2933
    3034    if (options->bkgRO) {
    3135      options->bkgRO->data_exists = false;
    32       options->bkgRO->parent->data_exists = false;
    33       options->bkgRO->parent->parent->data_exists = false;
     36      if (options->bkgRO->parent) {
     37        options->bkgRO->parent->data_exists = false;
     38        options->bkgRO->parent->parent->data_exists = false;
     39      }
    3440      psFree(options->bkgRO);
    3541      options->bkgRO = NULL;
  • branches/czw_branch/20120906/ppStack/src/ppStackCombineFinal.c

    r34623 r34666  
    33// This is the doomsday switch.
    44// #define TESTING                         // Enable test output
    5 bool ppStackCombineBackground(ppStackThreadData *stack, ppStackOptions *options, pmConfig *config)
    6 {
    7   psAssert(stack, "Require stack");
    8   psAssert(options, "Require options");
    9   psAssert(config, "Require configuration");
    10 
    11   psTimerStart("PPSTACK_BKGMED");
    12 
    13 
    14   pmReadout *bkgRO = options->bkgRO;
    15  
    16   psArray *inputs  = psArrayAlloc(options->num);
    17   for (int i = 0; i < options->num; i++) {
    18     ppStackFileActivationSingle(config, PPSTACK_FILES_BKG, true, i);
    19     pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT.BKGMODEL", i);
    20     pmFPAview *view = ppStackFilesIterateDown(config);
    21     pmReadout *ro = pmFPAviewThisReadout(view,file->fpa);
    22     inputs->data[i] = ro;
    23     pmFPAfileClose(file,view);
    24   }
    25   if (!pmStackSimpleMedianCombine(bkgRO,inputs)) {
    26     psFree(inputs);
    27     return(false);
    28   }
    29 #if 0
    30   if (!ppStackWriteImage("/tmp/test_forced.bkgmdl.fits",
    31                          bkgRO->parent->parent->parent->hdu->header,
    32                          bkgRO->image,
    33                          config)) {
    34     fprintf(stderr,"Failed to write image because fail.\n");
    35   }
    36 #endif
    37   for (int i = 0; i < options->num; i++) {
    38     pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT.BKGMODEL", i);
    39     pmFPAview *view = ppStackFilesIterateDown(config);
    40     bool success = pmFPAfileClose(file,view);
    41     if (!success) {
    42       psTrace("ppStack",5,"I failed at closing a file.\n");
    43     }
    44              
    45     psFitsClose(file->fits);
    46     file->fits = NULL;
    47     file->header = NULL;
    48     file->state = PM_FPA_STATE_CLOSED;
    49     file->wrote_phu = false;
    50     ppStackFileActivationSingle(config, PPSTACK_FILES_BKG, false, i);
    51   }
    52   psFree(inputs);
    53   bkgRO->data_exists = true;
    54   bkgRO->parent->data_exists = true;
    55   bkgRO->parent->parent->data_exists = true;
    56  
    57   return(true);
    58 }
    59  
    60 
    61 
    625
    636bool ppStackCombineFinal(ppStackThreadData *stack, psArray *covariances, ppStackOptions *options,
  • branches/czw_branch/20120906/ppStack/src/ppStackCombinePrepare.c

    r34623 r34666  
    6262
    6363    }
     64    else {
     65      options->bkgRO = NULL;
     66    }
    6467
    6568    psFree(view);
  • branches/czw_branch/20120906/ppStack/src/ppStackFiles.c

    r34623 r34666  
    1717/// Files required for the background
    1818static char *filesBkg[] = { "PPSTACK.INPUT.BKGMODEL", NULL };
     19
     20/// Files required for median only stacking
     21static char *filesMedian[] =  { "PPSTACK.INPUT",                                                     
     22                              NULL };
     23/// Files required for median only stacking
     24static char *filesMinimal[] =  { "PPSTACK.OUTPUT",                                                           
     25                              NULL };
    1926
    2027/// Regular (convolved) stack files
     
    4653      case PPSTACK_FILES_PHOT:     return filesPhot;
    4754    case PPSTACK_FILES_BKG:        return filesBkg;
     55    case PPSTACK_FILES_MEDIAN:        return filesMedian;
     56    case PPSTACK_FILES_MINIMAL:        return filesMinimal;
    4857      default:
    4958        psAbort("Unrecognised file list: %x", list);
  • branches/czw_branch/20120906/ppStack/src/ppStackLoop.h

    r34516 r34666  
    44// Loop over the inputs, doing the combination
    55bool ppStackLoop(
     6    pmConfig *config,                    // Configuration
     7    ppStackOptions *options             // Options for stacking
     8    );
     9// Median only loop.
     10bool ppStackMedianLoop(
    611    pmConfig *config,                    // Configuration
    712    ppStackOptions *options             // Options for stacking
  • branches/czw_branch/20120906/ppStack/src/ppStackPrepare.c

    r34095 r34666  
    132132    psVectorInit(options->inputMask, 0);
    133133    options->exposures = psVectorAlloc(options->num, PS_TYPE_F32);
     134
    134135    psVectorInit(options->exposures, NAN);
    135136
     
    150151
    151152        options->exposures->data.F32[i] = psMetadataLookupF32(NULL, cell->concepts, "CELL.EXPOSURE");
     153        if ((options->exposures->data.F32[i] == 0)||
     154            (!(isfinite(options->exposures->data.F32[i])))){
     155          options->exposures->data.F32[i] = psMetadataLookupF32(NULL,recipe,"DEFAULT.EXPTIME");
     156        }
    152157        options->sumExposure += options->exposures->data.F32[i];
    153158
  • branches/czw_branch/20120906/ppStack/src/ppStackSetup.c

    r34516 r34666  
    9191    options->bkgImages = psArrayAlloc(num);
    9292    pmFPAview *view = pmFPAviewAlloc(0);
     93    int nullMasks = 0;
     94    int nullVariances = 0;
    9395    for (int i = 0; i < num; i++) {
    9496        {
     
    98100        {
    99101            // We want the convolved mask, since that defines the area that has been tested for outliers
     102          if (options->convolve) {
    100103            options->origMasks->data[i] = psMemIncrRefCounter(options->convMasks->data[i]);
     104          }
     105          else {
     106            pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT.MASK", i);
     107            options->origMasks->data[i] = pmFPAfileName(file, view, config);
     108          }
     109          if (!(options->origMasks->data[i])) {
     110            nullMasks++;
     111          }
    101112        }
    102113        {
    103114            pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT.VARIANCE", i);
    104115            options->origVariances->data[i] = pmFPAfileName(file, view, config);
     116            if (!(options->origVariances->data[i])) {
     117              nullVariances++;
     118            }
    105119        }
    106120/*      { */
     
    109123/*      } */
    110124    }
     125    if (nullMasks == num) {
     126      psFree(options->origMasks);
     127    }
     128    if (nullVariances == num) {
     129      psFree(options->origVariances);
     130    }
     131   
    111132    psFree(view);
    112133
  • branches/czw_branch/20120906/ppStack/src/ppStackThread.c

    r34623 r34666  
    6868        PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, covariances, NULL);
    6969    }
    70 
     70   
    7171    ppStackThreadData *stack = psAlloc(sizeof(ppStackThreadData)); // Thread data, to return
    7272    psMemSetDeallocator(stack, (psFreeFunc)stackThreadDataFree);
     
    9797            psFree(resolved); \
    9898        }
     99        fprintf(stderr,"ppST:99 %s %s\n",pmConfigConvertFilename(imageNames->data[i], config, false, false),
     100                (char*)imageNames->data[i]);
     101               
    99102        IMAGE_OPEN(imageNames, stack->imageFits, i);
    100         IMAGE_OPEN(maskNames, stack->maskFits, i);
    101         IMAGE_OPEN(varianceNames, stack->varianceFits, i);
     103        if (maskNames) {
     104          IMAGE_OPEN(maskNames, stack->maskFits, i);
     105        }
     106        if (varianceNames) {
     107          IMAGE_OPEN(varianceNames, stack->varianceFits, i);
     108        }
    102109    }
    103110
  • branches/czw_branch/20120906/ppStack/src/ppStackUpdateHeader.c

    r34623 r34666  
    1111    bool wcsDone = false;           // Have we done the WCS?
    1212    for (int i = 0; i < options->num && !wcsDone; i++) {
    13         if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
     13      if ((options->inputMask)&&(options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i])) {
    1414            continue;
    1515        }
     
    127127
    128128    // Copy information into expRO, because it should be there too.
    129     pmHDU *expROhdu = pmHDUFromCell(expRO->parent);
    130     if (!expROhdu->header) {
    131       expROhdu->header = psMetadataAlloc();
     129    if ((expRO)&&(expRO->parent)) {
     130      pmHDU *expROhdu = pmHDUFromCell(expRO->parent);
     131      if (!expROhdu->header) {
     132        expROhdu->header = psMetadataAlloc();
     133      }
     134      expRO->parent->parent->parent->hdu->header = psMetadataCopy(expRO->parent->parent->parent->hdu->header,
     135                                                                  outRO->parent->parent->parent->hdu->header);
     136     
     137      expRO->parent->concepts = psMetadataCopy(expRO->parent->concepts,
     138                                               outRO->parent->concepts);
     139      expRO->parent->parent->concepts = psMetadataCopy(expRO->parent->parent->concepts,
     140                                                       outRO->parent->concepts);
     141      expRO->parent->parent->parent->concepts = psMetadataCopy(expRO->parent->parent->parent->concepts,
     142                                                               outRO->parent->parent->parent->concepts);
    132143    }
    133     expRO->parent->parent->parent->hdu->header = psMetadataCopy(expRO->parent->parent->parent->hdu->header,
    134                                                                 outRO->parent->parent->parent->hdu->header);
    135    
    136     expRO->parent->concepts = psMetadataCopy(expRO->parent->concepts,
    137                                              outRO->parent->concepts);
    138     expRO->parent->parent->concepts = psMetadataCopy(expRO->parent->parent->concepts,
    139                                                      outRO->parent->concepts);
    140     expRO->parent->parent->parent->concepts = psMetadataCopy(expRO->parent->parent->parent->concepts,
    141                                                              outRO->parent->parent->parent->concepts);
    142    
    143144   
    144145    return true;
Note: See TracChangeset for help on using the changeset viewer.