IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 17, 2009, 12:08:50 PM (17 years ago)
Author:
beaumont
Message:

merged with head

Location:
branches/cnb_branches/cnb_branch_20090301
Files:
1 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • branches/cnb_branches/cnb_branch_20090301

  • branches/cnb_branches/cnb_branch_20090301/ppImage

  • branches/cnb_branches/cnb_branch_20090301/ppImage/src/Makefile.am

    r20774 r23352  
    44        ppImage.h
    55
    6 ppImage_CFLAGS = $(PPIMAGE_CFLAGS) $(PPSTATS_CFLAGS) $(PSASTRO_CFLAGS) $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
     6#PPIMAGE_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
     7#PPIMAGE_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`
     8#PPIMAGE_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     9
     10# Force recompilation of ppImageVersion.c, since it gets the version information
     11# ppImageVersion.c: FORCE
     12#       touch ppImageVersion.c
     13# FORCE: ;
     14
     15ppImage_CFLAGS = $(PPIMAGE_CFLAGS) $(PPSTATS_CFLAGS) $(PSASTRO_CFLAGS) $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPPIMAGE_VERSION=$(SVN_VERSION) -DPPIMAGE_BRANCH=$(SVN_BRANCH) -DPPIMAGE_SOURCE=$(SVN_SOURCE)
    716ppImage_LDFLAGS = $(PPIMAGE_LIBS) $(PSASTRO_LIBS) $(PPSTATS_LIBS) $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
    817ppImage_SOURCES = \
  • branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImage.c

    r19928 r23352  
    2121        exit(PS_EXIT_CONFIG_ERROR);
    2222    }
     23
     24    ppImageVersionPrint();
    2325
    2426    // define recipe options
  • branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImage.h

    r21364 r23352  
    8686    int remnanceSize;                   // Size for remnance detection
    8787    float remnanceThresh;               // Threshold for remnance detection
     88
     89    char *normClass;                    // class to use for per-class normalization
    8890} ppImageOptions;
    8991
     
    208210psString ppImageVersion(void);
    209211
     212/// Return software source
     213psString ppImageSource(void);
     214
    210215/// Return long version information
    211216psString ppImageVersionLong(void);
    212217
    213 /// Update the metadata with version information for all dependencies
    214 void ppImageVersionMetadata(psMetadata *metadata ///< Metadata to update with version information
    215     );
     218/// Populate the header with version information for all dependencies
     219bool ppImageVersionHeader(psMetadata *metadata ///< Header to populate
     220    );
     221
     222/// Print version information
     223void ppImageVersionPrint(void);
    216224
    217225
  • branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageArguments.c

    r19943 r23352  
    1414    fprintf(stderr, "\t-chip CHIPNUM: Only process this chip number.\n");
    1515    fprintf(stderr, "\t-norm VALUE: Divide through by this value when done.\n");
     16    fprintf(stderr, "\t-normlist file.mdc: normalizations by class_id.\n");
    1617    fprintf(stderr, "\n");
    1718    fprintf(stderr, "Input options (single file / file list):\n");
     
    8081    if ((argnum = psArgumentGet(argc, argv, "-visual"))) {
    8182        psArgumentRemove(argnum, &argc, argv);
    82         psphotSetVisual (true);
     83        pmVisualSetVisual(true);
    8384    }
    8485
     
    8687    if ((argnum = psArgumentGet(argc, argv, "-threads"))) {
    8788        psArgumentRemove(argnum, &argc, argv);
    88         int nThreads = atoi(argv[argnum]);
     89        int nThreads = atoi(argv[argnum]);
    8990        psMetadataAddS32(config->arguments, PS_LIST_TAIL, "NTHREADS", 0, "number of warp threads", nThreads);
    9091        psArgumentRemove(argnum, &argc, argv);
    9192
    92         // create the thread pool with number of desired threads, supplying our thread launcher function
    93         // XXX need to determine the number of threads from the config data
    94         psThreadPoolInit (nThreads);
     93        // create the thread pool with number of desired threads, supplying our thread launcher function
     94        // XXX need to determine the number of threads from the config data
     95        psThreadPoolInit (nThreads);
    9596    }
    9697
     
    107108
    108109    // the input file is a required argument; if not found, we will exit
    109     bool status = pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list");
    110     if (!status) {
    111         usage ();
    112     }
     110    pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list");
    113111
    114112    // if these command-line options are supplied, load the file name lists into config->arguments
     
    128126    }
    129127
    130     // Optional normalisation factor
     128    // Optional normalization factor
    131129    if ((argnum = psArgumentGet(argc, argv, "-norm"))) {
    132130        psArgumentRemove(argnum, &argc, argv);
    133131        float norm = atof(argv[argnum]);
    134         psMetadataAddF32(config->arguments, PS_LIST_TAIL, "NORMALISATION", 0,
     132        psMetadataAddF32(config->arguments, PS_LIST_TAIL, "NORMALIZATION", 0,
    135133                         "Normalisation to apply", norm);
     134        psArgumentRemove(argnum, &argc, argv);
     135    }
     136
     137    // Optional per-class normalization table
     138    if ((argnum = psArgumentGet(argc, argv, "-normlist"))) {
     139        psArgumentRemove(argnum, &argc, argv);
     140
     141        unsigned int nFail = 0;
     142        psMetadata *normlist = psMetadataConfigRead (NULL, &nFail, argv[argnum], false);
     143        // XXX allow this file to be in nebulous?
     144
     145        psMetadataAddMetadata(config->arguments, PS_LIST_TAIL, "NORMALIZATION.TABLE", 0, "Normalization to apply", normlist);
     146        psFree (normlist);
    136147        psArgumentRemove(argnum, &argc, argv);
    137148    }
  • branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageDefineFile.c

    r13562 r23352  
    55# include "ppImage.h"
    66
    7 bool ppImageDefineFile (pmConfig *config, pmFPA *input, char *filerule, char *argname, pmFPAfileType fileType, pmDetrendType detrendType) {
     7bool ppImageDefineFile(pmConfig *config, pmFPA *input, char *filerule, char *argname,
     8                       pmFPAfileType fileType, pmDetrendType detrendType)
     9{
     10    bool status;
     11    pmFPAfile *file = NULL;             // File to be defined
    812
    9     bool status;
    10     pmFPAfile *file;
    11 
    12     // look for the file on the argument list
    13     file = pmFPAfileDefineFromArgs  (&status, config, filerule, argname);
    14     if (!status) {
    15         psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
    16         return false;
     13    if (!file) {
     14        // look for the file on the RUN metadata
     15        file = pmFPAfileDefineFromRun(&status, config, filerule);
     16        if (!status) {
     17            psError(PS_ERR_UNKNOWN, false, "failed to load file definition");
     18            return false;
     19        }
    1720    }
    18     if (file) {
    19         if (file->type != fileType) {
    20             psError(PS_ERR_IO, true, "%s is not of type %s", filerule, pmFPAfileStringFromType (fileType));
    21             return false;
    22         }
    23         return true;
     21    if (!file) {
     22        // look for the file on the argument list
     23        file = pmFPAfileDefineFromArgs(&status, config, filerule, argname);
     24        if (!status) {
     25            psError(PS_ERR_UNKNOWN, false, "failed to load file definition");
     26            return false;
     27        }
     28    }
     29    if (!file) {
     30        // look for the file in the camera config table
     31        file = pmFPAfileDefineFromConf(&status, config, filerule);
     32        if (!status) {
     33            psError(PS_ERR_UNKNOWN, false, "failed to load file definition");
     34            return false;
     35        }
     36    }
     37    if (!file) {
     38        // look for the file to be loaded from the detrend database
     39        file = pmFPAfileDefineFromDetDB(&status, config, filerule, input, detrendType);
     40        if (!status) {
     41            psError(PS_ERR_UNKNOWN, false, "failed to load file definition");
     42            return false;
     43        }
    2444    }
    2545
    26     // look for the file in the camera config table
    27     file = pmFPAfileDefineFromConf  (&status, config, filerule);
    28     if (!status) {
    29         psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
    30         return false;
    31     }
    32     if (file) {
    33         if (file->type != fileType) {
    34             psError(PS_ERR_IO, true, "%s is not of type %s", filerule, pmFPAfileStringFromType (fileType));
    35             return false;
    36         }
    37         return true;
     46    if (!file) {
     47        return false;
    3848    }
    3949
    40     // look for the file to be loaded from the detrend database
    41     file = pmFPAfileDefineFromDetDB (&status, config, filerule, input, detrendType);
    42     if (!status) {
    43         psError (PS_ERR_UNKNOWN, false, "failed to load file definition");
    44         return false;
     50    if (file->type != fileType) {
     51        psError(PS_ERR_IO, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType));
     52        return false;
    4553    }
    46     if (file) {
    47         if (file->type != fileType) {
    48             psError(PS_ERR_IO, true, "%s is not of type %s", filerule, pmFPAfileStringFromType (fileType));
    49             return false;
    50         }
    51         return true;
    52     }
    53     return false;
     54    return true;
    5455}
    5556
  • branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageDetrendReadout.c

    r21364 r23352  
    5454        if (!pmBiasSubtract(input, options->overscan, bias, oldDark, view)) {
    5555            psError(PS_ERR_UNKNOWN, false, "Unable to subtract bias.");
     56            psFree(detview);
    5657            return false;
    5758        }
     
    6768        if (!pmDarkApply(input, dark, options->maskValue)) {
    6869            psError(PS_ERR_UNKNOWN, false, "Unable to subtract dark.");
     70            psFree(detview);
    6971            return false;
    7072        }
     
    7577                        options->remnanceSize, options->remnanceThresh)) {
    7678            psError(PS_ERR_UNKNOWN, false, "Unable to mask remnance.");
     79            psFree(detview);
    7780            return false;
    7881        }
     
    8386        pmReadout *shutter = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.SHUTTER");
    8487        if (!pmShutterCorrectionApply(input, shutter, pmConfigMaskGet("FLAT", config))) {
     88            psFree(detview);
    8589            return false;
    8690        }
     
    9195        pmReadout *flat = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.FLAT");
    9296        if (!pmFlatField(input, flat, options->flatMask)) {
     97            psFree(detview);
    9398            return false;
    9499        }
    95100    }
    96101
    97     // Normalisation by a (known) constant
     102    // Normalization by a single (known) constant
    98103    bool mdok;                          // Status of MD lookup
    99     float norm = psMetadataLookupF32(&mdok, config->arguments, "NORMALISATION");
     104    float norm = psMetadataLookupF32(&mdok, config->arguments, "NORMALIZATION");
    100105    if (mdok && isfinite(norm) && norm != 1.0) {
    101106        pmHDU *hdu = pmHDUFromReadout(input); // HDU of interest
     
    108113    }
    109114
     115# if (1)
     116    // Normalization by per-class values
     117    psMetadata *normlist = psMetadataLookupMetadata(&mdok, config->arguments, "NORMALIZATION.TABLE");
     118    if (normlist) {
     119        pmFPAfile *inputFile = psMetadataLookupPtr(&mdok, config->files, "PPIMAGE.INPUT");
     120
     121        // get the menu of class IDs
     122        psMetadata *menu = psMetadataLookupMetadata(&mdok, inputFile->camera, "CLASSID");
     123        if (!menu) {
     124            psError(PS_ERR_IO, false, "Unable to find CLASSID metadata in camera configuration");
     125            psFree(detview);
     126            return false;
     127        }
     128        // get the rule for class_id for the desired class
     129        const char *rule = psMetadataLookupStr(&mdok, menu, options->normClass);
     130        if (!rule) {
     131            psError(PS_ERR_IO, false, "Unable to find NORM.CLASS value %s in CLASSID in camera configuration", options->normClass);
     132            psFree(detview);
     133            return false;
     134        }
     135        // get the class_id from the rule
     136        char *classID = pmFPAfileNameFromRule(rule, inputFile, view);
     137        if (!classID) {
     138            psError(PS_ERR_IO, false, "error converting CLASSID rule %s to name\n", rule);
     139            psFree(detview);
     140            return false;
     141        }
     142
     143        // get normalization from the class_id
     144        float norm = psMetadataLookupF32 (&mdok, normlist, classID);
     145
     146        pmHDU *hdu = pmHDUFromReadout(input); // HDU of interest
     147        psString comment = NULL;        // Comment to add
     148        psStringAppend(&comment, "Normalization: %f", norm);
     149        psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, comment, "");
     150        psFree(comment);
     151
     152        // apply the normalization
     153        psBinaryOp(input->image, input->image, "*", psScalarAlloc(norm, PS_TYPE_F32));
     154
     155        psFree (classID);
     156    }
     157# endif
     158
    110159    if (options->doFringe) {
    111160        pmCell *fringe = pmFPAfileThisCell(config->files, detview, "PPIMAGE.FRINGE");
    112161        if (!ppImageDetrendFringeMeasure(input, fringe, false, options)) {
     162            psFree(detview);
    113163            return false;
    114164        }
  • branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageLoop.c

    r21183 r23352  
    2525    }
    2626
    27     psString dump_file = psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG");
    28     if (dump_file) {
    29         pmConfigCamerasCull(config, NULL);
    30         pmConfigRecipesCull(config, "PPIMAGE,PPSTATS,PSPHOT,MASKS,PSASTRO");
    31 
    32         pmConfigDump(config, input->fpa, dump_file);
    33     }
     27    pmConfigCamerasCull(config, NULL);
     28    pmConfigRecipesCull(config, "PPIMAGE,PPSTATS,PSPHOT,MASKS,PSASTRO,JPEG");
    3429
    3530    pmFPAview *view = pmFPAviewAlloc(0);// View for level of interest
     
    6358
    6459            // Put version information into the header
    65             pmHDU *hdu = pmHDUFromCell(cell);
     60            pmHDU *hdu = pmHDUGetHighest(input->fpa, chip, cell);
    6661            if (hdu && hdu != lastHDU) {
    67                 ppImageVersionMetadata(hdu->header);
     62                ppImageVersionHeader(hdu->header);
    6863                lastHDU = hdu;
    6964            }
     
    9691                }
    9792
    98                 // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT
    99                 if (!ppImageDetrendFree (config, view)) {
    100                     ESCAPE("Unable to free detrend images");
    101                 }
     93                // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT
     94                if (!ppImageDetrendFree (config, view)) {
     95                    ESCAPE("Unable to free detrend images");
     96                }
    10297            }
    10398
     
    105100                ppImageDetrendRecord(cell, config, options, view);
    106101            }
    107             // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT
    108             if (!ppImageDetrendFree (config, view)) {
    109                 ESCAPE("Unable to free detrend images");
    110             }
    111         }
    112         // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT
    113         if (!ppImageDetrendFree (config, view)) {
    114             ESCAPE("Unable to free detrend images");
    115         }
     102            // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT
     103            if (!ppImageDetrendFree (config, view)) {
     104                ESCAPE("Unable to free detrend images");
     105            }
     106        }
     107        // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT
     108        if (!ppImageDetrendFree (config, view)) {
     109            ESCAPE("Unable to free detrend images");
     110        }
    116111
    117112        // Apply the fringe correction
     
    121116            }
    122117        }
    123         // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT
    124         if (!ppImageFringeFree (config, view)) {
    125             ESCAPE("Unable to free fringe images");
    126         }
     118        // free detrend images potentially in use: MASK, BIAS, DARK, SHUTTER, FLAT
     119        if (!ppImageFringeFree (config, view)) {
     120            ESCAPE("Unable to free fringe images");
     121        }
    127122
    128123        // measure various pixel-based statistics for this image
     
    152147        }
    153148
    154         // these may be used by ppImageSubtractBackground.
    155         // if these are defined as internal files, drop them here
    156         status = true;
    157         status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL");
    158         status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL.STDEV");
    159         status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND");
    160         if (!status) {
    161             psError(PSPHOT_ERR_PROG, false, "trouble dropping internal files");
    162             psFree (view);
    163             return false;
    164         }
     149        // these may be used by ppImageSubtractBackground.
     150        // if these are defined as internal files, drop them here
     151        status = true;
     152        status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL");
     153        status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL.STDEV");
     154        status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND");
     155        if (!status) {
     156            psError(PSPHOT_ERR_PROG, false, "trouble dropping internal files");
     157            psFree (view);
     158            return false;
     159        }
    165160
    166161        // binning (used for display) must take place after the background is replaced, if desired
     
    219214    }
    220215    psFree(view);
     216
     217    // Dump configuration
     218    psString dump_file = psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG");
     219    if (dump_file) {
     220        pmConfigDump(config, input->fpa, dump_file);
     221    }
    221222
    222223    // Write out summary statistics
  • branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageOptions.c

    r21364 r23352  
    8181    options->remnanceThresh  = 25.0;    // Threshold for remnance detection
    8282
     83    // per-class normalization source
     84    options->normClass       = NULL;    // per-class normalizations refer to this class
     85
    8386    return options;
    8487}
     
    278281    options->remnanceThresh = psMetadataLookupS32(NULL, recipe, "REMNANCE.THRESH");
    279282
     283    // per-class normalization source (just a reference; don't free)
     284    options->normClass = psMetadataLookupStr(NULL, recipe, "NORM.CLASS");
     285
    280286    return options;
    281287}
  • branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageParseCamera.c

    r21364 r23352  
    99    bool status = false;
    1010
    11     // the input image defines the camera, and all recipes and options the follow
    12     pmFPAfile *input = pmFPAfileDefineFromArgs (&status, config, "PPIMAGE.INPUT", "INPUT");
    13     if (!status || !input) {
    14         psError(PS_ERR_IO, false, "Failed to build FPA from PPIMAGE.INPUT");
    15         return NULL;
    16     }
    17     if (input->type != PM_FPA_FILE_IMAGE) {
    18         psError(PS_ERR_IO, true, "PPIMAGE.INPUT is not of type IMAGE");
    19         return NULL;
    20     }
    21 
    22     // if MASK or VARIANCE was supplied on command line, bind files to 'input'.
    23     // the mask and variance will be mosaicked with the image
    24     pmFPAfile *inputMask = pmFPAfileBindFromArgs(&status, input, config, "PPIMAGE.INPUT.MASK", "PPIMAGE.INPUT.MASK");
    25     if (!status) {
    26         psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
    27         return NULL;
    28     }
    29     if (inputMask) {
    30       if (inputMask->type != PM_FPA_FILE_MASK) {
    31         psError(PS_ERR_IO, true, "PPIMAGE.INPUT.MASK is not of type MASK");
    32         return NULL;
    33       }
    34     }
    35 
    36     pmFPAfile *inputVariance = pmFPAfileBindFromArgs(&status, input, config, "PPIMAGE.INPUT.VARIANCE", "PPIMAGE.INPUT.VARIANCE");
    37     if (!status) {
    38         psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
    39         return NULL;
    40     }
    41     if (inputVariance && inputVariance->type != PM_FPA_FILE_VARIANCE) {
    42         psError(PS_ERR_IO, true, "PPIMAGE.INPUT.VARIANCE is not of type VARIANCE");
    43         return NULL;
    44     }
     11    if (!ppImageDefineFile(config, NULL, "PPIMAGE.INPUT", "INPUT", PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_NONE)) {
     12        psError(PS_ERR_IO, false, "Can't find an input image source");
     13        return NULL;
     14    }
     15    pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PPIMAGE.INPUT"); // Input file
     16    psAssert(input, "We just put it there!");
    4517
    4618    // add recipe options supplied on command line
    47     psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, RECIPE_NAME);
     19    psMetadata *recipe  = psMetadataLookupPtr(&status, config->recipes, RECIPE_NAME);
    4820
    4921    // parse the options from the metadata format to the ppImageOptions structure
    50     ppImageOptions *options = ppImageOptionsParse (config);
     22    ppImageOptions *options = ppImageOptionsParse(config);
    5123
    5224    // the following are defined from the argument list, if given,
     
    5426    // not all input or output images are used in a given recipe
    5527    if (options->doBias) {
    56         if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.BIAS", "BIAS", PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_BIAS)) {
    57             psError (PS_ERR_IO, false, "Can't find a bias image source");
    58             psFree (options);
     28        if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.BIAS", "BIAS",
     29                               PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_BIAS)) {
     30            psError(PS_ERR_IO, false, "Can't find a bias image source");
     31            psFree(options);
    5932            return NULL;
    6033        }
    6134    }
    6235    if (options->doDark) {
    63         if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.DARK", "DARK", PM_FPA_FILE_DARK, PM_DETREND_TYPE_DARK)) {
    64             psError (PS_ERR_IO, false, "Can't find a dark image source");
    65             psFree (options);
     36        if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.DARK", "DARK",
     37                               PM_FPA_FILE_DARK, PM_DETREND_TYPE_DARK)) {
     38            psError(PS_ERR_IO, false, "Can't find a dark image source");
     39            psFree(options);
    6640            return NULL;
    6741        }
    6842    }
    6943    if (options->doMask) {
    70 
    71         if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.MASK", "MASK", PM_FPA_FILE_MASK, PM_DETREND_TYPE_MASK)) {
    72             psError (PS_ERR_IO, false, "Can't find a mask image source");
    73             psFree (options);
    74             return NULL;
    75         }
     44        if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.MASK", "MASK",
     45                               PM_FPA_FILE_MASK, PM_DETREND_TYPE_MASK)) {
     46            psError(PS_ERR_IO, false, "Can't find a mask image source");
     47            psFree(options);
     48            return NULL;
     49        }
     50
     51#if 0
     52        // I think this is now done automatically in the pmFPAfileDefine and pmFPAfileIOChecks -- PAP.
     53
    7654        // XXX have ppImageDefineFile return the pmFPAfile?
    7755        pmFPAfile *mask = psMetadataLookupPtr(&status, config->files, "PPIMAGE.MASK");
    78         psAssert (mask, "mask not defined?  not possible!");
     56        psAssert(mask, "Just defined the mask!");
    7957
    8058        // Need to read the names of bit masks from the mask header and set them in the
     
    8462            // XXX need to load the mask bit names from one of the headers
    8563            // this grabs the first available hdu : no guarantee that it will be valid, though
    86             pmHDU *hdu = pmHDUGetFirst (mask->fpa);
     64            pmHDU *hdu = pmHDUGetFirst(mask->fpa);
    8765            if (!hdu) {
    8866                psError(PS_ERR_IO, true, "no valid HDU for PPIMAGE.INPUT.MASK");
     
    9068            }
    9169            // XXX is this consistent with the pmConfigMaskReadHeader call above?
    92             if (!pmConfigMaskReadHeader (config, hdu->header)) {
     70            if (!pmConfigMaskReadHeader(config, hdu->header)) {
    9371                psError(PS_ERR_IO, false, "error in mask bits");
    9472                return NULL;
    9573            }
    9674        }
     75#endif
    9776    }
    9877    if (options->doShutter) {
    99         if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.SHUTTER", "SHUTTER", PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_SHUTTER)) {
    100             psError (PS_ERR_IO, false, "Can't find a shutter image source");
    101             psFree (options);
     78        if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.SHUTTER", "SHUTTER",
     79                               PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_SHUTTER)) {
     80            psError(PS_ERR_IO, false, "Can't find a shutter image source");
     81            psFree(options);
    10282            return NULL;
    10383        }
     
    10585
    10686    if (options->doFlat) {
    107         if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.FLAT", "FLAT", PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_FLAT)) {
    108             psError (PS_ERR_IO, false, "Can't find a flat image source");
    109             psFree (options);
    110             return NULL;
    111         }
    112     }
    113 
    114     int nThreads = psMetadataLookupS32 (&status, config->arguments, "NTHREADS");
     87        if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.FLAT", "FLAT",
     88                               PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_FLAT)) {
     89            psError(PS_ERR_IO, false, "Can't find a flat image source");
     90            psFree(options);
     91            return NULL;
     92        }
     93    }
     94
     95    int nThreads = psMetadataLookupS32(&status, config->arguments, "NTHREADS");
    11596    if (nThreads > 0) {
    116         int nScanRows = psMetadataLookupS32 (&status, recipe, "SCAN.ROWS");
    117         pmDetrendSetThreadTasks (nScanRows);
     97        int nScanRows = psMetadataLookupS32(&status, recipe, "SCAN.ROWS");
     98        pmDetrendSetThreadTasks(nScanRows);
    11899    }
    119100
     
    166147skip_fringe:
    167148    if (options->doFringe) {
    168         if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.FRINGE", "FRINGE", PM_FPA_FILE_FRINGE, PM_DETREND_TYPE_FRINGE)) {
     149        if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.FRINGE", "FRINGE",
     150                               PM_FPA_FILE_FRINGE, PM_DETREND_TYPE_FRINGE)) {
    169151            psError (PS_ERR_IO, false, "Can't find a fringe image source");
    170152            return NULL;
     
    283265        // define associated psphot input/output files
    284266        if (!psphotDefineFiles (config, psphotInput)) {
    285             psError(PSPHOT_ERR_CONFIG, false, "Trouble defining the additional input/output files for psphot");
     267            psError(PSPHOT_ERR_CONFIG, false,
     268                    "Trouble defining the additional input/output files for psphot");
    286269            return false;
    287270        }
     
    291274    if (options->doAstromChip || options->doAstromMosaic) {
    292275        if (!options->doPhotom) {
    293             psError (PSASTRO_ERR_CONFIG, false, "photometry mode is not selected; it is required for astrometry");
     276            psError(PSASTRO_ERR_CONFIG, false,
     277                    "Photometry mode is not selected; it is required for astrometry");
    294278            return false;
    295279        }
    296280
    297         pmFPAfile *psphotOutput = psMetadataLookupPtr (&status, config->files, "PSPHOT.OUTPUT");
    298         PS_ASSERT (psphotOutput, false);
    299 
    300         pmFPAfile *psastroInput = pmFPAfileDefineInput (config, psphotOutput->fpa, NULL, "PSASTRO.INPUT");
    301         PS_ASSERT (psastroInput, false);
     281        pmFPAfile *psphotOutput = psMetadataLookupPtr(&status, config->files, "PSPHOT.OUTPUT");
     282        PS_ASSERT(psphotOutput, false);
     283
     284        pmFPAfile *psastroInput = pmFPAfileDefineInput(config, psphotOutput->fpa, NULL, "PSASTRO.INPUT");
     285        PS_ASSERT(psastroInput, false);
    302286        psastroInput->mode = PM_FPA_MODE_REFERENCE;
    303287
    304288        // define associated psphot input/output files
    305         if (!psastroDefineFiles (config, psastroInput)) {
    306             psError(PSPHOT_ERR_CONFIG, false, "Trouble defining the additional input/output files for psastro");
     289        if (!psastroDefineFiles(config, psastroInput)) {
     290            psError(PSPHOT_ERR_CONFIG, false,
     291                    "Trouble defining the additional input/output files for psastro");
    307292            return false;
    308293        }
    309294
    310295        // deactivate the psastro files, reactive when needed
    311         pmFPAfileActivate (config->files, false, "PSASTRO.OUTPUT");
     296        pmFPAfileActivate(config->files, false, "PSASTRO.OUTPUT");
    312297    }
    313298
     
    325310
    326311    // outImage is used as a carrier: input to chipImage -> require the data to remain at the CHIP level
    327     outImage->freeLevel = PS_MIN (outImage->freeLevel, PM_FPA_LEVEL_CHIP);
     312    outImage->freeLevel = PS_MIN(outImage->freeLevel, PM_FPA_LEVEL_CHIP);
    328313    outImage->dataLevel = outImage->freeLevel;
    329     outImage->fileLevel = PS_MIN (outImage->fileLevel, outImage->dataLevel);
     314    outImage->fileLevel = PS_MIN(outImage->fileLevel, outImage->dataLevel);
    330315
    331316    // outMask and outVariance must be freed at the same level as outImage (all freed by pmFPAFreeData)
     
    342327
    343328    // the input data is the same as the outImage data : force the free levels to match
    344     input->freeLevel = PS_MIN (outImage->freeLevel, input->freeLevel);
     329    input->freeLevel = PS_MIN(outImage->freeLevel, input->freeLevel);
    345330
    346331    // define the binned target files (which may just be carriers for some camera configurations)
    347     pmFPAfile *bin1 = pmFPAfileDefineFromFPA (config, chipImage->fpa, options->xBin1, options->yBin1, "PPIMAGE.BIN1");
     332    pmFPAfile *bin1 = pmFPAfileDefineFromFPA(config, chipImage->fpa, options->xBin1, options->yBin1,
     333                                             "PPIMAGE.BIN1");
    348334    if (!bin1) {
    349335        psError(PS_ERR_IO, false, _("Unable to generate new file from PPIMAGE.BIN1"));
     
    357343    }
    358344
    359     pmFPAfile *bin2 = pmFPAfileDefineFromFPA (config, chipImage->fpa, options->xBin2, options->yBin2, "PPIMAGE.BIN2");
     345    pmFPAfile *bin2 = pmFPAfileDefineFromFPA(config, chipImage->fpa, options->xBin2, options->yBin2,
     346                                             "PPIMAGE.BIN2");
    360347    if (!bin2) {
    361348        psError(PS_ERR_IO, false, _("Unable to generate new file from PPIMAGE.BIN2"));
     
    373360    bin2->freeLevel = PM_FPA_LEVEL_FPA;
    374361
    375     pmFPAfile *jpg1 = pmFPAfileDefineOutput (config, byFPA1->fpa, "PPIMAGE.JPEG1");
     362    pmFPAfile *jpg1 = pmFPAfileDefineOutput(config, byFPA1->fpa, "PPIMAGE.JPEG1");
    376363    if (!jpg1) {
    377364        psError(PS_ERR_IO, false, _("Unable to generate new file from PPIMAGE.JPEG1"));
     
    384371        return NULL;
    385372    }
    386     pmFPAfile *jpg2 = pmFPAfileDefineOutput (config, byFPA2->fpa, "PPIMAGE.JPEG2");
     373    pmFPAfile *jpg2 = pmFPAfileDefineOutput(config, byFPA2->fpa, "PPIMAGE.JPEG2");
    387374    if (!jpg2) {
    388375        psError(PS_ERR_IO, false, _("Unable to generate new file from PPIMAGE.JPEG2"));
     
    404391    // Chip selection: turn on only the chips specified (pass status to suppress missing-key log msg)
    405392    char *chipLine = psMetadataLookupStr(&status, config->arguments, "CHIP_SELECTIONS");
    406     psArray *chips = psStringSplitArray (chipLine, ",", false);
     393    psArray *chips = psStringSplitArray(chipLine, ",", false);
    407394    if (chips->n > 0) {
    408395        pmFPASelectChip (input->fpa, -1, true); // deselect all chips
     
    454441    if (psTraceGetLevel("ppImage.config") > 0) {
    455442        // Get a look inside all the files.
    456         psMetadataIterator *filesIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, NULL); // Iterator
     443        psMetadataIterator *filesIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, NULL);
    457444        psMetadataItem *item;               // Item from iteration
    458445        fprintf(stderr, "Files:\n");
  • branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageReplaceBackground.c

    r21183 r23352  
    101101        }
    102102    }
    103     psImageBinning *binning = psMetadataLookupPtr(&status, psphotRecipe, "PSPHOT.BACKGROUND.BINNING"); // Binning for model
     103    psImageBinning *binning = psMetadataLookupPtr(&status, modelRO->analysis,
     104                                                  "PSPHOT.BACKGROUND.BINNING"); // Binning for model
    104105    if (!binning) {
    105106        psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find background binning");
  • branches/cnb_branches/cnb_branch_20090301/ppImage/src/ppImageVersion.c

    r14000 r23352  
    55#include "ppImage.h"
    66
    7 static const char *cvsTag = "$Name: not supported by cvs2svn $";// CVS tag name
     7#ifndef PPIMAGE_VERSION
     8#error "PPIMAGE_VERSION is not set"
     9#endif
     10#ifndef PPIMAGE_BRANCH
     11#error "PPIMAGE_BRANCH is not set"
     12#endif
     13#ifndef PPIMAGE_SOURCE
     14#error "PPIMAGE_SOURCE is not set"
     15#endif
     16
     17#define xstr(s) str(s)
     18#define str(s) #s
    819
    920psString ppImageVersion(void)
    1021{
    11     psString version = NULL;            // Version, to return
    12     psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION);
    13     return version;
     22    char *value = NULL;
     23    psStringAppend(&value, "%s@%s", xstr(PPIMAGE_BRANCH), xstr(PPIMAGE_VERSION));
     24    return value;
     25}
     26
     27psString ppImageSource(void)
     28{
     29    return psStringCopy (xstr(PPIMAGE_SOURCE));
    1430}
    1531
    1632psString ppImageVersionLong(void)
    1733{
    18     psString version = ppImageVersion(); // Version, to return
    19     psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag
    20     psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__);
    21     psFree(tag);
     34    psString version = ppImageVersion();  // Version, to return
     35    psString source = ppImageSource(); // Source
     36
     37    psStringPrepend(&version, "ppImage ");
     38    psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__);
     39    psFree(source);
     40
     41#ifdef __OPTIMIZE__
     42    psStringAppend(&version, " optimised");
     43#else
     44    psStringAppend(&version, " unoptimised");
     45#endif
     46
    2247    return version;
     48};
     49
     50bool ppImageVersionHeader(psMetadata *header)
     51{
     52    PS_ASSERT_METADATA_NON_NULL(header, false);
     53
     54    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     55    psString timeString = psTimeToISO(time); // The time in an ISO string
     56    psFree(time);
     57    psString history = NULL;               // History string
     58    psStringAppend(&history, "ppImage at %s", timeString);
     59    psFree(timeString);
     60    psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history);
     61    psFree(history);
     62
     63    psLibVersionHeader(header);
     64    psModulesVersionHeader(header);
     65    psphotVersionHeader(header);
     66    psastroVersionHeader(header);
     67    ppStatsVersionHeader(header);
     68
     69    psString version = ppImageVersion(); // ppImage software version
     70    psString source  = ppImageSource();  // ppImage software source
     71
     72    psStringPrepend(&version, "ppImage version: ");
     73    psStringPrepend(&source, "ppImage source: ");
     74
     75    psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, version);
     76    psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, source);
     77
     78    psFree(version);
     79    psFree(source);
     80
     81    return true;
    2382}
    2483
    2584
    26 void ppImageVersionMetadata(psMetadata *metadata)
     85void ppImageVersionPrint(void)
    2786{
    28     PS_ASSERT_METADATA_NON_NULL(metadata,);
     87    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
     88    psString timeString = psTimeToISO(time); // The time in an ISO string
     89    psFree(time);
     90    psLogMsg("ppImage", PS_LOG_INFO, "ppImage at %s", timeString);
     91    psFree(timeString);
    2992
    3093    psString pslib = psLibVersionLong();// psLib version
     
    3598    psString ppImage = ppImageVersionLong(); // ppImage version
    3699
    37     psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
    38     psString timeString = psTimeToISO(time); // The time in an ISO string
    39     psFree(time);
    40     psString head = NULL;               // Head string
    41     psStringAppend(&head, "ppImage processing at %s. Component information:", timeString);
    42     psFree(timeString);
     100    psLogMsg("ppImage", PS_LOG_INFO, "%s", pslib);
     101    psLogMsg("ppImage", PS_LOG_INFO, "%s", psmodules);
     102    psLogMsg("ppImage", PS_LOG_INFO, "%s", psphot);
     103    psLogMsg("ppImage", PS_LOG_INFO, "%s", psastro);
     104    psLogMsg("ppImage", PS_LOG_INFO, "%s", ppStats);
     105    psLogMsg("ppImage", PS_LOG_INFO, "%s", ppImage);
    43106
    44     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, head, "");
    45     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, pslib, "");
    46     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psmodules, "");
    47     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psphot, "");
    48     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, psastro, "");
    49     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppStats, "");
    50     psMetadataAddStr(metadata, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, ppImage, "");
    51 
    52     psFree(head);
    53107    psFree(pslib);
    54108    psFree(psmodules);
Note: See TracChangeset for help on using the changeset viewer.