20 import static ca.uqac.lif.cep.Connector.INPUT;
21 import static ca.uqac.lif.cep.Connector.OUTPUT;
23 import ca.uqac.lif.cep.Connector;
24 import ca.uqac.lif.cep.functions.ApplyFunction;
25 import ca.uqac.lif.cep.functions.FunctionTree;
26 import ca.uqac.lif.cep.functions.StreamVariable;
27 import ca.uqac.lif.cep.io.ReadLines;
28 import ca.uqac.lif.cep.mtnp.DrawPlot;
29 import ca.uqac.lif.cep.mtnp.UpdateTableStream;
30 import ca.uqac.lif.cep.signal.Smooth;
31 import ca.uqac.lif.cep.tmf.CountDecimate;
32 import ca.uqac.lif.cep.tmf.Fork;
33 import ca.uqac.lif.cep.tmf.Pump;
34 import ca.uqac.lif.cep.tmf.Splice;
35 import ca.uqac.lif.cep.tmf.Trim;
36 import ca.uqac.lif.cep.util.NthElement;
37 import ca.uqac.lif.cep.util.Numbers;
38 import ca.uqac.lif.cep.util.Strings;
39 import ca.uqac.lif.mtnp.plot.TwoDimensionalPlot.Axis;
40 import ca.uqac.lif.mtnp.plot.gral.Scatterplot;
57 public static void main(String[] args)
59 int start_year = 1985, end_year = 1992;
63 ReadLines[] readers =
new ReadLines[end_year - start_year + 1];
64 for (
int y = start_year; y <= end_year; y++)
66 readers[y - start_year] =
new ReadLines(
RadialAcceleration.class.getResourceAsStream(
"data/vy2_" + y +
".asc"));
71 Splice spl =
new Splice(readers);
74 CountDecimate cd =
new CountDecimate(24 * 1);
75 Connector.connect(spl, cd);
80 Trim ignore_beginning =
new Trim(39*7);
81 Connector.connect(cd, ignore_beginning);
84 ApplyFunction to_array =
new ApplyFunction(
new Strings.SplitString(
"\\s+"));
85 Connector.connect(ignore_beginning, to_array);
88 Fork fork =
new Fork(2);
89 Connector.connect(to_array, fork);
92 ApplyFunction format_date =
new ApplyFunction(
new FunctionTree(
FormatDate.
instance,
new FunctionTree(
new NthElement(0), StreamVariable.X),
new FunctionTree(
new NthElement(1), StreamVariable.X)));
93 Connector.connect(fork, 0, format_date, INPUT);
96 ApplyFunction get_au1 =
new ApplyFunction(
new FunctionTree(Numbers.numberCast,
new FunctionTree(
new NthElement(3), StreamVariable.X)));
97 Connector.connect(fork, 1, get_au1, INPUT);
101 Connector.connect(get_au1, speed);
105 Connector.connect(speed, acceleration);
106 Smooth smooth =
new Smooth(2);
107 Connector.connect(acceleration, smooth);
109 UpdateTableStream table =
new UpdateTableStream(
"Date",
"Acceleration");
111 Connector.connect(format_date, OUTPUT, table, 0);
112 Connector.connect(smooth, OUTPUT, table, 1);
114 CountDecimate reduce_resolution =
new CountDecimate(15);
115 Connector.connect(table, reduce_resolution);
116 Scatterplot plot =
new Scatterplot();
117 plot.withPoints(
false);
118 plot.setTitle(
"Planetary encounters of Voyager 2");
119 plot.setCaption(Axis.X,
"Days after launch");
120 plot.setCaption(Axis.Y,
"AU");
121 DrawPlot draw =
new DrawPlot(plot);
122 Connector.connect(reduce_resolution, draw);
123 Pump pump =
new Pump();
124 Connector.connect(draw, pump);
126 Connector.connect(pump, window);
Detect planetary encounters of Voyager 2 by analyzing its distance from the Earth.
Computes the slope between two successive points in a data stream (which is simply the difference bet...
Generate tables, charts and plots from event streams.
Receives a byte array as an input, and shows it in a Swing window as a picture.