diff options
author | David A. Madore <david+git@madore.org> | 2012-03-24 00:54:50 +0100 |
---|---|---|
committer | David A. Madore <david+git@madore.org> | 2012-03-27 19:31:16 +0200 |
commit | d64c37f6f24abbfb7e02b8f9ea670a9b5e794f2e (patch) | |
tree | f7c901d0554b3d822dab70a627e209fb4923f2b9 /org/madore/ephem/Smart97.java | |
download | ephem-d64c37f6f24abbfb7e02b8f9ea670a9b5e794f2e.tar.gz ephem-d64c37f6f24abbfb7e02b8f9ea670a9b5e794f2e.tar.bz2 ephem-d64c37f6f24abbfb7e02b8f9ea670a9b5e794f2e.zip |
Initial commit. This version doesn't do much but evaluate VSOP87/Smart97 series.
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); + } + +} |