11package org .sofwerx .torgi .gnss ;
22
3+ import android .util .Log ;
4+
5+ import org .apache .commons .math3 .stat .descriptive .moment .StandardDeviation ;
6+
37import java .util .ArrayList ;
48
59/**
610 * Represents relevant EW indicator values at one place in spacetime
711 */
812public class DataPoint {
13+ private final static String TAG ="TORGI.EW" ;
914 private SpaceTime spaceTime ;
1015 private ArrayList <SatMeasurement > measurements = null ;
1116
@@ -26,15 +31,91 @@ public GNSSEWValues getAverageMeasurements() {
2631 return SatMeasurement .getAverage (measurements );
2732 }
2833
29- //TODO hey dummy! maybe calculate the difference from baseline as well
34+ public ArrayList <GNSSEWValues > getAllGNSSEWValues () {
35+ if ((measurements == null ) || measurements .isEmpty ())
36+ return null ;
37+ ArrayList <GNSSEWValues > valuesList = new ArrayList <>();
38+ for (SatMeasurement measurement :measurements ) {
39+ if (measurement .getValues () != null )
40+ valuesList .add (measurement .getValues ());
41+ }
42+ if (valuesList .isEmpty ())
43+ valuesList = null ;
44+ return valuesList ;
45+ }
46+
47+ /**
48+ * Gets the average difference between values and baseline
49+ * @return
50+ */
51+ public GNSSEWValues getAverageDifference () {
52+ return SatMeasurement .getAverageDifference (measurements );
53+ }
54+
55+ public ArrayList <SatMeasurement > getMeasurementsByConstellation (Constellation con ) {
56+ if ((measurements != null ) && !measurements .isEmpty () && (con != null )) {
57+ ArrayList <SatMeasurement > conMeas = null ;
58+ for (SatMeasurement measurement :measurements ) {
59+ if ((measurement .getSat () != null ) && (measurement .getSat ().getConstellation () == con )) {
60+ if (conMeas == null )
61+ conMeas = new ArrayList <>();
62+ conMeas .add (measurement );
63+ }
64+ }
65+ return conMeas ;
66+ }
67+ return null ;
68+ }
3069
3170 /**
3271 * Gets the average GNSSEWValues for each constellation
33- * @return array with index corresponding to the constellation number of the constellation
72+ * @return array with the average value with index corresponding to the constellation number of the constellation
3473 */
3574 public GNSSEWValues [] getAverageMeasurementsByConstellation () {
3675 GNSSEWValues [] values = new GNSSEWValues [Constellation .size ()];
3776
77+ if ((measurements != null ) && !measurements .isEmpty ()) {
78+ Constellation con ;
79+ ArrayList <SatMeasurement > conMeas ;
80+ for (int i =0 ;i <values .length ;i ++) {
81+ con = Constellation .get (i );
82+ conMeas = getMeasurementsByConstellation (con );
83+ values [i ] = SatMeasurement .getAverage (conMeas );
84+ }
85+ }
86+
87+ return values ;
88+ }
89+
90+ public float getAllBaselinesCN0SD () {
91+ if ((measurements != null ) && !measurements .isEmpty ()) {
92+ ArrayList <GNSSEWValues > valuesWithCN0s = new ArrayList <>();
93+ for (SatMeasurement measurement :measurements ) {
94+ if ((measurement .getValues () != null ) && !Float .isNaN (measurement .getValues ().getCn0 ()))
95+ valuesWithCN0s .add (measurement .getValues ());
96+ }
97+ if (!valuesWithCN0s .isEmpty ()) {
98+ double [] values = new double [valuesWithCN0s .size ()];
99+ for (int i =0 ;i <values .length ;i ++) {
100+ values [i ] = valuesWithCN0s .get (i ).getCn0 ();
101+ }
102+ StandardDeviation devCal = new StandardDeviation ();
103+ float stdDev = (float )devCal .evaluate (values );
104+ Log .d (TAG ,"C/N0 stdDev across all satellites == " +Float .toString (stdDev ));
105+ return stdDev ;
106+ }
107+ }
108+ Log .d (TAG ,"Could not compute C/N0 stdDev across all satellites" );
109+ return Float .NaN ;
110+ }
111+
112+ /**
113+ * Gets the difference between baseline and current GNSSEWValues for each constellation
114+ * @return array with the average difference between value and baseline with index corresponding to the constellation number of the constellation
115+ */
116+ public GNSSEWValues [] getAverageDifferenceFromBaselineByConstellation () {
117+ GNSSEWValues [] values = new GNSSEWValues [Constellation .size ()];
118+
38119 if ((measurements != null ) && !measurements .isEmpty ()) {
39120 Constellation con ;
40121 ArrayList <SatMeasurement > conMeas ;
@@ -48,7 +129,7 @@ public GNSSEWValues[] getAverageMeasurementsByConstellation() {
48129 conMeas .add (measurement );
49130 }
50131 }
51- values [i ] = SatMeasurement .getAverage (conMeas );
132+ values [i ] = SatMeasurement .getAverageDifference (conMeas );
52133 }
53134 }
54135
0 commit comments