Index: trunk/psLib/src/astro/psEarthOrientation.c
===================================================================
--- trunk/psLib/src/astro/psEarthOrientation.c	(revision 9665)
+++ trunk/psLib/src/astro/psEarthOrientation.c	(revision 9976)
@@ -8,6 +8,6 @@
  *  @author Robert Daniel DeSonia, MHPCC
  *
- *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-20 00:17:21 $
+ *  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-11-14 21:15:43 $
  *
  *  Copyright 2005 Maui High Performance Computing Center, University of Hawaii
@@ -284,4 +284,9 @@
         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
                 "Aberration speed should not be equal to 0.\n");
+        return NULL;
+    }
+    if (fabs(speed) > 1.0) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                "Aberration speed should not greater than the speed of light!.\n");
         return NULL;
     }
@@ -445,5 +450,5 @@
     // Convert psTime to MJD
     double MJD = psTimeToMJD(time);
-    if (MJD == NAN) {
+    if (isnan(MJD)) {
         psError(PS_ERR_BAD_PARAMETER_VALUE, false,
                 "Time conversion to MJD failed.  Invalid input time.\n");
@@ -594,5 +599,5 @@
     //Convert the input time to MJD.  If NAN is returned, return NULL for the function.
     double MJD = psTimeToMJD(time);
-    if (MJD == NAN) {
+    if (isnan(MJD)) {
         psError(PS_ERR_BAD_PARAMETER_VALUE, false,
                 "Time conversion to MJD failed.  Invalid input time.\n");
@@ -762,5 +767,5 @@
     //Check if tidal corrections should be included.
     //If so, make sure values are positive and in the correct range.
-    if (tidalCorr != NULL && tidalCorr->s != 0.0) {
+    if (tidalCorr != NULL && fabs(tidalCorr->s) > FLT_EPSILON) {
         int nsec = in->nsec + (int)(tidalCorr->s * 1e9);
         if (nsec > 1e9) {
@@ -777,5 +782,5 @@
     //Calculate the Julian Date from the input time in UT1 format.
     double T = psTimeToJD(in);
-    if (T == NAN) {
+    if (isnan(T)) {
         psError(PS_ERR_BAD_PARAMETER_VALUE, false,
                 "Time conversion to JD failed.  Invalid input time.\n");
@@ -803,5 +808,5 @@
 
     double MJD = psTimeToMJD(time);
-    if (MJD == NAN) {
+    if ( isnan(MJD) ) {
         psError(PS_ERR_BAD_PARAMETER_VALUE, false,
                 "Time conversion to MJD failed.  Invalid input time.\n");
@@ -858,7 +863,7 @@
                 k = 2;
             }
-            if (k > (numRows-2)) {
-                k = numRows-2;
-            }
+            //            if (k > (numRows-2)) {
+            //                k = numRows-2;
+            //            }
             for (int m = k-1; m <= k+2; m++) {
                 xTerm = X->data.F64[m];
@@ -935,5 +940,5 @@
     // Convert psTime to MJD
     double MJD = psTimeToMJD(time);
-    if (MJD == NAN) {
+    if (isnan(MJD)) {
         psError(PS_ERR_BAD_PARAMETER_VALUE, false,
                 "Time conversion to MJD failed.  Invalid input time.\n");
@@ -1019,5 +1024,5 @@
     double MJD = psTimeToMJD(time);
     //    printf("\nMJD check = %.13g\n", MJD);
-    if (MJD == NAN) {
+    if (isnan(MJD)) {
         psError(PS_ERR_BAD_PARAMETER_VALUE, false,
                 "Time conversion to MJD failed.  Invalid input time.\n");
@@ -1252,16 +1257,20 @@
     // Calculate Julian centuries
     //If either input time is NULL, assume it to be J2000 -> from SDRS as of rev 18
+    psTime *from = NULL;
+    psTime *to = NULL;
     if (fromTime == NULL) {
         fromMJD = MJD_2000;
+        from = psTimeFromMJD(fromMJD);
     } else {
         fromMJD = psTimeToMJD(fromTime);
+        from = psTimeCopy(fromTime);
     }
     if (toTime == NULL) {
         toMJD = MJD_2000;
+        to = psTimeFromMJD(toMJD);
     } else {
         toMJD = psTimeToMJD(toTime);
-    }
-    psTime *from = NULL;
-    psTime *to = NULL;
+        to = psTimeCopy(toTime);
+    }
     if (fromMJD > toMJD) {
         psWarning("From time is later than to time in psSpherePrecess.\n");
@@ -1290,4 +1299,6 @@
         // Create transform with proper constants
         psSphereRot* tmpST = psSphereRotAlloc(alphaP, deltaP, phiP);
+        psFree(from);
+        psFree(to);
         return tmpST;
     } else if (mode == PS_PRECESS_IAU2000A) {
@@ -1296,16 +1307,4 @@
         //rotation corresponding to fromTime to the toTime rotation.
 
-        //Since the time inputs are allowed to be NULL, either convert the MJD time
-        //or copy to non-NULL time
-        if (fromTime == NULL) {
-            from = psTimeFromMJD(fromMJD);
-        } else {
-            from = psTimeCopy(fromTime);
-        }
-        if (toTime == NULL) {
-            to = psTimeFromMJD(toMJD);
-        } else {
-            to = psTimeCopy(toTime);
-        }
         //Calculate the earthpoles and quaternions corresponding to each time (from, to).
         //Combine the quaternions to produce the output psSphereRot.
@@ -1329,16 +1328,4 @@
         //for COMPLETE_A come from the IERS Bulletin A.
 
-        //Since the time inputs are allowed to be NULL, either convert the MJD time
-        //or copy to non-NULL time
-        if (fromTime == NULL) {
-            from = psTimeFromMJD(fromMJD);
-        } else {
-            from = psTimeCopy(fromTime);
-        }
-        if (toTime == NULL) {
-            to = psTimeFromMJD(toMJD);
-        } else {
-            to = psTimeCopy(toTime);
-        }
         //Calculate the earthpoles and quaternions corresponding to each time (from, to).
         //Add in the precession corrections from IERS bulletin A.
@@ -1371,17 +1358,4 @@
         //for COMPLETE_B come from the IERS Bulletin B.
 
-        //Since the time inputs are allowed to be NULL, either convert the MJD time
-        //or copy to non-NULL time
-        if (fromTime == NULL) {
-            from = psTimeFromMJD(fromMJD);
-        } else {
-            from = psTimeCopy(fromTime);
-        }
-        if (toTime == NULL) {
-            to = psTimeFromMJD(toMJD);
-        } else {
-            to = psTimeCopy(toTime);
-        }
-
         //Calculate the earthpoles and quaternions corresponding to each time (from, to).
         //Add in the precession corrections from IERS bulletin B.
