IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 14275


Ignore:
Timestamp:
Jul 17, 2007, 1:53:35 PM (19 years ago)
Author:
Paul Price
Message:

Using weight maps in ppStack.

Location:
trunk/ppStack/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStack/src/ppStackArguments.c

    r13750 r14275  
    1919    fprintf(stderr, "Usage: %s INPUTS.mdc OUTPUT_ROOT\n"
    2020            "where INPUTS.mdc contains various METADATAs, each with:\n"
    21             "\tIMAGE(STR):  Image filename\n"
    22             "\tMASK(STR):   Mask filename\n"
    23             "\tSEEING(F32): Seeing FWHM (pixels)\n"
    24             "\tWEIGHT(F32): Relative weighting to be applied\n"
    25             "\tSCALE(F32):  Relative scaling to be applied\n",
     21            "\tIMAGE(STR):     Image filename\n"
     22            "\tMASK(STR):      Mask filename\n"
     23            "\tWEIGHT(STR)     Weight map filename\n"
     24            "\tSEEING(F32):    Seeing FWHM (pixels)\n"
     25            "\tWEIGHTING(F32): Relative weighting to be applied\n"
     26            "\tSCALE(F32):     Relative scaling to be applied\n",
    2627            program);
    2728    fprintf(stderr, "\n");
  • trunk/ppStack/src/ppStackCamera.c

    r14238 r14275  
    1313bool ppStackCamera(pmConfig *config)
    1414{
     15    bool haveWeights = false;           // Do we have weight maps?
     16
    1517    psMetadata *inputs = psMetadataLookupMetadata(NULL, config->arguments, "INPUTS"); // The inputs info
    1618    psMetadataIterator *iter = psMetadataIteratorAlloc(inputs, PS_LIST_HEAD, NULL); // Iterator
     
    3638        bool mdok;
    3739        psString mask = psMetadataLookupStr(&mdok, input, "MASK"); // Name of mask
     40        psString weight = psMetadataLookupStr(&mdok, input, "WEIGHT"); // Name of weight map
    3841
    3942        float seeing = psMetadataLookupF32(NULL, input, "SEEING"); // Seeing FWHM
     
    4447        }
    4548
    46         float weight = psMetadataLookupF32(NULL, input, "WEIGHT"); // Relative weight
    47         if (isnan(weight)) {
    48             psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Component %s lacks WEIGHT of type F32", item->name);
     49        float weighting = psMetadataLookupF32(NULL, input, "WEIGHTING"); // Relative weighting
     50        if (isnan(weighting)) {
     51            psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Component %s lacks WEIGHTING of type F32", item->name);
    4952            psFree(iter);
    5053            return false;
     
    8588
    8689            bool status;
    87             pmFPAfile *maskFile = pmFPAfileBindFromArgs(&status, imageFile, config, "PPSTACK.INPUT.MASK", "MASK.FILENAMES");
     90            pmFPAfile *maskFile = pmFPAfileBindFromArgs(&status, imageFile, config, "PPSTACK.INPUT.MASK",
     91                                                        "MASK.FILENAMES");
    8892            if (!status) {
    8993                psError(PS_ERR_UNKNOWN, false, "Unable to define file from mask %d (%s)", i, mask);
     
    96100        }
    97101
     102        // Optionally add the weight file
     103        if (weight && strlen(weight) > 0) {
     104            haveWeights = true;
     105            psArray *weightFiles = psArrayAlloc(1); // Array of filenames for this FPA
     106            weightFiles->data[0] = psMemIncrRefCounter(weight);
     107            psMetadataAddArray(config->arguments, PS_LIST_TAIL, "WEIGHT.FILENAMES", PS_META_REPLACE,
     108                               "Filenames of weight files", weightFiles);
     109            psFree(weightFiles);
     110
     111            bool status;
     112            pmFPAfile *weightFile = pmFPAfileBindFromArgs(&status, imageFile, config, "PPSTACK.INPUT.WEIGHT",
     113                                                          "WEIGHT.FILENAMES");
     114            if (!status) {
     115                psError(PS_ERR_UNKNOWN, false, "Unable to define file from weight %d (%s)", i, weight);
     116                return false;
     117            }
     118            if (weightFile->type != PM_FPA_FILE_WEIGHT) {
     119                psError(PS_ERR_IO, true, "PPSTACK.INPUT.WEIGHT is not of type WEIGHT");
     120                return false;
     121            }
     122        }
     123
    98124        psMetadataAddF32(imageFile->fpa->analysis, PS_LIST_TAIL, "PPSTACK.SEEING", 0,
    99125                         "Seeing for image", seeing);
    100         psMetadataAddF32(imageFile->fpa->analysis, PS_LIST_TAIL, "PPSTACK.WEIGHT", 0,
    101                          "Relative weight for image", weight);
     126        psMetadataAddF32(imageFile->fpa->analysis, PS_LIST_TAIL, "PPSTACK.WEIGHTING", 0,
     127                         "Relative weighting for image", weighting);
    102128        psMetadataAddF32(imageFile->fpa->analysis, PS_LIST_TAIL, "PPSTACK.SCALE", 0,
    103129                         "Relative scale for image", scale);
     
    109135    if (psMetadataLookup(config->arguments, "MASK.FILENAMES")) {
    110136        psMetadataRemoveKey(config->arguments, "MASK.FILENAMES");
     137    }
     138    if (psMetadataLookup(config->arguments, "WEIGHT.FILENAMES")) {
     139        psMetadataRemoveKey(config->arguments, "WEIGHT.FILENAMES");
    111140    }
    112141
     
    180209    outMask->save = true;
    181210
     211    // Output weight
     212    if (haveWeights) {
     213        pmFPAfile *outWeight = pmFPAfileDefineOutput(config, output->fpa, "PPSTACK.OUTPUT.WEIGHT");
     214        if (!outWeight) {
     215            psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.OUTPUT.WEIGHT"));
     216            return false;
     217        }
     218        if (outWeight->type != PM_FPA_FILE_WEIGHT) {
     219            psError(PS_ERR_IO, true, "PPSTACK.OUTPUT.WEIGHT is not of type WEIGHT");
     220            return false;
     221        }
     222    }
     223
    182224    return true;
    183225}
  • trunk/ppStack/src/ppStackReadout.c

    r13613 r14275  
    4545
    4646        float seeing = psMetadataLookupF32(NULL, inputFile->fpa->analysis, "PPSTACK.SEEING"); // Seeing FWHM
    47         float weight = psMetadataLookupF32(NULL, inputFile->fpa->analysis, "PPSTACK.WEIGHT"); // Rel. weight
     47        float weighting = psMetadataLookupF32(NULL, inputFile->fpa->analysis,
     48                                              "PPSTACK.WEIGHTING"); // Relative weighting
    4849        float scale = psMetadataLookupF32(NULL, inputFile->fpa->analysis, "PPSTACK.SCALE"); // Rel. scale
    4950
     
    7778        totExposure += exposure;        // Total exposure time
    7879        (void)psBinaryOp(ro->image, ro->image, "/", psScalarAlloc(exposure, PS_TYPE_F32));
    79         pmStackData *data = pmStackDataAlloc(ro, seeing, weight); // Data to stack
     80        if (ro->weight) {
     81            (void)psBinaryOp(ro->weight, ro->weight, "/", psScalarAlloc(exposure, PS_TYPE_F32));
     82        }
     83        pmStackData *data = pmStackDataAlloc(ro, seeing, weighting); // Data to stack
    8084        psArrayAdd(stack, ARRAY_BUFFER, data);
    8185        psFree(data);                   // Drop reference
     
    100104    }
    101105
    102 #if 1
     106#ifdef INSPECTION_FILES
    103107    {
    104108        psFits *fits = psFitsOpen("combined.fits", "w");
     
    131135    }
    132136
    133 #if 1
     137#ifdef REJECTION_FILES
    134138    for (int i = 0; i < num; i++) {
    135139        pmStackData *data = stack->data[i]; // Data for this image
     
    157161    // Restore image to counts using the total exposure time
    158162    (void)psBinaryOp(outRO->image, outRO->image, "*", psScalarAlloc(totExposure, PS_TYPE_F32));
     163    if (outRO->weight) {
     164        (void)psBinaryOp(outRO->weight, outRO->weight, "*", psScalarAlloc(totExposure, PS_TYPE_F32));
     165    }
    159166    psMetadataAddF32(outRO->parent->concepts, PS_LIST_TAIL, "CELL.EXPOSURE", PS_META_REPLACE,
    160167                     "Summed exposure time (sec)", totExposure);
Note: See TracChangeset for help on using the changeset viewer.