IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 29, 2010, 3:55:49 PM (16 years ago)
Author:
eugene
Message:

update merges from trunk

Location:
branches/eam_branches/20100225
Files:
9 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20100225

  • branches/eam_branches/20100225/ppSub/src

    • Property svn:ignore
      •  

        old new  
        1313ppSubErrorCodes.c
        1414ppSubVersionDefinitions.h
         15ppSubConvolve
  • branches/eam_branches/20100225/ppSub/src/Makefile.am

    r24862 r27517  
    1 bin_PROGRAMS = ppSub ppSubKernel
     1bin_PROGRAMS = ppSub ppSubKernel ppSubConvolve
    22
    33if HAVE_SVNVERSION
     
    3434        ppSubData.c                     \
    3535        ppSubErrorCodes.c               \
     36        ppSubExit.c                     \
    3637        ppSubFiles.c                    \
    3738        ppSubLoop.c                     \
     
    5354ppSubKernel_SOURCES =           \
    5455        ppSubKernel.c
     56
     57ppSubConvolve_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSTATS_CFLAGS) $(PSPHOT_CFLAGS) $(PPSUB_CFLAGS)
     58ppSubConvolve_LDFLAGS  = $(PSLIB_LIBS)   $(PSMODULE_LIBS)   $(PPSTATS_LIBS)   $(PSPHOT_LIBS)   $(PPSUB_LIBS)
     59
     60ppSubConvolve_SOURCES =         \
     61        ppSubConvolve.c         \
     62        ppSubExit.c             \
     63        ppSubVersion.c
    5564
    5665noinst_HEADERS = \
  • branches/eam_branches/20100225/ppSub/src/ppSub.c

    r27078 r27517  
    2626    psLibInit(NULL);
    2727    psTimerStart("ppSub");
     28
     29    pmErrorRegister();
     30    ppSubErrorRegister();
     31    psphotErrorRegister();
    2832
    2933    ppSubData *data = NULL;             // Processing data
     
    6367
    6468 die:
    65     if (data && data->stats && data->statsFile) {
    66         psString stats = psMetadataConfigFormat(data->stats); // Statistics to output
    67         if (!stats || strlen(stats) == 0) {
    68             psError(PPSUB_ERR_IO, false, "Unable to format statistics file");
    69         } else if (fprintf(data->statsFile, "%s", stats) != strlen(stats)) {
    70             psError(PPSUB_ERR_IO, true, "Unable to write statistics file");
     69    {
     70        psExit exitValue = ppSubExitCode(PS_EXIT_SUCCESS); // Exit code
     71
     72        if (data && data->stats && data->statsFile) {
     73            psString stats = psMetadataConfigFormat(data->stats); // Statistics to output
     74            if (!stats || strlen(stats) == 0) {
     75                psError(PPSUB_ERR_IO, false, "Unable to format statistics file");
     76            } else if (fprintf(data->statsFile, "%s", stats) != strlen(stats)) {
     77                psError(PPSUB_ERR_IO, true, "Unable to write statistics file");
     78            }
     79            psFree(stats);
     80            if (fclose(data->statsFile) == EOF) {
     81                psError(PPSUB_ERR_IO, true, "Unable to close statistics file");
     82            }
     83            data->statsFile = NULL;
     84            pmConfigRunFilenameAddWrite(data->config, "STATS", data->statsName);
     85            exitValue = ppSubExitCode(exitValue);
    7186        }
    72         psFree(stats);
    73         if (fclose(data->statsFile) == EOF) {
    74             psError(PPSUB_ERR_IO, true, "Unable to close statistics file");
     87
     88        if (config && !ppSubFilesIterateUp(config, PPSUB_FILES_ALL)) {
     89            psError(psErrorCodeLast(), false, "Unable to close files.");
     90            exitValue = ppSubExitCode(exitValue);
     91            pmFPAfileFreeSetStrict(false);
    7592        }
    76         data->statsFile = NULL;
    77         pmConfigRunFilenameAddWrite(data->config, "STATS", data->statsName);
     93
     94        if (data) {
     95            psString dump_file = psMetadataLookupStr(NULL, data->config->arguments, "-dumpconfig");
     96            if (dump_file) {
     97                if (!pmConfigDump(data->config, dump_file)) {
     98                    psError(PPSUB_ERR_IO, false, "Unable to dump configuration.");
     99                    exitValue = ppSubExitCode(exitValue);
     100                }
     101            }
     102            psFree(data);
     103        }
     104
     105        psTrace("ppSub", 1, "Finished at %f sec\n", psTimerMark("ppSub"));
     106        psTimerStop();
     107
     108        pmVisualClose(); //close plot windows, if -visual is set
     109        pmModelClassCleanup();
     110        pmConfigDone();
     111        psLibFinalize();
     112
     113        exitValue = ppSubExitCode(exitValue);
     114        exit(exitValue);
    78115    }
    79 
    80     if (data) {
    81         psString dump_file = psMetadataLookupStr(NULL, data->config->arguments, "-dumpconfig");
    82         if (dump_file) {
    83             if (!pmConfigDump(data->config, dump_file)) {
    84                 psError(PPSUB_ERR_IO, false, "Unable to dump configuration.");
    85             }
    86         }
    87         psFree(data);
    88     }
    89 
    90     psExit exitValue = PS_EXIT_SUCCESS;        // Exit value for program
    91     psErrorCode errorCode = psErrorCodeLast(); // Error code
    92     if (errorCode != PS_ERR_NONE) {
    93         psErrorStackPrint(stderr, "Unable to perform subtraction.");
    94         switch (errorCode) {
    95           case PPSUB_ERR_UNKNOWN:
    96           case PS_ERR_UNKNOWN:
    97             exitValue = PS_EXIT_UNKNOWN_ERROR;
    98             break;
    99           case PS_ERR_IO:
    100           case PS_ERR_DB_CLIENT:
    101           case PS_ERR_DB_SERVER:
    102           case PS_ERR_BAD_FITS:
    103           case PS_ERR_OS_CALL_FAILED:
    104           case PPSUB_ERR_IO:
    105             exitValue = PS_EXIT_SYS_ERROR;
    106             break;
    107           case PS_ERR_BAD_PARAMETER_VALUE:
    108           case PS_ERR_BAD_PARAMETER_TYPE:
    109           case PS_ERR_BAD_PARAMETER_NULL:
    110           case PS_ERR_BAD_PARAMETER_SIZE:
    111           case PPSUB_ERR_ARGUMENTS:
    112           case PPSUB_ERR_CONFIG:
    113             exitValue = PS_EXIT_CONFIG_ERROR;
    114             break;
    115           case PPSUB_ERR_DATA:
    116           case PPSUB_ERR_NO_OVERLAP:
    117             exitValue = PS_EXIT_DATA_ERROR;
    118             break;
    119           case PS_ERR_UNEXPECTED_NULL:
    120           case PS_ERR_PROGRAMMING:
    121           case PPSUB_ERR_NOT_IMPLEMENTED:
    122           case PPSUB_ERR_PROG:
    123           default:
    124             // It's a programming error if we're not dealing with the error correctly
    125             exitValue = PS_EXIT_PROG_ERROR;
    126             break;
    127         }
    128     }
    129 
    130     if (config && !ppSubFilesIterateUp(config, PPSUB_FILES_ALL)) {
    131         psErrorStackPrint(stderr, "Unable to close files.");
    132     }
    133 
    134     psTrace("ppSub", 1, "Finished at %f sec\n", psTimerMark("ppSub"));
    135     psTimerStop();
    136 
    137     pmVisualClose(); //close plot windows, if -visual is set
    138     pmModelClassCleanup();
    139     pmConfigDone();
    140     psLibFinalize();
    141 
    142     exit(exitValue);
    143116}
  • branches/eam_branches/20100225/ppSub/src/ppSub.h

    r26899 r27517  
    165165bool ppSubCopyPSF (pmFPAfile *output, pmFPAfile *input, pmFPAview *view);
    166166
     167/// Return appropriate exit code
     168psExit ppSubExitCode(psExit exitValue   // Current exit value
     169    );
     170
    167171///@}
    168172#endif
  • branches/eam_branches/20100225/ppSub/src/ppSubArguments.c

    r27080 r27517  
    141141    if (data->statsName && strlen(data->statsName) > 0) {
    142142        psString resolved = pmConfigConvertFilename(data->statsName, config, true, true); // Resolved filename
     143        if (!resolved) {
     144            psError(psErrorCodeLast(), false, "Unable to resolve statistics file: %s", data->statsName);
     145            return false;
     146        }
    143147        data->statsFile = fopen(resolved, "w");
    144148        if (!data->statsFile) {
  • branches/eam_branches/20100225/ppSub/src/ppSubFiles.c

    r26899 r27517  
    183183    }
    184184
     185    psFree(view);
     186
     187    // Disable writing of data now that we've written things out
     188    if (files & PPSUB_FILES_CONV) {
     189        pmFPAview *view = ppSubViewReadout(); // View to readout
     190        {
     191            pmReadout *ro = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.CONV");
     192            if (ro) {
     193                ro->data_exists = ro->parent->data_exists = ro->parent->parent->data_exists = false;
     194            }
     195        }
     196        {
     197            pmReadout *ro = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV");
     198            if (ro) {
     199                ro->data_exists = ro->parent->data_exists = ro->parent->parent->data_exists = false;
     200            }
     201        }
     202        psFree(view);
     203    }
     204    if (files & PPSUB_FILES_SUB) {
     205        pmFPAview *view = ppSubViewReadout(); // View to readout
     206        pmReadout *ro = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT");
     207        if (ro) {
     208            ro->data_exists = ro->parent->data_exists = ro->parent->parent->data_exists = false;
     209        }
     210        psFree(view);
     211    }
     212    // Disable writing of data now that we've written things out
     213    if (files & PPSUB_FILES_INV) {
     214        pmFPAview *view = ppSubViewReadout(); // View to readout
     215        pmReadout *ro = pmFPAfileThisReadout(config->files, view, "PPSUB.INVERSE");
     216        if (ro) {
     217            ro->data_exists = ro->parent->data_exists = ro->parent->parent->data_exists = false;
     218        }
     219        psFree(view);
     220    }
     221
    185222    ppSubFilesActivate(config, PPSUB_FILES_ALL, false);
    186223
  • branches/eam_branches/20100225/ppSub/src/ppSubMatchPSFs.c

    r26982 r27517  
    331331    int threads = psMetadataLookupS32(NULL, config->arguments, "-threads"); // Number of threads
    332332    if (threads > 0) {
    333         pmSubtractionThreadsInit(inRO, refRO);
     333        pmSubtractionThreadsInit();
    334334    }
    335335
     
    340340        psImageCovarianceTruncate(refRO->covariance, COVAR_FRAC);
    341341    }
     342
     343    // Data doesn't exist until it's created in pmSubtraction...
     344    inConv->data_exists = inConv->parent->data_exists = inConv->parent->parent->data_exists = false;
     345    refConv->data_exists = refConv->parent->data_exists = refConv->parent->parent->data_exists = false;
    342346
    343347    // Match the PSFs
     
    349353    } else {
    350354        success = pmSubtractionMatch(inConv, refConv, inRO, refRO, footprint, stride, regionSize,
    351                                      spacing, threshold, detections->allSources, data->stamps, type, size, order,
    352                                      widths, orders, inner, ringsOrder, binning, penalty, optimum,
    353                                      optWidths, optOrder, optThresh, iter, rej, normFrac,
    354                                      sysErr, skyErr, kernelErr, covarFrac, maskVal, maskBad, maskPoor,
    355                                      poorFrac, badFrac, subMode);
     355                                     spacing, threshold, detections ? detections->allSources : NULL,
     356                                     data->stamps, type, size, order, widths, orders, inner, ringsOrder,
     357                                     binning, penalty, optimum, optWidths, optOrder, optThresh, iter, rej,
     358                                     normFrac, sysErr, skyErr, kernelErr, covarFrac,
     359                                     maskVal, maskBad, maskPoor, poorFrac, badFrac, subMode);
    356360    }
    357361
     
    376380
    377381    psFree(optWidths);
    378     pmSubtractionThreadsFinalize(inRO, refRO);
     382    pmSubtractionThreadsFinalize();
    379383
    380384    if (!success) {
  • branches/eam_branches/20100225/ppSub/src/ppSubVarianceRescale.c

    r26982 r27517  
    5454    pmReadout *readout = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT"); // Output image
    5555
     56    if (!readout->variance) {
     57        // Nothing to renormalise
     58        psWarning("Renormalisation of the variance requested, but no variance provided.");
     59        return true;
     60    }
     61
    5662    return pmReadoutVarianceRenormalise(readout, maskBad, num, minValid, maxValid);
    5763}
Note: See TracChangeset for help on using the changeset viewer.