//*********************************************************************************
// class BuildTime // default package
// Software released under the General Public License (version 2 or later), available at
// http://www.gnu.org/copyleft/gpl.html
//*********************************************************************************
import java.io.*;
import java.util.*;
/******************************************************************
Contains methods used to build class <CODE>jephem.astro.spacetime.Time</CODE>.
@author Thierry Graff
@history feb 14 2002 creation.
@todo
*****************************************************************/
public abstract class BuildTime{
private static final String LS = System.getProperty("line.separator");
//********************************************************************************
//******************************** main() ****************************************
//********************************************************************************
public static void main(String[] args){
// if(args[0].equalsIgnoreCase("buildTaiUtc")){
//buildTaiUtc();
testUt1Utc();
// }
}// end main
//**************** buildTaiUtc() ****************************************
/** Just rewrites tai-utc.txt, inverting the order of lines.
<BR>tai-utc.txt is modified version of tai-utc.dat.
*/
public static void buildTaiUtc(){
try{
String line;
List al = new ArrayList(40);
FileOutputStream fos = new FileOutputStream(new File("tai-utc2.txt"));
LineNumberReader lnr = new LineNumberReader(new FileReader(new File("tai-utc.txt")));
// read iput file and store it to the list
while((line = lnr.readLine()) != null){
al.add(line);
}
System.out.println("al.size() = " + al.size());
// write output file from end to beginning of the list
for(int i = al.size() - 1; i >= 0; i--){
fos.write(((String)(al.get(i)) + LS).getBytes());
}
fos.close();
}
catch(Exception e){
System.out.println("Exception" + e.toString());
e.printStackTrace();
System.exit(0);
}
}// end buildTaiUtc
//**************** buildTaiUtc() ****************************************
/** To test the formulae of ftp://maia.usno.navy.mil/ser7/ser7.dat. */
private static void testUt1Utc(){
double UT2_UT1;
double UT1_UTC;
double JD2000 = 2451545.0;
double T, jd;
double pi = Math.PI;
double MJD;
for (double i = 0; i < 50; i++){
jd = JD2000 + i;
MJD = jd - 2400000.5;
T = 2000.0 + (MJD - 51544.03) / 365.2422;
System.out.println("T = " + T);
UT2_UT1 = 0.022*Math.sin(2*pi*T) - 0.012*Math.cos(2*pi*T) - 0.006*Math.sin(4*pi*T) + 0.007*Math.cos(4*pi*T);
UT1_UTC = -0.1557 - 0.00055-(MJD - 52322) - (UT2_UT1);
System.out.println("UT1_UTC = " + UT1_UTC);
}
}// end testUt1Utc
}//end class BuildTime