Changeset 5435
- Timestamp:
- Oct 20, 2005, 1:06:24 PM (21 years ago)
- Location:
- trunk/psModules
- Files:
-
- 16 edited
-
src/astrom/pmAstrometry.c (modified) (16 diffs)
-
src/astrom/pmAstrometry.h (modified) (9 diffs)
-
src/config/pmConfig.c (modified) (2 diffs)
-
src/config/pmConfig.h (modified) (2 diffs)
-
src/detrend/pmFlatField.c (modified) (4 diffs)
-
src/detrend/pmFlatField.h (modified) (2 diffs)
-
src/detrend/pmNonLinear.c (modified) (2 diffs)
-
src/detrend/pmNonLinear.h (modified) (2 diffs)
-
src/imsubtract/pmSubtractBias.c (modified) (2 diffs)
-
src/imsubtract/pmSubtractBias.h (modified) (2 diffs)
-
src/objects/pmObjects.c (modified) (2 diffs)
-
test/astrom/tst_pmAstrometry.c (modified) (7 diffs)
-
test/config/Makefile.am (modified) (2 diffs)
-
test/detrend/tst_pmFlatField.c (modified) (18 diffs)
-
test/detrend/tst_pmNonLinear.c (modified) (9 diffs)
-
test/objects/tst_pmObjects01.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/astrom/pmAstrometry.c
r5170 r5435 8 8 * @author GLG, MHPCC 9 9 * 10 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $11 * @date $Date: 2005- 09-28 20:43:52$10 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-10-20 23:06:24 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 71 71 } 72 72 psFree(fpa->chips); 73 psFree(fpa-> header);74 psFree(fpa-> db);73 psFree(fpa->private); 74 psFree(fpa->phu); 75 75 } 76 76 } … … 93 93 psFree(chip->cells); 94 94 psFree(chip->parent); 95 psFree(chip->extname); 96 psFree(chip->pixels); 97 psFree(chip->header); 95 psFree(chip->private); 98 96 } 99 97 } … … 106 104 psFree(cell->toSky); 107 105 psFree(cell->concepts); 106 psFree(cell->camera); 108 107 psFree(cell->analysis); 109 108 // … … 117 116 psFree(cell->readouts); 118 117 psFree(cell->parent); 119 psFree(cell->extname); 120 psFree(cell->pixels); 121 psFree(cell->header); 118 psFree(cell->private); 122 119 } 123 120 } … … 128 125 psFree(readout->image); 129 126 psFree(readout->mask); 127 psFree(readout->weight); 128 psFree(readout->bias); 130 129 psFree(readout->analysis); 131 psFree(readout->concepts);132 130 psFree(readout->parent); 133 131 } … … 145 143 tmpReadout->image = NULL; 146 144 tmpReadout->mask = NULL; 145 tmpReadout->weight = NULL; 146 tmpReadout->bias = NULL; 147 147 tmpReadout->analysis = psMetadataAlloc(); 148 tmpReadout->concepts = psMetadataAlloc();149 148 tmpReadout->parent = cell; 150 149 if (cell != NULL) { … … 155 154 } 156 155 157 pmCell *pmCellAlloc(pmChip *chip) 156 pmCell *pmCellAlloc( 157 pmChip *chip, 158 psMetadata *cameradata, 159 psString name 160 ) 158 161 { 159 162 pmCell *tmpCell = (pmCell *) psAlloc(sizeof(pmCell)); … … 164 167 tmpCell->toFPA = NULL; 165 168 tmpCell->toSky = NULL; 166 tmpCell->analysis = psMetadataAlloc();167 169 tmpCell->concepts = psMetadataAlloc(); 170 psBool rc = psMetadataAddStr(tmpCell->concepts, PS_LIST_HEAD, "CELL.NAME", 0, NULL, name); 171 if (rc == false) { 172 psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not add CELL.NAME to metadata.\n"); 173 } 174 tmpCell->camera = cameradata; 175 psMemIncrRefCounter((psMetadata *) cameradata); 176 tmpCell->analysis = NULL; 168 177 tmpCell->readouts = psArrayAlloc(0); 169 178 tmpCell->parent = chip; … … 172 181 } 173 182 tmpCell->valid = false; 174 tmpCell->extname = NULL; 175 tmpCell->pixels = NULL; 176 tmpCell->header = NULL; 183 tmpCell->private = NULL; 177 184 178 185 psMemSetDeallocator(tmpCell, (psFreeFunc) cellFree); … … 180 187 } 181 188 182 pmChip *pmChipAlloc(pmFPA *fpa) 189 pmChip *pmChipAlloc( 190 pmFPA *fpa, 191 psString name 192 ) 183 193 { 184 194 pmChip *tmpChip = (pmChip *) psAlloc(sizeof(pmChip)); … … 189 199 tmpChip->fromFPA = NULL; 190 200 tmpChip->concepts = psMetadataAlloc(); 191 tmpChip->analysis = psMetadataAlloc(); 201 psBool rc = psMetadataAddStr(tmpChip->concepts, PS_LIST_HEAD, "CHIP.NAME", 0, NULL, name); 202 if (rc == false) { 203 psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not add CHIP.NAME to metadata.\n"); 204 } 205 tmpChip->analysis = NULL; 192 206 tmpChip->cells = psArrayAlloc(0); 193 207 tmpChip->parent = fpa; … … 196 210 } 197 211 tmpChip->valid = false; 198 tmpChip->extname = NULL; 199 tmpChip->pixels = NULL; 200 tmpChip->header = NULL; 212 tmpChip->private = NULL; 201 213 202 214 psMemSetDeallocator(tmpChip, (psFreeFunc) chipFree); … … 204 216 } 205 217 206 pmFPA *pmFPAAlloc( 207 const psMetadata *camera, 208 psDB *db) 218 pmFPA *pmFPAAlloc(const psMetadata *camera) 209 219 { 210 220 pmFPA *tmpFPA = (pmFPA *) psAlloc(sizeof(pmFPA)); … … 214 224 tmpFPA->projection = NULL; 215 225 tmpFPA->concepts = psMetadataAlloc(); 216 tmpFPA->analysis = psMetadataAlloc();226 tmpFPA->analysis = NULL; 217 227 tmpFPA->camera = camera; 218 228 psMemIncrRefCounter((psPtr) camera); 219 229 tmpFPA->chips = psArrayAlloc(0); 220 tmpFPA->header = NULL; 221 tmpFPA->db = db; 222 psMemIncrRefCounter((psPtr) db); 230 tmpFPA->private = NULL; 231 tmpFPA->phu = NULL; 223 232 224 233 psMemSetDeallocator(tmpFPA, (psFreeFunc) FPAFree); … … 739 748 psMetadataItem *pmReadoutGetConcept(pmReadout *readout, const char *concept) 740 749 { 741 return(psMetadataLookup(readout->concepts, concept)); 750 // return(psMetadataLookup(readout->concepts, concept)); 751 return(NULL); 742 752 } 743 753 -
trunk/psModules/src/astrom/pmAstrometry.h
r5170 r5435 8 8 * @author GLG, MHPCC 9 9 * 10 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $11 * @date $Date: 2005- 09-28 20:43:52$10 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-10-20 23:06:24 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 24 24 /// @addtogroup AstroImage 25 25 /// @{ 26 27 // XXXX: This is incorrect. Must determine what p_pmHDU is. 28 typedef struct 29 { 30 int what; 31 } 32 p_pmHDU; 26 33 27 34 /** Focal plane data structure … … 52 59 const psMetadata *camera; ///< Camera configuration 53 60 psArray *chips; ///< The chips 54 // FITS data 55 psMetadata *header; ///< The FITS header, if it corresponds to this level 56 psDB *db; ///< Database handle 61 p_pmHDU *private; ///< FITS data 62 psMetadata *phu; ///< Primary Header 57 63 } 58 64 pmFPA; … … 86 92 pmFPA *parent; ///< Parent FPA 87 93 bool valid; ///< Do we bother about reading and working with this chip? 88 // FITS data 89 const char *extname; ///< Extension name, if it corresponds to this level 90 psArray *pixels; ///< The pixel data, if it corresponds to this level 91 psMetadata *header; ///< The FITS header, if it corresponds to this level 94 p_pmHDU *private; ///< FITS data 92 95 } 93 96 pmChip; … … 113 116 // Information 114 117 psMetadata *concepts; ///< Cache for PS concepts 118 psMetadata *camera; ///< Camera Info 115 119 psMetadata *analysis; ///< Cell-level analysis metadata 116 120 psArray *readouts; ///< The readouts (referred to by number) 117 121 pmChip *parent; ///< Parent chip 118 122 bool valid; ///< Do we bother about reading and working with this cell? 119 // FITS data 120 const char *extname; ///< Extension name, if it corresponds to this level 121 psArray *pixels; ///< The pixel data, if it corresponds to this level 122 psMetadata *header; ///< The FITS header, if it corresponds to this level 123 p_pmHDU *private; ///< FITS data 123 124 } 124 125 pmCell; … … 143 144 // Information 144 145 psImage *image; ///< Imaging area of readout 145 // XXX: The following mask was removed from the pmReadout struct in recent SDRS146 // versions. However, I'm keeping it here since al ot of modules still require147 // it.148 146 psImage *mask; ///< Mask of input image 147 psImage *weight; ///< Weight of input image 148 psList *bias; ///< List of bias section (sub-)images 149 149 psMetadata *analysis; ///< Readout-level analysis metadata 150 psMetadata *concepts; ///< Cache for PS Concepts151 150 pmCell *parent; ///< Parent cell 152 151 } … … 178 177 */ 179 178 pmCell *pmCellAlloc( 180 pmChip *chip ///< Parent chip 179 pmChip *chip, ///< Parent chip 180 psMetadata *cameradata, 181 psString name 181 182 ); 182 183 … … 191 192 * @return pmChip* newly allocated pmChip 192 193 */ 193 pmChip *pmChipAlloc(pmFPA *fpa); 194 pmChip *pmChipAlloc( 195 pmFPA *fpa, 196 psString name 197 198 ); 194 199 195 200 /** Allocates a pmFPA … … 202 207 */ 203 208 pmFPA *pmFPAAlloc( 204 const psMetadata *camera, ///< Camera configuration 205 psDB *db ///< Database handle 209 const psMetadata *camera ///< Camera configuration 206 210 ); 207 211 -
trunk/psModules/src/config/pmConfig.c
r5356 r5435 3 3 * @author PAP, IfA 4 4 * 5 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $6 * @date $Date: 2005-10- 17 23:37:11$5 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2005-10-20 23:06:24 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 404 404 return recipe; 405 405 } 406 407 /****************************************************************************** 408 pmConfigDB(*site) 409 410 XXX: What should we use for the Database namespace in the call to psDBInit()? 411 This is currently NULL. 412 *****************************************************************************/ 413 414 psDB *pmConfigDB( 415 psMetadata *site) 416 { 417 PS_ASSERT_PTR_NON_NULL(site, NULL); 418 psBool mdStatus01 = false; 419 psBool mdStatus02 = false; 420 psBool mdStatus03 = false; 421 422 psString dbServer = psMetadataLookupStr(&mdStatus01, site, "DBSERVER"); 423 psString dbUsername = psMetadataLookupStr(&mdStatus02, site, "DBUSER"); 424 psString dbPassword = psMetadataLookupStr(&mdStatus03, site, "DBPASSWORD"); 425 if (!(mdStatus01 & mdStatus02 & mdStatus03)) { 426 psLogMsg(__func__, PS_LOG_WARN, "Could not determine database server name, userID, and password from site metadata.\n"); 427 return(NULL); 428 } 429 430 return(psDBInit(dbServer, dbUsername, dbPassword, NULL)); 431 } -
trunk/psModules/src/config/pmConfig.h
r5355 r5435 3 3 * @author PAP, IfA 4 4 * 5 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $6 * @date $Date: 2005-10- 17 21:34:12$5 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2005-10-20 23:06:24 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 84 84 ); 85 85 86 /** pmConfigDB 87 * 88 * pmConfigDB shall use the site configuration data to open a database handle. 89 * This is fairly straightforward at the moment, but will change when we beef up 90 * security. (TBD) 91 * 92 */ 93 psDB *pmConfigDB( 94 psMetadata *site 95 ); 96 97 86 98 #endif -
trunk/psModules/src/detrend/pmFlatField.c
r5170 r5435 18 18 * @author Ross Harman, MHPCC 19 19 * 20 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $21 * @date $Date: 2005- 09-28 20:43:52$20 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 21 * @date $Date: 2005-10-20 23:06:24 $ 22 22 * 23 23 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 38 38 39 39 40 bool pmFlatField(pmReadout *in, pmReadout *mask, const pmReadout *flat) 40 bool pmFlatField( 41 pmReadout *in, 42 const pmReadout *flat) 41 43 { 42 44 // XXX: Not sure if this is correct. Must consult with IfA. 43 PS_ASSERT_PTR_NON_NULL( mask, false);45 PS_ASSERT_PTR_NON_NULL(in->mask, false); 44 46 int i = 0; 45 47 int j = 0; … … 56 58 // Check for nulls 57 59 if (in == NULL) { 58 return true; // Readout m ay not have data in it60 return true; // Readout might have data in it 59 61 } else if(flat==NULL) { 60 62 psError( PS_ERR_BAD_PARAMETER_NULL, true, … … 74 76 return false; 75 77 } 76 inMask = mask->image;78 inMask = in->mask; 77 79 78 80 // Check input image and its mask are not larger than flat image -
trunk/psModules/src/detrend/pmFlatField.h
r5170 r5435 18 18 * @author Ross Harman, MHPCC 19 19 * 20 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $21 * @date $Date: 2005- 09-28 20:43:52$20 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 21 * @date $Date: 2005-10-20 23:06:24 $ 22 22 * 23 23 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 37 37 bool pmFlatField( 38 38 pmReadout *in, ///< Readout with input image 39 pmReadout *mask, ///< Input image mask40 39 const pmReadout *flat ///< Readout with flat image 41 40 ); -
trunk/psModules/src/detrend/pmNonLinear.c
r5170 r5435 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $8 * @date $Date: 2005- 09-28 20:43:52$7 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-10-20 23:06:24 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 56 56 inFluxe, and the corresponding value in outFlux. The image pixel will then 57 57 be set to the value from outFlux. 58 59 XXX: Must assert that filename exists. This should probably happen in 60 the lookup files. 58 61 *****************************************************************************/ 59 pmReadout *pmNonLinearityLookup(pmReadout *inputReadout, 60 const psVector *inFlux, 61 const psVector *outFlux) 62 pmReadout *pmNonLinearityLookup( 63 pmReadout *inputReadout, 64 const char *filename 65 ) 62 66 { 63 67 PS_ASSERT_PTR_NON_NULL(inputReadout,NULL); 64 68 PS_ASSERT_PTR_NON_NULL(inputReadout->image,NULL); 65 69 PS_ASSERT_IMAGE_TYPE(inputReadout->image, PS_TYPE_F32, NULL); 66 PS_ASSERT_PTR_NON_NULL(inFlux,NULL); 67 if (inFlux->n < 2) { 68 psError(PS_ERR_UNKNOWN,true, "pmNonLinearityLookup(): input vector less than 2 elements. Returning inputReadout image."); 69 return(inputReadout); 70 } 71 PS_ASSERT_PTR_NON_NULL(outFlux,NULL); 72 psS32 tableSize = inFlux->n; 73 if (inFlux->n != outFlux->n) { 74 tableSize = PS_MIN(inFlux->n, outFlux->n); 70 psLookupTable *tmpLT = psLookupTableAlloc(filename, "%f %f", 0); 71 psS32 numLines = psLookupTableRead(tmpLT); 72 psS32 numPixels = 0; 73 if (numLines < 2) { 75 74 psLogMsg(__func__, PS_LOG_WARN, 76 "WARNING: pmNonLinear.c: pmNonLinearityLookup(): input vectors have different sizes (%d, %d)\n", inFlux->n, outFlux->n); 77 } 78 PS_ASSERT_VECTOR_TYPE(inFlux, PS_TYPE_F32, NULL); 79 PS_ASSERT_VECTOR_TYPE(outFlux, PS_TYPE_F32, NULL); 80 81 psS32 i; 82 psS32 j; 83 psS32 binNum; 84 psScalar x; 85 psS32 numPixels = 0; 86 psF32 slope; 87 88 x.type.type = PS_TYPE_F32; 89 for (i=0;i<inputReadout->image->numRows;i++) { 90 for (j=0;j<inputReadout->image->numCols;j++) { 91 x.data.F32 = inputReadout->image->data.F32[i][j]; 92 binNum = p_psVectorBinDisect((psVector *)inFlux, &x); 93 94 if (binNum == -2) { 95 // We get here if x is below the table lookup range. 96 inputReadout->image->data.F32[i][j] = outFlux->data.F32[0]; 97 numPixels++; 98 99 } else if (binNum == -1) { 100 // We get here if x is above the table lookup range. 101 inputReadout->image->data.F32[i][j] = outFlux->data.F32[tableSize-1]; 102 numPixels++; 103 104 } else if (binNum < -2) { 105 // We get here if there was some other problem. 106 psError(PS_ERR_UNKNOWN,true, "pmNonLinearityLookup(): Could not perform p_psVectorBinDisect(). Returning inputReadout image."); 107 return(inputReadout); 108 numPixels++; 109 } else { 110 // Perform linear interpolation. 111 slope = (outFlux->data.F32[binNum+1] - outFlux->data.F32[binNum]) / 112 (inFlux->data.F32[binNum+1] - inFlux->data.F32[binNum]); 113 inputReadout->image->data.F32[i][j] = outFlux->data.F32[binNum] + 114 ((x.data.F32 - inFlux->data.F32[binNum]) * slope); 75 "WARNING: Lookup Table is too small. Returning original pmReadout.\n"); 76 } else { 77 for (psS32 i=0;i<inputReadout->image->numRows;i++) { 78 for (psS32 j=0;j<inputReadout->image->numCols;j++) { 79 psF64 tmpD = psLookupTableInterpolate(tmpLT, inputReadout->image->data.F32[i][j], 1); 80 if (!isnan(tmpD)) { 81 inputReadout->image->data.F32[i][j] = tmpD; 82 } else { 83 numPixels++; 84 } 115 85 } 116 86 } 87 if (numPixels > 0) { 88 psLogMsg(__func__, PS_LOG_WARN, 89 "WARNING: pmNonLinear.c: pmNonLinearityLookup(): %d pixels outside table.", numPixels); 90 } 117 91 } 118 if (numPixels > 0) { 119 psLogMsg(__func__, PS_LOG_WARN, 120 "WARNING: pmNonLinear.c: pmNonLinearityLookup(): %d pixels outside table.", numPixels); 121 } 92 122 93 return(inputReadout); 123 94 } -
trunk/psModules/src/detrend/pmNonLinear.h
r5170 r5435 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $8 * @date $Date: 2005- 09-28 20:43:52$7 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-10-20 23:06:24 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 18 18 #include "pmAstrometry.h" 19 19 20 pmReadout *pmNonLinearityPolynomial(pmReadout *in, 21 const psPolynomial1D *coeff); 20 pmReadout *pmNonLinearityPolynomial( 21 pmReadout *in, 22 const psPolynomial1D *coeff 23 ); 22 24 23 pmReadout *pmNonLinearityLookup(pmReadout *in, 24 const psVector *inFlux, 25 const psVector *outFlux); 25 pmReadout *pmNonLinearityLookup( 26 pmReadout *in, 27 const char *filename 28 ); 26 29 27 30 #endif -
trunk/psModules/src/imsubtract/pmSubtractBias.c
r5294 r5435 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-10- 12 21:02:04 $8 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-10-20 23:06:24 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 282 282 XXX: The SDRS does not specify type support. F32 is implemented here. 283 283 *****************************************************************************/ 284 pmReadout *pmSubtractBias(pmReadout *in, 285 void *fitSpec, 286 const psList *overscans, 287 pmOverscanAxis overScanAxis, 288 psStats *stat, 289 psS32 nBinOrig, 290 pmFit fit, 291 const pmReadout *bias) 284 pmReadout *pmSubtractBias( 285 pmReadout *in, 286 void *fitSpec, 287 pmFit fit, 288 bool overscan, 289 psStats *stat, 290 int nBin, 291 const pmReadout *bias, 292 const pmReadout *dark 293 ) 292 294 { 293 295 psTrace(".psModule.pmSubtracBias.pmSubtractBias", 4, -
trunk/psModules/src/imsubtract/pmSubtractBias.h
r5170 r5435 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2005- 09-28 20:43:52$8 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-10-20 23:06:24 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 38 38 } pmFit; 39 39 40 pmReadout *pmSubtractBias(pmReadout *in, ///< The input pmReadout image 41 void *fitSpec, ///< A polynomial or spline, defining the fit type. 42 const psList *overscans, ///< A psList of overscan images 43 pmOverscanAxis overScanAxis, ///< Defines how overscans are applied 44 psStats *stat, ///< The statistic to be used in combining overscan data 45 int nBin, ///< The amount of binning to be done image pixels. 46 pmFit fit, ///< PM_FIT_SPLINE, PM_FIT_POLYNOMIAL, or PM_FIT_NONE 47 const pmReadout *bias); ///< A possibly NULL bias pmReadout which is to be subtracted 40 pmReadout *pmSubtractBias( 41 pmReadout *in, ///< The input pmReadout image 42 void *fitSpec, ///< A polynomial or spline, defining the fit type. 43 pmFit fit, ///< PM_FIT_SPLINE, PM_FIT_POLYNOMIAL, or PM_FIT_NONE 44 bool overscan, 45 psStats *stat, ///< The statistic to be used in combining overscan data 46 int nBin, ///< The amount of binning to be done image pixels. 47 const pmReadout *bias, ///< A possibly NULL bias pmReadout which is to be subtracted 48 const pmReadout *dark ///< A possibly NULL bias pmReadout which is to be subtracted 49 ) 50 // OLD: remove this 51 // const psList *overscans, ///< A psList of overscan images 52 // pmOverscanAxis overScanAxis, ///< Defines how overscans are applied 48 53 49 54 #endif -
trunk/psModules/src/objects/pmObjects.c
r5255 r5435 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-10- 10 19:53:40$8 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-10-20 23:06:24 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 1445 1445 XXX: What is mode? 1446 1446 XXX: The top, bottom of the contour is not correctly determined. 1447 XXX EAM : this function sis using the model for the contour, but it should1447 XXX EAM : this function is using the model for the contour, but it should 1448 1448 be using only the image counts 1449 1449 *****************************************************************************/ -
trunk/psModules/test/astrom/tst_pmAstrometry.c
r5169 r5435 1 1 /** @file tst_pmAstrometry.c 2 2 * 3 * @brief Contains the tests forpmAstrometry.[ch]. Only the pmxxxAlloc()3 * @brief Contains the tests: pmAstrometry.[ch]. Only the pmxxxAlloc() 4 4 * and psFree() functionality are used here. 5 5 * 6 6 * @author George Gusciora, MHPCC 7 7 * 8 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2005- 09-28 20:42:51$8 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-10-20 23:06:24 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 32 32 }; 33 33 34 #define CHIP_ALLOC_NAME "ChipName" 35 #define CELL_ALLOC_NAME "CellName" 36 34 37 psS32 main(psS32 argc, char* argv[]) 35 38 { … … 44 47 // XXX: Do something more with these arguments. 45 48 const psMetadata *camera = psMetadataAlloc(); 46 psDB *db = NULL; 47 pmFPA* fpa = pmFPAAlloc(camera, db); 49 pmFPA* fpa = pmFPAAlloc(camera); 48 50 49 51 if (fpa == NULL) { 50 psLogMsg(__func__,PS_LOG_ERROR, " pmFPAAlloc returned a NULL.");52 psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc returned a NULL."); 51 53 return 1; 52 54 } 53 55 54 56 if (fpa->fromTangentPlane != NULL) { 55 psLogMsg(__func__,PS_LOG_ERROR, " pmFPAAlloc did not set ->fromTangentPlane to NULL.");57 psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->fromTangentPlane to NULL."); 56 58 return 2; 57 59 } 58 60 59 61 if (fpa->toTangentPlane != NULL) { 60 psLogMsg(__func__,PS_LOG_ERROR, " pmFPAAlloc did not set ->toTangentPlane to NULL.");62 psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->toTangentPlane to NULL."); 61 63 return 3; 62 64 } 63 65 if (fpa->projection != NULL) { 64 psLogMsg(__func__,PS_LOG_ERROR, " pmFPAAlloc did not set ->projection to NULL.");66 psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->projection to NULL."); 65 67 return 4; 66 68 } 67 69 68 70 if (fpa->concepts == NULL) { 69 psLogMsg(__func__,PS_LOG_ERROR, " pmFPAAlloc did not set ->concepts.");71 psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->concepts."); 70 72 return 5; 71 73 } 72 74 73 if (fpa->analysis == NULL) {74 psLogMsg(__func__,PS_LOG_ERROR, " pmFPAAlloc did not set ->analysis.");75 if (fpa->analysis != NULL) { 76 psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->analysis to NULL."); 75 77 return 6; 76 78 } 77 79 78 80 if (fpa->camera != camera) { 79 psLogMsg(__func__,PS_LOG_ERROR, " pmFPAAlloc did not set ->camera.");81 psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->camera."); 80 82 return 7; 81 83 } 82 84 83 85 if (fpa->chips == NULL) { 84 psLogMsg(__func__,PS_LOG_ERROR, " pmFPAAlloc did not set ->chips.");86 psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->chips."); 85 87 return 8; 86 88 } 87 89 88 if (fpa-> header!= NULL) {89 psLogMsg(__func__,PS_LOG_ERROR, " pmFPAAlloc did not set ->headerto NULL.");90 if (fpa->private != NULL) { 91 psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc did not set ->private to NULL."); 90 92 return 9; 91 93 } 92 94 93 if (fpa->db != db) { 94 psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc did not set ->db."); 95 psFree(fpa); 96 psFree(camera); 97 98 return 0; 99 } 100 101 static psS32 testChipAlloc(void) 102 { 103 const psMetadata *camera = psMetadataAlloc(); 104 pmFPA* fpa = pmFPAAlloc(camera); 105 if (fpa == NULL) { 106 psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc returned a NULL."); 107 return 1; 108 } 109 110 pmChip *chip = pmChipAlloc(fpa, CHIP_ALLOC_NAME); 111 if (chip == NULL) { 112 psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmChipAlloc returned a NULL."); 113 return 1; 114 } 115 116 if (chip->col0 != -1) { 117 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->col0 set improperly.\n"); 118 return 5; 119 } 120 121 if (chip->row0 != -1) { 122 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->row0 set improperly.\n"); 123 return 6; 124 } 125 126 if (chip->toFPA != NULL) { 127 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->toChip set improperly.\n"); 128 return 7; 129 } 130 131 if (chip->fromFPA != NULL) { 132 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->toFPA set improperly.\n"); 133 return 8; 134 } 135 136 if (chip->concepts == NULL) { 137 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->concepts set improperly.\n"); 138 return 21; 139 } else { 140 psMetadataItem *tmpMeta = psMetadataLookup(chip->concepts, "CHIP.NAME"); 141 if (0 != strcmp((char *) tmpMeta->data.V, CHIP_ALLOC_NAME)) { 142 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: The metadata was set improperly.\n"); 143 return (32); 144 } 145 // XXX: Code a test to ensure the metadata has the correct type 146 } 147 148 if (chip->analysis != NULL) { 149 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->analysis set improperly.\n"); 95 150 return 10; 96 151 } 97 152 98 psFree(camera);99 psFree(fpa);100 101 return 0;102 }103 104 static psS32 testChipAlloc(void)105 {106 const psMetadata *camera = psMetadataAlloc();107 psDB *db = NULL;108 pmFPA* fpa = pmFPAAlloc(camera, db);109 if (fpa == NULL) {110 psLogMsg(__func__,PS_LOG_ERROR, "pmFPAAlloc returned a NULL.");111 return 1;112 }113 114 pmChip *chip = pmChipAlloc(fpa);115 if (chip == NULL) {116 psLogMsg(__func__,PS_LOG_ERROR, "pmChipAlloc returned a NULL.");117 return 1;118 }119 120 if (chip->col0 != -1) {121 psLogMsg(__func__, PS_LOG_ERROR, "chip->col0 set improperly.\n");122 return 5;123 }124 125 if (chip->row0 != -1) {126 psLogMsg(__func__, PS_LOG_ERROR, "chip->row0 set improperly.\n");127 return 6;128 }129 130 if (chip->toFPA != NULL) {131 psLogMsg(__func__, PS_LOG_ERROR, "chip->toChip set improperly.\n");132 return 7;133 }134 135 if (chip->fromFPA != NULL) {136 psLogMsg(__func__, PS_LOG_ERROR, "chip->toFPA set improperly.\n");137 return 8;138 }139 140 if (chip->concepts == NULL) {141 psLogMsg(__func__, PS_LOG_ERROR, "chip->concepts set improperly.\n");142 return 21;143 }144 145 if (chip->analysis == NULL) {146 psLogMsg(__func__, PS_LOG_ERROR, "chip->analysis set improperly.\n");147 return 10;148 }149 150 153 if (chip->cells == NULL) { 151 psLogMsg(__func__, PS_LOG_ERROR, " chip->cells set improperly.\n");154 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->cells set improperly.\n"); 152 155 return 22; 153 156 } 154 157 155 158 if (chip->parent != fpa) { 156 psLogMsg(__func__, PS_LOG_ERROR, " chip->parent set improperly.\n");159 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->parent set improperly.\n"); 157 160 return 23; 158 161 } 159 162 160 163 if (chip->valid != false) { 161 psLogMsg(__func__, PS_LOG_ERROR, " chip->valid set improperly.\n");164 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->valid set improperly.\n"); 162 165 return 24; 163 166 } 164 167 165 if (chip-> extname != NULL) {166 psLogMsg(__func__, PS_LOG_ERROR, " chip->extname set improperly.\n");168 if (chip->private != NULL) { 169 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: chip->private set improperly.\n"); 167 170 return 25; 168 }169 170 if (chip->pixels != NULL) {171 psLogMsg(__func__, PS_LOG_ERROR, "chip->pixels set improperly.\n");172 return 26;173 }174 175 if (chip->header != NULL) {176 psLogMsg(__func__, PS_LOG_ERROR, "chip->header set improperly.\n");177 return 27;178 171 } 179 172 … … 187 180 static psS32 testCellAlloc(void) 188 181 { 189 psDB *db = NULL;190 182 const psMetadata *camera = psMetadataAlloc(); 191 pmFPA* fpa = pmFPAAlloc(camera , db);183 pmFPA* fpa = pmFPAAlloc(camera); 192 184 if (fpa == NULL) { 193 psLogMsg(__func__,PS_LOG_ERROR, " pmFPAAlloc returned a NULL.n");194 return 1; 195 } 196 197 pmChip *chip = pmChipAlloc(fpa );185 psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc returned a NULL.n"); 186 return 1; 187 } 188 189 pmChip *chip = pmChipAlloc(fpa, CHIP_ALLOC_NAME); 198 190 if (chip == NULL) { 199 psLogMsg(__func__,PS_LOG_ERROR, " pmChipAlloc returned a NULL.n");191 psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmChipAlloc returned a NULL.n"); 200 192 return 2; 201 193 } 202 194 203 pmCell *cell = pmCellAlloc(chip );195 pmCell *cell = pmCellAlloc(chip, (psMetadata *) camera, CELL_ALLOC_NAME); 204 196 if (cell == NULL) { 205 psLogMsg(__func__,PS_LOG_ERROR, " pmCellAlloc returned a NULL.n");197 psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmCellAlloc returned a NULL.n"); 206 198 return 3; 207 199 } 208 200 209 201 if (cell->col0 != -1) { 210 psLogMsg(__func__, PS_LOG_ERROR, " cell->col0 set improperly.\n");202 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->col0 set improperly.\n"); 211 203 return 5; 212 204 } 213 205 214 206 if (cell->row0 != -1) { 215 psLogMsg(__func__, PS_LOG_ERROR, " cell->row0 set improperly.\n");207 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->row0 set improperly.\n"); 216 208 return 6; 217 209 } 218 210 219 211 if (cell->toChip != NULL) { 220 psLogMsg(__func__, PS_LOG_ERROR, " cell->toChip set improperly.\n");212 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->toChip set improperly.\n"); 221 213 return 7; 222 214 } 223 215 224 216 if (cell->toFPA != NULL) { 225 psLogMsg(__func__, PS_LOG_ERROR, " cell->toFPA set improperly.\n");217 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->toFPA set improperly.\n"); 226 218 return 8; 227 219 } 228 220 229 221 if (cell->toSky != NULL) { 230 psLogMsg(__func__, PS_LOG_ERROR, " cell->toSky set improperly.\n");222 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->toSky set improperly.\n"); 231 223 return 9; 232 224 } 233 225 234 if (cell->analysis == NULL) { 235 psLogMsg(__func__, PS_LOG_ERROR, "cell->analysis set improperly.\n"); 226 if (cell->concepts == NULL) { 227 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->concepts set improperly.\n"); 228 return 21; 229 } else { 230 psMetadataItem *tmpMeta = psMetadataLookup(cell->concepts, "CELL.NAME"); 231 if (0 != strcmp((char *) tmpMeta->data.V, CELL_ALLOC_NAME)) { 232 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: The metadata was set improperly.\n"); 233 return (32); 234 } 235 // XXX: Code a test to ensure the metadata has the correct type 236 } 237 238 if (cell->camera != camera) { 239 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->camera set improperly.\n"); 240 return 20; 241 } 242 243 if (cell->analysis != NULL) { 244 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->analysis set improperly.\n"); 236 245 return 10; 237 246 } 238 247 239 if (cell->concepts == NULL) {240 psLogMsg(__func__, PS_LOG_ERROR, "cell->concepts set improperly.\n");241 return 21;242 }243 244 248 if (cell->readouts == NULL) { 245 psLogMsg(__func__, PS_LOG_ERROR, " cell->readouts set improperly.\n");249 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->readouts set improperly.\n"); 246 250 return 22; 247 251 } 248 252 249 253 if (cell->parent != chip) { 250 psLogMsg(__func__, PS_LOG_ERROR, " cell->parent set improperly.\n");254 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->parent set improperly.\n"); 251 255 return 23; 252 256 } 253 257 254 258 if (cell->valid != false) { 255 psLogMsg(__func__, PS_LOG_ERROR, " cell->valid set improperly.\n");259 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->valid set improperly.\n"); 256 260 return 24; 257 261 } 258 262 259 if (cell->extname != NULL) { 260 psLogMsg(__func__, PS_LOG_ERROR, "cell->extname set improperly.\n"); 261 return 25; 262 } 263 264 if (cell->pixels != NULL) { 265 psLogMsg(__func__, PS_LOG_ERROR, "cell->pixels set improperly.\n"); 266 return 26; 267 } 268 269 if (cell->header != NULL) { 270 psLogMsg(__func__, PS_LOG_ERROR, "cell->header set improperly.\n"); 263 if (cell->private != NULL) { 264 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: cell->private set improperly.\n"); 271 265 return 27; 272 266 } … … 282 276 static psS32 testReadoutAlloc(void) 283 277 { 284 psDB *db = NULL;285 278 const psMetadata *camera = psMetadataAlloc(); 286 pmFPA* fpa = pmFPAAlloc(camera , db);279 pmFPA* fpa = pmFPAAlloc(camera); 287 280 288 281 if (fpa == NULL) { 289 psLogMsg(__func__,PS_LOG_ERROR, " pmFPAAlloc returned a NULL.\n");290 return 1; 291 } 292 293 pmChip *chip = pmChipAlloc(fpa );282 psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmFPAAlloc returned a NULL.\n"); 283 return 1; 284 } 285 286 pmChip *chip = pmChipAlloc(fpa, "ChipName"); 294 287 if (chip == NULL) { 295 psLogMsg(__func__,PS_LOG_ERROR, " pmChipAlloc returned a NULL.\n");288 psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmChipAlloc returned a NULL.\n"); 296 289 return 2; 297 290 } 298 291 299 pmCell *cell = pmCellAlloc(chip );292 pmCell *cell = pmCellAlloc(chip, (psMetadata *) camera, "CellName"); 300 293 if (cell == NULL) { 301 psLogMsg(__func__,PS_LOG_ERROR, " pmCellAlloc returned a NULL.\n");294 psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmCellAlloc returned a NULL.\n"); 302 295 return 3; 303 296 } … … 305 298 pmReadout *readout = pmReadoutAlloc(cell); 306 299 if (readout == NULL) { 307 psLogMsg(__func__,PS_LOG_ERROR, " pmReadoutAlloc returned a NULL.\n");300 psLogMsg(__func__,PS_LOG_ERROR, "TEST ERROR: pmReadoutAlloc returned a NULL.\n"); 308 301 return 4; 309 302 } 310 303 311 304 if (readout->col0 != -1) { 312 psLogMsg(__func__, PS_LOG_ERROR, " pmReadout->col0 set improperly.\n");305 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->col0 set improperly.\n"); 313 306 return 5; 314 307 } 315 308 316 309 if (readout->row0 != -1) { 317 psLogMsg(__func__, PS_LOG_ERROR, " pmReadout->row0 set improperly.\n");310 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->row0 set improperly.\n"); 318 311 return 6; 319 312 } 320 313 321 314 if (readout->colBins != -1) { 322 psLogMsg(__func__, PS_LOG_ERROR, " pmReadout->colBins set improperly.\n");315 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->colBins set improperly.\n"); 323 316 return 7; 324 317 } 325 318 326 319 if (readout->rowBins != -1) { 327 psLogMsg(__func__, PS_LOG_ERROR, " pmReadout->colBins set improperly.\n");320 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->colBins set improperly.\n"); 328 321 return 8; 329 322 } 330 323 331 324 if (readout->image != NULL) { 332 psLogMsg(__func__, PS_LOG_ERROR, " pmReadout->image set improperly.\n");333 return 9;325 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->image set improperly.\n"); 326 return 10; 334 327 } 335 328 336 329 if (readout->mask != NULL) { 337 psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->mask set improperly.\n"); 338 return 10; 330 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->mask set improperly.\n"); 331 return 12; 332 } 333 334 if (readout->weight != NULL) { 335 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->weight set improperly.\n"); 336 return 14; 337 } 338 339 if (readout->bias != NULL) { 340 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->bias set improperly.\n"); 341 return 16; 339 342 } 340 343 341 344 if (readout->analysis == NULL) { 342 psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->analysis set improperly.\n"); 343 return 11; 344 } 345 346 if (readout->concepts == NULL) { 347 psLogMsg(__func__, PS_LOG_ERROR, "pmReadout->concepts set improperly.\n"); 348 return 12; 345 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->analysis set improperly.\n"); 346 return 18; 349 347 } 350 348 351 349 if (readout->parent != cell) { 352 psLogMsg(__func__, PS_LOG_ERROR, " pmReadout->parent set improperly.\n");353 return 15;350 psLogMsg(__func__, PS_LOG_ERROR, "TEST ERROR: pmReadout->parent set improperly.\n"); 351 return 20; 354 352 } 355 353 … … 362 360 return 0; 363 361 } 362 -
trunk/psModules/test/config/Makefile.am
r5169 r5435 4 4 AM_CFLAGS = @AM_CFLAGS@ $(PSMODULE_CFLAGS) $(SRCINC) 5 5 6 TESTS = 6 TESTS = \ 7 tst_pmConfig 8 9 tst_pmConfig_SOURCES = tst_pmConfig.c 7 10 8 11 check_PROGRAMS = $(TESTS) … … 10 13 TESTS_ENVIRONMENT = perl $(top_srcdir)/test/runTest --verified=$(srcdir)/verified 11 14 12 tests: 15 tests: $(TESTS) 16 17 EXTRA_DIST = verified 18 19 CLEANFILES = $(TESTS) temp/* 13 20 14 21 test: check -
trunk/psModules/test/detrend/tst_pmFlatField.c
r5169 r5435 21 21 * @author Ross Harman, MHPCC 22 22 * 23 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $24 * @date $Date: 2005- 09-28 20:42:52$23 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 24 * @date $Date: 2005-10-20 23:06:24 $ 25 25 * 26 26 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 85 85 inReadout->row0 = 0; 86 86 inReadout->col0 = 0; 87 CREATE_AND_SET_IMAGE(inMask, U8, 0, 3,3); 88 inReadout->mask = inMask; 89 PRINT_MATRIX((inReadout->mask),U8,"Input mask:"); 87 90 PRINT_MATRIX(inImage,F64,"Input image:"); 88 89 CREATE_AND_SET_IMAGE(inMask,U8,0,3,3)90 pmReadout *inMaskReadout = pmReadoutAlloc(NULL);91 inMaskReadout->image = inMask;92 inMaskReadout->row0 = 0;93 inMaskReadout->col0 = 0;94 PRINT_MATRIX(inMask,U8,"Input mask:");95 91 96 92 CREATE_AND_SET_IMAGE(flatImage1,F64,2.0,3,3) … … 101 97 PRINT_MATRIX(flatImage1,F64,"Flat image:"); 102 98 103 if ( !pmFlatField(inReadout, inMaskReadout,flatReadout) ) {99 if ( !pmFlatField(inReadout, flatReadout) ) { 104 100 psError(PS_ERR_UNKNOWN,true,"Test A - Returned false should be true"); 105 101 return 1; … … 116 112 PRINT_MATRIX(flatImage2, F64, "Flat image:"); 117 113 flatReadout->image = flatImage2; 118 if ( !pmFlatField(inReadout, inMaskReadout,flatReadout) ) {114 if ( !pmFlatField(inReadout, flatReadout) ) { 119 115 psError(PS_ERR_UNKNOWN,true,"Test B - Returned false should be true"); 120 116 return 2; 121 117 } 122 PRINT_MATRIX(in MaskReadout->image, PS_TYPE_MASK_DATA, "Resulting mask:");118 PRINT_MATRIX(inReadout->mask, PS_TYPE_MASK_DATA, "Resulting mask:"); 123 119 PRINT_MATRIX(inImage,F64,"Resulting image:"); 124 120 printFooter(stdout, "pmFlatField", "Test B - Mask flat image data", true); … … 135 131 psFree(inReadout->mask); 136 132 inReadout->mask = mask1; 137 if ( !pmFlatField(inReadout, inMaskReadout,flatReadout) ) {133 if ( !pmFlatField(inReadout, flatReadout) ) { 138 134 psError(PS_ERR_UNKNOWN,true,"Test C - Returned false should be true"); 139 135 return 3; … … 149 145 printNegativeTestHeader(stdout,"pmFlatField", "Test D - Attempt to use null flat readout", 150 146 "Null not allowed for flat readout", 0); 151 if( pmFlatField(inReadout, inMaskReadout,NULL) ) {147 if( pmFlatField(inReadout, NULL) ) { 152 148 psError(PS_ERR_UNKNOWN,true,"Test D - Returned true should be false"); 153 149 return 4; … … 162 158 psImage *temp = inReadout->image; 163 159 inReadout->image = NULL; 164 if ( pmFlatField(inReadout, inMaskReadout,flatReadout) ) {160 if ( pmFlatField(inReadout, flatReadout) ) { 165 161 psError(PS_ERR_UNKNOWN,true,"Test E - Returned true should be false" ); 166 162 return 5; 167 163 } 168 inReadout->image = temp ;164 inReadout->image = temp ; 169 165 printFooter(stdout, "pmFlatField", "Test E - Attempt to use null input image", true); 170 166 printf("\n\n\n"); … … 176 172 temp = flatReadout->image; 177 173 flatReadout->image = NULL; 178 if ( pmFlatField(inReadout, inMaskReadout,flatReadout) ) {174 if ( pmFlatField(inReadout, flatReadout) ) { 179 175 psError(PS_ERR_UNKNOWN,true,"Test F - Returned true should be false" ); 180 176 return 6; … … 191 187 temp = flatReadout->image; 192 188 flatReadout->image = smallFlat; 193 if ( pmFlatField(inReadout, inMaskReadout,flatReadout) ) {189 if ( pmFlatField(inReadout, flatReadout) ) { 194 190 psError(PS_ERR_UNKNOWN,true,"Test G - Returned true should be false"); 195 191 return 7; … … 198 194 printFooter(stdout, "pmFlatField", "Test G - Attempt to use input image bigger than flat image", true); 199 195 printf("\n\n\n"); 200 201 196 202 197 // Test H - Attempt to use input image mask bigger than flat image … … 204 199 "Input image mask size exceeds that of flat image", 0); 205 200 CREATE_AND_SET_IMAGE(largeMask,F64,0.0,5,5); 206 temp = inReadout->mask; 207 inMaskReadout->image = largeMask; 208 if ( pmFlatField(inReadout, inMaskReadout, flatReadout) ) { 201 inReadout->mask = largeMask; 202 if ( pmFlatField(inReadout, flatReadout) ) { 209 203 psError(PS_ERR_UNKNOWN,true,"Test H - Returned true should be false"); 210 204 return 8; 211 205 } 212 inReadout->mask = temp;213 206 printFooter(stdout, "pmFlatField", "Test H - Attempt to use input image mask bigger than flat image", true); 214 207 printf("\n\n\n"); 215 208 inReadout->mask = mask1; 216 209 217 210 // Test I - Attempt to use offset greater than input image … … 220 213 *(int*)&inReadout->col0 = 50; 221 214 *(int*)&inReadout->row0 = 50; 222 if ( pmFlatField(inReadout, inMaskReadout,flatReadout) ) {215 if ( pmFlatField(inReadout, flatReadout) ) { 223 216 psError(PS_ERR_UNKNOWN,true,"Test I - Returned true should be false"); 224 217 return 9; … … 234 227 "Complex types not allowed for input image", 0); 235 228 *(psElemType* ) & inReadout->image->type.type = PS_TYPE_C64; 236 if ( pmFlatField(inReadout, inMaskReadout,flatReadout) ) {229 if ( pmFlatField(inReadout, flatReadout) ) { 237 230 psError(PS_ERR_UNKNOWN,true,"Test J - Returned true should be false"); 238 231 return 10; … … 247 240 "Complex types not allowed for flat image", 0); 248 241 *(psElemType* ) & flatReadout->image->type.type = PS_TYPE_C64; 249 if ( pmFlatField(inReadout, inMaskReadout,flatReadout) ) {242 if ( pmFlatField(inReadout, flatReadout) ) { 250 243 psError(PS_ERR_UNKNOWN,true,"Test K - Returned ture should be false"); 251 244 return 11; … … 260 253 "Input and flat image types differ", 0); 261 254 *(psElemType* ) & flatReadout->image->type.type = PS_TYPE_F32; 262 if ( pmFlatField(inReadout, inMaskReadout,flatReadout) ) {255 if ( pmFlatField(inReadout, flatReadout) ) { 263 256 psError(PS_ERR_UNKNOWN,true,"Test L - Returned true should be false"); 264 257 return 12; … … 273 266 "Mask must be PS_TYPE_MASK type", 0); 274 267 *(psElemType* ) & inReadout->mask->type.type = PS_TYPE_F32; 275 if ( pmFlatField(inReadout, inMaskReadout,flatReadout) ) {268 if ( pmFlatField(inReadout, flatReadout) ) { 276 269 psError(PS_ERR_UNKNOWN,true,"Test M - Returned true should be false"); 277 270 return 13; … … 283 276 284 277 // Free memory 285 psFree(inMask);286 psFree(largeMask);287 inMaskReadout->image = NULL;288 psFree(inMaskReadout);289 278 psFree(inReadout); 290 279 psFree(flatReadout); … … 293 282 //psFree(flatImage1); 294 283 psFree(smallFlat); 284 psFree(largeMask); 295 285 296 286 return 0; -
trunk/psModules/test/detrend/tst_pmNonLinear.c
r5169 r5435 1 /* *@file tst_pmNonLinear.c1 /* @file tst_pmNonLinear.c 2 2 * 3 3 * @brief Contains the tests for pmNonLinear.c: … … 16 16 * @author GLG, MHPCC 17 17 * 18 * @version $Revision: 1.1 $ $Name: not supported by cvs2svn $ 19 * @date $Date: 2005-09-28 20:42:52 $ 18 * XXX: Add tests in which the lookup file has incorrect number of entries, 19 * and where the data is outside the pmReadout range. 20 * 21 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 22 * @date $Date: 2005-10-20 23:06:24 $ 20 23 * 21 24 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 37 40 }; 38 41 39 40 int main(int argc, char* argv[])41 {42 psLogSetFormat("HLNM");43 return !runTestSuite(stderr, "Test Point Driver", tests, argc, argv);44 }45 46 42 #define NUM_ROWS 8 47 43 #define NUM_COLS 8 44 #define LOOKUP_FILENAME ".tmp_tst_pmNonLinearLookupFile" 45 int main(int argc, char* argv[]) 46 { 47 psLogSetFormat("HLNM"); 48 // 49 // We generate a lookup file for future tests. We should probably remove 50 // it when we're done. 51 // 52 FILE *fp = fopen(LOOKUP_FILENAME, "w"); 53 ; 54 for (psS32 i=0;i<PS_MAX(NUM_COLS, NUM_ROWS)*3;i++) { 55 fprintf(fp, "%f %f\n", (float) i, (float) (2 * i)); 56 } 57 fclose(fp); 58 59 // system("rm LOOKUP_FILENAME"); 60 return !runTestSuite(stderr, "Test Point Driver", tests, argc, argv); 61 } 62 48 63 int doNonLinearityPolynomialTest(int numCols, int numRows) 49 64 { … … 105 120 float expect; 106 121 int testStatus = true; 107 int tableSize = PS_MAX(numCols, numRows)*2;108 122 psImage *myImage = psImageAlloc(numCols, numRows, PS_TYPE_F32); 109 123 pmReadout *myReadout = pmReadoutAlloc(NULL); 110 124 myReadout->image = myImage; 111 psVector *in = psVectorAlloc(tableSize, PS_TYPE_F32);112 psVector *out = psVectorAlloc(tableSize, PS_TYPE_F32);113 125 114 126 printPositiveTestHeader(stdout, "pmNonLinear", "doNonLinearityLookupTest"); … … 119 131 } 120 132 121 for (i=0;i<tableSize;i++) { 122 in->data.F32[i] = (float) i; 123 out->data.F32[i] = (float) (2 * i); 124 } 125 126 myReadout = pmNonLinearityLookup(myReadout, in, out); 133 myReadout = pmNonLinearityLookup(myReadout, LOOKUP_FILENAME); 127 134 for (i=0;i<numRows;i++) { 128 135 for (j=0;j<numCols;j++) { … … 136 143 } 137 144 138 139 psFree(myReadout); 140 psFree(in); 141 psFree(out); 145 psFree(myReadout); 142 146 printFooter(stdout, "pmNonLinear", "doNonLinearityLookupTest", true); 143 147 return(testStatus); … … 220 224 int test03() 221 225 { 222 int i; 223 int j; 224 int testStatus = true; 225 int tableSize = PS_MAX(NUM_COLS, NUM_ROWS)*3; 226 int testStatus = true; 226 227 psImage *myImage = psImageAlloc(NUM_COLS, NUM_ROWS, PS_TYPE_F32); 227 228 pmReadout *myReadout = pmReadoutAlloc(NULL); 228 229 pmReadout *rc = NULL; 229 230 myReadout->image = myImage; 230 psVector *in = psVectorAlloc(tableSize, PS_TYPE_F32);231 psVector *inOne = psVectorAlloc(1, PS_TYPE_F32);232 psVector *inSmall = psVectorAlloc(tableSize-1, PS_TYPE_F32);233 psVector *inBig = psVectorAlloc(tableSize+1, PS_TYPE_F32);234 psVector *out = psVectorAlloc(tableSize, PS_TYPE_F32);235 psVector *outOne = psVectorAlloc(1, PS_TYPE_F32);236 psVector *outSmall = psVectorAlloc(tableSize-1, PS_TYPE_F32);237 psVector *outBig = psVectorAlloc(tableSize+1, PS_TYPE_F32);238 231 239 232 test03Init(myReadout); 240 for (i=0;i<tableSize;i++) {241 in->data.F32[i] = (float) i;242 out->data.F32[i] = (float) (2 * i);243 inBig->data.F32[i] = (float) i;244 outBig->data.F32[i] = (float) (2 * i);245 if (i < tableSize-1) {246 inSmall->data.F32[i] = (float) i;247 outSmall->data.F32[i] = (float) (2 * i);248 }249 }250 inBig->data.F32[tableSize] = (float) tableSize;251 outBig->data.F32[tableSize] = (float) (2 * tableSize);252 inOne->data.F32[0] = 0.0;253 outOne->data.F32[0] = 0.0;254 255 233 printf("------------------------------------------------------------\n"); 256 234 printf("Calling pmNonLinearityLookup() with NULL input pmReadout. Should generate error, return NULL.\n"); 257 rc = pmNonLinearityLookup(NULL, in, out);235 rc = pmNonLinearityLookup(NULL, LOOKUP_FILENAME); 258 236 if (rc != NULL) { 259 237 printf("TEST ERROR: pmNonLinearityPolynomial() returned a non-NULL pmReadout\n"); … … 265 243 psImage *tmpImage = myReadout->image; 266 244 myReadout->image = NULL; 267 rc = pmNonLinearityLookup(myReadout, in, out);245 rc = pmNonLinearityLookup(myReadout, LOOKUP_FILENAME); 268 246 if (rc != NULL) { 269 247 printf("TEST ERROR: pmNonLinearityPolynomial() returned a non-NULL pmReadout\n"); … … 273 251 274 252 printf("------------------------------------------------------------\n"); 275 printf("Calling pmNonLinearityLookup() with NULL inFlux psVector. Should generate error, return NULL.\n"); 276 rc = pmNonLinearityLookup(myReadout, NULL, out); 277 if (rc != NULL) { 278 printf("TEST ERROR: pmNonLinearityPolynomial() returned a non-NULL pmReadout\n"); 279 testStatus = false; 280 } 281 282 printf("------------------------------------------------------------\n"); 283 printf("Calling pmNonLinearityLookup() with NULL outFlux psVector. Should generate error, return NULL.\n"); 284 rc = pmNonLinearityLookup(myReadout, in, NULL); 285 if (rc != NULL) { 286 printf("TEST ERROR: pmNonLinearityPolynomial() returned a non-NULL pmReadout\n"); 287 testStatus = false; 288 } 289 290 test03Init(myReadout); 291 printf("------------------------------------------------------------\n"); 292 printf("Calling pmNonLinearityLookup() with size difference in inFlux/outFLux psVectors. Should generate warning.\n"); 293 rc = pmNonLinearityLookup(myReadout, in, outBig); 253 printf("Calling pmNonLinearityLookup() with non-existent lookup file.\n"); 254 rc = pmNonLinearityLookup(myReadout, "I_DONT_EXIST"); 294 255 if (rc == NULL) { 295 256 printf("TEST ERROR: pmNonLinearityPolynomial() returned a NULL pmReadout\n"); 296 257 testStatus = false; 297 258 } 298 for (i=0;i<NUM_ROWS;i++) { 299 for (j=0;j<NUM_COLS;j++) { 300 psF32 expect = (float) (2 * (i + j)); 301 psF32 actual = rc->image->data.F32[i][j]; 302 if (FLT_EPSILON < fabs(expect - actual)) { 303 printf("TEST ERROR: image[%d][%d] is %f, should be %f\n", i, j, actual, expect); 304 testStatus = false; 305 } 306 } 307 } 308 309 310 test03Init(myReadout); 311 printf("------------------------------------------------------------\n"); 312 printf("Calling pmNonLinearityLookup() with size difference in inFlux/outFLux psVectors. Should generate warning.\n"); 313 rc = pmNonLinearityLookup(myReadout, in, outSmall); 314 if (rc == NULL) { 315 printf("TEST ERROR: pmNonLinearityPolynomial() returned a NULL pmReadout\n"); 316 testStatus = false; 317 } 318 for (i=0;i<NUM_ROWS;i++) { 319 for (j=0;j<NUM_COLS;j++) { 320 psF32 expect = (float) (2 * (i + j)); 321 psF32 actual = rc->image->data.F32[i][j]; 322 if (FLT_EPSILON < fabs(expect - actual)) { 323 printf("TEST ERROR: image[%d][%d] is %f, should be %f\n", i, j, actual, expect); 324 testStatus = false; 325 } 326 } 327 } 328 329 test03Init(myReadout); 330 printf("------------------------------------------------------------\n"); 331 printf("Calling pmNonLinearityLookup() with size difference in inFlux/outFLux psVectors. Should generate warning.\n"); 332 rc = pmNonLinearityLookup(myReadout, inSmall, out); 333 if (rc == NULL) { 334 printf("TEST ERROR: pmNonLinearityPolynomial() returned a NULL pmReadout\n"); 335 testStatus = false; 336 } 337 for (i=0;i<NUM_ROWS;i++) { 338 for (j=0;j<NUM_COLS;j++) { 339 psF32 expect = (float) (2 * (i + j)); 340 psF32 actual = rc->image->data.F32[i][j]; 341 if (FLT_EPSILON < fabs(expect - actual)) { 342 printf("TEST ERROR: image[%d][%d] is %f, should be %f\n", i, j, actual, expect); 343 testStatus = false; 344 } 345 } 346 } 347 348 test03Init(myReadout); 349 printf("------------------------------------------------------------\n"); 350 printf("Calling pmNonLinearityLookup() with size difference in inFlux/outFLux psVectors. Should generate warning.\n"); 351 rc = pmNonLinearityLookup(myReadout, inBig, out); 352 if (rc == NULL) { 353 printf("TEST ERROR: pmNonLinearityPolynomial() returned a NULL pmReadout\n"); 354 testStatus = false; 355 } 356 for (i=0;i<NUM_ROWS;i++) { 357 for (j=0;j<NUM_COLS;j++) { 358 psF32 expect = (float) (2 * (i + j)); 359 psF32 actual = rc->image->data.F32[i][j]; 360 if (FLT_EPSILON < fabs(expect - actual)) { 361 printf("TEST ERROR: image[%d][%d] is %f, should be %f\n", i, j, actual, expect); 362 testStatus = false; 363 } 364 } 365 } 366 367 test03Init(myReadout); 368 printf("------------------------------------------------------------\n"); 369 printf("Calling pmNonLinearityLookup() with size difference in inFlux/outFLux psVectors. Should generate warning.\n"); 370 rc = pmNonLinearityLookup(myReadout, inSmall, outBig); 371 if (rc == NULL) { 372 printf("TEST ERROR: pmNonLinearityPolynomial() returned a NULL pmReadout\n"); 373 testStatus = false; 374 } 375 for (i=0;i<NUM_ROWS;i++) { 376 for (j=0;j<NUM_COLS;j++) { 377 psF32 expect = (float) (2 * (i + j)); 378 psF32 actual = rc->image->data.F32[i][j]; 379 if (FLT_EPSILON < fabs(expect - actual)) { 380 printf("TEST ERROR: image[%d][%d] is %f, should be %f\n", i, j, actual, expect); 381 testStatus = false; 382 } 383 } 384 } 385 386 test03Init(myReadout); 387 printf("------------------------------------------------------------\n"); 388 printf("Calling pmNonLinearityLookup() with size difference in inFlux/outFLux psVectors. Should generate warning.\n"); 389 rc = pmNonLinearityLookup(myReadout, inBig, outSmall); 390 if (rc == NULL) { 391 printf("TEST ERROR: pmNonLinearityPolynomial() returned a NULL pmReadout\n"); 392 testStatus = false; 393 } 394 for (i=0;i<NUM_ROWS;i++) { 395 for (j=0;j<NUM_COLS;j++) { 396 psF32 expect = (float) (2 * (i + j)); 397 psF32 actual = rc->image->data.F32[i][j]; 398 if (FLT_EPSILON < fabs(expect - actual)) { 399 printf("TEST ERROR: image[%d][%d] is %f, should be %f\n", i, j, actual, expect); 400 testStatus = false; 401 } 402 } 403 } 404 405 test03Init(myReadout); 406 printf("------------------------------------------------------------\n"); 407 printf("Calling pmNonLinearityLookup() with inFlux psVector size 1. Should generate error, return original pmReadout.\n"); 408 rc = pmNonLinearityLookup(myReadout, inOne, out); 409 if (rc != myReadout) { 410 printf("TEST ERROR: pmNonLinearityPolynomial() did not return the original pmReadout\n"); 411 testStatus = false; 412 } 413 for (i=0;i<NUM_ROWS;i++) { 414 for (j=0;j<NUM_COLS;j++) { 415 psF32 expect = (float) ((i + j)); 416 psF32 actual = rc->image->data.F32[i][j]; 417 if (FLT_EPSILON < fabs(expect - actual)) { 418 printf("TEST ERROR: image[%d][%d] is %f, should be %f\n", i, j, actual, expect); 419 testStatus = false; 420 } 421 } 422 } 259 423 260 424 261 printf("------------------------------------------------------------\n"); 425 262 printf("Calling pmNonLinearityLookup() with one pixels outside inFlux range. Should generate warnings.\n"); 426 test03Init(myReadout); 427 myReadout->image->data.F32[0][0] = -1; 428 rc = pmNonLinearityLookup(myReadout, in, out); 429 if (rc == NULL) { 430 printf("TEST ERROR: pmNonLinearityPolynomial() returned a NULL pmReadout\n"); 431 testStatus = false; 432 } 433 for (i=0;i<NUM_ROWS;i++) { 434 for (j=0;j<NUM_COLS;j++) { 435 psF32 expect = (float) (2 * (i + j)); 436 psF32 actual = rc->image->data.F32[i][j]; 437 if(i==0 && j==0) { 438 if(actual != 0.0) { 439 printf("TEST ERROR: image[%d][%d] is %f, should be %f\n",i,j,actual,0.0); 440 } 441 } else { 442 if (FLT_EPSILON < fabs(expect - actual)) { 443 printf("TEST ERROR: image[%d][%d] is %f, should be %f\n", i, j, actual, expect); 444 testStatus = false; 445 } 446 } 447 } 448 } 449 450 printf("------------------------------------------------------------\n"); 451 printf("Calling pmNonLinearityLookup() with one pixels outside inFlux range. Should generate warnings.\n"); 452 test03Init(myReadout); 453 myReadout->image->data.F32[NUM_ROWS-1][NUM_COLS-1] = 100; 454 rc = pmNonLinearityLookup(myReadout, in, out); 455 if (rc == NULL) { 456 printf("TEST ERROR: pmNonLinearityPolynomial() returned a NULL pmReadout\n"); 457 testStatus = false; 458 } 459 for (i=0;i<NUM_ROWS;i++) { 460 for (j=0;j<NUM_COLS;j++) { 461 psF32 expect = (float) (2 * (i + j)); 462 psF32 actual = rc->image->data.F32[i][j]; 463 if(i==(NUM_ROWS-1) && j==(NUM_COLS-1)) { 464 if(actual != (tableSize-1)*2) { 465 printf("TEST ERROR: image[%d][%d] is %f, should be %f\n",i,j,actual,(tableSize-1)*2.0); 466 } 467 } else { 468 if (FLT_EPSILON < fabs(expect - actual)) { 469 printf("TEST ERROR: image[%d][%d] is %f, should be %f\n", i, j, actual, expect); 470 testStatus = false; 471 } 472 } 473 } 474 } 475 476 test03Init(myReadout); 477 printf("------------------------------------------------------------\n"); 478 printf("Calling pmNonLinearityLookup() with image values not in vector.\n"); 479 myReadout->image->data.F32[0][0] = 0.5; 480 rc = pmNonLinearityLookup(myReadout, in, out); 481 if (rc == NULL) { 482 printf("TEST ERROR: pmNonLinearityPolynomial() returned a NULL pmReadout\n"); 483 testStatus = false; 484 } 485 for (i=0;i<NUM_ROWS;i++) { 486 for (j=0;j<NUM_COLS;j++) { 487 psF32 expect = (float) (2 * (i + j)); 488 if(i==0 && j==0) { 489 expect = 1.0; 490 } 491 psF32 actual = rc->image->data.F32[i][j]; 492 if (FLT_EPSILON < fabs(expect - actual)) { 493 printf("TEST ERROR: image[%d][%d] is %f, should be %f\n", i, j, actual, expect); 494 testStatus = false; 495 } 496 } 497 } 498 499 psFree(myReadout); 500 psFree(in); 501 psFree(inOne); 502 psFree(inSmall); 503 psFree(inBig); 504 psFree(out); 505 psFree(outOne); 506 psFree(outSmall); 507 psFree(outBig); 263 264 psFree(myReadout); 508 265 509 266 printFooter(stdout, "pmNonLinear", "Testing bad input parameter conditions.", true); -
trunk/psModules/test/objects/tst_pmObjects01.c
r5258 r5435 1 /** @file tst_pm FindObjects.c1 /** @file tst_pmObjects.c 2 2 * 3 * @brief Contains the tests for pm SubtractSky.c:3 * @brief Contains the tests for pmObjects.c: 4 4 * 5 5 * test00: This code will ... … … 9 9 * XXX: Must test 10 10 * pmSourceRoughClass 11 * many others... 12 * 11 13 * 12 14 * XXX: Must test output results for many other functions. … … 23 25 Weakly Tested: 24 26 pmSourceMoments() 25 27 most of psObjects.c is not tested 26 28 * 27 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $28 * @date $Date: 2005-10- 10 21:55:42$29 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 30 * @date $Date: 2005-10-20 23:06:24 $ 29 31 * 30 32 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 47 49 //static int test06(void); 48 50 //static int test07(void); 49 /* 50 static int test08(void); 51 //static int test08(void); 51 52 static int test09(void); 52 53 static int test15(void); 53 54 static int test16(void); 54 55 static int test20(void); 55 */56 56 testDescription tests[] = { 57 57 {test00, 000, "pmObjects: structure allocators and deallocators", true, false}, … … 63 63 // {test06, 001, "pmObjects: pmSourceSetPixelsCircle()", true, false}, 64 64 // {test07, 001, "pmObjects: pmMin()", true, false}, 65 /* 66 {test08, 001, "pmObjects: pmSourceModelGuess()", true, false}, 67 {test09, 001, "pmObjects: pmSourceContour()", true, false}, 68 {test15, 001, "pmObjects: pmSourceAddModel()", true, false}, 69 {test16, 001, "pmObjects: pmSourceSubModel()", true, false}, 70 {test20, 001, "pmObjects: pmSourceSubModel()", true, false}, 71 */ 65 // {test08, 001, "pmObjects: pmSourceModelGuess()", true, false}, 66 {test09, 001, "pmObjects: pmSourceContour()", true, false}, 67 {test15, 001, "pmObjects: pmSourceAddModel()", true, false}, 68 {test16, 001, "pmObjects: pmSourceSubModel()", true, false}, 69 {test20, 001, "pmObjects: pmSourceSubModel()", true, false}, 72 70 {NULL} 73 71 }; … … 975 973 } 976 974 975 #define TST09_NUM_ROWS 70 976 #define TST09_NUM_COLS 70 977 #define TST09_SKY 5.0 978 #define TST09_INNER_RADIUS 3 979 #define TST09_OUTER_RADIUS 10 980 #define LEVEL (TST09_SKY + 10.0) 981 /****************************************************************************** 982 test09(): We first test pmSourceContour() with various NULL and unallowable 983 input parameters. 984 985 XXX: We don't verify the numbers. 986 *****************************************************************************/ 987 int test09( void ) 988 { 989 bool testStatus = true; 990 psImage *imgData = psImageAlloc(TST09_NUM_COLS, TST09_NUM_ROWS, PS_TYPE_F32); 991 psImageInit(imgData, TST09_SKY); 992 psImage *imgMask = psImageAlloc(TST09_NUM_COLS, TST09_NUM_ROWS, PS_TYPE_U8); 993 psImageInit(imgMask, 0); 994 pmPeak *tmpPeak = pmPeakAlloc((psF32) (TST09_NUM_ROWS / 2), 995 (psF32) (TST09_NUM_COLS / 2), 996 200.0, 997 PM_PEAK_LONE); 998 pmSource *tmpSource = pmSourceAlloc(); 999 tmpSource->pixels = imgData; 1000 tmpSource->mask = imgMask; 1001 tmpSource->peak = tmpPeak; 1002 psBool rc = pmSourceLocalSky(tmpSource, PS_STAT_SAMPLE_MEAN, 10.0); 1003 if (rc == false) { 1004 printf("TEST ERROR: pmSourceLocalSky() returned a FALSE pmSource.\n"); 1005 testStatus = false; 1006 } 1007 1008 printf("----------------------------------------------------------------------------------\n"); 1009 printf("Calling pmSourceContour with NULL pmSource . Should generate error, return FALSE.\n"); 1010 rc = pmSourceContour(NULL, imgData, LEVEL, PS_CONTOUR_CRUDE); 1011 if (rc != false) { 1012 printf("TEST ERROR: pmSourceContour() returned TRUE.\n"); 1013 testStatus = false; 1014 psFree(rc); 1015 } 1016 1017 printf("----------------------------------------------------------------------------------\n"); 1018 printf("Calling pmSourceContour with NULL psImage . Should generate error, return FALSE.\n"); 1019 rc = pmSourceContour(tmpSource, NULL, LEVEL, PS_CONTOUR_CRUDE); 1020 if (rc != FALSE) { 1021 printf("TEST ERROR: pmSourceContour() returned TRUE.\n"); 1022 testStatus = false; 1023 psFree(rc); 1024 } 1025 1026 // 1027 // XXX: pmSourceContour() has a problem with contour tops/bottoms. 1028 // Must correct this. 1029 // 1030 if (1) { 1031 printf("----------------------------------------------------------------------------------\n"); 1032 printf("Calling pmSourceContour with acceptable data.\n"); 1033 printf("NOTE: must figure out the parameters for this test to be meaningful.\n"); 1034 tmpSource->modelPSF->params->data.F32[0] = TST09_SKY; 1035 tmpSource->modelPSF->params->data.F32[1] = 15.0; 1036 tmpSource->modelPSF->params->data.F32[2] = (psF32) (TST09_NUM_ROWS / 2); 1037 tmpSource->modelPSF->params->data.F32[3] = (psF32) (TST09_NUM_COLS / 2); 1038 tmpSource->modelPSF->params->data.F32[4] = 2.0; 1039 tmpSource->modelPSF->params->data.F32[5] = 2.0; 1040 tmpSource->modelPSF->params->data.F32[6] = 2.0; 1041 rc = pmSourceContour(tmpSource, imgData, LEVEL, PS_CONTOUR_CRUDE); 1042 if (rc == false) { 1043 printf("TEST ERROR: pmSourceContour() returned FALSE.\n"); 1044 testStatus = false; 1045 } else { 1046 psFree(rc); 1047 } 1048 } 1049 1050 psFree(tmpSource); 1051 return(testStatus); 1052 } 1053 1054 #define TST15_NUM_ROWS 100 1055 #define TST15_NUM_COLS 100 1056 #define TST15_SKY 10.0 1057 #define TST15_INNER_RADIUS 3 1058 #define TST15_OUTER_RADIUS 5 1059 /****************************************************************************** 1060 test15(): We first test pmSourceAddModel() with various NULL and unallowable 1061 input parameters. 1062 1063 XXX: We don't verify the numbers. 1064 *****************************************************************************/ 1065 int test15( void ) 1066 { 1067 bool testStatus = true; 1068 psImage *imgData = psImageAlloc(TST15_NUM_COLS, TST15_NUM_ROWS, PS_TYPE_F32); 1069 psImageInit(imgData, TST15_SKY); 1070 psImage *imgMask = psImageAlloc(TST15_NUM_COLS, TST15_NUM_ROWS, PS_TYPE_U8); 1071 psImageInit(imgMask, 0); 1072 pmPeak *tmpPeak = pmPeakAlloc((psF32) (TST15_NUM_ROWS / 2), 1073 (psF32) (TST15_NUM_COLS / 2), 1074 200.0, 1075 PM_PEAK_LONE); 1076 pmSource *tmpSource = pmSourceAlloc(); 1077 tmpSource->pixels = imgData; 1078 tmpSource->mask = imgMask; 1079 tmpSource->peak = tmpPeak; 1080 psBool rc = pmSourceLocalSky(tmpSource, PS_STAT_SAMPLE_MEAN, 10.0); 1081 if (rc == false) { 1082 printf("TEST ERROR: pmSourceLocalSky() returned a FALSE pmSource.\n"); 1083 testStatus = false; 1084 } 1085 1086 1087 tmpSource->modelPSF = pmModelAlloc(PS_MODEL_GAUSS); 1088 tmpSource->modelPSF->params->data.F32[0] = 5.0; 1089 tmpSource->modelPSF->params->data.F32[1] = 70.0; 1090 tmpSource->modelPSF->params->data.F32[2] = (psF32) (TST15_NUM_ROWS / 2); 1091 tmpSource->modelPSF->params->data.F32[3] = (psF32) (TST15_NUM_COLS / 2); 1092 tmpSource->modelPSF->params->data.F32[4] = 1.0; 1093 tmpSource->modelPSF->params->data.F32[5] = 1.0; 1094 tmpSource->modelPSF->params->data.F32[6] = 2.0; 1095 1096 printf("----------------------------------------------------------------------------------\n"); 1097 printf("Calling pmSourceAddModel with NULL psImage. Should generate error, return FALSE.\n"); 1098 rc = pmSourceAddModel(NULL, tmpSource, true); 1099 if (rc == true) { 1100 printf("TEST ERROR: pmSourceAddModel() returned TRUE.\n"); 1101 testStatus = false; 1102 } 1103 1104 printf("----------------------------------------------------------------------------------\n"); 1105 printf("Calling pmSourceAddModel with NULL psSrc. Should generate error, return FALSE.\n"); 1106 rc = pmSourceAddModel(imgData, NULL, true); 1107 if (rc == true) { 1108 printf("TEST ERROR: pmSourceAddModel() returned TRUE.\n"); 1109 testStatus = false; 1110 } 1111 1112 printf("----------------------------------------------------------------------------------\n"); 1113 printf("Calling pmSourceAddModel with acceptable data.\n"); 1114 rc = pmSourceAddModel(imgData, tmpSource, true); 1115 if (rc != true) { 1116 printf("TEST ERROR: pmSourceAddModel() returned FALSE.\n"); 1117 testStatus = false; 1118 } 1119 1120 psFree(tmpSource); 1121 psFree(imgData); 1122 return(testStatus); 1123 } 1124 1125 #define TST16_NUM_ROWS 100 1126 #define TST16_NUM_COLS 100 1127 #define TST16_SKY 10.0 1128 #define TST16_INNER_RADIUS 3 1129 #define TST16_OUTER_RADIUS 5 1130 /****************************************************************************** 1131 test16(): We first test pmSourceSubModel() with various NULL and unallowable 1132 input parameters. 1133 1134 XXX: We don't verify the numbers. 1135 *****************************************************************************/ 1136 int test16( void ) 1137 { 1138 bool testStatus = true; 1139 psImage *imgData = psImageAlloc(TST16_NUM_COLS, TST16_NUM_ROWS, PS_TYPE_F32); 1140 for (psS32 i = 0 ; i < imgData->numRows; i++) { 1141 for (psS32 j = 0 ; j < imgData->numCols; j++) { 1142 imgData->data.F32[i][j] = TST16_SKY; 1143 } 1144 } 1145 pmSource *tmpSource = NULL; 1146 psBool rc = false; 1147 1148 pmPeak *tmpPeak = pmPeakAlloc((psF32) (TST16_NUM_ROWS / 2), 1149 (psF32) (TST16_NUM_COLS / 2), 1150 200.0, 1151 PM_PEAK_LONE); 1152 1153 printf("Calling pmSourceLocalSky with valid data.\n"); 1154 tmpPeak->x = (psF32) (TST16_NUM_ROWS / 2); 1155 tmpPeak->y = (psF32) (TST16_NUM_COLS / 2); 1156 tmpSource = pmSourceLocalSky(imgData, 1157 tmpPeak, 1158 PS_STAT_SAMPLE_MEAN, 1159 (psF32) TST16_INNER_RADIUS, 1160 (psF32) TST16_OUTER_RADIUS); 1161 1162 if (tmpSource == NULL) { 1163 printf("TEST ERROR: pmSourceLocalSky() returned a NULL pmSource.\n"); 1164 testStatus = false; 1165 } 1166 1167 tmpSource->modelPSF = pmModelAlloc(PS_MODEL_GAUSS); 1168 tmpSource->modelPSF->params->data.F32[0] = 5.0; 1169 tmpSource->modelPSF->params->data.F32[1] = 70.0; 1170 tmpSource->modelPSF->params->data.F32[2] = (psF32) (TST16_NUM_ROWS / 2); 1171 tmpSource->modelPSF->params->data.F32[3] = (psF32) (TST16_NUM_COLS / 2); 1172 tmpSource->modelPSF->params->data.F32[4] = 1.0; 1173 tmpSource->modelPSF->params->data.F32[5] = 1.0; 1174 tmpSource->modelPSF->params->data.F32[6] = 2.0; 1175 1176 printf("----------------------------------------------------------------------------------\n"); 1177 printf("Calling pmSourceSubModel with NULL psImage. Should generate error, return FALSE.\n"); 1178 rc = pmSourceSubModel(NULL, tmpSource, true); 1179 if (rc == true) { 1180 printf("TEST ERROR: pmSourceSubModel() returned TRUE.\n"); 1181 testStatus = false; 1182 } 1183 1184 printf("----------------------------------------------------------------------------------\n"); 1185 printf("Calling pmSourceSubModel with NULL psSrc. Should generate error, return FALSE.\n"); 1186 rc = pmSourceSubModel(imgData, NULL, true); 1187 if (rc == true) { 1188 printf("TEST ERROR: pmSourceSubModel() returned TRUE.\n"); 1189 testStatus = false; 1190 } 1191 1192 printf("----------------------------------------------------------------------------------\n"); 1193 printf("Calling pmSourceSubModel with acceptable data.\n"); 1194 rc = pmSourceSubModel(imgData, tmpSource, true); 1195 if (rc != true) { 1196 printf("TEST ERROR: pmSourceSubModel() returned FALSE.\n"); 1197 testStatus = false; 1198 } 1199 1200 psFree(tmpSource); 1201 psFree(imgData); 1202 return(testStatus); 1203 } 1204 1205 #define TST20_NUM_ROWS 100 1206 #define TST20_NUM_COLS 100 1207 #define TST20_SKY 10.0 1208 #define TST20_INNER_RADIUS 3 1209 #define TST20_OUTER_RADIUS 5 1210 /****************************************************************************** 1211 test20(): We first test pmSourceSubModel() with various NULL and unallowable 1212 input parameters. 1213 1214 XXX: We don't verify the numbers. 1215 *****************************************************************************/ 1216 int test20( void ) 1217 { 1218 bool testStatus = true; 1219 psImage *imgData = psImageAlloc(TST20_NUM_COLS, TST20_NUM_ROWS, PS_TYPE_F32); 1220 for (psS32 i = 0 ; i < imgData->numRows; i++) { 1221 for (psS32 j = 0 ; j < imgData->numCols; j++) { 1222 imgData->data.F32[i][j] = TST20_SKY; 1223 } 1224 } 1225 pmSource *tmpSource = NULL; 1226 psBool rc = false; 1227 1228 pmPeak *tmpPeak = pmPeakAlloc((psF32) (TST20_NUM_ROWS / 2), 1229 (psF32) (TST20_NUM_COLS / 2), 1230 200.0, 1231 PM_PEAK_LONE); 1232 1233 printf("Calling pmSourceLocalSky with valid data.\n"); 1234 tmpPeak->x = (psF32) (TST20_NUM_ROWS / 2); 1235 tmpPeak->y = (psF32) (TST20_NUM_COLS / 2); 1236 tmpSource = pmSourceLocalSky(imgData, 1237 tmpPeak, 1238 PS_STAT_SAMPLE_MEAN, 1239 (psF32) TST20_INNER_RADIUS, 1240 (psF32) TST20_OUTER_RADIUS); 1241 1242 if (tmpSource == NULL) { 1243 printf("TEST ERROR: pmSourceLocalSky() returned a NULL pmSource.\n"); 1244 testStatus = false; 1245 } 1246 1247 tmpSource->modelPSF = pmModelAlloc(PS_MODEL_GAUSS); 1248 1249 1250 tmpSource->modelPSF->params->data.F32[0] = 5.0; 1251 tmpSource->modelPSF->params->data.F32[1] = 70.0; 1252 tmpSource->modelPSF->params->data.F32[2] = (psF32) (TST20_NUM_ROWS / 2); 1253 tmpSource->modelPSF->params->data.F32[3] = (psF32) (TST20_NUM_COLS / 2); 1254 tmpSource->modelPSF->params->data.F32[4] = 1.0; 1255 tmpSource->modelPSF->params->data.F32[5] = 1.0; 1256 tmpSource->modelPSF->params->data.F32[6] = 2.0; 1257 1258 printf("----------------------------------------------------------------------------------\n"); 1259 printf("Calling pmSourceFitModel with NULL psImage. Should generate error, return FALSE.\n"); 1260 rc = pmSourceFitModel(tmpSource, NULL); 1261 if (rc == true) { 1262 printf("TEST ERROR: pmSourceFitModel() returned TRUE.\n"); 1263 testStatus = false; 1264 } 1265 1266 printf("----------------------------------------------------------------------------------\n"); 1267 printf("Calling pmSourceFitModel with NULL pmSource. Should generate error, return FALSE.\n"); 1268 rc = pmSourceFitModel(NULL, imgData); 1269 if (rc == true) { 1270 printf("TEST ERROR: pmSourceFitModel() returned TRUE.\n"); 1271 testStatus = false; 1272 } 1273 1274 printf("----------------------------------------------------------------------------------\n"); 1275 printf("Calling pmSourceFitModel with acceptable data.\n"); 1276 rc = pmSourceFitModel(tmpSource, imgData); 1277 printf("pmSourceFitModel returned %d\n", rc); 1278 1279 // XXX: Memory leaks are not being tested 1280 psVector *junk = psVectorAlloc(10, PS_TYPE_F32); 1281 junk->data.F32[0] = 0.0; 1282 1283 psFree(tmpSource); 1284 psFree(imgData); 1285 return(testStatus); 1286 } 1287 1288 977 1289 // this code will 978 1290
Note:
See TracChangeset
for help on using the changeset viewer.
