summaryrefslogtreecommitdiffstats
path: root/org/madore/ephem/Test3.java
blob: f6753adcbfc1d45d9eae69df6cb594928aa28f68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package org.madore.ephem;

import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;

public final class Test3 {

    public static void main(String[] args) {
	Comput.SumPoisson2Terms smart97f = Smart97.getFunc(Smart97.Variable.SIDTIME);
	try {
	    // http://data.iers.org/products/214/14443/orig/eopc04_08_IAU2000.62-now
	    FileInputStream str = new FileInputStream("/tmp/eopc04_08_IAU2000.62-now");
	    BufferedReader in = new BufferedReader(new InputStreamReader(str, "utf-8"));
	    String s;
	    while ( ( s = in.readLine() ) != null ) {
		String[] fields = s.split("\\s+");
		if ( fields.length<1 || ! fields[0].matches("\\d{4}") )
		    continue;
		int mjd = Integer.parseInt(fields[3]);
		double utcOffset = Time.utcOffset(mjd, 0);
		double t = Ephem.fromJd((utcOffset+32.184)/86400. + mjd + 2400000.5);
		double smart97sidtime = smart97f.v(t/10)/1296000000000L;
		double ut1Offset = Double.parseDouble(fields[6]);
		double off = ut1Offset - utcOffset;
		double θ = 0.7790572732640
		    + 1.00273781191135448*(mjd-51544.5 + ut1Offset/86400);
		double sidtime = θ + Nutation.eqorg(t)/1296000;
		System.out.format("%d\t%.12f\t%.12f\n", mjd, sidtime, smart97sidtime);
	    }
	} catch ( Exception e ) {
	    throw new RuntimeException(e);
	}
    }

}