IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 26, 2009, 1:59:32 PM (17 years ago)
Author:
beaumont
Message:

merged with trunk

Location:
branches/cnb_branches/cnb_branch_20090301
Files:
25 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/cnb_branches/cnb_branch_20090301

  • branches/cnb_branches/cnb_branch_20090301/psphot

  • branches/cnb_branches/cnb_branch_20090301/psphot/src

    • Property svn:ignore
      •  

        old new  
        1616polyfitTest
        1717growthTest
         18psphotVersionDefinitions.h
  • branches/cnb_branches/cnb_branch_20090301/psphot/src/Makefile.am

    r23352 r24244  
    11lib_LTLIBRARIES = libpsphot.la
    22
    3 # PSPHOT_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
    4 # PSPHOT_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
    5 # PSPHOT_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
    6 #
    7 # # Force recompilation of psphotVersion.c, since it gets the version information
    8 # psphotVersion.c: FORCE
    9 #       touch psphotVersion.c
    10 # FORCE: ;
     3if HAVE_SVNVERSION
     4PSPHOT_VERSION=`$(SVNVERSION) ..`
     5else
     6PSPHOT_VERSION="UNKNOWN"
     7endif
    118
    12 libpsphot_la_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPSPHOT_VERSION=$(PSPHOT_VERSION) -DPSPHOT_BRANCH=$(PSPHOT_BRANCH) -DPSPHOT_SOURCE=$(SVN_SOURCE)
     9if HAVE_SVN
     10PSPHOT_BRANCH=`$(SVN) info .. | $(SED) -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'`
     11PSPHOT_SOURCE=`$(SVN) info | $(SED) -n -e 's/Repository UUID: // p'`
     12else
     13PSPHOT_BRANCH="UNKNOWN"
     14PSPHOT_SOURCE="UNKNOWN"
     15endif
     16
     17# Force recompilation of psphotVersion.c, since it gets the version information
     18psphotVersion.c: psphotVersionDefinitions.h
     19psphotVersionDefinitions.h: psphotVersionDefinitions.h.in FORCE
     20        -$(RM) psphotVersionDefinitions.h
     21        $(SED) -e "s|@PSPHOT_VERSION@|\"$(PSPHOT_VERSION)\"|" -e "s|@PSPHOT_BRANCH@|\"$(PSPHOT_BRANCH)\"|" -e "s|@PSPHOT_SOURCE@|\"$(PSPHOT_SOURCE)\"|" psphotVersionDefinitions.h.in > psphotVersionDefinitions.h
     22FORCE: ;
     23
     24libpsphot_la_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
    1325libpsphot_la_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
    1426
     
    129141
    130142# Error codes.
    131 BUILT_SOURCES = psphotErrorCodes.h psphotErrorCodes.c
     143BUILT_SOURCES = psphotErrorCodes.h psphotErrorCodes.c psphotVersionDefinitions.h
    132144CLEANFILES = psphotErrorCodes.h psphotErrorCodes.c
    133145EXTRA_DIST = psphotErrorCodes.dat psphotErrorCodes.c.in psphotErrorCodes.h.in \
  • branches/cnb_branches/cnb_branch_20090301/psphot/src/psphot.c

    r23352 r24244  
    11# include "psphotStandAlone.h"
    2 
    3 static void usage (void) {
    4     fprintf (stderr, "USAGE: psphot [-file image(s)] [-list imagelist] (output)\n");
    5     exit (PS_EXIT_CONFIG_ERROR);
    6 }
    72
    83int main (int argc, char **argv) {
     
    149    // load command-line arguments, options, and system config data
    1510    pmConfig *config = psphotArguments (argc, argv);
    16     if (!config) {
    17         psErrorStackPrint(stderr, "Error reading arguments\n");
    18         usage ();
    19     }
     11    assert(config);
    2012
    2113    psphotVersionPrint();
  • branches/cnb_branches/cnb_branch_20090301/psphot/src/psphot.h

    r23594 r24244  
    3131bool            psphotReadoutCleanup (pmConfig *config, pmReadout *readout, psMetadata *recipe, pmDetections *detections, pmPSF *psf, psArray *sources);
    3232bool            psphotDefineFiles (pmConfig *config, pmFPAfile *input);
     33void            psphotFilesActivate(pmConfig *config, bool state);
     34
    3335bool            psphotSetMaskBits (pmConfig *config);
    3436bool            psphotSetMaskRecipe (pmConfig *config, psImageMaskType maskValue, psImageMaskType markValue);
  • branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotApResid.c

    r21519 r24244  
    355355
    356356        if (j > 2) {
    357             bool status = true;
    358             status &= psVectorStats (statsS, dASubset, NULL, mkSubset, 0xff);
    359             status &= psVectorStats (statsM, dMSubset, NULL, mkSubset, 0xff);
    360             if (!status) { psErrorClear (); }
     357            if (!psVectorStats (statsS, dASubset, NULL, mkSubset, 0xff)) {
     358                psError(PS_ERR_UNKNOWN, false, "failure to measure stats");
     359                return false;
     360            }
     361            if (!psVectorStats (statsM, dMSubset, NULL, mkSubset, 0xff)) {
     362                psError(PS_ERR_UNKNOWN, false, "failure to measure stats");
     363                return false;
     364            }
    361365            dSo->data.F32[i] = statsS->robustStdev;
    362366            dMo->data.F32[i] = statsM->sampleMean;
    363367            dRo->data.F32[i] = statsS->robustStdev / statsM->sampleMean;
    364             //      fprintf (stderr, "%d (%d) : sys: %f, phot: %f, rat: %f\n", i, j, dSo->data.F32[i], dMo->data.F32[i], dRo->data.F32[i]);
    365368        } else {
    366369            dSo->data.F32[i] = NAN;
     
    375378    psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN);
    376379    if (!psVectorStats (stats, dRo, NULL, NULL, 0)) {
    377         // XXX better testing of raised error
    378         psErrorClear();
     380        psError(PS_ERR_UNKNOWN, false, "failure to measure stats");
     381        return false;
    379382    }
    380383
  • branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotArguments.c

    r23352 r24244  
    11# include "psphotStandAlone.h"
     2
     3static void writeHelpInfo(const char* program, pmConfig* config, FILE* ofile)
     4{
     5  fprintf(ofile,
     6          "Usage: one of the following\n"
     7          "%s -file fname1[,fname2,...] -mask maskfile1[,maskfile2,...]\n"
     8          "     -variance varfile1[,varfile2,...] OutFileBaseName\n"
     9          "\n"
     10          "%s -list FileNameList [-masklist MaskFileNameList] \n"
     11          "     -variancelist VarFileNameList OutFileBaseName\n"
     12          "\n"
     13          "%s -help\n"
     14          "\n"
     15          "%s -version\n"
     16          "\n"
     17          "where:\n"
     18          "  FileNameList is a text file containing filenames, one per line\n"
     19          "  MaskFileNameList is a text file of mask filenames, one per line\n"
     20          "  VarFileNameList is a text file of variance filenames, one per line\n"
     21          "  OutFileBaseName is the 'root name' for output files\n"
     22          "\n"
     23          "additional options:\n"
     24          "  -modeltest xObj yObj [-model DEFAULT|ModelName] \n"
     25          "        [-fitmode DEFAULT|PSF|CONV] [-fitset FitFileName]\n"
     26          "     Test fit for object at the given coordinates.  ModelName\n"
     27          "     is one of PS_MODEL_GAUSS, PS_MODEL_PGAUSS, PS_MODEL_QGAUSS,\n"
     28          "     PS_MODEL_RGAUSS, PS_MODEL_PS1_V1, or PS_MODEL_SERSIC.\n"
     29          "     FitFileName is a file of x,y,Io triples.\n"
     30          "  -psf PsfFile1[,PsfFile2,...] or -psflist PsfFileNameList\n"
     31          "     specify PSF rather than letting %s estimate it\n"
     32          "  -src SrcFile1[,SrcFile2,...] or -srclist SrcFileNameList\n"
     33          "     specify additional sources for PSF generation\n"
     34          "  -chip nn[,nn,...]\n"
     35          "     select detector chips to process; default is all.\n"
     36          "     Indices correspond to zero-based offset in the FPA metadata table.\n"
     37          "  -photcode PhotoCodeName\n"
     38          "     specify photocode\n"
     39          "  -region RegionString\n"
     40          "     specify analysis region.  String is of form '[x0:x1,y0:y1]'\n"
     41          "     To use this option you must define a default in psphot.config\n"
     42          "  -visual\n"
     43          "     turns on interactive display mode\n"
     44          "  -dumpconfig CfgFileName\n"
     45          "     causes config info to be dumped to the named file.\n"
     46          "  -break NOTHING|BACKMDL|PEAKS|MOMENTS|PSFMODEL|ENSEMBLE|PASS1\n"
     47          "     choose a point at which to exit processing early\n"
     48          "  -nthreads n\n"
     49          "     set number of parallel threads of execution\n"
     50          "  -F OldFileRule ReplacementFileRule\n"
     51          "     change file naming rule; e.g. '-F PSPHOT.OUTPUT PSPHOT.OUT.CMF.MEF'\n"
     52          "  -D name stringval\n"
     53          "     set a string-valued config parameter\n"
     54          "  -Di name intval\n"
     55          "     set an integer-valued config parameter\n"
     56          "  -Df name fval\n"
     57          "     set a float-valued config parameter\n"
     58          "  -Db name boolval\n"
     59          "     set a boolean-valued config parameter\n"
     60          "  -v, -vv, -vvv\n"
     61          "     set increasing levels of verbosity\n"
     62          "  -logfmt FormatString\n"
     63          "     set format string used for log messages\n"
     64          "  -trace Fac Lvl\n"
     65          "     set tracing for facility Fac to integer Lvl, e.g. '-trace err 10'\n"
     66          "  -trace-levels\n"
     67          "     print current trace levels\n",
     68          program,program,program,program,program);
     69    psFree(config);
     70    pmConfigDone();
     71    psLibFinalize();
     72    exit(PS_EXIT_SUCCESS);
     73}
     74
     75static void usage(const char *program,  // Name of the program
     76                  psMetadata *arguments, // Command-line arguments
     77                  pmConfig *config,      // Configuration
     78                  int exitCode
     79                  )
     80{
     81  fprintf(stderr,
     82          "Usage: one of the following\n"
     83          "%s -file fname1[,fname2,...] -mask maskfile1[,maskfile2,...]\n"
     84          "     -variance varfile1[,varfile2,...] OutFileBaseName\n"
     85          "\n"
     86          "%s -list FileNameList [-masklist MaskFileNameList] \n"
     87          "     -variancelist VarFileNameList OutFileBaseName\n"
     88          "\n"
     89          "Try '%s -help' for more options and explanation\n",
     90          program,program,program);
     91    if (exitCode != PS_EXIT_SUCCESS)
     92      psErrorStackPrint(stderr, "Error reading arguments\n");
     93    psFree(config);
     94    pmConfigDone();
     95    psLibFinalize();
     96    exit(exitCode);
     97}
    298
    399pmConfig *psphotArguments(int argc, char **argv) {
     
    5101    int N;
    6102    bool status;
    7 
    8     if (argc == 1) {
    9         psError(PSPHOT_ERR_ARGUMENTS, true, "Too few arguments: %d", argc);
    10         return NULL;
    11     }
    12 
    13     if ((N = psArgumentGet (argc, argv, "-version"))) {
    14         psString version;
    15         version = psphotVersionLong();    fprintf (stdout, "%s\n", version); psFree (version);
    16         version = psModulesVersionLong(); fprintf (stdout, "%s\n", version); psFree (version);
    17         version = psLibVersionLong();     fprintf (stdout, "%s\n", version); psFree (version);
    18         exit (0);
    19     }
    20103
    21104    // load config data from default locations
     
    23106    if (config == NULL) {
    24107        psError(PSPHOT_ERR_CONFIG, false, "Can't read site configuration");
    25         return NULL;
    26     }
     108        exit(PS_EXIT_CONFIG_ERROR);
     109    }
     110
     111    PSARGUMENTS_INSTANTIATE_GENERICS( psphot, config, argc, argv );
    27112
    28113    // save the following additional recipe values based on command-line options
     
    30115    psMetadata *options = pmConfigRecipeOptions (config, PSPHOT_RECIPE);
    31116
    32     // Number of threads
    33     if ((N = psArgumentGet(argc, argv, "-threads"))) {
    34         psArgumentRemove(N, &argc, argv);
    35         int nThreads = atoi(argv[N]);
    36         psMetadataAddS32(config->arguments, PS_LIST_TAIL, "NTHREADS", 0, "number of psphot threads", nThreads);
    37         psArgumentRemove(N, &argc, argv);
    38 
    39         // create the thread pool with number of desired threads, supplying our thread launcher function
    40         psThreadPoolInit (nThreads);
    41     }
    42     psphotSetThreads();
     117    // Number of threads is handled
     118    PSARGUMENTS_INSTANTIATE_THREADSARG( psphot, config, argc, argv )
    43119
    44120    // run the test model (requires X,Y coordinate)
    45121    if ((N = psArgumentGet (argc, argv, "-modeltest"))) {
     122        if (argc<=N+2) {
     123          psError(PSPHOT_ERR_ARGUMENTS, true,
     124                  "Expected to see 2 more arguments; saw %d", argc - 1);
     125          exit(PS_EXIT_CONFIG_ERROR);
     126        }
     127
    46128        psMetadataAddBool (options, PS_LIST_TAIL, "TEST_FIT",   0, "", true);
    47129        psMetadataAddF32  (options, PS_LIST_TAIL, "TEST_FIT_X", 0, "", atof(argv[N+1]));
     
    54136        // specify the modeltest model
    55137        if ((N = psArgumentGet (argc, argv, "-model"))) {
     138            if (argc<=N+1) {
     139              psError(PSPHOT_ERR_ARGUMENTS, true,
     140                      "Expected to see 1 more argument; saw %d", argc - 1);
     141              exit(PS_EXIT_CONFIG_ERROR);
     142            }
    56143            psArgumentRemove (N, &argc, argv);
    57144            psMetadataAddStr (options, PS_LIST_TAIL, "TEST_FIT_MODEL", 0, "", argv[N]);
     
    61148        // specify the test fit mode
    62149        if ((N = psArgumentGet (argc, argv, "-fitmode"))) {
     150            if (argc<=N+1) {
     151              psError(PSPHOT_ERR_ARGUMENTS, true,
     152                      "Expected to see 1 more argument; saw %d", argc - 1);
     153              exit(PS_EXIT_CONFIG_ERROR);
     154            }
    63155            psArgumentRemove (N, &argc, argv);
    64156            psMetadataAddStr (options, PS_LIST_TAIL, "TEST_FIT_MODE", 0, "", argv[N]);
     
    66158        }
    67159        if ((N = psArgumentGet (argc, argv, "-fitset"))) {
     160            if (argc<=N+1) {
     161              psError(PSPHOT_ERR_ARGUMENTS, true,
     162                      "Expected to see 1 more argument; saw %d", argc - 1);
     163              exit(PS_EXIT_CONFIG_ERROR);
     164            }
    68165            psArgumentRemove (N, &argc, argv);
    69166            psMetadataAddStr (options, PS_LIST_TAIL, "TEST_FIT_SET", 0, "", argv[N]);
     
    74171    // photcode : used in output to supplement header data (argument or recipe?)
    75172    if ((N = psArgumentGet (argc, argv, "-photcode"))) {
     173        if (argc<=N+1) {
     174          psError(PSPHOT_ERR_ARGUMENTS, true,
     175                  "Expected to see 1 more argument; saw %d", argc - 1);
     176          exit(PS_EXIT_CONFIG_ERROR);
     177        }
    76178        psArgumentRemove (N, &argc, argv);
    77179        psMetadataAddStr (options, PS_LIST_TAIL, "PHOTCODE", PS_META_REPLACE, "", argv[N]);
     
    87189    // break : used from recipe throughout psphotReadout
    88190    if ((N = psArgumentGet (argc, argv, "-break"))) {
     191        if (argc<=N+1) {
     192          psError(PSPHOT_ERR_ARGUMENTS, true,
     193                  "Expected to see 1 more argument; saw %d", argc - 1);
     194          exit(PS_EXIT_CONFIG_ERROR);
     195        }
    89196        psArgumentRemove (N, &argc, argv);
    90197        psMetadataAddStr (options, PS_LIST_TAIL, "BREAK_POINT", PS_META_REPLACE, "", argv[N]);
    91         psArgumentRemove (N, &argc, argv);
    92     }
    93 
    94     // fitmode : used from recipe throughout psphotReadout
    95     if ((N = psArgumentGet (argc, argv, "-fitmode"))) {
    96         psArgumentRemove (N, &argc, argv);
    97         psMetadataAddStr (options, PS_LIST_TAIL, "FITMODE", PS_META_REPLACE, "", argv[N]);
    98198        psArgumentRemove (N, &argc, argv);
    99199    }
     
    101201    // analysis region : overrides recipe value, used in psphotReadout/psphotEnsemblePSF
    102202    if ((N = psArgumentGet (argc, argv, "-region"))) {
     203        if (argc<=N+1) {
     204          psError(PSPHOT_ERR_ARGUMENTS, true,
     205                  "Expected to see 1 more argument; saw %d", argc - 1);
     206          exit(PS_EXIT_CONFIG_ERROR);
     207        }
    103208        psArgumentRemove (N, &argc, argv);
    104209        psMetadataAddStr (options, PS_LIST_TAIL, "ANALYSIS_REGION", 0, "", argv[N]);
     
    108213    // chip selection is used to limit chips to be processed
    109214    if ((N = psArgumentGet (argc, argv, "-chip"))) {
     215        if (argc<=N+1) {
     216          psError(PSPHOT_ERR_ARGUMENTS, true,
     217                  "Expected to see 1 more argument; saw %d", argc - 1);
     218          exit(PS_EXIT_CONFIG_ERROR);
     219        }
    110220        psArgumentRemove (N, &argc, argv);
    111221        psMetadataAddStr (config->arguments, PS_LIST_TAIL, "CHIP_SELECTIONS", PS_DATA_STRING, "", argv[N]);
     
    121231    pmConfigFileSetsMD (config->arguments, &argc, argv, "SRC",    "-src",    "-srclist");
    122232
     233    if (argc == 1) {
     234        psError(PSPHOT_ERR_ARGUMENTS, true, "Too few arguments: %d", argc);
     235        usage(argv[0], config->arguments, config, PS_EXIT_CONFIG_ERROR);
     236    }
     237
     238    if (psArgumentGet(argc, argv, "-help")
     239        || psArgumentGet(argc, argv, "-h"))
     240      writeHelpInfo(argv[0], config, stdout);
     241     
    123242    // the input file is a required argument; if not found, we will exit
    124243    status = pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list");
    125244    if (!status) {
    126245        psError(PSPHOT_ERR_ARGUMENTS, false, "pmConfigFileSetsMD failed to parse arguments");
    127         return NULL;
     246        usage(argv[0], config->arguments, config, PS_EXIT_CONFIG_ERROR);
    128247    }
    129248
    130249    if (argc != 2) {
    131250        psError(PSPHOT_ERR_ARGUMENTS, true, "Expected to see one more argument; saw %d", argc - 1);
    132         return NULL;
     251        usage(argv[0], config->arguments, config, PS_EXIT_CONFIG_ERROR);
    133252    }
    134253
  • branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotBlendFit.c

    r21519 r24244  
    197197        if (source->type == PM_SOURCE_TYPE_SATURATED) continue;
    198198
    199         // skip DBL second sources (ie, added by psphotFitBlob)
     199        // skip DBL second sources (ie, added by psphotFitBlob
    200200        if (source->mode &  PM_SOURCE_MODE_PAIR) continue;
    201201
  • branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotChoosePSF.c

    r21183 r24244  
    361361
    362362    psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV | PS_STAT_SAMPLE_QUARTILE);
    363     psVectorStats (stats, fwhmMajor, NULL, NULL, 0);
     363    if (!psVectorStats (stats, fwhmMajor, NULL, NULL, 0)) {
     364        psError(PS_ERR_UNKNOWN, false, "failure to measure stats for FWHM MAJOR");
     365        return false;
     366    }
     367
    364368    psMetadataAddF32 (recipe, PS_LIST_TAIL, "FWHM_MAJ",   PS_META_REPLACE, "PSF FWHM Major axis (mean)", stats->sampleMean);
    365369    psMetadataAddF32 (recipe, PS_LIST_TAIL, "FW_MJ_SG",   PS_META_REPLACE, "PSF FWHM Major axis (sigma)", stats->sampleStdev);
     
    367371    psMetadataAddF32 (recipe, PS_LIST_TAIL, "FW_MJ_UQ",   PS_META_REPLACE, "PSF FWHM Major axis (upper quartile)", stats->sampleUQ);
    368372
    369     psVectorStats (stats, fwhmMinor, NULL, NULL, 0);
     373    if (!psVectorStats (stats, fwhmMinor, NULL, NULL, 0)) {
     374        psError(PS_ERR_UNKNOWN, false, "failure to measure stats for FWHM MINOR");
     375        return false;
     376    }
    370377    psMetadataAddF32 (recipe, PS_LIST_TAIL, "FWHM_MIN",   PS_META_REPLACE, "PSF FWHM Minor axis (mean)", stats->sampleMean);
    371378    psMetadataAddF32 (recipe, PS_LIST_TAIL, "FW_MN_SG",   PS_META_REPLACE, "PSF FWHM Minor axis (sigma)", stats->sampleStdev);
  • branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotCleanup.c

    r23594 r24244  
    22
    33void psphotCleanup (pmConfig *config) {
     4
     5    // Dump configuration if requested
     6    bool status;
     7    psString dump_file = psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG");
     8    if (dump_file) {
     9        (void)pmConfigCamerasCull(config,NULL);
     10        (void)pmConfigRecipesCull(config,NULL);
     11        pmConfigDump(config, dump_file);
     12    }
    413
    514    psFree (config);
  • branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotDefineFiles.c

    r14892 r24244  
    11# include "psphotInternal.h"
     2
     3// List of output files
     4static const char *outputFiles[] = { "PSPHOT.OUTPUT", "PSPHOT.RESID", "PSPHOT.BACKMDL",
     5                                     "PSPHOT.BACKMDL.STDEV", "PSPHOT.BACKGND", "PSPHOT.BACKSUB",
     6                                     "PSPHOT.PSF.SAVE", "SOURCE.PLOT.MOMENTS", "SOURCE.PLOT.PSFMODEL",
     7                                     "SOURCE.PLOT.APRESID", NULL };
    28
    39// XXX we need to be able to distinguish several cases:
     
    133139    return true;
    134140}
     141
     142void psphotFilesActivate(pmConfig *config, bool state)
     143{
     144    for (int i = 0; outputFiles[i]; i++) {
     145        if (!pmFPAfileActivate(config->files, state, outputFiles[i])) {
     146            psErrorClear();
     147        }
     148    }
     149
     150    return;
     151}
  • branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotDiagnosticPlots.c

    r21108 r24244  
    4040
    4141    psStats *stats = psStatsAlloc (PS_STAT_MAX | PS_STAT_MIN);
    42     psVectorStats (stats, values, NULL, NULL, 0);
     42    if (!psVectorStats (stats, values, NULL, NULL, 0)) {
     43        psError(PS_ERR_UNKNOWN, false, "failure to measure stats for histogram");
     44        return false;
     45    }
    4346
    4447    psHistogram *histogram = psHistogramAlloc (stats->min, stats->max, 1000);
     
    6366    psStatsInit (stats);
    6467    stats->options = PS_STAT_MAX | PS_STAT_MIN;
    65     psVectorStats (stats, histogram->nums, NULL, NULL, 0);
     68    if (!psVectorStats (stats, histogram->nums, NULL, NULL, 0)) {
     69        psError(PS_ERR_UNKNOWN, false, "failure to measure stats for histogram");
     70        return false;
     71    }
    6672
    6773    // scale the plot to hold the histogram
     
    100106    psStatsInit (stats);
    101107    stats->options = PS_STAT_MAX | PS_STAT_MIN;
    102     psVectorStats (stats, histogram->nums, NULL, NULL, 0);
     108    if (!psVectorStats (stats, histogram->nums, NULL, NULL, 0)) {
     109        psError(PS_ERR_UNKNOWN, false, "failure to measure stats for histogram");
     110        return false;
     111    }
    103112
    104113    // scale the plot to hold the histogram
  • branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotErrorCodes.h.in

    r11308 r24244  
    99 */
    1010typedef enum {
    11     PSPHOT_ERR_BASE = 1300,
     11    PSPHOT_ERR_BASE = 3000,
    1212    PSPHOT_ERR_${ErrorCode},
    1313    PSPHOT_ERR_NERROR
  • branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotImageLoop.c

    r23352 r24244  
    7575                }
    7676
     77                psImageMaskType maskSat = pmConfigMaskGet("SAT", config); // Mask value for saturated pixels
     78                if (!pmReadoutMaskNonfinite(readout, maskSat)) {
     79                    psError(psErrorCodeLast(), false, "Unable to mask non-finite pixels.");
     80                    psFree(view);
     81                    return false;
     82                }
     83
    7784                // run the actual photometry analysis on this chip/cell/readout
    7885                if (!psphotReadout (config, view)) {
  • branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotImageQuality.c

    r20471 r24244  
    8888                     "Number of stars used for IQ measurements", M2->n);
    8989
     90// XXX make this a recipe option
    9091#if (USE_SAMPLE)
    9192    psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV | PS_STAT_SAMPLE_QUARTILE);
  • branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotMakeResiduals.c

    r21366 r24244  
    200200            // measure the robust median to determine a baseline reference value
    201201            *fluxClip = *fluxClipDef;
    202             psVectorStats (fluxClip, fluxes, NULL, fmasks, fmaskVal);
    203             psErrorClear();             // clear (ignore) any outstanding errors
     202            if (!psVectorStats (fluxClip, fluxes, NULL, fmasks, fmaskVal)) {
     203                psError(PSPHOT_ERR_CONFIG, false, "Error calculating residual stats");
     204                return false;
     205            }
     206            if (isnan(fluxClip->robustMedian)) {
     207                resid->Ro->data.F32[oy][ox] = 0.0;
     208                resid->Rx->data.F32[oy][ox] = 0.0;
     209                resid->Ry->data.F32[oy][ox] = 0.0;
     210                resid->mask->data.PM_TYPE_RESID_MASK_DATA[oy][ox] = badMask;
     211                continue;
     212            }
    204213
    205214            // mark input pixels which are more than N sigma from the median
     
    220229                // measure the desired statistic on the unclipped pixels
    221230                *fluxStats = *fluxStatsDef;
    222                 psVectorStats (fluxStats, fluxes, NULL, fmasks, fmaskVal);
    223                 psErrorClear();         // clear (ignore) any outstanding errors
     231                if (!psVectorStats (fluxStats, fluxes, NULL, fmasks, fmaskVal)) {
     232                    psError(PSPHOT_ERR_CONFIG, false, "Error calculating residual stats");
     233                    return false;
     234                }
    224235
    225236                resid->Ro->data.F32[oy][ox] = psStatsGetValue(fluxStats, statOption);
    226237                resid->Rx->data.F32[oy][ox] = resid->Ry->data.F32[oy][ox] = 0.0;
    227                 //resid->variance->data.F32[oy][ox] = fluxStats->sampleStdev;
     238
     239                if (isnan(resid->Ro->data.F32[oy][ox])) {
     240                    resid->Ro->data.F32[oy][ox] = 0.0;
     241                    resid->Rx->data.F32[oy][ox] = 0.0;
     242                    resid->Ry->data.F32[oy][ox] = 0.0;
     243                    resid->mask->data.PM_TYPE_RESID_MASK_DATA[oy][ox] = badMask;
     244                    continue;
     245                }
    228246
    229247                if (fabs(resid->Ro->data.F32[oy][ox]) < pixelSN*fluxStats->sampleStdev/sqrt(nKeep)) {
  • branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotMaskReadout.c

    r23594 r24244  
    3939      psImage *mk = readout->mask;
    4040      for (int j = 0; j < im->numRows; j++) {
    41         for (int i = 0; i < im->numCols; i++) {
    42           if (isfinite(im->data.F32[j][i]) && isfinite(wt->data.F32[j][i])) continue;
    43           mk->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskBad;
    44         }
     41        for (int i = 0; i < im->numCols; i++) {
     42          if (isfinite(im->data.F32[j][i]) && isfinite(wt->data.F32[j][i])) continue;
     43          mk->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskBad;
     44        }
    4545      }
    4646    }
  • branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotModelBackground.c

    r23352 r24244  
    189189
    190190            if (gotX && gotY) {
    191                 psTraceSetLevel ("psLib.math.vectorFittedStats_v4", 6);
    192                 psTraceSetLevel ("psLib.math.vectorRobustStats", 6);
     191                (void) psTraceSetLevel ("psLib.math.vectorFittedStats_v4", 6);
     192                (void) psTraceSetLevel ("psLib.math.vectorRobustStats", 6);
    193193            } else {
    194                 psTraceSetLevel ("psLib.math.vectorFittedStats_v4", 0);
    195                 psTraceSetLevel ("psLib.math.vectorRobustStats", 0);
     194                (void) psTraceSetLevel ("psLib.math.vectorFittedStats_v4", 0);
     195                (void) psTraceSetLevel ("psLib.math.vectorRobustStats", 0);
    196196            }
    197197            # endif
  • branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotReadout.c

    r23594 r24244  
    6161    // display the backsub and backgnd images
    6262    psphotVisualShowBackground (config, view, readout);
    63 
     63   
    6464    // run a single-model test if desired (exits from here if test is run)
    6565    psphotModelTest (config, view, recipe);
  • branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotReadoutCleanup.c

    r20769 r24244  
    99    if (psErrorCodeLast() == PSPHOT_ERR_DATA) {
    1010        psErrorStackPrint(stderr, "Error in the psphot readout analysis");
    11         psErrorClear();
    12     } 
    13     if (psErrorCodeLast() != PS_ERR_NONE) { 
    14         psFree (psf);
    15         psFree (sources);
    16         psFree (detections);
    17         return false;
     11        psErrorClear();
     12    }
     13    if (psErrorCodeLast() != PS_ERR_NONE) {
     14        psFree (psf);
     15        psFree (sources);
     16        psFree (detections);
     17        return false;
    1818    }
    1919
     
    2222        if (!psphotPSFstats (readout, recipe, psf)) {
    2323            psError(PSPHOT_ERR_PROG, false, "Failed to measure PSF shape parameters");
    24             psFree (psf);
    25             psFree (sources);
    26             psFree (detections);
     24            psFree (psf);
     25            psFree (sources);
     26            psFree (detections);
    2727            return false;
    2828        }
     
    3232        if (!psphotMomentsStats (readout, recipe, sources)) {
    3333            psError(PSPHOT_ERR_PROG, false, "Failed to measure Moment shape parameters");
    34             psFree (psf);
    35             psFree (sources);
    36             psFree (detections);
     34            psFree (psf);
     35            psFree (sources);
     36            psFree (detections);
    3737            return false;
    3838        }
    3939    }
     40
     41    // Check to see if the image quality was measured
     42    if (!psf) {
     43        bool mdok;                      // Status of MD lookup
     44        int nIQ = psMetadataLookupS32(&mdok, recipe, "IQ_NSTAR"); // Number of stars for IQ measurement
     45        if (!mdok || nIQ <= 0) {
     46            psError(PSPHOT_ERR_DATA, false, "Unable to measure image quality");
     47            psFree (psf);
     48            psFree (sources);
     49            psFree (detections);
     50            return false;
     51        }
     52    }
     53
    4054
    4155    // write NSTARS to the image header
     
    4862    psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.HEADER",  PS_DATA_METADATA, "header stats", header);
    4963    if (sources) {
    50         psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "psphot sources", sources);
     64        psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "psphot sources", sources);
    5165    }
    5266    if (psf) {
    53         // save the psf for possible output.  if there was already an entry, it was loaded from external sources
    54         // the new one may have been updated or modified, so replace the existing entry.  We
    55         // are required to save it on the chip, but this will cause problems if we ever want to
    56         // run psphot on an unmosaiced image
    57         pmCell *cell = readout->parent;
    58         pmChip *chip = cell->parent;
    59         psMetadataAdd (chip->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_DATA_UNKNOWN | PS_META_REPLACE,  "psphot psf", psf);
     67        // save the psf for possible output.  if there was already an entry, it was loaded from external sources
     68        // the new one may have been updated or modified, so replace the existing entry.  We
     69        // are required to save it on the chip, but this will cause problems if we ever want to
     70        // run psphot on an unmosaiced image
     71        pmCell *cell = readout->parent;
     72        pmChip *chip = cell->parent;
     73        psMetadataAdd (chip->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_DATA_UNKNOWN | PS_META_REPLACE,  "psphot psf", psf);
    6074    }
    6175
    6276    if (psErrorCodeLast() != PS_ERR_NONE) {
    6377        psErrorStackPrint(stderr, "unexpected remaining errors");
    64         abort();
     78        abort();
    6579    }
    6680
  • branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotRoughClass.c

    r21183 r24244  
    9191        return false;
    9292    }
    93     if (!psfClump.X || !psfClump.Y) {
     93    if (!psfClump.X || !psfClump.Y || isnan(psfClump.X) || isnan(psfClump.Y)) {
    9494        psLogMsg ("psphot", 4, "Failed to find a valid PSF clump for region %f,%f - %f,%f\n", region->x0, region->y0, region->x1, region->y1);
    9595        return false;
  • branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotSourceFits.c

    r21519 r24244  
    234234    pmSource *tmpSrc = pmSourceAlloc ();
    235235
     236    // XXX need to handle failures better here
    236237    pmModel *EXT = psphotFitEXT (readout, source, modelTypeEXT, maskVal, markVal);
    237238    okEXT = psphotEvalEXT (tmpSrc, EXT);
    238     chiEXT = EXT->chisq / EXT->nDOF;
    239 
     239    chiEXT = EXT ? EXT->chisq / EXT->nDOF : NAN;
     240
     241    // DBL will always be defined, but DBL->data[n] might not
    240242    psArray *DBL = psphotFitDBL (readout, source, maskVal, markVal);
    241243    okDBL  = psphotEvalDBL (tmpSrc, DBL->data[0]);
     
    244246
    245247    // correct first model chisqs for flux trend
     248    chiDBL = NAN;
    246249    ONE = DBL->data[0];
    247     chiTrend = psPolynomial1DEval (psf->ChiTrend, ONE->params->data.F32[1]);
    248     ONE->chisqNorm = ONE->chisq / chiTrend;
    249 
    250     // save chisq for double-star/galaxy comparison
    251     chiDBL = ONE->chisq / ONE->nDOF;
     250    if (ONE) {
     251      chiTrend = psPolynomial1DEval (psf->ChiTrend, ONE->params->data.F32[1]);
     252      ONE->chisqNorm = ONE->chisq / chiTrend;
     253      chiDBL = ONE->chisq / ONE->nDOF; // save chisq for double-star/galaxy comparison
     254    }
    252255
    253256    // correct second model chisqs for flux trend
    254257    ONE = DBL->data[1];
    255     chiTrend = psPolynomial1DEval (psf->ChiTrend, ONE->params->data.F32[1]);
    256     ONE->chisqNorm = ONE->chisq / chiTrend;
     258    if (ONE) {
     259      chiTrend = psPolynomial1DEval (psf->ChiTrend, ONE->params->data.F32[1]);
     260      ONE->chisqNorm = ONE->chisq / chiTrend;
     261    }
    257262
    258263    psFree (tmpSrc);
    259264
    260     // psTraceSetLevel("psModules.objects.pmSourceFitSet", 0);
     265    // (void) psTraceSetLevel("psModules.objects.pmSourceFitSet", 0);
    261266
    262267    if (okEXT && okDBL) {
  • branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotTest.c

    r21355 r24244  
    5050    }
    5151
    52     psTraceSetLevel ("psLib.sys.mutex", 3);
     52    (void) psTraceSetLevel ("psLib.sys.mutex", 3);
    5353
    5454    int nThreads = atoi (argv[2]);
  • branches/cnb_branches/cnb_branch_20090301/psphot/src/psphotVersion.c

    r23352 r24244  
    11#include "psphotInternal.h"
     2#include "psphotVersionDefinitions.h"
    23
    34#ifdef HAVE_KAPA
     
    1516#endif
    1617
    17 #define xstr(s) str(s)
    18 #define str(s) #s
    19 
    2018psString psphotVersion(void)
    2119{
    2220    char *value = NULL;
    23     psStringAppend(&value, "%s@%s", xstr(PSPHOT_BRANCH), xstr(PSPHOT_VERSION));
     21    psStringAppend(&value, "%s@%s", PSPHOT_BRANCH, PSPHOT_VERSION);
    2422    return value;
    2523}
     
    2725psString psphotSource(void)
    2826{
    29     return psStringCopy(xstr(PSPHOT_SOURCE));
     27    return psStringCopy(PSPHOT_SOURCE);
    3028}
    3129
Note: See TracChangeset for help on using the changeset viewer.