IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21368


Ignore:
Timestamp:
Feb 5, 2009, 5:10:36 PM (17 years ago)
Author:
Paul Price
Message:

Merging pap_branch_20090128. Resolved a small number of conflicts. Compiles, but not tested in detail.

Location:
trunk/pswarp/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/pswarp/src/pswarp.h

    r21323 r21368  
    66 *
    77 *  @author IfA
    8  *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2009-02-05 20:44:04 $
     8 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-02-06 03:10:36 $
    1010 *  Copyright 2009 Institute for Astronomy, University of Hawaii
    1111 */
     
    3131#define PSWARP_ANALYSIS_VARFACTOR "PSWARP.VARFACTOR" ///< Name for variance factor in analysis metadata
    3232#define PSWARP_ANALYSIS_GOODPIX   "PSWARP.GOODPIX" ///< Name for number of good pixels in analysis metadata
     33#define PSWARP_ANALYSIS_COVARIANCES "PSWARP.COVARIANCES" ///< Name for covariance matrices on analysis MD
    3334
    3435/**
     
    4344} pswarpMap;
    4445
    45 /* the pswarpMapGrid carries a collection of pswarpMag structures representing 
     46/* the pswarpMapGrid carries a collection of pswarpMag structures representing
    4647 * the local value of the pswarpMap at different locations in the image.
    4748 */
     
    6667
    6768    /** output values for this tile */
    68     long goodPixels;                    //< Number of good pixels
    69     int xMin, xMax, yMin, yMax;         //< Bounds of tile
     69    long goodPixels;                    ///< Number of good pixels
     70    int xMin, xMax, yMin, yMax;         ///< Bounds of tile
     71    psKernel *covariance;               ///< Covariance matrix
    7072} pswarpTransformTileArgs;
    7173
  • trunk/pswarp/src/pswarpArguments.c

    r21323 r21368  
    66 *
    77 *  @author IfA
    8  *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2009-02-05 20:44:04 $
     8 *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-02-06 03:10:36 $
    1010 *  Copyright 2009 Institute for Astronomy, University of Hawaii
    1111 */
     
    9292    }
    9393
    94     // the mask and weight entries are optional (build from gain?)
     94    // the mask and variance entries are optional (build from gain?)
    9595    pmConfigFileSetsMD (config->arguments, &argc, argv, "MASK",   "-mask",   "-masklist");
    96     pmConfigFileSetsMD (config->arguments, &argc, argv, "WEIGHT", "-weight", "-weightlist");
     96    pmConfigFileSetsMD (config->arguments, &argc, argv, "VARIANCE", "-variance", "-variancelist");
    9797
    9898    if (argc != 3) {
  • trunk/pswarp/src/pswarpFileNames.h

    r21171 r21368  
    88
    99// Lists of file rules for the detectors
    10 static char *detectorFiles[] = { 
    11   "PSWARP.INPUT", 
    12   "PSWARP.MASK", 
    13   "PSWARP.WEIGHT",
    14   NULL 
     10static char *detectorFiles[] = {
     11  "PSWARP.INPUT",
     12  "PSWARP.MASK",
     13  "PSWARP.VARIANCE",
     14  NULL
    1515};
    1616
    1717// Lists of file rules for the skycells
    18 static char *skycellFiles[] = { 
    19   "PSWARP.OUTPUT", 
    20   "PSWARP.OUTPUT.MASK", 
    21   "PSWARP.OUTPUT.WEIGHT",
    22   NULL 
     18static char *skycellFiles[] = {
     19  "PSWARP.OUTPUT",
     20  "PSWARP.OUTPUT.MASK",
     21  "PSWARP.OUTPUT.VARIANCE",
     22  NULL
    2323};
    2424
    2525// Lists of file rules for photometry
    26 static char *photFiles[] = { 
    27   "PSPHOT.INPUT", 
     26static char *photFiles[] = {
     27  "PSPHOT.INPUT",
    2828  "PSPHOT.OUTPUT",
    2929#if PSPHOT_FIND_PSF
     
    3131#endif
    3232  "PSPHOT.RESID",
    33   "PSPHOT.BACKMDL", 
    34   "PSPHOT.BACKMDL.STDEV", 
    35   "PSPHOT.BACKGND", 
     33  "PSPHOT.BACKMDL",
     34  "PSPHOT.BACKMDL.STDEV",
     35  "PSPHOT.BACKGND",
    3636  "PSPHOT.BACKSUB",
    37   "PSPHOT.PSF.SAVE", 
    38   "SOURCE.PLOT.MOMENTS", 
     37  "PSPHOT.PSF.SAVE",
     38  "SOURCE.PLOT.MOMENTS",
    3939  "SOURCE.PLOT.PSFMODEL",
    40   "SOURCE.PLOT.APRESID", 
    41   NULL 
     40  "SOURCE.PLOT.APRESID",
     41  NULL
    4242};
    4343
    4444// Lists of file rules for the detectors and skycells, and an independent list of everything else
    45 static char *independentFiles[] = { 
     45static char *independentFiles[] = {
    4646  "PSWARP.ASTROM", // Read independently from the input pixels
    4747  "PSWARP.SKYCELL", // Don't care about the skycell once we have its WCS
    4848  "PSWARP.OUTPUT.SOURCES", // Save these independently so we can do the PSF
    49   NULL 
     49  NULL
    5050};
    5151
  • trunk/pswarp/src/pswarpLoop.c

    r21323 r21368  
    66 *
    77 *  @author IfA
    8  *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2009-02-05 20:44:04 $
     8 *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-02-06 03:10:36 $
    1010 *  Copyright 2009 Institute for Astronomy, University of Hawaii
    1111 */
     
    1313#include "pswarp.h"
    1414#include <ppStats.h>
    15 
    16 #define WCS_NONLIN_TOL 0.001            ///< Non-linear tolerance for header WCS
    17 #define PSPHOT_FIND_PSF 1               ///< Use psphot's findPSF function?
    18 #define TESTING 0                       ///< Testing output?
    19 
    20 #include "pswarpFileNames.h" ///< Lists of file rules used at different stages
    21 
    22 /**
    23  * XXX these are generic functions which should be moved to psModules
    24  * Activate a list of files
    25  */
    26 static void fileActivation(pmConfig *config, ///< Configuration
    27                            char **files, ///< Files to turn on/off
    28                            bool state   ///< Activation state
     15#include "pswarpFileNames.h"            // Lists of file rules used at different stages
     16
     17#define WCS_NONLIN_TOL 0.001            // Non-linear tolerance for header WCS
     18#define PSPHOT_FIND_PSF 1               // Use psphot's findPSF function?
     19#define TESTING 0                       // Testing output?
     20
     21
     22// XXX these are generic functions which should be moved to psModules
     23// Activate a list of files
     24static void fileActivation(pmConfig *config, // Configuration
     25                           char **files, // Files to turn on/off
     26                           bool state   // Activation state
    2927    )
    3028{
     
    293291    }
    294292
     293    // Set covariance matrix for output
     294    {
     295        psList *covariances = psMetadataLookupPtr(&mdok, output->analysis,
     296                                                  PSWARP_ANALYSIS_COVARIANCES); // Covariance matrices
     297        psAssert(covariances, "Should be there");
     298        psArray *covars = psListToArray(covariances); // Array of covariance matrices
     299        output->covariance = psImageCovarianceAverage(covars);
     300        psFree(covars);
     301        psMetadataRemoveKey(output->analysis, PSWARP_ANALYSIS_COVARIANCES);
     302    }
     303
    295304    if (!pmConceptsAverageCells(outCell, cells, NULL, NULL, false)) {
    296305        psError(PS_ERR_UNKNOWN, false, "Unable to average cell concepts.");
     
    348357        ioChecksBefore(config);
    349358
    350         // supply the readout and fpa of interest to psphot
     359        // supply the readout and fpa of interest to psphot
    351360        pmFPAfile *photFile = psMetadataLookupPtr(NULL, config->files, "PSPHOT.INPUT");
    352361        pmFPACopy(photFile->fpa, outFPA);
     
    359368        // We can adjust the weight directly since this is a deep copy
    360369        pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa);
    361         float vf = psMetadataLookupF32(NULL, photRO->parent->concepts, "CELL.VARFACTOR"); ///< Variance factor
    362         psBinaryOp(photRO->weight, photRO->weight, "*", psScalarAlloc(vf, PS_TYPE_F32));
    363 
    364         // grab the sources of interest from the storage location (pmFPAfile PSPHOT.INPUT.CMF)
    365         psArray *sources = psphotLoadPSFSources (config, view);
    366         if (!sources) {
     370        float vf = psMetadataLookupF32(NULL, photRO->parent->concepts, "CELL.VARFACTOR"); // Variance factor
     371        psBinaryOp(photRO->variance, photRO->variance, "*", psScalarAlloc(vf, PS_TYPE_F32));
     372
     373        // grab the sources of interest from the storage location (pmFPAfile PSPHOT.INPUT.CMF)
     374        psArray *sources = psphotLoadPSFSources (config, view);
     375        if (!sources) {
    367376            psError(PS_ERR_UNKNOWN, false, "No sources supplied to measure PSF");
    368377            return false;
    369378        }
    370379
    371         // measure the PSF using these sources
     380        // measure the PSF using these sources
    372381        if (!psphotReadoutFindPSF(config, view, sources)) {
    373382            psError(PS_ERR_UNKNOWN, false, "Unable to determine PSF for warped image.");
  • trunk/pswarp/src/pswarpParseCamera.c

    r21323 r21368  
    66 *
    77 *  @author IfA
    8  *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2009-02-05 20:44:04 $
     8 *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-02-06 03:10:36 $
    1010 *  Copyright 2009 Institute for Astronomy, University of Hawaii
    1111 */
     
    5757    }
    5858
    59     pmFPAfile *inWeight = pmFPAfileBindFromArgs(&status, input, config, "PSWARP.WEIGHT", "WEIGHT");
     59    pmFPAfile *inVariance = pmFPAfileBindFromArgs(&status, input, config, "PSWARP.VARIANCE", "VARIANCE");
    6060    if (!status) {
    6161        psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
    6262        return NULL;
    6363    }
    64     if (!inWeight) {
    65         psLogMsg ("pswarp", 3, "no weight supplied\n");
     64    if (!inVariance) {
     65        psLogMsg ("pswarp", 3, "no variance supplied\n");
    6666    }
    6767
     
    9090    outMask->save = true;
    9191
    92     if (inWeight) {
    93         pmFPAfile *outWeight = pmFPAfileDefineSkycell(config, output->fpa, "PSWARP.OUTPUT.WEIGHT");
    94         if (!outWeight) {
    95             psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.OUTPUT.WEIGHT");
     92    if (inVariance) {
     93        pmFPAfile *outVariance = pmFPAfileDefineSkycell(config, output->fpa, "PSWARP.OUTPUT.VARIANCE");
     94        if (!outVariance) {
     95            psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.OUTPUT.VARIANCE");
    9696            return false;
    9797        }
    98         outWeight->save = true;
     98        outVariance->save = true;
    9999    }
    100100
  • trunk/pswarp/src/pswarpSetMaskBits.c

    r21323 r21368  
    66 *
    77 *  @author IfA
    8  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2009-02-05 20:44:04 $
     8 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-02-06 03:10:36 $
    1010 *  Copyright 2009 Institute for Astronomy, University of Hawaii
    1111 */
     
    2020 * updated in the config metadata.
    2121 */
    22 bool pswarpSetMaskBits (pmConfig *config) {
    23 
    24     psImageMaskType maskIn = 0x00;                      ///< mask for the input image
    25     psImageMaskType markIn = 0x00;                      ///< mark for the input image
    26     psImageMaskType maskOut = 0x00;                     ///< mask for the output image
     22bool pswarpSetMaskBits (pmConfig *config)
     23{
     24    psImageMaskType maskIn = 0x00;                      // mask for the input image
     25    psImageMaskType markIn = 0x00;                      // mark for the input image
     26    psImageMaskType maskOut = 0x00;                     // mask for the output image
    2727
    2828    // this function sets the required single-image mask bits
    2929    if (!pmConfigMaskSetBits (&maskIn, &markIn, config)) {
    30         psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values");
    31         return false;
     30        psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values");
     31        return false;
    3232    }
    3333
    3434    // mask for non-linear flat regions (default to DETECTOR if not defined)
    35     psImageMaskType badMask = pmConfigMaskGet("BAD.WARP", config); 
     35    psImageMaskType badMask = pmConfigMaskGet("BAD.WARP", config);
    3636    if (!badMask) {
    37         badMask = 0x01;
    38         pmConfigMaskSet (config, "BAD.WARP", badMask);
     37        badMask = 0x01;
     38        pmConfigMaskSet (config, "BAD.WARP", badMask);
    3939    }
    4040    maskOut |= badMask;
    4141
    4242    // mask for non-linear flat regions (default to DETECTOR if not defined)
    43     psImageMaskType poorMask = pmConfigMaskGet("POOR.WARP", config); 
     43    psImageMaskType poorMask = pmConfigMaskGet("POOR.WARP", config);
    4444    if (!poorMask) {
    45         poorMask = 0x02;
    46         pmConfigMaskSet (config, "POOR.WARP", poorMask);
     45        poorMask = 0x02;
     46        pmConfigMaskSet (config, "POOR.WARP", poorMask);
    4747    }
    4848    maskOut |= poorMask;
  • trunk/pswarp/src/pswarpTransformReadout.c

    r21323 r21368  
    66 *
    77 *  @author IfA
    8  *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2009-02-05 20:44:04 $
     8 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-02-06 03:10:36 $
    1010 *  Copyright 2009 Institute for Astronomy, University of Hawaii
    1111 */
     
    4141    psAssert(mdok, "MASK.INPUT was not defined");
    4242
    43     int nThreads = psMetadataLookupS32(&mdok, config->arguments, "NTHREADS"); ///< Number of threads
     43    if (!input->covariance) {
     44        input->covariance = psImageCovarianceNone();
     45    }
     46
     47    int nThreads = psMetadataLookupS32(&mdok, config->arguments, "NTHREADS"); // Number of threads
    4448    if (!mdok) {
    4549        nThreads = 0;
     
    8589    // Interpolation options : move these from the arguments to explicit assignments
    8690    psImageInterpolation *interp = psImageInterpolationAlloc(interpolationMode, input->image,
    87                                                              input->weight, input->mask, maskIn,
     91                                                             input->variance, input->mask, maskIn,
    8892                                                             NAN, NAN, maskBad, maskPoor, poorFrac,
    8993                                                             numKernels);
    9094
    91     if (input->weight && !output->weight) {
    92         output->weight = psImageAlloc(output->image->numCols, output->image->numRows, PS_TYPE_F32);
    93         psImageInit(output->weight, NAN);
     95    if (input->variance && !output->variance) {
     96        output->variance = psImageAlloc(output->image->numCols, output->image->numRows, PS_TYPE_F32);
     97        psImageInit(output->variance, NAN);
    9498    }
    9599    if ((input->mask || maskPoor || maskBad) && !output->mask) {
     
    135139    psThreadJob *job = NULL;
    136140    int xMin = output->image->numCols, xMax = 0, yMin = output->image->numRows, yMax = 0; // Bounds
    137     int goodPixels = 0;                 ///< total number of good pixels across all tiles
     141    int goodPixels = 0;                 // total number of good pixels across all tiles
     142    psList *covariances = psMetadataLookupPtr(&mdok, output->analysis,
     143                                              PSWARP_ANALYSIS_COVARIANCES); // Collection of covar. matrices
     144    if (!covariances) {
     145        covariances = psListAlloc(NULL);
     146        psMetadataAddList(output->analysis, PS_LIST_TAIL, PSWARP_ANALYSIS_COVARIANCES, 0,
     147                          "Collection of covariance matrices", covariances);
     148    }
    138149    while ((job = psThreadJobGetDone()) != NULL) {
    139150        if (job->args->n < 1) {
     
    147158            yMin = PS_MIN(args->yMin, yMin);
    148159            yMax = PS_MAX(args->yMax, yMax);
     160            if (args->covariance) {
     161                psListAdd(covariances, PS_LIST_TAIL, args->covariance);
     162            }
    149163        }
    150164        psFree(job);
  • trunk/pswarp/src/pswarpTransformTile.c

    r21323 r21368  
    66 *
    77 *  @author IfA
    8  *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2009-02-05 20:44:04 $
     8 *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-02-06 03:10:36 $
    1010 *  Copyright 2009 Institute for Astronomy, University of Hawaii
    1111 */
     
    2020    psFree(args->interp);
    2121    psFree(args->region);
     22    psFree(args->covariance);
    2223    return;
    2324}
     
    4243    args->yMin = PS_MAX_S32;
    4344    args->yMax = PS_MIN_S32;
     45    args->covariance = NULL;
    4446
    4547    return args;
     
    6062    // Dereference images for convenience
    6163    psF32 **outImageData     = args->output->image->data.F32;
    62     psF32 **outVarData       = (args->output->weight) ? args->output->weight->data.F32 : NULL;
     64    psF32 **outVarData       = (args->output->variance) ? args->output->variance->data.F32 : NULL;
    6365    psImageMaskType **outMaskData = (args->output->mask)   ? args->output->mask->data.PS_TYPE_IMAGE_MASK_DATA : NULL;
    6466    psImageMaskType **inMaskData  = (args->input->mask)    ? args->input->mask->data.PS_TYPE_IMAGE_MASK_DATA : NULL;
     
    9294            }
    9395
    94             double imageValue, varValue; // Value of image and variance map
    95 
    9696            // psImagePixelInterpolate determines the value at pixel coordinate (x,y) in child coordinates
     97            double imageValue, varValue; // Value of image and variance map
    9798            psImageMaskType maskValue = inMaskData ? inMaskData[(int)yIn][(int)xIn] : 0; // Value of mask
    98 
    9999            if (!psImageInterpolate(&imageValue, &varValue, &maskValue, xIn, yIn, args->interp)) {
    100100                psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image.");
     
    118118    }
    119119
     120    if (goodPixels > 0) {
     121        float xOut = 0.5 * (xMin + xMax), yOut = 0.5 * (yMin + yMax); // Position of interest on output
     122        double xIn, yIn;                // Position of interest on input
     123        pswarpMapApply(&xIn, &yIn, map, xOut + 0.5, yOut + 0.5);
     124        // XXX Why are we subtracting the *output* col0,row0 from the *input* coordinates?
     125        // I expect these are zero, so that it makes no difference, but it's distracting.
     126        xIn -= outCol0;
     127        yIn -= outRow0;
     128        psKernel *kernel = psImageInterpolationKernel(xIn, yIn, args->interp->mode); // Interpolation kernel
     129        args->covariance = psImageCovarianceCalculate(kernel, args->input->covariance);
     130        psFree(kernel);
     131    }
     132
    120133    args->goodPixels = goodPixels;
    121134    args->xMin = xMin;
Note: See TracChangeset for help on using the changeset viewer.