Changeset 6184 for trunk/psLib/src/astro
- Timestamp:
- Jan 23, 2006, 10:04:31 AM (21 years ago)
- Location:
- trunk/psLib/src/astro
- Files:
-
- 4 edited
-
psEarthOrientation.c (modified) (2 diffs)
-
psEarthOrientation.h (modified) (3 diffs)
-
psTime.c (modified) (4 diffs)
-
psTime.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psEarthOrientation.c
r6039 r6184 8 8 * @author Robert Daniel DeSonia, MHPCC 9 9 * 10 * @version $Revision: 1. 29$ $Name: not supported by cvs2svn $11 * @date $Date: 2006-01- 18 23:49:06$10 * @version $Revision: 1.30 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2006-01-23 20:04:31 $ 12 12 * 13 13 * Copyright 2005 Maui High Performance Computing Center, University of Hawaii … … 1462 1462 } 1463 1463 1464 /****************************************************************************** 1465 psSpherePrecess(coords, fromTime, toTime): 1466 1467 XXX: Use static memory for tmpST. 1468 *****************************************************************************/ 1469 psSphere *psSpherePrecess(psSphere *coords, 1470 const psTime *fromTime, 1471 const psTime *toTime) 1464 psSphereRot *psSpherePrecess(const psTime *fromTime, 1465 const psTime *toTime, 1466 psPrecessMethod mode) 1472 1467 { 1473 1468 // Check input for NULL pointers 1474 PS_ASSERT_PTR_NON_NULL(coords, NULL); 1475 PS_ASSERT_PTR_NON_NULL(fromTime, NULL); 1476 PS_ASSERT_PTR_NON_NULL(toTime, NULL); 1477 1469 if (fromTime == NULL && toTime == NULL) { 1470 psError(PS_ERR_BAD_PARAMETER_NULL, true, 1471 "Invalid time inputs. fromTime & toTime cannot both be NULL.\n"); 1472 return NULL; 1473 } 1474 PS_ASSERT_INT_WITHIN_RANGE(mode, PS_PRECESS_ROUGH, PS_PRECESS_IAU2000A, NULL); 1475 psF64 fromMJD, toMJD; 1478 1476 // Calculate Julian centuries 1479 psF64 fromMJD = psTimeToMJD(fromTime); 1480 psF64 toMJD = psTimeToMJD(toTime); 1481 psF64 T = (toMJD - fromMJD) / JULIAN_CENTURY; 1482 1483 // Calculate conversion constants 1484 // psF64 alphaP = DEG_TO_RAD(90.0) - ((DEG_TO_RAD(0.6406161) * T) + 1485 psF64 alphaP = DEG_TO_RAD(180.0) + ((DEG_TO_RAD(0.6406161) * T) + 1486 (DEG_TO_RAD(0.0000839) * T * T) + 1487 (DEG_TO_RAD(0.000005) * T * T * T)); 1488 1489 psF64 deltaP = (DEG_TO_RAD(0.5567530) * T) - 1490 (DEG_TO_RAD(0.0001185) * T * T) - 1491 (DEG_TO_RAD(0.0000116) * T * T * T); 1492 1493 // psF64 phiP = DEG_TO_RAD(90.0) + ((DEG_TO_RAD(0.6406161) * T) + 1494 psF64 phiP = DEG_TO_RAD(180.0) + ((DEG_TO_RAD(0.6406161) * T) + 1495 (DEG_TO_RAD(0.0003041) * T * T) + 1496 (DEG_TO_RAD(0.0000051) * T * T * T)); 1497 1498 // Create transform with proper constants 1499 psSphereRot* tmpST = psSphereRotAlloc(alphaP, deltaP, phiP); 1500 1477 //If either input time is NULL, assume it to be J2000 -> from SDRS as of rev 18 1478 if (fromTime == NULL) { 1479 fromMJD = MJD_2000; 1480 } else { 1481 fromMJD = psTimeToMJD(fromTime); 1482 } 1483 if (toTime == NULL) { 1484 toMJD = MJD_2000; 1485 } else { 1486 toMJD = psTimeToMJD(toTime); 1487 } 1488 psTime *from = NULL; 1489 psTime *to = NULL; 1490 1491 if (mode == PS_PRECESS_ROUGH) { 1492 //For PS_PRECESS_ROUGH, no time/earthpole corrections are used. This is the 1493 //lowest level of detail mode. 1494 psF64 T = (toMJD - fromMJD) / JULIAN_CENTURY; 1495 1496 // Calculate conversion constants 1497 // psF64 alphaP = DEG_TO_RAD(90.0) - ((DEG_TO_RAD(0.6406161) * T) + 1498 psF64 alphaP = DEG_TO_RAD(180.0) + ((DEG_TO_RAD(0.6406161) * T) + 1499 (DEG_TO_RAD(0.0000839) * T * T) + 1500 (DEG_TO_RAD(0.000005) * T * T * T)); 1501 1502 psF64 deltaP = (DEG_TO_RAD(0.5567530) * T) - 1503 (DEG_TO_RAD(0.0001185) * T * T) - 1504 (DEG_TO_RAD(0.0000116) * T * T * T); 1505 1506 // psF64 phiP = DEG_TO_RAD(90.0) + ((DEG_TO_RAD(0.6406161) * T) + 1507 psF64 phiP = DEG_TO_RAD(180.0) + ((DEG_TO_RAD(0.6406161) * T) + 1508 (DEG_TO_RAD(0.0003041) * T * T) + 1509 (DEG_TO_RAD(0.0000051) * T * T * T)); 1510 1511 // Create transform with proper constants 1512 psSphereRot* tmpST = psSphereRotAlloc(alphaP, deltaP, phiP); 1513 return tmpST; 1514 } else if (mode == PS_PRECESS_IAU2000A) { 1515 //For IAU2000A mode, run psEOC_PrecessionModel and then psSphereRot_CEOtoGCRS for 1516 //each time. Then difference the resulting rotations by adding the inverse 1517 //rotation corresponding to fromTime to the toTime rotation. 1518 1519 //Since the time inputs are allowed to be NULL, either convert the MJD time 1520 //or copy to non-NULL time 1521 if (fromTime == NULL) { 1522 from = psTimeFromMJD(fromMJD); 1523 } else { 1524 from = p_psTimeCopy(fromTime); 1525 } 1526 if (toTime == NULL) { 1527 to = psTimeFromMJD(toMJD); 1528 } else { 1529 to = p_psTimeCopy(toTime); 1530 } 1531 1532 psEarthPole *fromEP = psEOC_PrecessionModel(from); 1533 psSphereRot *fromRot = psSphereRot_CEOtoGCRS(fromEP); 1534 psEarthPole *toEP = psEOC_PrecessionModel(to); 1535 psSphereRot *toRot = psSphereRot_CEOtoGCRS(toEP); 1536 psSphereRot *fromConj = psSphereRotConjugate(NULL, fromRot); 1537 psSphereRot *out = psSphereRotCombine(NULL, toRot, fromConj); 1538 psFree(from); 1539 psFree(to); 1540 psFree(fromEP); 1541 psFree(fromRot); 1542 psFree(toEP); 1543 psFree(toRot); 1544 psFree(fromConj); 1545 return out; 1546 } else if (mode == PS_PRECESS_COMPLETE_A) { 1547 //For PS_PRECESS_COMPLETE_A the same procedure as IAU2000A is used but with 1548 //additional earthpole corrections from psEOC_PrecessionCorr. The corrections 1549 //for COMPLETE_A come from the IERS Bulletin A. 1550 1551 //Since the time inputs are allowed to be NULL, either convert the MJD time 1552 //or copy to non-NULL time 1553 if (fromTime == NULL) { 1554 from = psTimeFromMJD(fromMJD); 1555 } else { 1556 from = p_psTimeCopy(fromTime); 1557 } 1558 if (toTime == NULL) { 1559 to = psTimeFromMJD(toMJD); 1560 } else { 1561 to = p_psTimeCopy(toTime); 1562 } 1563 1564 psEarthPole *fromEP = psEOC_PrecessionModel(from); 1565 psEarthPole *fromCorr = psEOC_PrecessionCorr(from, PS_IERS_A); 1566 fromEP->x += fromCorr->x; 1567 fromEP->y += fromCorr->y; 1568 fromEP->s += fromCorr->s; 1569 psSphereRot *fromRot = psSphereRot_CEOtoGCRS(fromEP); 1570 psEarthPole *toEP = psEOC_PrecessionModel(to); 1571 psEarthPole *toCorr = psEOC_PrecessionCorr(to, PS_IERS_A); 1572 toEP->x += toCorr->x; 1573 toEP->y += toCorr->y; 1574 toEP->s += toCorr->s; 1575 psSphereRot *toRot = psSphereRot_CEOtoGCRS(toEP); 1576 psSphereRot *fromConj = psSphereRotConjugate(NULL, fromRot); 1577 psSphereRot *out = psSphereRotCombine(NULL, toRot, fromConj); 1578 psFree(from); 1579 psFree(to); 1580 psFree(fromEP); 1581 psFree(fromCorr); 1582 psFree(fromRot); 1583 psFree(toEP); 1584 psFree(toCorr); 1585 psFree(toRot); 1586 psFree(fromConj); 1587 return out; 1588 } else { //mode == PS_PRECESS_COMPLETE_B 1589 //For PS_PRECESS_COMPLETE_B the same procedure as IAU2000A is used but with 1590 //additional earthpole corrections from psEOC_PrecessionCorr. The corrections 1591 //for COMPLETE_B come from the IERS Bulletin B. 1592 1593 //Since the time inputs are allowed to be NULL, either convert the MJD time 1594 //or copy to non-NULL time 1595 if (fromTime == NULL) { 1596 from = psTimeFromMJD(fromMJD); 1597 } else { 1598 from = p_psTimeCopy(fromTime); 1599 } 1600 if (toTime == NULL) { 1601 to = psTimeFromMJD(toMJD); 1602 } else { 1603 to = p_psTimeCopy(toTime); 1604 } 1605 1606 psEarthPole *fromEP = psEOC_PrecessionModel(from); 1607 psEarthPole *fromCorr = psEOC_PrecessionCorr(from, PS_IERS_B); 1608 fromEP->x += fromCorr->x; 1609 fromEP->y += fromCorr->y; 1610 fromEP->s += fromCorr->s; 1611 psSphereRot *fromRot = psSphereRot_CEOtoGCRS(fromEP); 1612 psEarthPole *toEP = psEOC_PrecessionModel(to); 1613 psEarthPole *toCorr = psEOC_PrecessionCorr(to, PS_IERS_B); 1614 toEP->x += toCorr->x; 1615 toEP->y += toCorr->y; 1616 toEP->s += toCorr->s; 1617 psSphereRot *toRot = psSphereRot_CEOtoGCRS(toEP); 1618 psSphereRot *fromConj = psSphereRotConjugate(NULL, fromRot); 1619 psSphereRot *out = psSphereRotCombine(NULL, toRot, fromConj); 1620 psFree(from); 1621 psFree(to); 1622 psFree(fromEP); 1623 psFree(fromCorr); 1624 psFree(fromRot); 1625 psFree(toEP); 1626 psFree(toCorr); 1627 psFree(toRot); 1628 psFree(fromConj); 1629 return out; 1630 } 1501 1631 // Apply transform to coordinates 1502 psSphere *out = psSphereRotApply(NULL, tmpST, coords); 1503 if (out->r < -0.0001) { 1504 out->r += 2.0 * M_PI; 1505 } 1506 1507 psFree(tmpST); 1508 1509 return(out); 1632 // psSphere *out = psSphereRotApply(NULL, tmpST, coords); 1633 // if (out->r < -0.0001) { 1634 // out->r += 2.0 * M_PI; 1635 // } 1510 1636 } -
trunk/psLib/src/astro/psEarthOrientation.h
r6039 r6184 9 9 * @author Robert Daniel DeSonia, MHPCC 10 10 * 11 * @version $Revision: 1.1 3$ $Name: not supported by cvs2svn $12 * @date $Date: 2006-01- 18 23:49:06$11 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2006-01-23 20:04:31 $ 13 13 * 14 14 * Copyright 2005 Maui High Performance Computing Center, University of Hawaii … … 40 40 typedef enum { 41 41 PS_PRECESS_ROUGH, ///< roughest, lowest level of detail 42 PS_PRECESS_COMPLETE, ///< complete level of detail 42 PS_PRECESS_COMPLETE_A, ///< complete level of detail using IERS A 43 PS_PRECESS_COMPLETE_B, ///< complete level of detail using IERS B 43 44 PS_PRECESS_IAU2000A, ///< highest level of detail 44 45 } … … 179 180 * between two times. The equinoxes shall be Julian equinoxes. 180 181 * 181 * @return psSphere* the resulting spherical rotation 182 * If NULL is provided for either time, it is assumed to have the reference 183 * equinox value of J2000. The mode argument is used to specify the level of 184 * detail used in the calculation. 185 * 186 * @return psSphere*: the resulting spherical rotation 182 187 */ 183 psSphere * psSpherePrecess(184 psSphere *coords, ///< coordinates (modified in-place)188 psSphereRot* psSpherePrecess( 189 // psSphere *coords, ///< coordinates (modified in-place) 185 190 const psTime *fromTime, ///< equinox of coords input 186 const psTime *toTime ///< equinox of coords output 191 const psTime *toTime, ///< equinox of coords output 192 psPrecessMethod mode ///< level of detail to use 187 193 ); 188 194 -
trunk/psLib/src/astro/psTime.c
r6036 r6184 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.7 7$ $Name: not supported by cvs2svn $13 * @date $Date: 2006-01- 18 20:59:31 $12 * @version $Revision: 1.78 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-01-23 20:04:31 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 920 920 PS_ASSERT_PTR_NON_NULL(time, NULL); 921 921 psTime *out = NULL; 922 //Also see psEOC_PolarTideCorr for more info. 922 923 923 924 // Convert psTime to MJD … … 982 983 out = psTimeAlloc(time->type); 983 984 *out = *time; 984 // out->sec = time->sec;985 // out->nsec = time->nsec;986 // out->leapsecond = time->leapsecond;987 985 if (out->type != PS_TIME_UT1) { 988 986 out = psTimeConvert(out, PS_TIME_UT1); 989 987 } 988 //see if corrections include seconds or just nano-seconds 989 //nano-seconds must be converted (scaled) to integer values & total cannot be negative 990 990 if (fabs(CORZ) > 1.0) { 991 991 int sec = (int)CORZ; … … 1806 1806 } 1807 1807 1808 psTime *p_psTimeCopy(const psTime *inTime) 1809 { 1810 PS_ASSERT_PTR_NON_NULL(inTime, NULL); 1811 psTime *outTime = psTimeAlloc(inTime->type); 1812 *outTime = *inTime; 1813 return outTime; 1814 } 1815 -
trunk/psLib/src/astro/psTime.h
r6036 r6184 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.4 4$ $Name: not supported by cvs2svn $14 * @date $Date: 2006-01- 18 20:59:31 $13 * @version $Revision: 1.45 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2006-01-23 20:04:31 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 432 432 psF64 psTimerStop(void); 433 433 434 /** Private function for copying a psTime. 435 * 436 * @return psTime*: New copy of existing psTime. 437 */ 438 psTime *p_psTimeCopy( 439 const psTime *inTime ///< input time to copy. 440 ); 441 434 442 /// @} 435 443
Note:
See TracChangeset
for help on using the changeset viewer.
