Changeset 21368
- Timestamp:
- Feb 5, 2009, 5:10:36 PM (17 years ago)
- Location:
- trunk/pswarp/src
- Files:
-
- 8 edited
-
pswarp.h (modified) (4 diffs)
-
pswarpArguments.c (modified) (2 diffs)
-
pswarpFileNames.h (modified) (2 diffs)
-
pswarpLoop.c (modified) (5 diffs)
-
pswarpParseCamera.c (modified) (3 diffs)
-
pswarpSetMaskBits.c (modified) (2 diffs)
-
pswarpTransformReadout.c (modified) (5 diffs)
-
pswarpTransformTile.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pswarp/src/pswarp.h
r21323 r21368 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.1 7$ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02-0 5 20:44:04$8 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-06 03:10:36 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ … … 31 31 #define PSWARP_ANALYSIS_VARFACTOR "PSWARP.VARFACTOR" ///< Name for variance factor in analysis metadata 32 32 #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 33 34 34 35 /** … … 43 44 } pswarpMap; 44 45 45 /* the pswarpMapGrid carries a collection of pswarpMag structures representing 46 /* the pswarpMapGrid carries a collection of pswarpMag structures representing 46 47 * the local value of the pswarpMap at different locations in the image. 47 48 */ … … 66 67 67 68 /** 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 70 72 } pswarpTransformTileArgs; 71 73 -
trunk/pswarp/src/pswarpArguments.c
r21323 r21368 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.2 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02-0 5 20:44:04$8 * @version $Revision: 1.24 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-06 03:10:36 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ … … 92 92 } 93 93 94 // the mask and weightentries are optional (build from gain?)94 // the mask and variance entries are optional (build from gain?) 95 95 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"); 97 97 98 98 if (argc != 3) { -
trunk/pswarp/src/pswarpFileNames.h
r21171 r21368 8 8 9 9 // Lists of file rules for the detectors 10 static char *detectorFiles[] = { 11 "PSWARP.INPUT", 12 "PSWARP.MASK", 13 "PSWARP. WEIGHT",14 NULL 10 static char *detectorFiles[] = { 11 "PSWARP.INPUT", 12 "PSWARP.MASK", 13 "PSWARP.VARIANCE", 14 NULL 15 15 }; 16 16 17 17 // Lists of file rules for the skycells 18 static char *skycellFiles[] = { 19 "PSWARP.OUTPUT", 20 "PSWARP.OUTPUT.MASK", 21 "PSWARP.OUTPUT. WEIGHT",22 NULL 18 static char *skycellFiles[] = { 19 "PSWARP.OUTPUT", 20 "PSWARP.OUTPUT.MASK", 21 "PSWARP.OUTPUT.VARIANCE", 22 NULL 23 23 }; 24 24 25 25 // Lists of file rules for photometry 26 static char *photFiles[] = { 27 "PSPHOT.INPUT", 26 static char *photFiles[] = { 27 "PSPHOT.INPUT", 28 28 "PSPHOT.OUTPUT", 29 29 #if PSPHOT_FIND_PSF … … 31 31 #endif 32 32 "PSPHOT.RESID", 33 "PSPHOT.BACKMDL", 34 "PSPHOT.BACKMDL.STDEV", 35 "PSPHOT.BACKGND", 33 "PSPHOT.BACKMDL", 34 "PSPHOT.BACKMDL.STDEV", 35 "PSPHOT.BACKGND", 36 36 "PSPHOT.BACKSUB", 37 "PSPHOT.PSF.SAVE", 38 "SOURCE.PLOT.MOMENTS", 37 "PSPHOT.PSF.SAVE", 38 "SOURCE.PLOT.MOMENTS", 39 39 "SOURCE.PLOT.PSFMODEL", 40 "SOURCE.PLOT.APRESID", 41 NULL 40 "SOURCE.PLOT.APRESID", 41 NULL 42 42 }; 43 43 44 44 // Lists of file rules for the detectors and skycells, and an independent list of everything else 45 static char *independentFiles[] = { 45 static char *independentFiles[] = { 46 46 "PSWARP.ASTROM", // Read independently from the input pixels 47 47 "PSWARP.SKYCELL", // Don't care about the skycell once we have its WCS 48 48 "PSWARP.OUTPUT.SOURCES", // Save these independently so we can do the PSF 49 NULL 49 NULL 50 50 }; 51 51 -
trunk/pswarp/src/pswarpLoop.c
r21323 r21368 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.3 6$ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02-0 5 20:44:04$8 * @version $Revision: 1.37 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-06 03:10:36 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ … … 13 13 #include "pswarp.h" 14 14 #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 24 static void fileActivation(pmConfig *config, // Configuration 25 char **files, // Files to turn on/off 26 bool state // Activation state 29 27 ) 30 28 { … … 293 291 } 294 292 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 295 304 if (!pmConceptsAverageCells(outCell, cells, NULL, NULL, false)) { 296 305 psError(PS_ERR_UNKNOWN, false, "Unable to average cell concepts."); … … 348 357 ioChecksBefore(config); 349 358 350 // supply the readout and fpa of interest to psphot359 // supply the readout and fpa of interest to psphot 351 360 pmFPAfile *photFile = psMetadataLookupPtr(NULL, config->files, "PSPHOT.INPUT"); 352 361 pmFPACopy(photFile->fpa, outFPA); … … 359 368 // We can adjust the weight directly since this is a deep copy 360 369 pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); 361 float vf = psMetadataLookupF32(NULL, photRO->parent->concepts, "CELL.VARFACTOR"); // /<Variance factor362 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) { 367 376 psError(PS_ERR_UNKNOWN, false, "No sources supplied to measure PSF"); 368 377 return false; 369 378 } 370 379 371 // measure the PSF using these sources380 // measure the PSF using these sources 372 381 if (!psphotReadoutFindPSF(config, view, sources)) { 373 382 psError(PS_ERR_UNKNOWN, false, "Unable to determine PSF for warped image."); -
trunk/pswarp/src/pswarpParseCamera.c
r21323 r21368 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.2 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02-0 5 20:44:04$8 * @version $Revision: 1.24 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-06 03:10:36 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ … … 57 57 } 58 58 59 pmFPAfile *in Weight = pmFPAfileBindFromArgs(&status, input, config, "PSWARP.WEIGHT", "WEIGHT");59 pmFPAfile *inVariance = pmFPAfileBindFromArgs(&status, input, config, "PSWARP.VARIANCE", "VARIANCE"); 60 60 if (!status) { 61 61 psError (PS_ERR_UNKNOWN, false, "failed to load find definition"); 62 62 return NULL; 63 63 } 64 if (!in Weight) {65 psLogMsg ("pswarp", 3, "no weightsupplied\n");64 if (!inVariance) { 65 psLogMsg ("pswarp", 3, "no variance supplied\n"); 66 66 } 67 67 … … 90 90 outMask->save = true; 91 91 92 if (in Weight) {93 pmFPAfile *out Weight = pmFPAfileDefineSkycell(config, output->fpa, "PSWARP.OUTPUT.WEIGHT");94 if (!out Weight) {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"); 96 96 return false; 97 97 } 98 out Weight->save = true;98 outVariance->save = true; 99 99 } 100 100 -
trunk/pswarp/src/pswarpSetMaskBits.c
r21323 r21368 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02-0 5 20:44:04$8 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-06 03:10:36 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ … … 20 20 * updated in the config metadata. 21 21 */ 22 bool pswarpSetMaskBits (pmConfig *config) {23 24 psImageMaskType maskIn = 0x00; ///<mask for the input image25 psImageMaskType markIn = 0x00; ///<mark for the input image26 psImageMaskType maskOut = 0x00; ///<mask for the output image22 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 27 27 28 28 // this function sets the required single-image mask bits 29 29 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; 32 32 } 33 33 34 34 // 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); 36 36 if (!badMask) { 37 badMask = 0x01;38 pmConfigMaskSet (config, "BAD.WARP", badMask);37 badMask = 0x01; 38 pmConfigMaskSet (config, "BAD.WARP", badMask); 39 39 } 40 40 maskOut |= badMask; 41 41 42 42 // 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); 44 44 if (!poorMask) { 45 poorMask = 0x02;46 pmConfigMaskSet (config, "POOR.WARP", poorMask);45 poorMask = 0x02; 46 pmConfigMaskSet (config, "POOR.WARP", poorMask); 47 47 } 48 48 maskOut |= poorMask; -
trunk/pswarp/src/pswarpTransformReadout.c
r21323 r21368 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02-0 5 20:44:04$8 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-06 03:10:36 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ … … 41 41 psAssert(mdok, "MASK.INPUT was not defined"); 42 42 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 44 48 if (!mdok) { 45 49 nThreads = 0; … … 85 89 // Interpolation options : move these from the arguments to explicit assignments 86 90 psImageInterpolation *interp = psImageInterpolationAlloc(interpolationMode, input->image, 87 input-> weight, input->mask, maskIn,91 input->variance, input->mask, maskIn, 88 92 NAN, NAN, maskBad, maskPoor, poorFrac, 89 93 numKernels); 90 94 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); 94 98 } 95 99 if ((input->mask || maskPoor || maskBad) && !output->mask) { … … 135 139 psThreadJob *job = NULL; 136 140 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 } 138 149 while ((job = psThreadJobGetDone()) != NULL) { 139 150 if (job->args->n < 1) { … … 147 158 yMin = PS_MIN(args->yMin, yMin); 148 159 yMax = PS_MAX(args->yMax, yMax); 160 if (args->covariance) { 161 psListAdd(covariances, PS_LIST_TAIL, args->covariance); 162 } 149 163 } 150 164 psFree(job); -
trunk/pswarp/src/pswarpTransformTile.c
r21323 r21368 6 6 * 7 7 * @author IfA 8 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02-0 5 20:44:04$8 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-06 03:10:36 $ 10 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 11 */ … … 20 20 psFree(args->interp); 21 21 psFree(args->region); 22 psFree(args->covariance); 22 23 return; 23 24 } … … 42 43 args->yMin = PS_MAX_S32; 43 44 args->yMax = PS_MIN_S32; 45 args->covariance = NULL; 44 46 45 47 return args; … … 60 62 // Dereference images for convenience 61 63 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; 63 65 psImageMaskType **outMaskData = (args->output->mask) ? args->output->mask->data.PS_TYPE_IMAGE_MASK_DATA : NULL; 64 66 psImageMaskType **inMaskData = (args->input->mask) ? args->input->mask->data.PS_TYPE_IMAGE_MASK_DATA : NULL; … … 92 94 } 93 95 94 double imageValue, varValue; // Value of image and variance map95 96 96 // psImagePixelInterpolate determines the value at pixel coordinate (x,y) in child coordinates 97 double imageValue, varValue; // Value of image and variance map 97 98 psImageMaskType maskValue = inMaskData ? inMaskData[(int)yIn][(int)xIn] : 0; // Value of mask 98 99 99 if (!psImageInterpolate(&imageValue, &varValue, &maskValue, xIn, yIn, args->interp)) { 100 100 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image."); … … 118 118 } 119 119 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 120 133 args->goodPixels = goodPixels; 121 134 args->xMin = xMin;
Note:
See TracChangeset
for help on using the changeset viewer.
