Changeset 4770 for trunk/psModules/src
- Timestamp:
- Aug 15, 2005, 3:10:36 PM (21 years ago)
- Location:
- trunk/psModules/src
- Files:
-
- 15 edited
-
pmAstrometry.c (modified) (8 diffs)
-
pmAstrometry.h (modified) (18 diffs)
-
pmFlatField.c (modified) (3 diffs)
-
pmFlatField.h (modified) (2 diffs)
-
pmMaskBadPixels.c (modified) (2 diffs)
-
pmMaskBadPixels.h (modified) (2 diffs)
-
pmNonLinear.c (modified) (5 diffs)
-
pmNonLinear.h (modified) (2 diffs)
-
pmObjects.c (modified) (49 diffs)
-
pmObjects.h (modified) (14 diffs)
-
pmReadoutCombine.c (modified) (5 diffs)
-
pmSubtractBias.c (modified) (4 diffs)
-
pmSubtractBias.h (modified) (3 diffs)
-
pmSubtractSky.c (modified) (3 diffs)
-
pmSubtractSky.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/pmAstrometry.c
r4754 r4770 8 8 * @author GLG, MHPCC 9 9 * 10 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-08-1 1 00:03:51$10 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-08-16 01:10:34 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 23 23 #include "pmAstrometry.h" 24 24 25 psDB wow;26 27 25 /***************************************************************************** 28 checkValidImageCoords(): this is a private function which simply 29 determines if the supplied x,y coordinates are in the range for the supplied 30 psImage. 26 checkValidImageCoords(): this is a private function which simply determines if 27 the supplied x,y coordinates are in the range for the supplied psImage. 28 29 XXX: What about col0 and row0 30 XXX: This should return a psBool. 31 31 *****************************************************************************/ 32 /*33 32 static psS32 checkValidImageCoords(double x, 34 33 double y, … … 36 35 { 37 36 PS_ASSERT_IMAGE_NON_NULL(tmpImage, 0); 38 37 39 38 if ((x < 0.0) || (x > (double)tmpImage->numCols) || 40 39 (y < 0.0) || (y > (double)tmpImage->numRows)) { 41 40 return (0); 42 41 } 43 42 44 43 return (1); 45 44 } 46 */ 47 /* 48 static void FPAFree(psFPA* fpa) 45 46 /****************************************************************************** 47 XXX: Is this the correct way to free metadata? 48 XXX: Is this the correct way to free database structs? 49 *****************************************************************************/ 50 51 static void FPAFree(pmFPA *fpa) 49 52 { 50 53 if (fpa != NULL) { 51 psFree(fpa->chips);52 psFree(fpa->grommit);53 psFree(fpa->exposure);54 psFree(fpa->metadata);55 54 psFree(fpa->fromTangentPlane); 56 55 psFree(fpa->toTangentPlane); 57 psFree(fpa->pattern);58 psFree(fpa->colorPlus);59 psFree(fpa->colorMinus);60 56 psFree(fpa->projection); 61 } 62 } 63 */ 64 65 /* 66 static void chipFree(psChip* chip) 57 psFree(fpa->concepts); 58 psFree(fpa->analysis); 59 psFree(fpa->camera); 60 psFree(fpa->chips); 61 psFree(fpa->header); 62 psFree(fpa->db); 63 } 64 } 65 66 static void chipFree(pmChip* chip) 67 67 { 68 68 if (chip != NULL) { 69 psFree(chip->cells);70 psFree(chip->metadata);71 69 psFree(chip->toFPA); 72 70 psFree(chip->fromFPA); 73 } 74 } 75 */ 76 77 /* 78 static void cellFree(psCell* cell) 71 psFree(chip->concepts); 72 psFree(chip->analysis); 73 psFree(chip->cells); 74 psFree(chip->parent); 75 psFree(chip->extname); 76 psFree(chip->pixels); 77 psFree(chip->header); 78 } 79 } 80 81 static void cellFree(pmCell *cell) 79 82 { 80 83 if (cell != NULL) { 84 psFree(cell->toChip); 85 psFree(cell->toFPA); 86 psFree(cell->toSky); 87 psFree(cell->concepts); 88 psFree(cell->analysis); 81 89 psFree(cell->readouts); 82 psFree(cell->metadata); 83 psFree(cell->toChip); 84 psFree(cell->fromChip); 85 psFree(cell->toFPA); 86 psFree(cell->toTP); 87 psFree(cell->toSky); 88 } 89 } 90 */ 91 92 static void readoutFree(psReadout* readout) 90 psFree(cell->parent); 91 psFree(cell->extname); 92 psFree(cell->pixels); 93 psFree(cell->header); 94 } 95 } 96 97 static void readoutFree(pmReadout *readout) 93 98 { 94 99 if (readout != NULL) { 95 100 psFree(readout->image); 96 101 psFree(readout->mask); 97 psFree(readout->objects); 98 psFree(readout->metadata); 99 } 100 } 101 102 /* 103 static void observatoryFree(psObservatory* obs) 104 { 105 if (obs != NULL) { 106 psFree(obs->name); 107 } 108 } 109 */ 110 /* 111 static void exposureFree(psExposure* exp) 112 { 113 if (exp != NULL) { 114 psFree(exp->time); 115 psFree(exp->observatory); 116 psFree(exp->cameraName); 117 psFree(exp->telescopeName); 118 } 119 } 120 */ 121 /* 122 static void fixedPatternFree(psFixedPattern* fp) 123 { 124 if (fp != NULL) { 125 for (psS32 i = 0; i < fp->p_ps_xRows; i++) { 126 psFree(fp->x[i]); 127 } 128 129 for (psS32 j = 0; j < fp->p_ps_yRows; j++) { 130 psFree(fp->y[j]); 131 } 132 133 psFree(fp->x); 134 psFree(fp->y); 135 } 136 } 137 */ 102 psFree(readout->analysis); 103 psFree(readout->concepts); 104 psFree(readout->parent); 105 } 106 } 107 108 109 pmReadout *pmReadoutAlloc(pmCell *cell) 110 { 111 pmReadout *tmpReadout = (pmReadout *) psAlloc(sizeof(pmReadout)); 112 113 tmpReadout->col0 = -1; 114 tmpReadout->row0 = -1; 115 tmpReadout->colBins = -1; 116 tmpReadout->rowBins = -1; 117 tmpReadout->image = NULL; 118 tmpReadout->mask = NULL; 119 tmpReadout->analysis = psMetadataAlloc(); 120 tmpReadout->concepts = psMetadataAlloc(); 121 tmpReadout->parent = cell; 122 123 if (cell != NULL) { 124 cell->readouts = psArrayAdd(cell->readouts, 1, (psPtr) tmpReadout); 125 } 126 psMemSetDeallocator(tmpReadout, (psFreeFunc) readoutFree); 127 return(tmpReadout); 128 } 129 130 pmCell *pmCellAlloc(pmChip *chip) 131 { 132 pmCell *tmpCell = (pmCell *) psAlloc(sizeof(pmCell)); 133 134 tmpCell->col0 = -1; 135 tmpCell->row0 = -1; 136 tmpCell->toChip = NULL; 137 tmpCell->toFPA = NULL; 138 tmpCell->toSky = NULL; 139 tmpCell->analysis = psMetadataAlloc(); 140 tmpCell->concepts = psMetadataAlloc(); 141 tmpCell->readouts = psArrayAlloc(0); 142 tmpCell->parent = chip; 143 if (chip != NULL) { 144 chip->cells = psArrayAdd(chip->cells, 1, (psPtr) tmpCell); 145 } 146 tmpCell->valid = false; 147 tmpCell->extname = NULL; 148 tmpCell->pixels = NULL; 149 tmpCell->header = NULL; 150 151 psMemSetDeallocator(tmpCell, (psFreeFunc) cellFree); 152 return(tmpCell); 153 } 154 155 pmChip *pmChipAlloc(pmFPA *fpa) 156 { 157 pmChip *tmpChip = (pmChip *) psAlloc(sizeof(pmChip)); 158 159 tmpChip->col0 = -1; 160 tmpChip->row0 = -1; 161 tmpChip->toFPA = NULL; 162 tmpChip->fromFPA = NULL; 163 tmpChip->concepts = psMetadataAlloc(); 164 tmpChip->analysis = psMetadataAlloc(); 165 tmpChip->cells = psArrayAlloc(0); 166 tmpChip->parent = fpa; 167 if (fpa != NULL) { 168 fpa->chips = psArrayAdd(fpa->chips, 1, (psPtr) tmpChip); 169 } 170 tmpChip->valid = false; 171 tmpChip->extname = NULL; 172 tmpChip->pixels = NULL; 173 tmpChip->header = NULL; 174 175 psMemSetDeallocator(tmpChip, (psFreeFunc) chipFree); 176 return(tmpChip); 177 } 178 179 pmFPA *pmFPAAlloc( 180 const psMetadata *camera, 181 psDB *db) 182 { 183 pmFPA *tmpFPA = (pmFPA *) psAlloc(sizeof(pmFPA)); 184 185 tmpFPA->fromTangentPlane = NULL; 186 tmpFPA->toTangentPlane = NULL; 187 tmpFPA->projection = NULL; 188 tmpFPA->concepts = psMetadataAlloc(); 189 tmpFPA->analysis = psMetadataAlloc(); 190 tmpFPA->camera = camera; 191 tmpFPA->chips = psArrayAlloc(0); 192 tmpFPA->header = NULL; 193 tmpFPA->db = db; 194 195 psMemSetDeallocator(tmpFPA, (psFreeFunc) FPAFree); 196 return(tmpFPA); 197 } 198 199 bool cellCheckParents(pmCell *cell) 200 { 201 if (cell == NULL) { 202 return(true); 203 } 204 psBool flag = true; 205 206 for (psS32 i = 0 ; i < cell->readouts->n ; i++) { 207 pmReadout *tmpReadout = (pmReadout *) cell->readouts->data[i]; 208 PS_ASSERT_PTR_NON_NULL(tmpReadout, false); 209 if (tmpReadout->parent != cell) { 210 tmpReadout->parent = cell; 211 flag = false; 212 } 213 } 214 return(flag); 215 } 216 217 bool chipCheckParents(pmChip *chip) 218 { 219 if (chip == NULL) { 220 return(true); 221 } 222 psBool flag = true; 223 224 for (psS32 i = 0 ; i < chip->cells->n ; i++) { 225 pmCell *tmpCell = (pmCell *) chip->cells->data[i]; 226 PS_ASSERT_PTR_NON_NULL(tmpCell, false); 227 if (tmpCell->parent != chip) { 228 tmpCell->parent = chip; 229 flag = false; 230 } 231 232 flag &= cellCheckParents(tmpCell); 233 } 234 return(flag); 235 } 236 237 bool pmFPACheckParents(pmFPA *fpa) 238 { 239 if (fpa == NULL) { 240 return(true); 241 } 242 psBool flag = true; 243 244 for (psS32 i = 0 ; i < fpa->chips->n ; i++) { 245 pmChip *tmpChip = (pmChip *) fpa->chips->data[i]; 246 PS_ASSERT_PTR_NON_NULL(tmpChip, false); 247 if (tmpChip->parent != fpa) { 248 tmpChip->parent = fpa; 249 flag = false; 250 } 251 252 flag &= chipCheckParents(tmpChip); 253 } 254 return(flag); 255 } 256 257 258 259 // HEY 138 260 /*****************************************************************************/ 139 261 /* FUNCTION IMPLEMENTATION - PUBLIC */ 140 262 /*****************************************************************************/ 141 263 142 /* 143 * XXX: Verify that you interpreted the SDR correctly. 144 * 145 * XXX: This assumes that x,y must be of type F64 146 */ 147 /* 148 psFixedPattern* psFixedPatternAlloc(double x0, 149 double y0, 150 double xScale, 151 double yScale, 152 const psImage *x, 153 const psImage *y) 154 { 155 psFixedPattern *tmp; 156 psS32 i; 157 psS32 j; 158 159 PS_ASSERT_IMAGE_NON_NULL(x, NULL); 160 PS_ASSERT_IMAGE_NON_NULL(y, NULL); 161 PS_ASSERT_IMAGE_TYPE(x, PS_TYPE_F64, NULL); 162 PS_ASSERT_IMAGE_TYPE(y, PS_TYPE_F64, NULL); 163 164 tmp = (psFixedPattern *) psAlloc(sizeof(psFixedPattern)); 165 // XXX: Is this correct? 166 tmp->nX = (x->numCols * x->numRows); 167 tmp->nY = (y->numCols * y->numRows); 168 tmp->x0 = x0; 169 tmp->y0 = y0; 170 tmp->xScale = xScale; 171 tmp->yScale = yScale; 172 tmp->p_ps_xRows = x->numRows; 173 tmp->p_ps_xCols = x->numCols; 174 tmp->p_ps_yRows = y->numRows; 175 tmp->p_ps_yCols = y->numCols; 176 tmp->x = (double **) psAlloc(x->numRows * sizeof(double *)); 177 for (i=0;i<x->numRows;i++) { 178 (tmp->x)[i] = (double *) psAlloc(x->numCols * sizeof(double)); 179 } 180 for (i=0;i<x->numRows;i++) { 181 for (j=0;j<x->numCols;j++) { 182 (tmp->x)[i][j] = x->data.F64[i][j]; 183 } 184 } 185 186 tmp->y = (double **) psAlloc(y->numRows * sizeof(double *)); 187 for (i=0;i<y->numRows;i++) { 188 (tmp->y)[i] = (double *) psAlloc(y->numCols * sizeof(double)); 189 } 190 for (i=0;i<y->numRows;i++) { 191 for (j=0;j<y->numCols;j++) { 192 (tmp->y)[i][j] = y->data.F64[i][j]; 193 } 194 } 195 196 psMemSetDeallocator(tmp,(psFreeFunc)fixedPatternFree); 197 198 return(tmp); 199 } 200 */ 201 /* 202 psExposure* psExposureAlloc(double ra, 203 double dec, 204 double hourAngle, 205 double zenithDistance, 206 double azimuth, 207 const psTime* time, 208 float rotAngle, 209 float temperature, 210 float pressure, 211 float humidity, 212 float exposureTime, 213 float wavelength, 214 const psObservatory* observatory) 215 { 216 PS_ASSERT_PTR_NON_NULL(observatory, NULL); 217 218 psExposure* exp = psAlloc(sizeof(psExposure)); 219 *(double *)&exp->ra = ra; 220 *(double *)&exp->dec = dec; 221 *(double *)&exp->hourAngle = hourAngle; 222 *(double *)&exp->zenithDistance = zenithDistance; 223 *(double *)&exp->azimuth = azimuth; 224 *(float *)&exp->rotAngle = rotAngle; 225 *(float *)&exp->temperature = temperature; 226 *(float *)&exp->pressure = pressure; 227 *(float *)&exp->humidity = humidity; 228 *(float *)&exp->exposureTime = exposureTime; 229 *(float *)&exp->wavelength = wavelength; 230 231 exp->time = psMemIncrRefCounter((psPtr)time); 232 exp->observatory = psMemIncrRefCounter((psPtr)observatory); 233 234 // XXX: how is this value derived? 235 *(double *)&exp->lst = psTimeToLMST((psTime*)time,observatory->longitude); 236 *(float *)&exp->positionAngle = 0.0f; // XXX: need input, see Bug #207 237 *(float *)&exp->parallacticAngle = 0.0f; // XXX: need input, see Bug #207 238 *(float *)&exp->airmass = 0.0f; // XXX: needs calculation! = slaAirmas(zenithDistance); 239 *(float *)&exp->parallacticFactor = 0.0f; 240 exp->cameraName = NULL; 241 exp->telescopeName = NULL; 242 243 psMemSetDeallocator(exp,(psFreeFunc)exposureFree); 244 245 return exp; 246 } 247 */ 248 /* 249 psObservatory* psObservatoryAlloc(const char* name, 250 double latitude, 251 double longitude, 252 double height, 253 double tlr) 254 { 255 psObservatory* obs = psAlloc(sizeof(psObservatory)); 256 257 if (name == NULL) { 258 obs->name = NULL; 259 } else { 260 obs->name = psAlloc(strlen(name)+1); 261 strcpy((char*)obs->name, name); 262 } 263 264 *(double *)&obs->latitude = latitude; 265 *(double *)&obs->longitude = longitude; 266 *(double *)&obs->height = height; 267 *(double *)&obs->tlr = tlr; 268 269 psMemSetDeallocator(obs,(psFreeFunc)observatoryFree); 270 271 return obs; 272 } 273 */ 274 /* 275 psFPA* psFPAAlloc(psS32 nChips, 276 const psExposure* exp) 277 { 278 PS_ASSERT_INT_NONNEGATIVE(nChips, NULL); 279 280 psFPA* newFPA = psAlloc(sizeof(psFPA)); 281 282 // create array of NULL chips of the size nChips 283 newFPA->chips = psArrayAlloc(nChips); 284 psPtr* chips = newFPA->chips->data; 285 for (psS32 i=0;i<nChips;i++) { 286 chips[i] = NULL; 287 } 288 newFPA->chips->n = 0; // per requirement 289 290 newFPA->metadata = NULL; 291 newFPA->fromTangentPlane = NULL; 292 newFPA->toTangentPlane = NULL; 293 newFPA->pattern = NULL; 294 295 if (exp != NULL) { 296 newFPA->exposure = psMemIncrRefCounter((psExposure*)exp); 297 newFPA->grommit = psGrommitAlloc(exp); 298 } else { 299 newFPA->exposure = NULL; 300 newFPA->grommit = NULL; 301 } 302 303 newFPA->colorPlus = NULL; 304 newFPA->colorMinus = NULL; 305 newFPA->projection = NULL; 306 307 newFPA->rmsX = 0.0f; 308 newFPA->rmsY = 0.0f; 309 newFPA->chi2 = 0.0f; 310 311 psMemSetDeallocator(newFPA,(psFreeFunc)FPAFree); 312 313 return newFPA; 314 } 315 */ 316 /* 317 * psChip constructor 318 */ 319 /* 320 psChip* psChipAlloc(psS32 nCells, 321 psFPA *parentFPA) 322 { 323 PS_ASSERT_INT_NONNEGATIVE(nCells, NULL); 324 325 psChip* chip = psAlloc(sizeof(psChip)); 326 327 // create array of NULL psCells 328 int n = (nCells > 0) ? nCells : 1; 329 chip->cells = psArrayAlloc(n); 330 psPtr* cells = chip->cells->data; 331 for (psS32 i=0;i<n;i++) { 332 cells[i] = NULL; 333 } 334 chip->cells->n = 0; // per requirement 335 336 *(int*)&chip->row0 = 0; 337 *(int*)&chip->col0 = 0; 338 339 chip->metadata = NULL; 340 341 chip->toFPA = NULL; 342 chip->fromFPA = NULL; 343 344 chip->parent = parentFPA; 345 346 psMemSetDeallocator(chip,(psFreeFunc)chipFree); 347 348 return chip; 349 350 } 351 */ 352 /* 353 * psCell constructor 354 */ 355 /* 356 psCell* psCellAlloc(psS32 nReadouts, 357 psChip* parentChip) 358 { 359 PS_ASSERT_INT_NONNEGATIVE(nReadouts, NULL); 360 361 psCell* cell = psAlloc(sizeof(psCell)); 362 363 // create array of NULL psReadouts 364 int n = (nReadouts > 0) ? nReadouts : 1; 365 cell->readouts = psArrayAlloc(n); 366 psPtr* readouts = cell->readouts->data; 367 for (psS32 i=0;i<n;i++) { 368 readouts[i] = NULL; 369 } 370 cell->readouts->n = 0; // per requirement 371 372 *(int*)&cell->row0 = 0; 373 *(int*)&cell->col0 = 0; 374 375 cell->metadata = NULL; 376 377 cell->toChip = NULL; 378 cell->fromChip = NULL; 379 cell->toFPA = NULL; 380 cell->toTP = NULL; 381 cell->toSky = NULL; 382 383 cell->parent = parentChip; 384 385 psMemSetDeallocator(cell,(psFreeFunc)cellFree); 386 387 return cell; 388 389 390 } 391 */ 392 393 psReadout *pmReadoutAlloc(pmCell *cell) 394 { 395 psReadout* readout = psAlloc(sizeof(psReadout)); 396 397 *(psU32*)&readout->colBins = 1; 398 *(psU32*)&readout->rowBins = 1; 399 *(psU32*)&readout->rowParity = 0; 400 *(psU32*)&readout->colParity = 0; 401 *(psS32*)&readout->col0 = 0; 402 *(psS32*)&readout->row0 = 0; 403 404 readout->image = NULL; 405 readout->mask = NULL; 406 readout->objects = NULL; 407 readout->metadata = NULL; 408 409 psMemSetDeallocator(readout,(psFreeFunc)readoutFree); 410 411 return readout; 412 } 413 414 /* 415 psGrommit* psGrommitAlloc(const psExposure* exp) 416 { 417 PS_ASSERT_PTR_NON_NULL(exp, NULL); 418 419 psSphere* polarMotion = p_psTimeGetPoleCoords(exp->time); 420 421 psGrommit* grommit = (psGrommit* ) psAlloc(sizeof(psGrommit)); 422 423 *(double*)&grommit->latitude = exp->observatory->latitude; 424 *(double*)&grommit->longitude = exp->observatory->longitude; 425 *(double*)&grommit->height = exp->observatory->height; 426 *(double*)&grommit->abberationMag = 0.0; // XXX: need to figure out what to set here. 427 *(double*)&grommit->temperature = exp->temperature; 428 *(double*)&grommit->pressure = exp->pressure; 429 *(double*)&grommit->humidity = exp->humidity; 430 *(double*)&grommit->wavelength = exp->wavelength; 431 *(double*)&grommit->lapseRate = exp->observatory->tlr; 432 *(double*)&grommit->refractA = polarMotion->r; // XXX: need to figure out what to set here too. 433 *(double*)&grommit->refractB = polarMotion->d; // XXX: need to figure out what to set here too. 434 *(double*)&grommit->siderealTime = psTimeToMJD(exp->time); // XXX: this is probably not correct 435 436 psFree(polarMotion); 437 438 return (grommit); 439 } 440 */ 441 /* 442 psCell* psCellInFPA(const psPlane* fpaCoord, 443 const psFPA* FPA) 264 pmCell* pmCellInFPA(const psPlane* fpaCoord, 265 const pmFPA* FPA) 444 266 { 445 267 PS_ASSERT_PTR_NON_NULL(fpaCoord, NULL); 446 268 PS_ASSERT_PTR_NON_NULL(FPA, NULL); 447 448 p sChip* tmpChip = NULL;269 270 pmChip* tmpChip = NULL; 449 271 psPlane chipCoord; 450 p sCell* outCell = NULL;451 272 pmCell* outCell = NULL; 273 452 274 // Determine which chip contains the fpaCoords. 453 tmpChip = p sChipInFPA(fpaCoord, FPA);275 tmpChip = pmChipInFPA(fpaCoord, FPA); 454 276 if (tmpChip == NULL) { 455 277 return(NULL); 456 278 } 457 279 458 280 // Convert to those chip coordinates. 459 281 psCoordFPAToChip(&chipCoord, fpaCoord, tmpChip); 460 282 461 283 // Determine which cell contains those chip coordinates. 462 outCell = p sCellInChip(&chipCoord, tmpChip);463 284 outCell = pmCellInChip(&chipCoord, tmpChip); 285 464 286 return (outCell); 465 287 } 466 */ 467 /* 468 psChip* psChipInFPA(const psPlane* fpaCoord, 469 const psFPA* FPA) 288 289 pmChip* pmChipInFPA(const psPlane* fpaCoord, 290 const pmFPA* FPA) 470 291 { 471 292 PS_ASSERT_PTR_NON_NULL(fpaCoord, NULL); 472 293 PS_ASSERT_PTR_NON_NULL(FPA, NULL); 473 294 PS_ASSERT_PTR_NON_NULL(FPA->chips, NULL); 474 295 475 296 psArray* chips = FPA->chips; 476 297 psS32 nChips = chips->n; 477 298 psPlane chipCoord; 478 p sCell *tmpCell = NULL;479 299 pmCell *tmpCell = NULL; 300 480 301 // Loop through every chip in this FPA. Convert the original FPA 481 302 // coordinates to chip coordinates for that chip. Then, determine if any 482 303 // cells in that chip contain those chip coordinates. 483 304 484 305 for (psS32 i = 0; i < nChips; i++) { 485 p sChip* tmpChip = chips->data[i];306 pmChip* tmpChip = chips->data[i]; 486 307 PS_ASSERT_PTR_NON_NULL(tmpChip, NULL); 487 308 PS_ASSERT_PTR_NON_NULL(tmpChip->fromFPA, NULL); 488 309 489 310 psPlaneTransformApply(&chipCoord, tmpChip->fromFPA, fpaCoord); 490 491 tmpCell = p sCellInChip(&chipCoord, tmpChip);311 312 tmpCell = pmCellInChip(&chipCoord, tmpChip); 492 313 if (tmpCell != NULL) { 493 314 return(tmpChip); 494 315 } 495 316 } 496 317 497 318 // XXX: Print warning here? 498 319 return (NULL); 499 320 } 500 */ 501 /* 502 p sCell* psCellInChip(const psPlane* chipCoord,503 const p sChip* chip)321 322 323 pmCell* pmCellInChip(const psPlane* chipCoord, 324 const pmChip* chip) 504 325 { 505 326 PS_ASSERT_PTR_NON_NULL(chipCoord, NULL); 506 327 PS_ASSERT_PTR_NON_NULL(chip, NULL); 507 328 508 329 psPlane cellCoord; 509 330 psArray* cells; 510 331 511 332 cells = chip->cells; 512 333 if (cells == NULL) { 513 334 return NULL; 514 335 } 515 336 516 337 // We loop over each cell in the chip. We transform the chipCoord into 517 338 // a cellCoord for that cell and determine if that cellCoord is valid. 518 339 // If so, then we return that cell. 519 340 520 341 for (psS32 i = 0; i < cells->n; i++) { 521 p sCell* tmpCell = (psCell* ) cells->data[i];342 pmCell* tmpCell = (pmCell* ) cells->data[i]; 522 343 PS_ASSERT_PTR_NON_NULL(tmpCell, NULL); 523 PS_ASSERT_PTR_NON_NULL(tmpCell->fromChip, NULL); 344 345 psPlaneTransform *chipToCell = NULL; 346 if (1 != p_psIsProjectionLinear(tmpCell->toChip)) { 347 // XXX: Generate warning message. 348 // XXX: Can we use the following function to derive a transform? 349 // chipToCell = psPlaneTransformInvert(NULL, tmpCell->toChip, NULL, -1); 350 } else { 351 chipToCell = p_psPlaneTransformLinearInvert(tmpCell->toChip); 352 } 353 354 PS_ASSERT_PTR_NON_NULL(chipToCell, NULL); 524 355 psArray* readouts = tmpCell->readouts; 525 356 526 357 if (readouts != NULL) { 527 358 for (psS32 j = 0; j < readouts->n; j++) { 528 p sReadout* tmpReadout = readouts->data[j];359 pmReadout* tmpReadout = readouts->data[j]; 529 360 PS_ASSERT_READOUT_NON_NULL(tmpReadout, NULL); 530 361 531 362 psPlaneTransformApply(&cellCoord, 532 tmpCell->fromChip,363 chipToCell, 533 364 chipCoord); 534 365 535 366 if (checkValidImageCoords(cellCoord.x, 536 367 cellCoord.y, … … 540 371 } 541 372 } 542 } 543 373 psFree(chipToCell); 374 } 375 544 376 return (NULL); 545 377 } 546 */ 547 /* 378 379 548 380 psPlane* psCoordCellToChip(psPlane* outCoord, 549 381 const psPlane* inCoord, 550 const p sCell* cell)382 const pmCell* cell) 551 383 { 552 384 PS_ASSERT_PTR_NON_NULL(inCoord, NULL); 553 385 PS_ASSERT_PTR_NON_NULL(cell, NULL); 554 386 555 387 return (psPlaneTransformApply(outCoord, cell->toChip, inCoord)); 556 388 } 557 */ 558 /* 389 390 559 391 psPlane* psCoordChipToFPA(psPlane* outCoord, 560 392 const psPlane* inCoord, 561 const p sChip* chip)393 const pmChip* chip) 562 394 { 563 395 PS_ASSERT_PTR_NON_NULL(inCoord, NULL); 564 396 PS_ASSERT_PTR_NON_NULL(chip, NULL); 565 397 566 398 return (psPlaneTransformApply(outCoord, chip->toFPA, inCoord)); 567 399 } 568 */ 569 /* 400 401 402 570 403 psPlane* psCoordFPAToTP(psPlane* outCoord, 571 404 const psPlane* inCoord, 572 405 double color, 573 406 double magnitude, 574 const p sFPA* fpa)407 const pmFPA* fpa) 575 408 { 576 409 PS_ASSERT_PTR_NON_NULL(inCoord, NULL); 577 410 PS_ASSERT_PTR_NON_NULL(fpa, NULL); 578 411 579 412 return(psPlaneDistortApply(outCoord, fpa->toTangentPlane, inCoord, 580 413 color, magnitude)); 581 414 } 582 */ 415 583 416 /***************************************************************************** 584 417 XXX: What about units for the (x,y) coords? 585 418 *****************************************************************************/ 586 /*587 419 psSphere* psCoordTPToSky(psSphere* outSphere, 588 420 const psPlane* tpCoord, 589 const psGrommit* grommit) 421 const psProjection *projection 422 ) 590 423 { 591 424 PS_ASSERT_PTR_NON_NULL(tpCoord, NULL); 592 PS_ASSERT_PTR_NON_NULL(grommit, NULL); 593 425 594 426 if (outSphere == NULL) { 595 427 outSphere = (psSphere* ) psAlloc(sizeof(psSphere)); 596 428 } 597 429 598 430 // XXX: this was done by a SLALIB call -- needs to be reimplemented 599 431 psWarning("Warning! psCoordTPToSky functionality is no longer implemented"); 600 432 // slaAopqk(tpCoord->x, tpCoord->y, (double*)grommit, 601 433 // &AOB, &ZOB, &HOB, &outSphere->r, &outSphere->d); 602 434 603 435 return (outSphere); 604 436 } 605 */ 606 /* 437 438 439 607 440 psPlane* psCoordCellToFPA(psPlane* fpaCoord, 608 441 const psPlane* cellCoord, 609 const p sCell* cell)442 const pmCell* cell) 610 443 { 611 444 PS_ASSERT_PTR_NON_NULL(cellCoord, NULL); 612 445 PS_ASSERT_PTR_NON_NULL(cell, NULL); 613 446 614 447 return (psPlaneTransformApply(fpaCoord, cell->toFPA, cellCoord)); 615 448 } 616 */ 617 /* 449 450 451 618 452 psSphere* psCoordCellToSky(psSphere* skyCoord, 619 453 const psPlane* cellCoord, 620 454 double color, 621 455 double magnitude, 622 const p sCell* cell)456 const pmCell* cell) 623 457 { 624 458 PS_ASSERT_PTR_NON_NULL(cellCoord, NULL); … … 628 462 PS_ASSERT_PTR_NON_NULL(cell->parent->parent, NULL); 629 463 PS_ASSERT_PTR_NON_NULL(cell->parent->parent->toTangentPlane, NULL); 630 PS_ASSERT_PTR_NON_NULL(cell->parent->parent->exposure, NULL);631 464 // PS_ASSERT_PTR_NON_NULL(cell->parent->parent->exposure, NULL); 465 632 466 psPlane* fpaCoord = NULL; 633 467 psPlane* tpCoord = NULL; 634 p sFPA* parFPA = (cell->parent)->parent;635 psGrommit* tmpGrommit = NULL;636 468 pmFPA* parFPA = (cell->parent)->parent; 469 // psGrommit* tmpGrommit = NULL; 470 637 471 // Convert the input cell coordinates to FPA coordinates. 638 472 fpaCoord = psPlaneTransformApply(fpaCoord, cell->toFPA, cellCoord); 639 473 640 474 // Convert the FPA coordinates to tangent plane Coordinates. 641 475 tpCoord = psPlaneDistortApply(tpCoord, parFPA->toTangentPlane, 642 476 fpaCoord, color, magnitude); 643 477 644 478 // Generate a grommit for this FPA. 645 tmpGrommit = psGrommitAlloc(parFPA->exposure);646 479 // tmpGrommit = psGrommitAlloc(parFPA->exposure); 480 647 481 // Convert the tangent plane Coordinates to sky coordinates. 648 skyCoord = psCoordTPToSky(skyCoord, tpCoord, tmpGrommit);649 482 // skyCoord = psCoordTPToSky(skyCoord, tpCoord, tmpGrommit); 483 650 484 psFree(fpaCoord); 651 485 psFree(tpCoord); 652 psFree(tmpGrommit);653 486 // psFree(tmpGrommit); 487 654 488 return(skyCoord); 655 489 } 656 657 */ 658 /* 490 491 659 492 psSphere* psCoordCellToSkyQuick(psSphere* outSphere, 660 493 const psPlane* cellCoord, 661 const p sCell* cell)494 const pmCell* cell) 662 495 { 663 496 PS_ASSERT_PTR_NON_NULL(cellCoord, NULL); … … 667 500 PS_ASSERT_PTR_NON_NULL(cell->parent->parent, NULL); 668 501 PS_ASSERT_PTR_NON_NULL(cell->parent->parent->projection, NULL); 669 if (cell->toSky) { 670 // XXX: Should we use toTP or toSky? 671 psLogMsg(__func__, PS_LOG_WARN, 672 "WARNING: psCoordCellToSkyQuick(): The cell->toSky transform is ignored. The cell->toTP transform is being used."); 673 } 674 675 psPlane *tpCoord = NULL; 676 psChip *chip = cell->parent; 677 psFPA *FPA = chip->parent; 678 psProjectionType oldProjectionType; 679 680 if (outSphere == NULL) { 681 outSphere = (psSphere* ) psAlloc(sizeof(psSphere)); 682 } 683 684 // Determine the tangent plane coordinates. 685 tpCoord = psPlaneTransformApply(NULL, cell->toTP, cellCoord); 686 687 // Save the old projection type and set the new projection type to TAN. 688 oldProjectionType = FPA->projection->type; 689 FPA->projection->type = PS_PROJ_TAN; 690 691 // Deproject the tangent plane coordinates a sphere. 692 outSphere = psDeproject(tpCoord, FPA->projection); 693 694 // Restore old projection type. Free memory. 695 FPA->projection->type = oldProjectionType; 696 psFree(tpCoord); 697 698 return (outSphere); 699 } 700 */ 502 503 psLogMsg(__func__, PS_LOG_WARN, 504 "WARNING: psCoordCellToSkyQuick(): This function is not fully specified in the SDRS. Returning NULL.\n"); 505 return(NULL); 506 507 /* 508 if (cell->toSky) { 509 // XXX: Should we use toTP or toSky? 510 psLogMsg(__func__, PS_LOG_WARN, 511 "WARNING: psCoordCellToSkyQuick(): The cell->toSky transform is ignored. The cell->toTP transform is being used."); 512 } 513 514 psPlane *tpCoord = NULL; 515 pmChip *chip = cell->parent; 516 pmFPA *FPA = chip->parent; 517 psProjectionType oldProjectionType; 518 519 if (outSphere == NULL) { 520 outSphere = (psSphere* ) psAlloc(sizeof(psSphere)); 521 } 522 523 // Determine the tangent plane coordinates. 524 tpCoord = psPlaneTransformApply(NULL, cell->toTP, cellCoord); 525 526 // Save the old projection type and set the new projection type to TAN. 527 oldProjectionType = FPA->projection->type; 528 FPA->projection->type = PS_PROJ_TAN; 529 530 // Deproject the tangent plane coordinates a sphere. 531 outSphere = psDeproject(tpCoord, FPA->projection); 532 533 // Restore old projection type. Free memory. 534 FPA->projection->type = oldProjectionType; 535 psFree(tpCoord); 536 537 return (outSphere); 538 */ 539 } 540 701 541 702 542 /***************************************************************************** 703 543 XXX: What about units for the (x,y) coords? 704 544 *****************************************************************************/ 705 /*706 545 psPlane* psCoordSkyToTP(psPlane* tpCoord, 707 546 const psSphere* in, 708 const ps Grommit* grommit)547 const psProjection *projection) 709 548 { 710 549 PS_ASSERT_PTR_NON_NULL(in, NULL); 711 PS_ASSERT_PTR_NON_NULL(grommit, NULL);712 550 // PS_ASSERT_PTR_NON_NULL(grommit, NULL); 551 713 552 // char* type = "RA"; 714 553 715 554 if (tpCoord == NULL) { 716 555 tpCoord = (psPlane* ) psAlloc(sizeof(psPlane)); 717 556 } 718 557 719 558 // XXX: this was done by a SLALIB call -- needs to be reimplemented 720 559 psWarning("Warning! psCoordSkyToTP functionality is no longer implemented"); 721 560 // slaOapqk(type, in->r, in->d, (double*)grommit, &tpCoord->x, &tpCoord->y); 722 561 723 562 return(tpCoord); 724 563 } 725 */ 726 /* 564 565 727 566 psPlane* psCoordTPToFPA(psPlane* fpaCoord, 728 567 const psPlane* tpCoord, 729 568 double color, 730 569 double magnitude, 731 const p sFPA* fpa)570 const pmFPA* fpa) 732 571 { 733 572 PS_ASSERT_PTR_NON_NULL(tpCoord, NULL); 734 573 PS_ASSERT_PTR_NON_NULL(fpa, NULL); 735 574 PS_ASSERT_PTR_NON_NULL(fpa->fromTangentPlane, NULL); 736 575 737 576 return (psPlaneDistortApply(fpaCoord, fpa->fromTangentPlane, 738 577 tpCoord, color, magnitude)); 739 578 } 740 */ 741 /* 579 580 742 581 psPlane* psCoordFPAToChip(psPlane* chipCoord, 743 582 const psPlane* fpaCoord, 744 const p sChip* chip)583 const pmChip* chip) 745 584 { 746 585 PS_ASSERT_PTR_NON_NULL(fpaCoord, NULL); 747 586 PS_ASSERT_PTR_NON_NULL(chip, NULL); 748 587 PS_ASSERT_PTR_NON_NULL(chip->fromFPA, NULL); 749 588 750 589 chipCoord = psPlaneTransformApply(chipCoord, chip->fromFPA, fpaCoord); 751 590 return(chipCoord); 752 591 } 753 */ 754 /* 592 593 755 594 psPlane* psCoordChipToCell(psPlane* cellCoord, 756 595 const psPlane* chipCoord, 757 const p sCell* cell)596 const pmCell* cell) 758 597 { 759 598 PS_ASSERT_PTR_NON_NULL(chipCoord, NULL); 760 599 PS_ASSERT_PTR_NON_NULL(cell, NULL); 761 PS_ASSERT_PTR_NON_NULL(cell->fromChip, NULL); 762 763 cellCoord = psPlaneTransformApply(cellCoord, cell->fromChip, chipCoord); 600 PS_ASSERT_PTR_NON_NULL(cell->parent, NULL); 601 602 pmCell *tmpCell = pmCellInChip(chipCoord, cell->parent); 603 PS_ASSERT_PTR_NON_NULL(tmpCell->toChip, NULL); 604 psPlaneTransform *tmpChipToCell = p_psPlaneTransformLinearInvert(tmpCell->toChip); 605 PS_ASSERT_PTR_NON_NULL(tmpChipToCell, NULL); 606 cellCoord = psPlaneTransformApply(cellCoord, tmpChipToCell, chipCoord); 607 psFree(tmpChipToCell); 764 608 return(cellCoord); 765 609 } 766 */ 767 /* 610 611 768 612 psPlane* psCoordSkyToCell(psPlane* cellCoord, 769 613 const psSphere* skyCoord, 770 doublecolor,771 doublemagnitude,772 const p sCell* cell)614 float color, 615 float magnitude, 616 const pmCell* cell) 773 617 { 774 618 PS_ASSERT_PTR_NON_NULL(skyCoord, NULL); … … 776 620 PS_ASSERT_PTR_NON_NULL(cell->parent, NULL); 777 621 PS_ASSERT_PTR_NON_NULL(cell->parent->parent, NULL); 778 PS_ASSERT_PTR_NON_NULL(cell->parent->parent->grommit, NULL); 779 780 psChip *parChip = cell->parent; 781 psFPA *parFPA = parChip->parent; 782 psGrommit* grommit = parFPA->grommit; 783 622 // PS_ASSERT_PTR_NON_NULL(cell->parent->parent->grommit, NULL); 623 624 pmChip *parChip = cell->parent; 625 pmFPA *parFPA = parChip->parent; 626 784 627 // Convert the skyCoords to tangent plane coords. 785 psPlane *tpCoord = psCoordSkyToTP( tpCoord, skyCoord, grommit);786 628 psPlane *tpCoord = psCoordSkyToTP(NULL, skyCoord, parFPA->projection); 629 787 630 // Convert the tangent plane coords to FPA coords. 788 psPlane *fpaCoord = psCoordTPToFPA(fpaCoord, tpCoord, color, 789 magnitude, parFPA); 790 631 psPlane *fpaCoord = psCoordTPToFPA(NULL, tpCoord, color, magnitude, parFPA); 632 791 633 // Convert the FPA coords to chip coords. 792 psPlane *chipCoord = psCoordFPAToChip( chipCoord, fpaCoord, parChip);793 634 psPlane *chipCoord = psCoordFPAToChip(NULL, fpaCoord, parChip); 635 794 636 // Convert the chip coords to cell coords. 795 637 cellCoord = psCoordChipToCell(cellCoord, chipCoord, cell); 796 638 797 639 psFree(tpCoord); 798 640 psFree(fpaCoord); 799 641 psFree(chipCoord); 800 642 801 643 return (cellCoord); 802 644 } 803 */ 804 /* 645 646 805 647 psPlane* psCoordSkyToCellQuick(psPlane* cellCoord, 806 648 const psSphere* skyCoord, 807 const p sCell* cell)649 const pmCell* cell) 808 650 { 809 651 PS_ASSERT_PTR_NON_NULL(skyCoord, NULL); … … 812 654 PS_ASSERT_PTR_NON_NULL(cell->parent->parent, NULL); 813 655 PS_ASSERT_PTR_NON_NULL(cell->parent->parent->projection, NULL); 814 PS_ASSERT_PTR_NON_NULL(cell->toTP, NULL); 815 if (cell->toSky) { 816 // XXX: Should we use toTP or toSky? 817 psLogMsg(__func__, PS_LOG_WARN, 818 "WARNING: psCoordSkyToCellQuick(): The cell->toSky transform is ignored. The cell->toTP transform is being used."); 819 } 820 821 psPlane *tpCoord = NULL; 822 psChip *whichChip = cell->parent; 823 psFPA *whichFPA = whichChip->parent; 824 psProjectionType oldProjectionType; 825 psPlaneTransform *TPtoCell = NULL; 826 827 // Save the old projection type and set the new projection type to TAN. 828 oldProjectionType = whichFPA->projection->type; 829 whichFPA->projection->type = PS_PROJ_TAN; 830 831 if (cellCoord == NULL) { 832 cellCoord = (psPlane* ) psAlloc(sizeof(psPlane)); 833 } 834 835 tpCoord = psProject(skyCoord, whichFPA->projection); 836 837 // generate an error if cell->toTP is not linear. 838 if (0 == p_psIsProjectionLinear(cell->toTP)) { 839 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 840 PS_ERRORTEXT_psAstrometry_NONLINEAR_TRANSFORM, 841 "cell to tangent plane"); 842 } 843 844 TPtoCell = p_psPlaneTransformLinearInvert(cell->toTP); 845 cellCoord = psPlaneTransformApply(cellCoord, TPtoCell, tpCoord); 846 847 // Restore old projection type. Free memory. 848 whichFPA->projection->type = oldProjectionType; 849 psFree(tpCoord); 850 return (cellCoord); 851 } 852 */ 853 854 656 657 658 psLogMsg(__func__, PS_LOG_WARN, 659 "WARNING: psCoordSkyToCellQuick(): This function is not fully specified in the SDRS. Returning NULL.\n"); 660 return(NULL); 661 /* 662 663 if (cell->toSky) { 664 // XXX: Should we use toTP or toSky? 665 psLogMsg(__func__, PS_LOG_WARN, 666 "WARNING: psCoordSkyToCellQuick: The cell->toSky transform is ignored. The cell->toTP transform is being used."); 667 } 668 669 psPlane *tpCoord = NULL; 670 pmChip *whichChip = cell->parent; 671 pmFPA *whichFPA = whichChip->parent; 672 psProjectionType oldProjectionType; 673 psPlaneTransform *TPtoCell = NULL; 674 675 // Save the old projection type and set the new projection type to TAN. 676 oldProjectionType = whichFPA->projection->type; 677 whichFPA->projection->type = PS_PROJ_TAN; 678 679 if (cellCoord == NULL) { 680 cellCoord = (psPlane* ) psAlloc(sizeof(psPlane)); 681 } 682 683 tpCoord = psProject(skyCoord, whichFPA->projection); 684 685 // generate an error if cell->toTP is not linear. 686 if (0 == p_psIsProjectionLinear(cell->toTP)) { 687 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 688 PS_ERRORTEXT_psAstrometry_NONLINEAR_TRANSFORM, 689 "cell to tangent plane"); 690 } 691 692 TPtoCell = p_psPlaneTransformLinearInvert(cell->toTP); 693 cellCoord = psPlaneTransformApply(cellCoord, TPtoCell, tpCoord); 694 695 // Restore old projection type. Free memory. 696 whichFPA->projection->type = oldProjectionType; 697 psFree(tpCoord); 698 return (cellCoord); 699 */ 700 } 701 702 703 -
trunk/psModules/src/pmAstrometry.h
r4754 r4770 8 8 * @author GLG, MHPCC 9 9 * 10 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-08-1 1 00:03:51$10 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-08-16 01:10:34 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 143 143 // Information 144 144 psImage *image; ///< Imaging area of readout 145 // XXX: The following mask was removed from the pmReadout struct in recent SDRS 146 // versions. However, I'm keeping it here since al ot of modules still require 147 // it. 148 psImage *mask; ///< Mask of input image 145 149 psMetadata *analysis; ///< Readout-level analysis metadata 146 150 psMetadata *concepts; ///< Cache for PS Concepts 147 151 pmCell *parent; ///< Parent cell 148 152 } 149 psReadout; 150 151 /** Allocates a psReadout 153 pmReadout; 154 155 156 /** Allocates a pmReadout 152 157 * 153 158 * The constructor shall make an empty pmReadout. If the parent cell is not … … 156 161 * other pointers in the structure shall be initialized to NULL. 157 162 * 158 * @return p sReadout* newly allocated psReadout with all internal pointers set to NULL159 */ 160 p sReadout *pmReadoutAlloc(163 * @return pmReadout* newly allocated pmReadout with all internal pointers set to NULL 164 */ 165 pmReadout *pmReadoutAlloc( 161 166 pmCell *cell ///< Parent cell 162 167 ); 163 168 164 /** Allocates a p sCell169 /** Allocates a pmCell 165 170 * 166 171 * The constructor shall make an empty pmCell. If the parent chip is not NULL, 167 * the parent link is made and the cell shall be placed in the parentThe 168 * constructor shall make an empty psCell.s array of cells. The readouts 169 * array shall be allocated with a zero size, and the metadata containers 170 * constructed. All other pointers in the structure shall be initialized to 171 * NULL. 172 * 173 * @return psCell* newly allocated psCell 172 * the parent link is made and the cell shall be placed in the parents array of 173 * cells. The readouts array shall be allocated with a zero size, and the 174 * metadata containers constructed. All other pointers in the structure shall be 175 * initialized to NULL. 176 * 177 * @return pmCell* newly allocated pmCell 174 178 */ 175 179 pmCell *pmCellAlloc( … … 198 202 */ 199 203 pmFPA *pmFPAAlloc( 200 const psMetadata *camera ///< Camera configuration 201 // psDB *db ///< Database handle 202 ); 203 204 const psMetadata *camera, ///< Camera configuration 205 psDB *db ///< Database handle 206 ); 207 208 209 /** Verify parent links. 210 * 211 * This function checks the validity of the parent links in the FPA hierarchy. 212 * If a parent link is not set (or not set correctly), it is corrected, and the 213 * function shall return false. If all the parent pointers were correct, the 214 * function shall return true. 215 * 216 */ 217 bool pmFPACheckParents( 218 pmFPA *fpa 219 ); 220 221 222 223 /** FUNC DESC 224 * 225 * 226 * 227 * 228 */ 204 229 205 230 … … 211 236 212 237 213 214 215 216 217 218 /** Wallace's Grommit219 *220 * SLALib requires several elements to perform the transformations between221 * the tangent plane and the sky. Pre-computing these quantities for each222 * exposure means that subsequent transformations are faster. For historical223 * reasons, this structure is known colloquially as "Wallace's Grommit".224 *225 */226 227 /*228 typedef struct229 {230 const double latitude; ///< geodetic latitude (radians)231 const double longitude; ///< longitude + ... (radians)232 const double height; ///< height (HM)233 const double abberationMag; ///< magnitude of diurnal aberration vector234 const double temperature; ///< ambient temperature (TDK)235 const double pressure; ///< pressure (PMB)236 const double humidity; ///< relative humidity (RH)237 const double wavelength; ///< wavelength (WL)238 const double lapseRate; ///< lapse rate (TLR)239 const double refractA, refractB; ///< refraction constants A and B (radians)240 const double siderealTime; ///< local apparent sidereal time (radians)241 }242 psGrommit;243 */244 245 246 /** Fixed Pattern Corrections247 *248 * The fixed pattern is a correction to the general astrometric solution249 * formed by summing the residuals from many observations. The intent is to250 * correct for higher-order distortions in the camera system on a coarse251 * grid (larger than individual pixels, but smaller than a single cell).252 * Hence, in addition to the offsets, we need to specify the size and scale253 * of the grid in x and y as well as the origin of the grid.254 */255 /*256 typedef struct257 {258 psS32 nX; ///< Number of elements in x direction259 psS32 nY; ///< Number of elements in y direction260 double x0; ///< X Position of 0,0 corner on focal plane261 double y0; ///< Y Position of 0,0 corner on focal plane262 double xScale; ///< Scale of the grid in x direction263 double yScale; ///< Scale of the grid in x direction264 /// XXX: I added the following memvers to facilitate the psFreeing of the x,y data structures.265 psS32 p_ps_xRows; ///< Number of rows in the x member266 psS32 p_ps_xCols; ///< Number of cols in the x member267 psS32 p_ps_yRows; ///< Number of rows in the y member268 psS32 p_ps_yCols; ///< Number of cols in the y member269 double **x; ///< The grid of offsets in x270 double **y; ///< The grid of offsets in y271 }272 psFixedPattern;273 */274 275 276 /** Observatory Information277 *278 * A container for the observatory data that doesn't change per exposure.279 *280 */281 /*typedef struct282 {283 const char* name; ///< Name of observatory284 const double latitude; ///< Latitude of observatory, east positive (degrees?)285 const double longitude; ///< Longitude of observatory (degrees?)286 const double height; ///< Height of observatory in meters287 const double tlr; ///< Tropospheric Lapse Rate288 }289 psObservatory;290 */291 292 /** Exposure Information293 *294 * Several quantities from the telescope in order to make a first guess at295 * the astrometric solution. From these quantities, further quantities can296 * be derivedand stored for later use.297 *298 */299 /*typedef struct psExposure300 {301 const double ra; ///< Telescope boresight, right ascention302 const double dec; ///< Telescope boresight, declination303 const double hourAngle; ///< Hour angle304 const double zenithDistance; ///< Zenith distance305 const double azimuth; ///< Azimuth306 const psTime* time; ///< Time of observation307 const float rotAngle; ///< Rotator position angle in degrees? XXX: see bug#209308 const float temperature; ///< Air temperature in Kelvin309 const float pressure; ///< Air pressure in mB310 const float humidity; ///< Relative humidity, for refraction311 const float exposureTime; ///< Exposure time312 const float wavelength; ///< Wavelength in microns313 const psObservatory* observatory; ///< Observatory data314 315 // Derived quantities316 const double lst; ///< Local Sidereal Time317 const float positionAngle; ///< Position angle318 const float parallacticAngle; ///< Parallactic angle319 const float airmass; ///< Airmass, calculated from zenith distance320 const float parallacticFactor; ///< Parallactic factor321 const char* cameraName; ///< name of camera which provided exposure322 const char* telescopeName; ///< name of telescope which provided exposure323 }324 psExposure;325 */326 327 /** Allocator for psFixedPattern struct328 *329 * Allocates a new psFixedPattern struct with the attributes coorsponding330 * to the parameters set to the said input values.331 *332 * @return psFixedPattern* New psFixedPattern struct.333 */334 /*psFixedPattern* psFixedPatternAlloc(335 double x0, ///< X Position of 0,0 corner on focal plane336 double y0, ///< Y Position of 0,0 corner on focal plane337 double xScale, ///< Scale of the grid in x direction338 double yScale, ///< Scale of the grid in x direction339 const psImage *x, ///< The grid of offsets in x340 const psImage *y ///< The grid of offsets in y341 );342 */343 344 /** Allocator for psExposure345 *346 * We need several quantities from the telescope in order to make a first347 * guess at the astrometric solution. From these quantities, further348 * quantities can be derived and stored for later use.349 *350 * @return psExposure* New psExposure struct351 */352 /*psExposure* psExposureAlloc(353 double ra, ///< Telescope boresight, right ascention354 double dec, ///< Telescope boresight, declination355 double hourAngle, ///< Hour angle356 double zenithDistance, ///< Zenith distance357 double azimuth, ///< Azimuth358 const psTime* time, ///< time of observation359 float rotAngle, ///< Rotator position angle360 float temperature, ///< Temperature361 float pressure, ///< Pressure362 float humidity, ///< Relative humidity363 float exposureTime, ///< Exposure time364 float wavelength, ///< wavelength365 const psObservatory* observatory ///< Observatory data366 );367 */368 369 /** Allocator for psObservatory370 *371 * This function shall construct a new psObservatory with attributes372 * cooresponding to the function parameters.373 *374 * @return psObservatory* new psObservatory struct375 */376 /*psObservatory* psObservatoryAlloc(377 const char* name, ///< Name of observatory378 double latitude, ///< Latitude of observatory, east positive379 double longitude, ///< Longitude of observatory380 double height, ///< Height of observatory381 double tlr ///< Tropospheric Lapse Rate382 );383 */384 385 /** Allocates a Wallace's Grommit structure.386 *387 * The psGrommit is calculated from telescope information for the particular388 * exposure.389 *390 * @return psGrommit* New grommit structure.391 */392 /*psGrommit* psGrommitAlloc(393 const psExposure* exp ///< the cooresponding exposure structure.394 );395 */396 397 238 /** Find cooresponding cell for given FPA coordinate 398 239 * 399 * @return p sCell* the cell cooresponding to the coord in FPA400 */ 401 /*psCell* psCellInFPA(240 * @return pmCell* the cell cooresponding to the coord in FPA 241 */ 242 pmCell* pmCellInFPA( 402 243 const psPlane* coord, ///< the coordinate in FPA plane 403 const p sFPA* FPA ///< the FPA to search for the cell404 ); 405 */ 244 const pmFPA* FPA ///< the FPA to search for the cell 245 ); 246 406 247 407 248 /** Find cooresponding chip for given FPA coordinate 408 249 * 409 * @return p sChip* the chip cooresponding to coord410 */ 411 /*psChip* psChipInFPA(250 * @return pmChip* the chip cooresponding to coord 251 */ 252 pmChip* pmChipInFPA( 412 253 const psPlane* coord, ///< the coordinate in FPA plane 413 const p sFPA* FPA ///< the FPA to search for the cell414 ); 415 */ 254 const pmFPA* FPA ///< the FPA to search for the cell 255 ); 256 416 257 417 258 /** Find cooresponding cell for given Chip coordinate 418 259 * 419 * @return p sCell* the cell cooresponding to coord420 */ 421 /*psCell* psCellInChip(260 * @return pmCell* the cell cooresponding to coord 261 */ 262 pmCell* pmCellInChip( 422 263 const psPlane* coord, ///< the coordinate in Chip plane 423 const p sChip* chip ///< the chip to search for the cell424 ); 425 */ 264 const pmChip* chip ///< the chip to search for the cell 265 ); 266 426 267 427 268 /** Translate a cell coordinate into a chip coordinate … … 429 270 * @return psPlane* the resulting chip coordinate 430 271 */ 431 /*psPlane* psCoordCellToChip(272 psPlane* psCoordCellToChip( 432 273 psPlane* out, ///< a plane struct to recycle. If NULL, a new struct is created 433 274 const psPlane* in, ///< the coordinate within Cell 434 const p sCell* cell ///< the Cell in interest435 ); 436 */ 275 const pmCell* cell ///< the Cell in interest 276 ); 277 437 278 438 279 /** Translate a chip coordinate into a FPA coordinate … … 440 281 * @return psPlane* the resulting FPA coordinate 441 282 */ 442 /*psPlane* psCoordChipToFPA(283 psPlane* psCoordChipToFPA( 443 284 psPlane* out, ///< a plane struct to recycle. If NULL, a new struct is created 444 285 const psPlane* in, ///< the coordinate within Chip 445 const p sChip* chip ///< the chip in interest446 ); 447 */ 286 const pmChip* chip ///< the chip in interest 287 ); 288 448 289 449 290 /** Translate a FPA coordinate into a Tangent Plane coordinate … … 451 292 * @return psPlane* the resulting Tangent Plane coordinate 452 293 */ 453 /*psPlane* psCoordFPAToTP(294 psPlane* psCoordFPAToTP( 454 295 psPlane* out, ///< a plane struct to recycle. If NULL, a new struct is created 455 296 const psPlane* in, ///< the coordinate within FPA 456 297 double color, ///< Color of source 457 298 double magnitude, ///< Magnitude of source 458 const p sFPA* fpa ///< the FPA in interest459 ); 460 */ 299 const pmFPA* fpa ///< the FPA in interest 300 ); 301 461 302 462 303 /** Translate a Tangent Plane coordinate into a Sky coordinate … … 464 305 * @return psSphere* the resulting Sky coordinate 465 306 */ 466 /*psSphere* psCoordTPToSky(307 psSphere* psCoordTPToSky( 467 308 psSphere* out, ///< a sphere struct to recycle. If NULL, a new struct is created 468 const psPlane* in, ///< the coordinate within Tangent Plane 469 const psGrommit* grommit ///< the grommit of the tangent plane 470 ); 471 */ 309 const psPlane* in, ///< the coordinate within Tangent Plane 310 const psProjection *projection 311 ); 472 312 473 313 /** Translate a cell coordinate into a FPA coordinate … … 475 315 * @return psPlane* the resulting FPA coordinate 476 316 */ 477 /*psPlane* psCoordCellToFPA(317 psPlane* psCoordCellToFPA( 478 318 psPlane* out, ///< a plane struct to recycle. If NULL, a new struct is created 479 319 const psPlane* in, ///< the coordinate within cell 480 const p sCell* cell ///< the cell in interest481 ); 482 */ 320 const pmCell* cell ///< the cell in interest 321 ); 322 483 323 484 324 /** Translate a cell coordinate into a Sky coordinate … … 486 326 * @return psSphere* the resulting Sky coordinate 487 327 */ 488 /*psSphere* psCoordCellToSky(328 psSphere* psCoordCellToSky( 489 329 psSphere* out, ///< a sphere struct to recycle. If NULL, a new struct is created 490 330 const psPlane* in, ///< the coordinate within cell 491 331 double color, ///< Color of source 492 332 double magnitude, ///< Magnitude of source 493 const p sCell* cell ///< the cell in interest494 ); 495 */ 333 const pmCell* cell ///< the cell in interest 334 ); 335 496 336 497 337 /** Translate a cell coordinate into a Sky coordinate using a 'quick and … … 500 340 * @return psSphere* the resulting Sky coordinate 501 341 */ 502 /*psSphere* psCoordCellToSkyQuick(342 psSphere* psCoordCellToSkyQuick( 503 343 psSphere* out, ///< a sphere struct to recycle. If NULL, a new struct is created 504 344 const psPlane* in, ///< the coordinate within cell 505 const p sCell* cell ///< the cell in interest506 ); 507 */ 345 const pmCell* cell ///< the cell in interest 346 ); 347 508 348 509 349 /** Translate a Sky coordinate into a Tangent Plane coordinate … … 511 351 * @return psPlane* the resulting Tangent Plane coordinate 512 352 */ 513 /*psPlane* psCoordSkyToTP(353 psPlane* psCoordSkyToTP( 514 354 psPlane* out, ///< a plane struct to recycle. If NULL, a new struct is created 515 355 const psSphere* in, ///< the sky coordinate 516 const psGrommit* grommit ///< the grommit 517 ); 518 */ 356 const psProjection *projection 357 ); 519 358 520 359 /** Translate a Tangent Plane coordinate into a FPA coordinate … … 522 361 * @return psPlane* the resulting FPA coordinate 523 362 */ 524 /*psPlane* psCoordTPToFPA(363 psPlane* psCoordTPToFPA( 525 364 psPlane* out, ///< a plane struct to recycle. If NULL, a new struct is created 526 365 const psPlane* in, ///< the coordinate within tangent plane 527 366 double color, ///< Color of source 528 367 double magnitude, ///< Magnitude of source 529 const p sFPA* fpa ///< the FPA of interest530 ); 531 */ 368 const pmFPA* fpa ///< the FPA of interest 369 ); 370 532 371 533 372 /** Translate a FPA coordinate into a chip coordinate … … 535 374 * @return psPlane* the resulting chip coordinate 536 375 */ 537 /*psPlane* psCoordFPAToChip(376 psPlane* psCoordFPAToChip( 538 377 psPlane* out, ///< a plane struct to recycle. If NULL, a new struct is created 539 378 const psPlane* in, ///< the FPA coordinate 540 const p sChip* chip ///< the chip of interest541 ); 542 */ 379 const pmChip* chip ///< the chip of interest 380 ); 381 543 382 544 383 /** Translate a chip coordinate into a cell coordinate … … 546 385 * @return psPlane* the resulting cell coordinate 547 386 */ 548 /*psPlane* psCoordChipToCell(387 psPlane* psCoordChipToCell( 549 388 psPlane* out, ///< a plane struct to recycle. If NULL, a new struct is created 550 389 const psPlane* in, ///< the Chip coordinate 551 const p sCell* cell ///< the cell of interest552 ); 553 */ 390 const pmCell* cell ///< the cell of interest 391 ); 392 554 393 555 394 /** Translate a sky coordinate into a cell coordinate … … 557 396 * @return psPlane* the resulting cell coordinate 558 397 */ 559 /*psPlane* psCoordSkyToCell(398 psPlane* psCoordSkyToCell( 560 399 psPlane* out, ///< a plane struct to recycle. If NULL, a new struct is created 561 400 const psSphere* in, ///< the Sky coordinate 562 double color,///< Color of source563 double magnitude,///< Magnitude of source564 const p sCell* cell ///< the cell of interest565 ); 566 */ 401 float color, ///< Color of source 402 float magnitude, ///< Magnitude of source 403 const pmCell* cell ///< the cell of interest 404 ); 405 567 406 568 407 /** Translate a sky coordinate into a cell coordinate using a 'quick and … … 571 410 * @return psPlane* the resulting cell coordinate 572 411 */ 573 /*psPlane* psCoordSkyToCellQuick(412 psPlane* psCoordSkyToCellQuick( 574 413 psPlane* out, ///< a plane struct to recycle. If NULL, a new struct is created 575 414 const psSphere* in, ///< the Sky coordinate 576 const p sCell* cell ///< the cell of interest577 ); 578 */ 415 const pmCell* cell ///< the cell of interest 416 ); 417 579 418 580 419 #endif // #ifndef PS_ASTROMETRY_H -
trunk/psModules/src/pmFlatField.c
r2299 r4770 18 18 * @author Ross Harman, MHPCC 19 19 * 20 * @version $Revision: 1.1 7$ $Name: not supported by cvs2svn $21 * @date $Date: 200 4-11-06 02:42:03$20 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $ 21 * @date $Date: 2005-08-16 01:10:34 $ 22 22 * 23 23 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 38 38 39 39 40 bool pmFlatField(p sReadout *in, const psReadout *flat)40 bool pmFlatField(pmReadout *in, pmReadout *mask, const pmReadout *flat) 41 41 { 42 // XXX: Not sure if this is correct. Must consult with IfA. 43 PS_ASSERT_PTR_NON_NULL(mask, false); 42 44 int i = 0; 43 45 int j = 0; … … 71 73 PS_ERRORTEXT_pmFlatField_NULL_FLAT_IMAGE); 72 74 return false; 73 } else if(in->mask == NULL) {74 in->mask = psImageAlloc(inImage->numCols, inImage->numRows, PS_TYPE_MASK);75 memset(in->mask->data.V[0], 0, inImage->numCols*inImage->numRows*PSELEMTYPE_SIZEOF(PS_TYPE_MASK));76 75 } 77 inMask = in->mask;76 inMask = mask->image; 78 77 79 78 // Check input image and its mask are not larger than flat image 79 80 80 if(inImage->numRows>flatImage->numRows || inImage->numCols>flatImage->numCols) { 81 81 psError( PS_ERR_BAD_PARAMETER_SIZE, true, -
trunk/psModules/src/pmFlatField.h
r4754 r4770 18 18 * @author Ross Harman, MHPCC 19 19 * 20 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $21 * @date $Date: 2005-08-1 1 00:03:51$20 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 21 * @date $Date: 2005-08-16 01:10:34 $ 22 22 * 23 23 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 36 36 */ 37 37 bool pmFlatField( 38 psReadout *in, ///< Redout with input image and mask 39 const psReadout *flat ///< Readout with flat image 38 pmReadout *in, ///< Readout with input image 39 pmReadout *mask, ///< Input image mask 40 const pmReadout *flat ///< Readout with flat image 40 41 ); 41 42 -
trunk/psModules/src/pmMaskBadPixels.c
r2275 r4770 19 19 * @author Ross Harman, MHPCC 20 20 * 21 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $22 * @date $Date: 200 4-11-04 02:02:10$21 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 22 * @date $Date: 2005-08-16 01:10:34 $ 23 23 * 24 24 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 36 36 #include "pmMaskBadPixelsErrors.h" 37 37 38 bool pmMaskBadPixels(p sReadout *in, const psImage *mask, unsigned int maskVal, float sat,38 bool pmMaskBadPixels(pmReadout *in, const psImage *mask, unsigned int maskVal, float sat, 39 39 unsigned int growVal, int grow) 40 40 { -
trunk/psModules/src/pmMaskBadPixels.h
r4754 r4770 19 19 * @author Ross Harman, MHPCC 20 20 * 21 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $22 * @date $Date: 2005-08-1 1 00:03:51$21 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 22 * @date $Date: 2005-08-16 01:10:34 $ 23 23 * 24 24 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 52 52 */ 53 53 bool pmMaskBadPixels( 54 p sReadout *in, ///< Readout containing input image data.54 pmReadout *in, ///< Readout containing input image data. 55 55 const psImage *mask, ///< Mask data to be added to readout mask data. 56 56 unsigned int maskVal, ///< Mask value to determine what to add to input mask. -
trunk/psModules/src/pmNonLinear.c
r4030 r4770 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-0 5-25 20:28:32$7 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-08-16 01:10:34 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 24 24 25 25 /****************************************************************************** 26 pmNonLinearityLookup(): This routine will take an p sReadout image as input26 pmNonLinearityLookup(): This routine will take an pmReadout image as input 27 27 and a 1-D polynomial. For each pixel in the input image, the polynomial will 28 28 be evaluated at that pixels value, and the image pixel will then be set to … … 30 30 *****************************************************************************/ 31 31 32 p sReadout *pmNonLinearityPolynomial(psReadout *inputReadout,32 pmReadout *pmNonLinearityPolynomial(pmReadout *inputReadout, 33 33 const psPolynomial1D *input1DPoly) 34 34 { … … 51 51 52 52 /****************************************************************************** 53 pmNonLinearityLookup(): This routine will take an p sReadout image as input53 pmNonLinearityLookup(): This routine will take an pmReadout image as input 54 54 and two input vectors, which constitute a lookup table. For each pixel in 55 55 the input image, that pixels value will be determined in the input vector … … 57 57 be set to the value from outFlux. 58 58 *****************************************************************************/ 59 p sReadout *pmNonLinearityLookup(psReadout *inputReadout,59 pmReadout *pmNonLinearityLookup(pmReadout *inputReadout, 60 60 const psVector *inFlux, 61 61 const psVector *outFlux) -
trunk/psModules/src/pmNonLinear.h
r4754 r4770 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-08-1 1 00:03:51$7 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-08-16 01:10:34 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 18 18 #include "pmAstrometry.h" 19 19 20 p sReadout *pmNonLinearityPolynomial(psReadout *in,20 pmReadout *pmNonLinearityPolynomial(pmReadout *in, 21 21 const psPolynomial1D *coeff); 22 22 23 p sReadout *pmNonLinearityLookup(psReadout *in,23 pmReadout *pmNonLinearityLookup(pmReadout *in, 24 24 const psVector *inFlux, 25 25 const psVector *outFlux); -
trunk/psModules/src/pmObjects.c
r4579 r4770 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1.3 0$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-0 7-19 01:44:48$8 * @version $Revision: 1.31 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-08-16 01:10:34 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 20 20 21 21 /****************************************************************************** 22 pmPeakAlloc(): Allocate the p sPeak data structure and set appropriate members.23 *****************************************************************************/ 24 p sPeak *pmPeakAlloc(psS32 x,22 pmPeakAlloc(): Allocate the pmPeak data structure and set appropriate members. 23 *****************************************************************************/ 24 pmPeak *pmPeakAlloc(psS32 x, 25 25 psS32 y, 26 26 psF32 counts, 27 p sPeakType class)28 { 29 p sPeak *tmp = (psPeak *) psAlloc(sizeof(psPeak));27 pmPeakType class) 28 { 29 pmPeak *tmp = (pmPeak *) psAlloc(sizeof(pmPeak)); 30 30 tmp->x = x; 31 31 tmp->y = y; … … 37 37 38 38 /****************************************************************************** 39 pmMomentsAlloc(): Allocate the p sMoments structure and initialize the members39 pmMomentsAlloc(): Allocate the pmMoments structure and initialize the members 40 40 to zero. 41 41 *****************************************************************************/ 42 p sMoments *pmMomentsAlloc()43 { 44 p sMoments *tmp = (psMoments *) psAlloc(sizeof(psMoments));42 pmMoments *pmMomentsAlloc() 43 { 44 pmMoments *tmp = (pmMoments *) psAlloc(sizeof(pmMoments)); 45 45 tmp->x = 0.0; 46 46 tmp->y = 0.0; … … 56 56 } 57 57 58 static void modelFree(p sModel *tmp)58 static void modelFree(pmModel *tmp) 59 59 { 60 60 psFree(tmp->params); … … 63 63 64 64 /****************************************************************************** 65 pmModelAlloc(): Allocate the p sModel structure, along with its parameters,65 pmModelAlloc(): Allocate the pmModel structure, along with its parameters, 66 66 and initialize the type member. Initialize the params to 0.0. 67 67 XXX EAM: changing params and dparams to psVector 68 68 *****************************************************************************/ 69 p sModel *pmModelAlloc(psModelType type)70 { 71 p sModel *tmp = (psModel *) psAlloc(sizeof(psModel));69 pmModel *pmModelAlloc(pmModelType type) 70 { 71 pmModel *tmp = (pmModel *) psAlloc(sizeof(pmModel)); 72 72 73 73 tmp->type = type; … … 99 99 break; 100 100 default: 101 psError(PS_ERR_UNKNOWN, true, "Undefined p sModelType");101 psError(PS_ERR_UNKNOWN, true, "Undefined pmModelType"); 102 102 return(NULL); 103 103 } … … 116 116 We might need to increase the reference counter and decrease it here. 117 117 *****************************************************************************/ 118 static void sourceFree(p sSource *tmp)118 static void sourceFree(pmSource *tmp) 119 119 { 120 120 psFree(tmp->peak); … … 122 122 // psFree(tmp->mask); 123 123 psFree(tmp->moments); 124 psFree(tmp->models); 125 } 126 127 /****************************************************************************** 128 pmSourceAlloc(): Allocate the psSource structure and initialize its members 124 psFree(tmp->modelPSF); 125 psFree(tmp->modelFLT); 126 } 127 128 /****************************************************************************** 129 pmSourceAlloc(): Allocate the pmSource structure and initialize its members 129 130 to NULL. 130 131 *****************************************************************************/ 131 p sSource *pmSourceAlloc()132 { 133 p sSource *tmp = (psSource *) psAlloc(sizeof(psSource));132 pmSource *pmSourceAlloc() 133 { 134 pmSource *tmp = (pmSource *) psAlloc(sizeof(pmSource)); 134 135 tmp->peak = NULL; 135 136 tmp->pixels = NULL; 136 137 tmp->mask = NULL; 137 138 tmp->moments = NULL; 138 tmp->models = NULL; 139 tmp->modelPSF = NULL; 140 tmp->modelFLT = NULL; 139 141 tmp->type = 0; 140 142 psMemSetDeallocator(tmp, (psFreeFunc) sourceFree); … … 272 274 psS32 col, 273 275 psF32 counts, 274 p sPeakType type)275 { 276 p sPeak *tmpPeak = pmPeakAlloc(col, row, counts, type);276 pmPeakType type) 277 { 278 pmPeak *tmpPeak = pmPeakAlloc(col, row, counts, type); 277 279 278 280 if (list == NULL) { … … 379 381 // Step through all local peaks in this row. 380 382 for (psU32 i = 0 ; i < row1->n ; i++ ) { 381 p sPeakType myType = PM_PEAK_UNDEF;383 pmPeakType myType = PM_PEAK_UNDEF; 382 384 col = row1->data.U32[i]; 383 385 … … 527 529 // printf("pmCullPeaks(): list size is %d\n", peaks->size); 528 530 while (tmpListElem != NULL) { 529 p sPeak *tmpPeak = (psPeak *) tmpListElem->data;531 pmPeak *tmpPeak = (pmPeak *) tmpListElem->data; 530 532 if ((tmpPeak->counts > maxValue) || 531 533 ((valid != NULL) && … … 553 555 554 556 for (int i = 0; i < peaks->n; i++) { 555 p sPeak *tmpPeak = (psPeak *) peaks->data[i];557 pmPeak *tmpPeak = (pmPeak *) peaks->data[i]; 556 558 if (tmpPeak->counts > maxValue) 557 559 continue; … … 566 568 567 569 /****************************************************************************** 568 p sSource *pmSourceLocalSky(image, peak, innerRadius, outerRadius): this569 routine creates a new p sSource data structure and sets the following members:570 ->p sPeak571 ->p sMoments->sky570 pmSource *pmSourceLocalSky(image, peak, innerRadius, outerRadius): this 571 routine creates a new pmSource data structure and sets the following members: 572 ->pmPeak 573 ->pmMoments->sky 572 574 573 575 The sky value is set from the pixels in the square annulus surrounding the … … 590 592 or they use the image row/column offsets. 591 593 592 XXX: Should we simply set p sSource->peak = peak? If so, should we increase594 XXX: Should we simply set pmSource->peak = peak? If so, should we increase 593 595 the reference counter? Or, should we copy the data structure? 594 596 … … 602 604 members. 603 605 *****************************************************************************/ 604 p sSource *pmSourceLocalSky(const psImage *image,605 const p sPeak *peak,606 pmSource *pmSourceLocalSky(const psImage *image, 607 const pmPeak *peak, 606 608 psStatsOptions statsOptions, 607 609 psF32 innerRadius, … … 723 725 // Create the output mySource, and set appropriate members. 724 726 // 725 p sSource *mySource = pmSourceAlloc();726 mySource->peak = (p sPeak *) peak;727 pmSource *mySource = pmSourceAlloc(); 728 mySource->peak = (pmPeak *) peak; 727 729 mySource->moments = pmMomentsAlloc(); 728 730 psF64 tmpF64; … … 746 748 XXX: macro this for performance. 747 749 *****************************************************************************/ 748 static bool checkRadius(p sPeak *peak,750 static bool checkRadius(pmPeak *peak, 749 751 psF32 radius, 750 752 psS32 x, … … 781 783 /****************************************************************************** 782 784 pmSourceMoments(source, radius): this function takes a subImage defined in the 783 p sSource data structure, along with the peak location, and determines the785 pmSource data structure, along with the peak location, and determines the 784 786 various moments associated with that peak. 785 787 786 788 Requires the following to have been created: 787 p sSource788 p sSource->peak789 p sSource->pixels789 pmSource 790 pmSource->peak 791 pmSource->pixels 790 792 791 793 XXX: The peak calculations are done in image coords, not subImage coords. … … 793 795 XXX: mask values? 794 796 *****************************************************************************/ 795 p sSource *pmSourceMoments(psSource *source,797 pmSource *pmSourceMoments(pmSource *source, 796 798 psF32 radius) 797 799 { … … 925 927 int pmComparePeakAscend (const void **a, const void **b) 926 928 { 927 p sPeak *A = *(psPeak **)a;928 p sPeak *B = *(psPeak **)b;929 pmPeak *A = *(pmPeak **)a; 930 pmPeak *B = *(pmPeak **)b; 929 931 930 932 psF32 diff; … … 940 942 int pmComparePeakDescend (const void **a, const void **b) 941 943 { 942 p sPeak *A = *(psPeak **)a;943 p sPeak *B = *(psPeak **)b;944 pmPeak *A = *(pmPeak **)a; 945 pmPeak *B = *(pmPeak **)b; 944 946 945 947 psF32 diff; … … 992 994 for (psS32 i = 0 ; i < sources->n ; i++) 993 995 { 994 p sSource *tmpSrc = (psSource *) sources->data[i];996 pmSource *tmpSrc = (pmSource *) sources->data[i]; 995 997 PS_ASSERT_PTR_NON_NULL(tmpSrc, false); // just skip this one? 996 998 PS_ASSERT_PTR_NON_NULL(tmpSrc->moments, false); // just skip this one? … … 1027 1029 // measure statistics on Sx, Sy if Sx, Sy within range of clump 1028 1030 { 1029 p sPeak *clump;1031 pmPeak *clump; 1030 1032 psF32 minSx, maxSx; 1031 1033 psF32 minSy, maxSy; … … 1054 1056 for (psS32 i = 0 ; i < sources->n ; i++) 1055 1057 { 1056 p sSource *tmpSrc = (psSource *) sources->data[i];1058 pmSource *tmpSrc = (pmSource *) sources->data[i]; 1057 1059 1058 1060 if (tmpSrc->moments->Sx < minSx) … … 1103 1105 for (psS32 i = 0 ; i < sources->n ; i++) { 1104 1106 1105 p sSource *tmpSrc = (psSource *) sources->data[i];1107 pmSource *tmpSrc = (pmSource *) sources->data[i]; 1106 1108 1107 1109 tmpSrc->peak->class = 0; … … 1197 1199 the pmSourceSetLocal() function. 1198 1200 *****************************************************************************/ 1199 bool pmSourceSetPixelsCircle(p sSource *source,1201 bool pmSourceSetPixelsCircle(pmSource *source, 1200 1202 const psImage *image, 1201 1203 psF32 radius) … … 1293 1295 /****************************************************************************** 1294 1296 pmSourceModelGuess(source, image, model): This function allocates a new 1295 p sModel structure and stores it in the psSource data structure specified in1297 pmModel structure and stores it in the pmSource data structure specified in 1296 1298 the argument list. The model type is specified in the argument list. The 1297 params array in that p sModel structure are allocated, and then set to the1299 params array in that pmModel structure are allocated, and then set to the 1298 1300 appropriate values. This function returns true if everything was successful. 1299 1301 … … 1306 1308 image, not subImage coords. Therefore, the calls to the model evaluation 1307 1309 functions will be in image, not subImage coords. Remember this. 1308 *****************************************************************************/ 1309 bool pmSourceModelGuess(psSource *source, 1310 1311 XXX: The source->models member used to be allocated here. Now I assume 1312 ->modelPSF should be allocated 1313 *****************************************************************************/ 1314 bool pmSourceModelGuess(pmSource *source, 1310 1315 const psImage *image, 1311 p sModelType model)1316 pmModelType model) 1312 1317 { 1313 1318 PS_ASSERT_PTR_NON_NULL(source, false); … … 1316 1321 PS_ASSERT_IMAGE_NON_NULL(image, false); 1317 1322 PS_ASSERT_IMAGE_TYPE(image, PS_TYPE_F32, false); 1318 if (source->model s!= NULL) {1319 psLogMsg(__func__, PS_LOG_WARN, "WARNING: source->model s was non-NULL; calling psFree(source->models).\n");1320 psFree(source->model s);1323 if (source->modelPSF != NULL) { 1324 psLogMsg(__func__, PS_LOG_WARN, "WARNING: source->modelPSF was non-NULL; calling psFree(source->modelPSF).\n"); 1325 psFree(source->modelPSF); 1321 1326 } 1322 1327 if (!((model == PS_MODEL_GAUSS) || … … 1330 1335 } 1331 1336 1332 source->model s= pmModelAlloc(model);1333 1334 psVector *params = source->model s->params;1337 source->modelPSF = pmModelAlloc(model); 1338 1339 psVector *params = source->modelPSF->params; 1335 1340 1336 1341 switch (model) { … … 1364 1369 params->data.F32[6] = source->moments->Sxy; 1365 1370 // XXX: What are these? 1366 // source->model s->params[7] = B2;1367 // source->model s->params[8] = B3;1371 // source->modelPSF->params[7] = B2; 1372 // source->modelPSF->params[8] = B3; 1368 1373 return(true); 1369 1374 … … 1420 1425 /****************************************************************************** 1421 1426 evalModel(source, level, row): a private function which evaluates the 1422 source->model function at the specified coords. The coords are subImage, not1427 source->modelPSF function at the specified coords. The coords are subImage, not 1423 1428 image coords. 1424 1429 … … 1430 1435 the coords is in subImage or image space. 1431 1436 1432 XXX: This should probably be a public p sModules function.1437 XXX: This should probably be a public pmModules function. 1433 1438 1434 1439 XXX: Use static vectors for x. … … 1439 1444 testing. Try to reproduce that and debug. 1440 1445 *****************************************************************************/ 1441 static psF32 evalModel(p sSource *src,1446 static psF32 evalModel(pmSource *src, 1442 1447 psU32 row, 1443 1448 psU32 col) 1444 1449 { 1445 1450 PS_ASSERT_PTR_NON_NULL(src, false); 1446 PS_ASSERT_PTR_NON_NULL(src->model s, false);1447 PS_ASSERT_PTR_NON_NULL(src->model s->params, false);1448 1449 // XXX: The following step will not be necessary if the model s->params1451 PS_ASSERT_PTR_NON_NULL(src->modelPSF, false); 1452 PS_ASSERT_PTR_NON_NULL(src->modelPSF->params, false); 1453 1454 // XXX: The following step will not be necessary if the modelPSF->params 1450 1455 // member is a psVector. Suggest to IfA. 1451 1456 1452 // XXX EAM: done: model s->params is now a vector1453 psVector *params = src->model s->params;1457 // XXX EAM: done: modelPSF->params is now a vector 1458 psVector *params = src->modelPSF->params; 1454 1459 1455 1460 // … … 1461 1466 psF32 tmpF; 1462 1467 1463 switch (src->model s->type) {1468 switch (src->modelPSF->type) { 1464 1469 case PS_MODEL_GAUSS: 1465 1470 tmpF = pmMinLM_Gauss2D(NULL, params, x); … … 1481 1486 break; 1482 1487 default: 1483 psError(PS_ERR_UNKNOWN, true, "Undefined p sModelType");1488 psError(PS_ERR_UNKNOWN, true, "Undefined pmModelType"); 1484 1489 return(NAN); 1485 1490 } … … 1500 1505 XXX: The result is returned in image coords. 1501 1506 *****************************************************************************/ 1502 static psF32 findValue(p sSource *source,1507 static psF32 findValue(pmSource *source, 1503 1508 psF32 level, 1504 1509 psU32 row, … … 1575 1580 XXX: The top, bottom of the contour is not correctly determined. 1576 1581 *****************************************************************************/ 1577 psArray *pmSourceContour(p sSource *source,1582 psArray *pmSourceContour(pmSource *source, 1578 1583 const psImage *image, 1579 1584 psF32 level, … … 1585 1590 PS_ASSERT_PTR_NON_NULL(source->peak, false); 1586 1591 PS_ASSERT_PTR_NON_NULL(source->pixels, false); 1587 PS_ASSERT_PTR_NON_NULL(source->model s, false);1592 PS_ASSERT_PTR_NON_NULL(source->modelPSF, false); 1588 1593 1589 1594 // … … 1692 1697 XXX: Probably should remove the "image" argument. 1693 1698 *****************************************************************************/ 1694 bool pmSourceFitModel(p sSource *source,1699 bool pmSourceFitModel(pmSource *source, 1695 1700 const psImage *image) 1696 1701 { … … 1699 1704 PS_ASSERT_PTR_NON_NULL(source->peak, false); 1700 1705 PS_ASSERT_PTR_NON_NULL(source->pixels, false); 1701 PS_ASSERT_PTR_NON_NULL(source->model s, false);1706 PS_ASSERT_PTR_NON_NULL(source->modelPSF, false); 1702 1707 PS_ASSERT_IMAGE_NON_NULL(image, false); 1703 1708 PS_ASSERT_IMAGE_TYPE(image, PS_TYPE_F32, false); … … 1742 1747 PM_SOURCE_FIT_MODEL_TOLERANCE); 1743 1748 1744 psVector *params = source->model s->params;1745 1746 switch (source->model s->type) {1749 psVector *params = source->modelPSF->params; 1750 1751 switch (source->modelPSF->type) { 1747 1752 case PS_MODEL_GAUSS: 1748 1753 rc = psMinimizeLMChi2(myMin, NULL, params, NULL, x, y, yErr, pmMinLM_Gauss2D); … … 1764 1769 break; 1765 1770 default: 1766 psError(PS_ERR_UNKNOWN, true, "Undefined p sModelType");1771 psError(PS_ERR_UNKNOWN, true, "Undefined pmModelType"); 1767 1772 rc = false; 1768 1773 } 1769 1774 // XXX EAM: we need to do something (give an error?) if rc is false 1770 1775 // XXX EAM: save the resulting chisq, nDOF, nIter 1771 source->model s->chisq = myMin->value;1772 source->model s->nDOF = y->n - params->n;1773 source->model s->nIter = myMin->iter;1776 source->modelPSF->chisq = myMin->value; 1777 source->modelPSF->nDOF = y->n - params->n; 1778 source->modelPSF->nIter = myMin->iter; 1774 1779 1775 1780 psFree(x); … … 1780 1785 1781 1786 static bool sourceAddOrSubModel(psImage *image, 1782 p sSource *src,1787 pmSource *src, 1783 1788 bool center, 1784 1789 psS32 flag) … … 1788 1793 PS_ASSERT_PTR_NON_NULL(src->peak, false); 1789 1794 PS_ASSERT_PTR_NON_NULL(src->pixels, false); 1790 PS_ASSERT_PTR_NON_NULL(src->model s, false);1795 PS_ASSERT_PTR_NON_NULL(src->modelPSF, false); 1791 1796 PS_ASSERT_IMAGE_NON_NULL(image, false); 1792 1797 PS_ASSERT_IMAGE_TYPE(image, PS_TYPE_F32, false); 1793 1798 1794 1799 psVector *x = psVectorAlloc(2, PS_TYPE_F32); 1795 psVector *params = src->model s->params;1800 psVector *params = src->modelPSF->params; 1796 1801 1797 1802 for (psS32 i = 0; i < src->pixels->numRows; i++) { … … 1808 1813 x->data.F32[0] = (float) imageCol; 1809 1814 x->data.F32[1] = (float) imageRow; 1810 switch (src->model s->type) {1815 switch (src->modelPSF->type) { 1811 1816 case PS_MODEL_GAUSS: 1812 1817 pixelValue = pmMinLM_Gauss2D(NULL, params, x); … … 1828 1833 break; 1829 1834 default: 1830 psError(PS_ERR_UNKNOWN, true, "Undefined p sModelType");1835 psError(PS_ERR_UNKNOWN, true, "Undefined pmModelType"); 1831 1836 psFree(x); 1832 1837 return(false); … … 1851 1856 *****************************************************************************/ 1852 1857 bool pmSourceAddModel(psImage *image, 1853 p sSource *src,1858 pmSource *src, 1854 1859 bool center) 1855 1860 { … … 1860 1865 *****************************************************************************/ 1861 1866 bool pmSourceSubModel(psImage *image, 1862 p sSource *src,1867 pmSource *src, 1863 1868 bool center) 1864 1869 { -
trunk/psModules/src/pmObjects.h
r4579 r4770 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-0 7-19 01:44:48$7 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-08-16 01:10:34 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 23 23 #include "pslib.h" 24 24 25 /** pmPeakType 26 * 27 * A peak pixel may have several features which may be determined when the 28 * peak is found or measured. These are specified by the pmPeakType enum. 29 * PM_PEAK_LONE represents a single pixel which is higher than its 8 immediate 30 * neighbors. The PM_PEAK_EDGE represents a peak pixel which touching the image 31 * edge. The PM_PEAK_FLAT represents a peak pixel which has more than a specific 32 * number of neighbors at the same value, within some tolarence: 33 * 34 */ 25 35 typedef enum { 26 PM_PEAK_LONE, ///< Isolated peak. 27 PM_PEAK_EDGE, ///< Peak on edge. 28 PM_PEAK_FLAT, ///< Peak has equal-value neighbors. 29 PM_PEAK_UNDEF ///< Undefined. 30 } psPeakType; 31 36 PM_PEAK_LONE, ///< Isolated peak. 37 PM_PEAK_EDGE, ///< Peak on edge. 38 PM_PEAK_FLAT, ///< Peak has equal-value neighbors. 39 PM_PEAK_UNDEF ///< Undefined. 40 } pmPeakType; 41 42 /** pmPeak data structure 43 * 44 * 45 * 46 */ 32 47 typedef struct 33 48 { 34 psS32 x;///< X-coordinate of peak pixel.35 psS32 y;///< Y-coordinate of peak pixel.36 psF32 counts;///< Value of peak pixel (above sky?).37 p sPeakType class;///< Description of peak.49 int x; ///< X-coordinate of peak pixel. 50 int y; ///< Y-coordinate of peak pixel. 51 float counts; ///< Value of peak pixel (above sky?). 52 pmPeakType class; ///< Description of peak. 38 53 } 39 psPeak; 40 54 pmPeak; 55 56 /** pmMoments data structure 57 * 58 * 59 * 60 */ 41 61 typedef struct 42 62 { 43 psF32 x;///< X-coord of centroid.44 psF32 y;///< Y-coord of centroid.45 psF32 Sx;///< x-second moment.46 psF32 Sy;///< y-second moment.47 psF32 Sxy;///< xy cross moment.48 psF32 Sum;///< Pixel sum above sky (background).49 psF32 Peak;///< Peak counts above sky.50 psF32 Sky;///< Sky level (background).51 psS32 nPixels;///< Number of pixels used.63 float x; ///< X-coord of centroid. 64 float y; ///< Y-coord of centroid. 65 float Sx; ///< x-second moment. 66 float Sy; ///< y-second moment. 67 float Sxy; ///< xy cross moment. 68 float Sum; ///< Pixel sum above sky (background). 69 float Peak; ///< Peak counts above sky. 70 float Sky; ///< Sky level (background). 71 int nPixels; ///< Number of pixels used. 52 72 } 53 psMoments; 54 73 pmMoments; 74 75 /** pmModelType enumeration 76 * 77 * 78 * 79 */ 55 80 typedef enum { 56 PS_MODEL_GAUSS, ///< Regular 2-D Gaussian 57 PS_MODEL_PGAUSS, ///< Psuedo 2-D Gaussian 58 PS_MODEL_TWIST_GAUSS, ///< 2-D Twisted Gaussian 59 PS_MODEL_WAUSS, ///< 2-D Waussian 60 PS_MODEL_SERSIC, ///< Sersic 61 PS_MODEL_SERSIC_CORE, ///< Sersic Core 62 PS_MODEL_UNDEFINED ///< Undefined 63 } psModelType; 64 65 // XXX: It will be better if params, and dparams, were psVectors. 81 PS_MODEL_GAUSS, ///< Regular 2-D Gaussian 82 PS_MODEL_PGAUSS, ///< Psuedo 2-D Gaussian 83 PS_MODEL_TWIST_GAUSS, ///< 2-D Twisted Gaussian 84 PS_MODEL_WAUSS, ///< 2-D Waussian 85 PS_MODEL_SERSIC, ///< Sersic 86 PS_MODEL_SERSIC_CORE, ///< Sersic Core 87 PS_MODEL_UNDEFINED ///< Undefined 88 } pmModelType; 89 90 /** pmModel data structure 91 * 92 * 93 * 94 */ 95 // XXX: The SDRS has the "type" member of type psS32. 66 96 typedef struct 67 97 { 68 p sModelType type;///< Model to be used.69 psVector *params; ///< Paramater values.70 psVector *dparams; ///< Parameter errors.71 psF32 chisq;///< Fit chi-squared.72 psS32 nDOF;///< number of degrees of freedom73 psS32 nIter;///< number of iterations to reach min98 pmModelType type; ///< Model to be used. 99 psVector *params; ///< Paramater values. 100 psVector *dparams; ///< Parameter errors. 101 float chisq; ///< Fit chi-squared. 102 int nDOF; ///< number of degrees of freedom 103 int nIter; ///< number of iterations to reach min 74 104 } 75 psModel; 76 105 pmModel; 106 107 /** pmSourceType enumeration 108 * 109 * 110 * 111 */ 77 112 typedef enum { 78 113 PS_SOURCE_PSFSTAR, … … 84 119 PS_SOURCE_BRIGHTSTAR, 85 120 PS_SOURCE_OTHER 86 } psSourceType; 87 121 } pmSourceType; 122 123 /** pmSource data structure 124 * 125 * This source has the capacity for several types of measurements. The 126 * simplest measurement of a source is the location and flux of the peak pixel 127 * associated with the source: 128 * 129 */ 88 130 typedef struct 89 131 { 90 psPeak *peak; ///< Description of peak pixel. 91 psImage *pixels; ///< Rectangular region including object pixels. 92 psImage *mask; ///< Mask which marks pixels associated with objects. 93 psMoments *moments; ///< Basic moments measure for the object. 94 psModel *models; ///< Model parameters and type. 95 psSourceType type; ///< Best identification of object. 132 pmPeak *peak; ///< Description of peak pixel. 133 psImage *pixels; ///< Rectangular region including object pixels. 134 psImage *mask; ///< Mask which marks pixels associated with objects. 135 pmMoments *moments; ///< Basic moments measure for the object. 136 pmModel *modelPSF; ///< PSF model parameters and type 137 pmModel *modelFLT; ///< FLT model parameters and type 138 pmSourceType type; ///< Best identification of object. 96 139 } 97 psSource; 98 99 psPeak *pmPeakAlloc(psS32 x, ///< Row-coordinate in image space 100 psS32 y, ///< Col-coordinate in image space 101 psF32 counts, ///< The value of the peak pixel 102 psPeakType class ///< The type of peak pixel 103 ); 104 105 psMoments *pmMomentsAlloc(); 106 psModel *pmModelAlloc(psModelType type); 107 psSource *pmSourceAlloc(); 140 pmSource; 141 142 /** pmPeak data structure 143 * 144 * 145 * 146 */ 147 typedef struct 148 { 149 psS32 type; ///< PSF Model in use 150 psArray *params; ///< Model parameters (psPolynomial2D) 151 psF32 chisq; ///< PSF goodness statistic 152 psS32 nPSFstars; ///< number of stars used to measure PSF 153 } 154 pmPSF; 155 156 157 158 pmPeak *pmPeakAlloc( 159 int x, ///< Row-coordinate in image space 160 int y, ///< Col-coordinate in image space 161 float counts, ///< The value of the peak pixel 162 pmPeakType class ///< The type of peak pixel 163 ); 164 165 pmMoments *pmMomentsAlloc(); 166 pmModel *pmModelAlloc(pmModelType type); 167 pmSource *pmSourceAlloc(); 108 168 109 169 /****************************************************************************** … … 112 172 the location (x value) of all peaks. 113 173 *****************************************************************************/ 114 psVector *pmFindVectorPeaks(const psVector *vector, ///< The input vector (psF32) 115 psF32 threshold ///< Threshold above which to find a peak 116 ); 174 psVector *pmFindVectorPeaks( 175 const psVector *vector, ///< The input vector (float) 176 float threshold ///< Threshold above which to find a peak 177 ); 117 178 118 179 /****************************************************************************** … … 121 182 value) of all peaks. 122 183 *****************************************************************************/ 123 psArray *pmFindImagePeaks(const psImage *image, ///< The input image where peaks will be found (psF32) 124 psF32 threshold ///< Threshold above which to find a peak 125 ); 184 psArray *pmFindImagePeaks( 185 const psImage *image, ///< The input image where peaks will be found (float) 186 float threshold ///< Threshold above which to find a peak 187 ); 126 188 127 189 /****************************************************************************** … … 129 191 a peak value above the given maximum, or fall outside the valid region. 130 192 *****************************************************************************/ 131 psList *pmCullPeaks(psList *peaks, ///< The psList of peaks to be culled 132 psF32 maxValue, ///< Cull peaks above this value 133 const psRegion *valid ///< Cull peaks otside this psRegion 134 ); 135 136 /****************************************************************************** 137 psSource *pmSourceLocalSky(image, peak, innerRadius, outerRadius): 193 psList *pmCullPeaks( 194 psList *peaks, ///< The psList of peaks to be culled 195 float maxValue, ///< Cull peaks above this value 196 const psRegion *valid ///< Cull peaks otside this psRegion 197 ); 198 199 /****************************************************************************** 200 pmSource *pmSourceLocalSky(image, peak, innerRadius, outerRadius): 138 201 139 202 *****************************************************************************/ 140 psSource *pmSourceLocalSky(const psImage *image, ///< The input image (psF32) 141 const psPeak *peak, ///< The peak for which the psSource struct is created. 142 psStatsOptions statsOptions, ///< The statistic used in calculating the background sky 143 psF32 innerRadius, ///< The inner radius of the suqare annulus for calculating sky 144 psF32 outerRadius ///< The outer radius of the suqare annulus for calculating sky 145 ); 146 147 /****************************************************************************** 148 *****************************************************************************/ 149 psSource *pmSourceMoments(psSource *source, ///< The input psSource for which moments will be computed 150 psF32 radius ///< Use a circle of pixels around the peak 151 ); 203 pmSource *pmSourceLocalSky( 204 const psImage *image, ///< The input image (float) 205 const pmPeak *peak, ///< The peak for which the psSource struct is created. 206 psStatsOptions statsOptions, ///< The statistic used in calculating the background sky 207 float innerRadius, ///< The inner radius of the suqare annulus for calculating sky 208 float outerRadius ///< The outer radius of the suqare annulus for calculating sky 209 ); 210 211 /****************************************************************************** 212 *****************************************************************************/ 213 pmSource *pmSourceMoments( 214 pmSource *source, ///< The input pmSource for which moments will be computed 215 float radius ///< Use a circle of pixels around the peak 216 ); 152 217 153 218 /****************************************************************************** … … 155 220 source classification. 156 221 *****************************************************************************/ 157 bool pmSourceRoughClass(psArray *source, ///< The input psSource 158 psMetadata *metadata ///< Contains classification parameters 159 ); 222 bool pmSourceRoughClass( 223 psArray *source, ///< The input pmSource 224 psMetadata *metadata ///< Contains classification parameters 225 ); 160 226 /****************************************************************************** 161 227 pmSourceSetPixelCircle(source, image, radius) 162 228 *****************************************************************************/ 163 bool pmSourceSetPixelsCircle(psSource *source, ///< The input psSource 164 const psImage *image, ///< The input image (psF32) 165 psF32 radius ///< The radius of the circle 166 ); 167 168 /****************************************************************************** 169 *****************************************************************************/ 170 bool pmSourceModelGuess(psSource *source, ///< The input psSource 171 const psImage *image, ///< The input image (psF32) 172 psModelType model ///< The type of model to be created. 173 ); 229 bool pmSourceSetPixelsCircle( 230 pmSource *source, ///< The input pmSource 231 const psImage *image, ///< The input image (float) 232 float radius ///< The radius of the circle 233 ); 234 235 /****************************************************************************** 236 *****************************************************************************/ 237 bool pmSourceModelGuess( 238 pmSource *source, ///< The input pmSource 239 const psImage *image, ///< The input image (float) 240 pmModelType model ///< The type of model to be created. 241 ); 174 242 175 243 /****************************************************************************** … … 179 247 } pmContourType; 180 248 181 psArray *pmSourceContour(psSource *source, ///< The input psSource 182 const psImage *image, ///< The input image (psF32) (this arg should be removed) 183 psF32 level, ///< The level of the contour 184 pmContourType mode ///< Currently this must be PS_CONTOUR_CRUDE 185 ); 186 187 /****************************************************************************** 188 *****************************************************************************/ 189 bool pmSourceFitModel(psSource *source, ///< The input psSource 190 const psImage *image ///< The input image (psF32) 191 ); 192 193 /****************************************************************************** 194 *****************************************************************************/ 195 bool pmSourceAddModel(psImage *image, ///< The opuut image (psF32) 196 psSource *source, ///< The input psSource 197 bool center ///< A boolean flag that determines whether pixels are centered 198 ); 199 200 /****************************************************************************** 201 *****************************************************************************/ 202 bool pmSourceSubModel(psImage *image, ///< The output image (psF32) 203 psSource *source, ///< The input psSource 204 bool center ///< A boolean flag that determines whether pixels are centered 205 ); 249 psArray *pmSourceContour( 250 pmSource *source, ///< The input pmSource 251 const psImage *image, ///< The input image (float) (this arg should be removed) 252 float level, ///< The level of the contour 253 pmContourType mode ///< Currently this must be PS_CONTOUR_CRUDE 254 ); 255 256 /****************************************************************************** 257 *****************************************************************************/ 258 bool pmSourceFitModel( 259 pmSource *source, ///< The input pmSource 260 const psImage *image ///< The input image (float) 261 ); 262 263 /****************************************************************************** 264 *****************************************************************************/ 265 bool pmSourceAddModel( 266 psImage *image, ///< The opuut image (float) 267 pmSource *source, ///< The input pmSource 268 bool center ///< A boolean flag that determines whether pixels are centered 269 ); 270 271 /****************************************************************************** 272 *****************************************************************************/ 273 bool pmSourceSubModel( 274 psImage *image, ///< The output image (float) 275 pmSource *source, ///< The input pmSource 276 bool center ///< A boolean flag that determines whether pixels are centered 277 ); 206 278 207 279 /****************************************************************************** 208 280 XXX: Why only *x argument? 209 XXX EAM: psMinimizeLMChi2Func returns psF64, not psF32281 XXX EAM: psMinimizeLMChi2Func returns psF64, not float 210 282 *****************************************************************************/ 211 283 float pmMinLM_Gauss2D( 212 psVector *deriv, ///< A possibly-NULL structure for the output derivatives213 const psVector *params, ///< A psVector which holds the parameters of this function214 const psVector *x ///< A psVector which holds the row/col coordinate284 psVector *deriv, ///< A possibly-NULL structure for the output derivatives 285 const psVector *params, ///< A psVector which holds the parameters of this function 286 const psVector *x ///< A psVector which holds the row/col coordinate 215 287 ); 216 288 … … 218 290 *****************************************************************************/ 219 291 float pmMinLM_PsuedoGauss2D( 220 psVector *deriv, ///< A possibly-NULL structure for the output derivatives221 const psVector *params, ///< A psVector which holds the parameters of this function222 const psVector *x ///< A psVector which holds the row/col coordinate292 psVector *deriv, ///< A possibly-NULL structure for the output derivatives 293 const psVector *params, ///< A psVector which holds the parameters of this function 294 const psVector *x ///< A psVector which holds the row/col coordinate 223 295 ); 224 296 … … 226 298 *****************************************************************************/ 227 299 float pmMinLM_Wauss2D( 228 psVector *deriv, ///< A possibly-NULL structure for the output derivatives229 const psVector *params, ///< A psVector which holds the parameters of this function230 const psVector *x ///< A psVector which holds the row/col coordinate300 psVector *deriv, ///< A possibly-NULL structure for the output derivatives 301 const psVector *params, ///< A psVector which holds the parameters of this function 302 const psVector *x ///< A psVector which holds the row/col coordinate 231 303 ); 232 304 … … 234 306 *****************************************************************************/ 235 307 float pmMinLM_TwistGauss2D( 236 psVector *deriv, ///< A possibly-NULL structure for the output derivatives237 const psVector *params, ///< A psVector which holds the parameters of this function238 const psVector *x ///< A psVector which holds the row/col coordinate308 psVector *deriv, ///< A possibly-NULL structure for the output derivatives 309 const psVector *params, ///< A psVector which holds the parameters of this function 310 const psVector *x ///< A psVector which holds the row/col coordinate 239 311 ); 240 312 … … 242 314 *****************************************************************************/ 243 315 float pmMinLM_Sersic( 244 psVector *deriv, ///< A possibly-NULL structure for the output derivatives245 const psVector *params, ///< A psVector which holds the parameters of this function246 const psVector *x ///< A psVector which holds the row/col coordinate316 psVector *deriv, ///< A possibly-NULL structure for the output derivatives 317 const psVector *params, ///< A psVector which holds the parameters of this function 318 const psVector *x ///< A psVector which holds the row/col coordinate 247 319 ); 248 320 … … 250 322 *****************************************************************************/ 251 323 float pmMinLM_SersicCore( 252 psVector *deriv, ///< A possibly-NULL structure for the output derivatives253 const psVector *params, ///< A psVector which holds the parameters of this function254 const psVector *x ///< A psVector which holds the row/col coordinate324 psVector *deriv, ///< A possibly-NULL structure for the output derivatives 325 const psVector *params, ///< A psVector which holds the parameters of this function 326 const psVector *x ///< A psVector which holds the row/col coordinate 255 327 ); 256 328 … … 258 330 *****************************************************************************/ 259 331 float pmMinLM_PsuedoSersic( 260 psVector *deriv, ///< A possibly-NULL structure for the output derivatives 261 const psVector *params, ///< A psVector which holds the parameters of this function 262 const psVector *x ///< A psVector which holds the row/col coordinate 263 ); 264 332 psVector *deriv, ///< A possibly-NULL structure for the output derivatives 333 const psVector *params, ///< A psVector which holds the parameters of this function 334 const psVector *x ///< A psVector which holds the row/col coordinate 335 ); 336 337 338 /** 339 * 340 * The object model functions are defined to allow for the flexible addition 341 * of new object models. Every object model, with parameters represented by 342 * pmModel, has an associated set of functions which provide necessary support 343 * operations. A set of abstract functions allow the programmer to select the 344 * approriate function or property for a specific named object model. 345 * 346 */ 347 348 /** 349 * 350 * This function is the model chi-square minimization function for this model. 351 * 352 */ 353 typedef psMinimizeLMChi2Func pmModelFunc; 354 355 356 /** 357 * 358 * This function returns the integrated flux for the given model parameters. 359 */ 360 typedef psF64 (*pmModelFlux)(const psVector *params); 361 362 363 /** 364 * 365 * This function provides the model guess parameters based on the details of 366 * the given source. 367 * 368 */ 369 typedef bool (*pmModelGuessFunc)(pmModel *model, pmSource *source); 370 371 372 /** 373 * 374 * This function constructs the PSF model for the given source based on the 375 * supplied psf and the FLT model for the object. 376 * 377 */ 378 typedef bool (*pmModelFromPSFFunc)(pmModel *modelPSF, pmModel *modelFLT, pmPSF *psf); 379 380 381 /** 382 * 383 * This function returns the radius at which the given model and parameters 384 * achieves the given flux. 385 * 386 */ 387 typedef psF64 (*pmModelRadius)(const psVector *params, double flux); 388 389 390 /** 391 * 392 * Each of the function types above has a corresponding function which returns 393 * the function given the model type: 394 * 395 */ 396 pmModelFunc pmModelFunc_GetFunction (pmModelType type); 397 pmModelFlux pmModelFlux_GetFunction (pmModelType type); 398 pmModelGuessFunc pmModelGuessFunc_GetFunction (pmModelType type); 399 pmModelFromPSFFunc pmModelFromPSFFunc_GetFunction (pmModelType type); 400 pmModelRadius pmModelRadius_GetFunction (pmModelType type); 265 401 266 402 #endif -
trunk/psModules/src/pmReadoutCombine.c
r4425 r4770 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1.2 4$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-0 6-29 01:39:10$7 * @version $Revision: 1.25 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-08-16 01:10:34 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 72 72 psS32 minInputRows = PS_MAX_S32; 73 73 psListElem *tmpInput = NULL; 74 p sReadout *tmpReadout = NULL;74 pmReadout *tmpReadout = NULL; 75 75 psS32 numInputs = 0; 76 76 psS32 tmpI; … … 98 98 tmpInput = (psListElem *) inputs->head; 99 99 while (NULL != tmpInput) { 100 tmpReadout = (p sReadout *) tmpInput->data;100 tmpReadout = (pmReadout *) tmpInput->data; 101 101 PS_ASSERT_READOUT_NON_NULL(tmpReadout, output); 102 102 PS_ASSERT_READOUT_NON_EMPTY(tmpReadout, output); … … 182 182 psVector *outColLower = psVectorAlloc(numInputs, PS_TYPE_U32); 183 183 psVector *outColUpper = psVectorAlloc(numInputs, PS_TYPE_U32); 184 p sReadout **tmpReadouts = (psReadout **) psAlloc(numInputs * sizeof(psReadout *));184 pmReadout **tmpReadouts = (pmReadout **) psAlloc(numInputs * sizeof(pmReadout *)); 185 185 186 186 // For each input readout, we create a pointer to that readout in … … 191 191 tmpInput = (psListElem *) inputs->head; 192 192 while (NULL != tmpInput) { 193 tmpReadouts[i] = (p sReadout *) tmpInput->data;193 tmpReadouts[i] = (pmReadout *) tmpInput->data; 194 194 outRowLower->data.U32[i] = tmpReadouts[i]->row0 + tmpReadouts[i]->image->row0; 195 195 outColLower->data.U32[i] = tmpReadouts[i]->col0 + tmpReadouts[i]->image->col0; -
trunk/psModules/src/pmSubtractBias.c
r4579 r4770 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.3 5$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-0 7-19 01:44:48$8 * @version $Revision: 1.36 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-08-16 01:10:34 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 27 27 place from the input image. 28 28 *****************************************************************************/ 29 static p sReadout *SubtractFrame(psReadout *in,30 const p sReadout *bias)29 static pmReadout *SubtractFrame(pmReadout *in, 30 const pmReadout *bias) 31 31 { 32 32 psS32 i; … … 245 245 XXX: The SDRS does not specify type support. F32 is implemented here. 246 246 *****************************************************************************/ 247 p sReadout *pmSubtractBias(psReadout *in,247 pmReadout *pmSubtractBias(pmReadout *in, 248 248 void *fitSpec, 249 249 const psList *overscans, … … 252 252 psS32 nBinOrig, 253 253 pmFit fit, 254 const p sReadout *bias)254 const pmReadout *bias) 255 255 { 256 256 psTrace(".psModule.pmSubtracBias.pmSubtractBias", 4, -
trunk/psModules/src/pmSubtractBias.h
r4754 r4770 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-08-1 1 00:03:51$8 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-08-16 01:10:34 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 38 38 } pmFit; 39 39 40 p sReadout *pmSubtractBias(psReadout *in, ///< The input psReadout image40 pmReadout *pmSubtractBias(pmReadout *in, ///< The input pmReadout image 41 41 void *fitSpec, ///< A polynomial or spline, defining the fit type. 42 42 const psList *overscans, ///< A psList of overscan images … … 45 45 int nBin, ///< The amount of binning to be done image pixels. 46 46 pmFit fit, ///< PM_FIT_SPLINE, PM_FIT_POLYNOMIAL, or PM_FIT_NONE 47 const p sReadout *bias); ///< A possibly NULL bias psReadout which is to be subtracted47 const pmReadout *bias); ///< A possibly NULL bias pmReadout which is to be subtracted 48 48 49 49 #endif -
trunk/psModules/src/pmSubtractSky.c
r4425 r4770 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1.2 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-0 6-29 01:39:10$8 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-08-16 01:10:34 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 453 453 454 454 /****************************************************************************** 455 p sReadout pmSubtractSky():455 pmReadout pmSubtractSky(): 456 456 457 457 XXX: use static vectors for myStats, and the binned image … … 461 461 XXX: Sync the psTrace message facilities. 462 462 *****************************************************************************/ 463 p sReadout *pmSubtractSky(psReadout *in,463 pmReadout *pmSubtractSky(pmReadout *in, 464 464 void *fitSpec, 465 465 psFit fit, -
trunk/psModules/src/pmSubtractSky.h
r4754 r4770 6 6 * @author GLG, MHPCC 7 7 * 8 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $9 * @date $Date: 2005-08-1 1 00:03:51$8 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2005-08-16 01:10:34 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 32 32 } psFit; 33 33 34 p sReadout *pmSubtractSky(psReadout *in,34 pmReadout *pmSubtractSky(pmReadout *in, 35 35 void *fitSpec, 36 36 psFit fit,
Note:
See TracChangeset
for help on using the changeset viewer.
