IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 17, 2009, 2:31:20 PM (17 years ago)
Author:
Paul Price
Message:

Cleaning up. Had trouble getting the output photometry file written out, but works now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSub/src/ppSubMatchPSFs.c

    r21360 r21524  
    66 *
    77 *  @author IfA
    8  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2009-02-06 01:37:17 $
     8 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-02-18 00:31:20 $
    1010 *  Copyright 2009 Institute for Astronomy, University of Hawaii
    1111 */
    1212
     13#ifdef HAVE_CONFIG_H
     14#include <config.h>
     15#endif
     16
     17#include <stdio.h>
     18#include <pslib.h>
     19#include <psmodules.h>
     20#include <psphot.h>
     21
    1322#include "ppSub.h"
    1423
    15 /** Generate the PSF-matching kernel and convolve the images as needed.  Most of this function
    16  * involves looking up the parameters in the recipe and supplying them to the function
    17  * pmSubtractionMatch();
    18  */
    19 
    20 bool ppSubMatchPSFs (pmConfig *config, const pmFPAview *view) {
    21 
    22     bool mdok;                          // Status of MD lookup
     24bool ppSubMatchPSFs(pmConfig *config, const pmFPAview *view)
     25{
     26    psAssert(config, "Require configuration");
     27    psAssert(view, "Require view");
    2328
    2429    // Look up recipe values
     
    2631    psAssert(recipe, "We checked this earlier, so it should be here.");
    2732
    28     // input images
     33    // Input images
    2934    pmReadout *inRO = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT"); // Input readout
    3035    pmReadout *refRO = pmFPAfileThisReadout(config->files, view, "PPSUB.REF"); // Reference readout
    3136
    32     // get or generate output image holders
    33     pmReadout *inConv = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.CONV"); // Input convolved readout
     37    // Output image holders
     38    pmReadout *inConv = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.CONV"); // Input convolved
    3439    if (!inConv) {
    35         pmCell *cell = pmFPAfileThisCell(config->files, view, "PPSUB.INPUT.CONV"); // Input convolved readout
    36         inConv = pmReadoutAlloc(cell); // Convolved version of input
     40        pmCell *cell = pmFPAfileThisCell(config->files, view, "PPSUB.INPUT.CONV"); // Cell for convolved input
     41        inConv = pmReadoutAlloc(cell);
    3742    }
    38     pmReadout *refConv = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV"); // Reference convolved readout
     43    pmReadout *refConv = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV"); // Reference convolved
    3944    if (!refConv) {
    40         pmCell *cell = pmFPAfileThisCell(config->files, view, "PPSUB.REF.CONV"); // Input convolved readout
    41         refConv = pmReadoutAlloc(cell); // Convolved version of input
     45        pmCell *cell = pmFPAfileThisCell(config->files, view, "PPSUB.REF.CONV"); // Cell for convolved ref.
     46        refConv = pmReadoutAlloc(cell);
    4247    }
    4348
    44     // options which control the generation of optimal parameters
    45     bool optimum = psMetadataLookupBool(&mdok, recipe, "OPTIMUM"); // Derive optimum parameters?
    46     float optMin = psMetadataLookupF32(&mdok, recipe, "OPTIMUM.MIN"); // Minimum width for search
    47     float optMax = psMetadataLookupF32(&mdok, recipe, "OPTIMUM.MAX"); // Maximum width for search
    48     float optStep = psMetadataLookupF32(&mdok, recipe, "OPTIMUM.STEP"); // Step for search
     49    bool mdok;                          // Status of MD lookup
    4950
    50     // Vector with FWHMs for optimum search
    51     psVector *optWidths = NULL;
    52     if (optimum) {
    53         optWidths = psVectorCreate(optWidths, optMin, optMax, optStep, PS_TYPE_F32);
    54     }
    55 
    56     // Sources in image : these must be loaded from previous analysis stages
    57     pmReadout *sourcesRO = pmFPAfileThisReadout(config->files, view, "PPSUB.SOURCES"); // Readout with sources
    58     psArray *sources = NULL;           
     51    // Sources in image, used for stamps: these must be loaded from previous analysis stages
     52    pmReadout *sourcesRO = pmFPAfileThisReadout(config->files, view, "PPSUB.SOURCES"); // Readout with sources
     53    psArray *sources = NULL;            // Sources in image; used for stamps
    5954    if (sourcesRO) {
    6055        sources = psMetadataLookupPtr(&mdok, sourcesRO->analysis, "PSPHOT.SOURCES");
     
    6661    float spacing = psMetadataLookupF32(NULL, recipe, "STAMP.SPACING"); // Typical stamp spacing
    6762    float threshold = psMetadataLookupF32(NULL, recipe, "STAMP.THRESHOLD"); // Threshold for stmps
    68 
    6963    const char *stampsName = psMetadataLookupStr(&mdok, config->arguments, "STAMPS"); // Filename for stamps
    7064
    7165    const char *typeStr = psMetadataLookupStr(NULL, recipe, "KERNEL.TYPE"); // Kernel type
    7266    psAssert(typeStr, "We put it here in ppSubArguments.c");
    73 
    7467    pmSubtractionKernelsType type = pmSubtractionKernelsTypeFromString(typeStr); // Type of kernel
    7568    if (type == PM_SUBTRACTION_KERNEL_NONE) {
     
    8780    int binning = psMetadataLookupS32(NULL, recipe, "SPAM.BINNING"); // Binning for SPAM kernel
    8881    float penalty = psMetadataLookupF32(NULL, recipe, "PENALTY"); // Penalty for wideness
    89 
    90     int optOrder = psMetadataLookupS32(&mdok, recipe, "OPTIMUM.ORDER"); // Order for search
    91     float optThresh = psMetadataLookupF32(&mdok, recipe, "OPTIMUM.TOL"); // Tolerance for search
    92 
    9382    int iter = psMetadataLookupS32(NULL, recipe, "ITER"); // Rejection iterations
    9483    float rej = psMetadataLookupF32(NULL, recipe, "REJ"); // Rejection threshold
     
    9887    float poorFrac = psMetadataLookupF32(&mdok, recipe, "POOR.FRACTION"); // Fraction for "poor"
    9988
    100     // XXX EAM : do we need to / want to define different values for BAD and POOR subtraction vs BAD and POOR warp?
    101     psImageMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Bits to mask going in to pmSubtractionMatch
     89    // Options which control the generation of optimal parameters
     90    bool optimum = psMetadataLookupBool(&mdok, recipe, "OPTIMUM"); // Derive optimum parameters?
     91    float optMin = psMetadataLookupF32(&mdok, recipe, "OPTIMUM.MIN"); // Minimum width for search
     92    float optMax = psMetadataLookupF32(&mdok, recipe, "OPTIMUM.MAX"); // Maximum width for search
     93    float optStep = psMetadataLookupF32(&mdok, recipe, "OPTIMUM.STEP"); // Step for search
     94    psVector *optWidths = NULL;         // Vector with FWHMs for optimum search
     95    if (optimum) {
     96        optWidths = psVectorCreate(optWidths, optMin, optMax, optStep, PS_TYPE_F32);
     97    }
     98    int optOrder = psMetadataLookupS32(&mdok, recipe, "OPTIMUM.ORDER"); // Order for search
     99    float optThresh = psMetadataLookupF32(&mdok, recipe, "OPTIMUM.TOL"); // Tolerance for search
     100
     101    // XXX Do we need/want to define different values for BAD and POOR subtraction vs BAD and POOR warp?
     102    psImageMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Bits to mask in inputs
    102103    psImageMaskType maskPoor = pmConfigMaskGet("POOR.WARP", config); // Bits to mask for poor pixels
    103104    psImageMaskType maskBad = pmConfigMaskGet("BLANK", config); // Bits to mask for bad pixels
     
    124125    pmSubtractionThreadsFinalize(inRO, refRO);
    125126
     127    psImageCovarianceTransfer(inConv->variance, inConv->covariance);
     128    psImageCovarianceTransfer(refConv->variance, refConv->covariance);
     129
    126130    // XXX drop the pixels associated with inRO and refRO (now that we have inConv and refConf)
    127131
Note: See TracChangeset for help on using the changeset viewer.