Changeset 1514
- Timestamp:
- Aug 11, 2004, 7:36:53 PM (22 years ago)
- Location:
- trunk/psLib/src/astronomy
- Files:
-
- 2 edited
-
psAstrometry.c (modified) (24 diffs)
-
psAstrometry.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astronomy/psAstrometry.c
r1510 r1514 8 8 * @author George Gusciora, MHPCC 9 9 * 10 * @version $Revision: 1.2 0$ $Name: not supported by cvs2svn $11 * @date $Date: 2004-08-12 0 3:11:45$10 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-08-12 05:36:53 $ 12 12 * 13 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 44 44 } 45 45 46 /* 47 XXX: Several members of the psGrommit data structure have no direct 48 counterpart in the psExposure structure. How are we to determine them? 49 */ 46 extern void sla_aoppa(double date, double dut, double elongm, 47 double phim, double him, double xp, 48 double yp, double tdk, double pmb, 49 double rh, double wl, double tlr, 50 double *AOPRMS); 51 #define TBD 0.0 52 /***************************************************************************** 53 XXX: Several of the input params to sla_aoppa() are currently undefined. 54 We are awaiting futher direction from IfA on this. 55 *****************************************************************************/ 50 56 psGrommit* psGrommitAlloc(const psExposure* exp) 51 57 { … … 54 60 } 55 61 62 double date = TBD; // "mjd" in psExposure will become a psTime 63 // from which it will be possible to get UTC. 64 double dut = 0.0; 65 double elongm = TBD; 66 double phim = TBD; 67 double hm = TBD; 68 double xp = 0.0; 69 double yp = 0.0; 70 double tdk = exp->temperature; 71 double pmb = exp->pressure; 72 double rh = exp->humidity; 73 double wl = exp->wavelength; 74 double tlr = TBD; 75 double *AOPRMS = NULL; 76 77 sla_aoppa(date, dut, elongm, phim, hm, xp, yp, 78 tdk, pmb, rh, wl, tlr, AOPRMS); 79 56 80 psGrommit* grommit = (psGrommit* ) psAlloc(sizeof(psGrommit)); 57 58 /* 59 * extern void sla_aoppa(double date, double dut, double elongm, double phim, double him, double xp, 60 * double yp, double tdk, double pmb, double rh, double wl, double tlr, double *AOPRMS); 61 * 62 * sla_aoppa(date, deltaUT, meanLongitude, meanLatitude, height, xp, yp, exp->temperature, exp->pressure, 63 * exp->humidity, wavelength, tlr); */ 64 *(double *)&grommit->latitude = exp->dec; // XXX Is this correct? 65 *(double *)&grommit->sinLat = sin(grommit->latitude); 66 *(double *)&grommit->cosLat = cos(grommit->latitude); 67 *(double *)&grommit->abberationMag = 0.0; 68 *(double *)&grommit->height = 0.0; 69 *(double *)&grommit->temperature = exp->temperature; 70 *(double *)&grommit->pressure = exp->pressure; 71 *(double *)&grommit->humidity = exp->humidity; 72 *(double *)&grommit->wavelength = 0.0; 73 *(double *)&grommit->lapseRate = 0.0; 74 *(double *)&grommit->refractA = 0.0; 75 *(double *)&grommit->refractB = 0.0; 76 *(double *)&grommit->longitudeOffset = exp->ra; // XXX Is this correct? 77 *(double *)&grommit->siderealTime = 0.0; 81 *(double *)&grommit->latitude = AOPRMS[0]; 82 *(double *)&grommit->sinLat = AOPRMS[1]; 83 *(double *)&grommit->cosLat = AOPRMS[2]; 84 *(double *)&grommit->height = AOPRMS[3]; 85 *(double *)&grommit->abberationMag = AOPRMS[4]; 86 *(double *)&grommit->temperature = AOPRMS[5]; 87 *(double *)&grommit->pressure = AOPRMS[6]; 88 *(double *)&grommit->humidity = AOPRMS[7]; 89 *(double *)&grommit->wavelength = AOPRMS[8]; 90 *(double *)&grommit->lapseRate = AOPRMS[9]; 91 *(double *)&grommit->refractA = AOPRMS[10]; 92 *(double *)&grommit->refractB = AOPRMS[11]; 93 *(double *)&grommit->longitudeOffset = AOPRMS[12]; 94 *(double *)&grommit->siderealTime = AOPRMS[13]; 78 95 79 96 return (grommit); … … 92 109 psPlane* chipCoord = NULL; 93 110 111 if (fpaCoord == NULL) { 112 psAbort(__func__, "input parameter fpaCoord is NULL."); 113 } 94 114 if (FPA == NULL) { 95 return(NULL); 96 } 97 if (fpaCoord == NULL) { 98 return(NULL); 115 psAbort(__func__, "input parameter FPA is NULL."); 99 116 } 100 117 … … 133 150 134 151 /***************************************************************************** 135 XXX: Return the answer in "out". 152 XXX: Should we return the result in "out"? 136 153 *****************************************************************************/ 137 154 psChip* psChipInFPA(psChip* out, … … 143 160 psPlane* chipCoord = NULL; 144 161 psCell *tmpCell = NULL; 162 163 if (fpaCoord == NULL) { 164 psAbort(__func__, "input parameter fpaCoord is NULL."); 165 } 166 if (FPA == NULL) { 167 psAbort(__func__, "input parameter FPA is NULL."); 168 } 145 169 146 170 // Loop through every chip in this FPA. Convert the original … … 150 174 for (int i = 0; i < nChips; i++) { 151 175 psChip* tmpChip = chips->data[i]; 152 153 chipCoord = psPlaneTransformApply(chipCoord, tmpChip->fromFPA, fpaCoord); 176 chipCoord = psPlaneTransformApply(chipCoord, tmpChip->fromFPA, 177 fpaCoord); 178 154 179 tmpCell = psCellInChip(tmpCell, chipCoord, tmpChip); 155 180 if (tmpCell != NULL) { … … 164 189 165 190 /***************************************************************************** 166 XXX: if we find no cell with has this coordinate, we return NULL. 167 XXX: must deallocate memory. 168 XXX: must return the cell in the "outCell" parameter. 169 XXX: verify the NULL parameter error handling. 191 XXX: Should we return the result in "out"? 170 192 *****************************************************************************/ 171 193 psCell* psCellInChip(psCell* outCell, … … 175 197 psPlane* cellCoord = NULL; 176 198 psArray* cells; 177 psReadout *tmpReadout = NULL;178 199 179 200 // We return NULL if either of the input parameters is NULL. 201 if (chipCoord == NULL) { 202 psAbort(__func__, "the 'chipCoord' parameter is NULL\n"); 203 } 180 204 if (chip == NULL) { 181 return NULL; 182 } 183 184 if (chipCoord == NULL) { 185 return NULL; 205 psAbort(__func__, "the 'chip' parameter is NULL\n"); 186 206 } 187 207 … … 196 216 for (int i = 0; i < cells->n; i++) { 197 217 psCell* tmpCell = (psCell* ) cells->data[i]; 198 // XXX: figure this out 199 // psReadout *tmpReadout = tmpCell->readouts; 200 201 while (tmpReadout != NULL) { 202 cellCoord = psPlaneTransformApply(cellCoord, 203 tmpCell->fromChip, 204 chipCoord); 205 206 if (p_psCheckValidImageCoords(cellCoord->x, cellCoord->y, tmpReadout->image)) { 207 psFree(cellCoord); 208 return (tmpCell); 218 psArray* readouts = tmpCell->readouts; 219 220 if (readouts != NULL) { 221 for (int j = 0; j < readouts->n; j++) { 222 psReadout* tmpReadout = readouts->data[j]; 223 224 cellCoord = psPlaneTransformApply(cellCoord, 225 tmpCell->fromChip, 226 chipCoord); 227 228 if (p_psCheckValidImageCoords(cellCoord->x, 229 cellCoord->y, 230 tmpReadout->image)) { 231 psFree(cellCoord); 232 return (tmpCell); 233 } 209 234 } 210 tmpReadout++;211 235 } 212 236 } … … 220 244 const psCell* cell) 221 245 { 246 if (inCoord == NULL) { 247 psAbort(__func__, "input parameter inCoord is NULL."); 248 } 249 if (cell == NULL) { 250 psAbort(__func__, "input parameter cell is NULL."); 251 } 252 222 253 return (psPlaneTransformApply(outCoord, cell->toChip, inCoord)); 223 254 } … … 227 258 const psChip* chip) 228 259 { 260 if (inCoord == NULL) { 261 psAbort(__func__, "input parameter inCoord is NULL."); 262 } 263 if (chip == NULL) { 264 psAbort(__func__, "input parameter chip is NULL."); 265 } 266 229 267 return (psPlaneTransformApply(outCoord, chip->toFPA, inCoord)); 230 268 } … … 236 274 const psFPA* fpa) 237 275 { 276 if (inCoord == NULL) { 277 psAbort(__func__, "input parameter inCoord is NULL."); 278 } 279 if (fpa == NULL) { 280 psAbort(__func__, "input parameter fpa is NULL."); 281 } 282 238 283 return(psPlaneDistortApply(outCoord, fpa->toTangentPlane, inCoord, 239 284 magnitude, color)); … … 245 290 const psGrommit* grommit) 246 291 { 292 if (tpCoord == NULL) { 293 psAbort(__func__, "input parameter tpCoord is NULL."); 294 } 295 if (grommit == NULL) { 296 psAbort(__func__, "input parameter grommit is NULL."); 297 } 247 298 if (outSphere == NULL) { 248 299 outSphere = (psSphere* ) psAlloc(sizeof(psSphere)); … … 263 314 const psCell* cell) 264 315 { 316 if (cellCoord == NULL) { 317 psAbort(__func__, "input parameter cellCoord is NULL."); 318 } 319 if (cell == NULL) { 320 psAbort(__func__, "input parameter cell is NULL."); 321 } 322 265 323 return (psPlaneTransformApply(fpaCoord, cell->toFPA, cellCoord)); 266 324 } 267 325 268 /*****************************************************************************269 XXX: determine the grommit from the FPA associated with this chip.270 *****************************************************************************/271 326 psSphere* psCoordCellToSky(psSphere* skyCoord, 272 327 const psPlane* cellCoord, … … 275 330 const psCell* cell) 276 331 { 332 if (cellCoord == NULL) { 333 psAbort(__func__, "input parameter cellCoord is NULL."); 334 } 335 if (cell == NULL) { 336 psAbort(__func__, "input parameter cell is NULL."); 337 } 338 277 339 psPlane* fpaCoord = NULL; 278 340 psPlane* tpCoord = NULL; … … 284 346 285 347 // Convert the FPA coordinates to tangent plane Coordinates. 286 tpCoord = psPlaneDistortApply(tpCoord, parFPA->toTangentPlane, fpaCoord, magnitude, color); 348 tpCoord = psPlaneDistortApply(tpCoord, parFPA->toTangentPlane, 349 fpaCoord, magnitude, color); 287 350 288 351 // Generate a grommit for this FPA. … … 307 370 const psCell* cell) 308 371 { 372 if (cellCoord == NULL) { 373 psAbort(__func__, "input parameter cellCoord is NULL."); 374 } 375 if (cell == NULL) { 376 psAbort(__func__, "input parameter cell is NULL."); 377 } 378 309 379 psPlane *tpCoord = NULL; 310 380 psChip *chip = cell->parent; … … 340 410 const psGrommit* grommit) 341 411 { 412 if (in == NULL) { 413 psAbort(__func__, "input parameter in is NULL."); 414 } 415 if (grommit == NULL) { 416 psAbort(__func__, "input parameter grommit is NULL."); 417 } 418 342 419 /* 343 420 extern void sla_AOPQK(RAP, DAP, AOPRMS, AOB, ZOB, HOB, DOB, ROB); … … 367 444 const psFPA* fpa) 368 445 { 446 if (tpCoord == NULL) { 447 psAbort(__func__, "input parameter tpCoord is NULL."); 448 } 449 if (fpa == NULL) { 450 psAbort(__func__, "input parameter fpa is NULL."); 451 } 452 369 453 return (psPlaneDistortApply(fpaCoord, fpa->fromTangentPlane, 370 454 tpCoord, magnitude, color)); 371 455 } 372 456 373 /*****************************************************************************374 XXX: must first determine which chip contains this chipcoord.375 *****************************************************************************/376 457 psPlane* psCoordFPAToChip(psPlane* chipCoord, 377 458 const psPlane* fpaCoord, 378 459 const psChip* chip) 379 460 { 380 return (psPlaneTransformApply(chipCoord, chip->fromFPA, fpaCoord)); 381 } 382 383 /***************************************************************************** 384 XXX: must first determine which cell contains this chipcoord. 385 *****************************************************************************/ 461 if (fpaCoord == NULL) { 462 psAbort(__func__, "input parameter fpaCoord is NULL."); 463 } 464 if (chip == NULL) { 465 psAbort(__func__, "input parameter chip is NULL."); 466 } 467 468 psFPA *FPA = chip->parent; 469 if (FPA == NULL) { 470 psAbort(__func__, "chip->parent is NULL"); 471 } 472 473 psChip *newChip = psChipInFPA(newChip, fpaCoord, FPA); 474 if (newChip == NULL) { 475 return(NULL); 476 } 477 478 chipCoord = psPlaneTransformApply(chipCoord, newChip->fromFPA, fpaCoord); 479 psFree(newChip); 480 return(chipCoord); 481 } 482 386 483 psPlane* psCoordChipToCell(psPlane* cellCoord, 387 484 const psPlane* chipCoord, 388 485 const psCell* cell) 389 486 { 390 return (psPlaneTransformApply(cellCoord, cell->fromChip, chipCoord)); 391 } 392 393 /***************************************************************************** 394 XXX: once this works, get rid of the individual pointers for the various 395 coords. 396 XXX: must determine which cell contains this chipcoord. 397 *****************************************************************************/ 487 if (chipCoord == NULL) { 488 psAbort(__func__, "input parameter chipCoord is NULL."); 489 } 490 if (cell == NULL) { 491 psAbort(__func__, "input parameter cell is NULL."); 492 } 493 494 psChip *chip = cell->parent; 495 if (chip == NULL) { 496 psAbort(__func__, "cell->parent is NULL"); 497 } 498 499 psCell *newCell = psCellInChip(newCell, chipCoord, chip); 500 if (newCell == NULL) { 501 return(NULL); 502 } 503 504 cellCoord = psPlaneTransformApply(cellCoord, newCell->fromChip, chipCoord); 505 psFree(newCell); 506 return(cellCoord); 507 } 508 398 509 psPlane* psCoordSkyToCell(psPlane* cellCoord, 399 510 const psSphere* skyCoord, … … 402 513 const psCell* cell) 403 514 { 404 psChip *whichChip = cell->parent; 405 psFPA *whichFPA = whichChip->parent; 406 psGrommit* grommit = whichFPA->grommit; 515 if (skyCoord == NULL) { 516 psAbort(__func__, "input parameter skyCoord is NULL."); 517 } 518 if (cell == NULL) { 519 psAbort(__func__, "input parameter cell is NULL."); 520 } 521 522 psChip *parChip = cell->parent; 523 psFPA *parFPA = parChip->parent; 524 psGrommit* grommit = parFPA->grommit; 407 525 408 526 // Convert the skyCoords to tangent plane coords. … … 411 529 // Convert the tangent plane coords to FPA coords. 412 530 psPlane *fpaCoord = psCoordTPToFPA(fpaCoord, tpCoord, color, 413 magnitude, whichFPA);531 magnitude, parFPA); 414 532 415 533 // Convert the FPA coords to chip coords. 416 psPlane *chipCoord = psCoordFPAToChip(chipCoord, fpaCoord, whichChip);534 psPlane *chipCoord = psCoordFPAToChip(chipCoord, fpaCoord, parChip); 417 535 418 536 // Convert the chip coords to cell coords. … … 427 545 428 546 /***************************************************************************** 429 XXX: hmmm: does this work? 547 p_psIsProjectionLinear(): this is a private function which simply determines 548 if the supplied psPlaneTransform transform is linear: if any of the 549 cooefficients of order 2 are higher are non-zero, then it is not linear. 430 550 *****************************************************************************/ 551 int p_psIsProjectionLinear(psPlaneTransform *transform) 552 { 553 int i = 0; 554 if (transform == NULL) { 555 psAbort(__func__, "input parameter transform is NULL."); 556 } 557 558 for (i=2;i<(transform->x->nX);i++) { 559 if (transform->x->coeff[i][0] != 0.0) { 560 return(0); 561 } 562 } 563 for (i=2;i<(transform->x->nY);i++) { 564 if (transform->x->coeff[0][i] != 0.0) { 565 return(0); 566 } 567 } 568 569 for (i=2;i<(transform->y->nX);i++) { 570 if (transform->y->coeff[i][0] != 0.0) { 571 return(0); 572 } 573 } 574 for (i=2;i<(transform->y->nY);i++) { 575 if (transform->y->coeff[0][i] != 0.0) { 576 return(0); 577 } 578 } 579 580 return(1); 581 } 582 583 /***************************************************************************** 584 p_psInvertPlaneTransform(transform): : this is a private function which 585 simply inverts the supplied psPlaneTransform transform. It assumes that 586 "transform" is linear. 587 *****************************************************************************/ 588 psPlaneTransform *p_psInvertPlaneDistortTransform(psPlaneTransform *transform) 589 { 590 if (transform == NULL) { 591 psAbort(__func__, "input parameter transform is NULL."); 592 } 593 psPlaneTransform *out = psAlloc(sizeof(psPlaneTransform)); 594 595 // XXX: figure it out 596 return(out); 597 } 598 431 599 psPlane* psCoordSkyToCellQuick(psPlane* cellCoord, 432 600 const psSphere* skyCoord, 433 601 const psCell* cell) 434 602 { 603 if (skyCoord == NULL) { 604 psAbort(__func__, "input parameter skyCoord is NULL."); 605 } 606 if (cell == NULL) { 607 psAbort(__func__, "input parameter cell is NULL."); 608 } 609 435 610 psPlane *tpCoord = NULL; 436 611 psChip *whichChip = cell->parent; … … 449 624 tpCoord = psProject(skyCoord, whichFPA->projection); 450 625 451 // XXX: generate an error if cell->toTP is not linear. 452 453 // XXX: Invert cell->toTP, store in TPtoCell. 626 // generate an error if cell->toTP is not linear. 627 if (0 == p_psIsProjectionLinear(cell->toTP)) { 628 psAbort(__func__, "the cell->toTP transfrom is not linear.\n"); 629 } 630 631 TPtoCell = p_psInvertPlaneDistortTransform(cell->toTP); 454 632 cellCoord = psPlaneTransformApply(cellCoord, TPtoCell, tpCoord); 455 633 -
trunk/psLib/src/astronomy/psAstrometry.h
r1510 r1514 8 8 * @author George Gusciora, MHPCC 9 9 * 10 * @version $Revision: 1.2 0$ $Name: not supported by cvs2svn $11 * @date $Date: 2004-08-12 0 3:11:45$10 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-08-12 05:36:53 $ 12 12 * 13 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 204 204 const float humidity; ///< Relative humidity, for refraction 205 205 const float exposureTime; ///< Exposure time 206 const double wavelength; ///< Wavelength 206 207 207 208 /* Derived quantities */
Note:
See TracChangeset
for help on using the changeset viewer.
