blob: 3fa2b8063d885dab1623f5f623010937aed036fb (
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
37
38
39
40
41
42
43
44
45
46
|
package org.madore.ephem;
import java.util.List;
import java.util.ArrayList;
import java.util.EnumMap;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
public final class Smart97 {
public static enum Variable {
CHI("chi"), P("p"), EPSILON("epsilon"),
PHI("phi"), OMEGA("omega"), SIDTIME("sidtime");
final String name;
Variable(String name) { this.name = name; }
}
private static EnumMap<Variable, Comput.SumPoissonTerms> data = new EnumMap<Variable, Comput.SumPoissonTerms>(Variable.class);
public static Comput.SumPoissonTerms getFunc(Variable v) {
if ( ! data.containsKey(v) ) {
List<Comput.PoissonTerm> series = new ArrayList<Comput.PoissonTerm>();
try {
InputStream str = Smart97.class.getResourceAsStream("smart97-simp.dat");
BufferedReader in = new BufferedReader(new InputStreamReader(str, "utf-8"));
String s;
while ( ( s = in.readLine() ) != null ) {
String[] fields = s.split("\t");
if ( ! fields[0].equals("orient") || ! fields[1].equals(v.name) )
continue;
int deg = Integer.parseInt(fields[2]);
double c = Double.parseDouble(fields[3]);
double phi = Double.parseDouble(fields[4]);
double om = Double.parseDouble(fields[5]);
series.add(Comput.PoissonTerm.cphi(deg, c, phi, om));
}
} catch ( Exception e ) {
throw new RuntimeException(e);
}
data.put(v, new Comput.SumPoissonTerms(series));
}
return data.get(v);
}
}
|