diff options
Diffstat (limited to 'org/madore/ephem/Smart97.java')
-rw-r--r-- | org/madore/ephem/Smart97.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/org/madore/ephem/Smart97.java b/org/madore/ephem/Smart97.java new file mode 100644 index 0000000..3fa2b80 --- /dev/null +++ b/org/madore/ephem/Smart97.java @@ -0,0 +1,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); + } + +} |