test/sct_test_accuracy.c

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 by Aleksander Morgado Juez                         *
00003  *   scitime@aleksander_morgado.mm.st                                      *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Library General Public License as       *
00007  *   published by the Free Software Foundation; either version 2 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU Library General Public     *
00016  *   License along with this program; if not, write to the                 *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #include <stdio.h>
00022 #include "scitime.h"
00023 
00024 #define MAX_DATES   6
00025 #define MAX_SECS    8
00026 
00032 int main(int argc, char** argv)
00033 {
00034     SCT_ACCURACY accuracy;
00035     double dates [MAX_DATES];
00036     double secs [MAX_SECS];
00037     sct_time    epoch1;
00038     sct_time    epoch2;
00039     sct_time    delta; 
00040     int ind;
00041 
00042     printf("\n\n---------------------------Test Getting accuracy from JD...\n");
00043     dates[0] = 1.0;
00044     dates[1] = 10.0;
00045     dates[2] = 100.0;
00046     dates[3] = 1.0E20;
00047     dates[4] = -1.0E20;
00048     dates[5] = 1.0E-20;
00049     for(ind = 0; ind < MAX_DATES; ind++)
00050     {
00051         accuracy = sct_get_accuracy_from_jd(dates[ind]);
00052         printf("For date '%.20lE', accuracy is '%d'\n",dates[ind],(int)accuracy);
00053     }
00054 
00055     printf("\n\n-------------------------Test Getting accuracy from secs...\n");
00056     secs[0] = 1.0;
00057     secs[1] = 1234.2;
00058     secs[2] = 1.1234567890;
00059     secs[3] = 1.123456789012345;
00060     secs[4] = 1.12345678901234567890;
00061     secs[5] = 1234567890.1234567890;
00062     secs[6] = 1E20;
00063     secs[7] = 1E-20;
00064     for(ind = 0; ind < MAX_SECS; ind++)
00065     {
00066         accuracy = sct_get_accuracy_from_secs(secs[ind]);
00067         printf("For secs '%.20lE', accuracy is '%d'\n",secs[ind],(int)accuracy);
00068     }
00069 
00070     printf("\n\n-------------------------Test scitime elements diff...\n");
00071     printf("Diff between a MJD2000 stored with automatic accuracy and a MJD2000"
00072         " with explicit accuracy set to SECS...\n");
00073     sct_set_mjd2000(&epoch1, 0.0);
00074     sct_set_mjd2000(&epoch2, 0.5);
00075     sct_set_accuracy(&epoch2, SCT_ACCURACY_SECS);
00076     sct_diff(&delta, &epoch1, &epoch2);
00077 
00078     printf("\n\n-------------------------Test scitime elements add...\n");
00079     printf("MJD2000 stored with automatic accuracy being added 15 femtosecs\n");
00080     sct_set_mjd2000(&epoch1, 0.0);
00081     sct_add_deltaDSF(&epoch1, &epoch1, 0, 0, 15);
00082 
00083     printf("\n\n");
00084     return 0;
00085 }
00086 

Generated on Sun May 20 15:32:42 2007 for scitime by  doxygen 1.5.1