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
17+ public DataPoint () {}
18+
1219 public DataPoint (SpaceTime spaceTime , ArrayList <SatMeasurement > measurements ) {
1320 this .spaceTime = spaceTime ;
1421 this .measurements = measurements ;
@@ -26,15 +33,91 @@ public GNSSEWValues getAverageMeasurements() {
2633 return SatMeasurement .getAverage (measurements );
2734 }
2835
29- //TODO hey dummy! maybe calculate the difference from baseline as well
36+ public ArrayList <GNSSEWValues > getAllGNSSEWValues () {
37+ if ((measurements == null ) || measurements .isEmpty ())
38+ return null ;
39+ ArrayList <GNSSEWValues > valuesList = new ArrayList <>();
40+ for (SatMeasurement measurement :measurements ) {
41+ if (measurement .getValues () != null )
42+ valuesList .add (measurement .getValues ());
43+ }
44+ if (valuesList .isEmpty ())
45+ valuesList = null ;
46+ return valuesList ;
47+ }
48+
49+ /**
50+ * Gets the average difference between values and baseline
51+ * @return
52+ */
53+ public GNSSEWValues getAverageDifference () {
54+ return SatMeasurement .getAverageDifference (measurements );
55+ }
56+
57+ public ArrayList <SatMeasurement > getMeasurementsByConstellation (Constellation con ) {
58+ if ((measurements != null ) && !measurements .isEmpty () && (con != null )) {
59+ ArrayList <SatMeasurement > conMeas = null ;
60+ for (SatMeasurement measurement :measurements ) {
61+ if ((measurement .getSat () != null ) && (measurement .getSat ().getConstellation () == con )) {
62+ if (conMeas == null )
63+ conMeas = new ArrayList <>();
64+ conMeas .add (measurement );
65+ }
66+ }
67+ return conMeas ;
68+ }
69+ return null ;
70+ }
3071
3172 /**
3273 * Gets the average GNSSEWValues for each constellation
33- * @return array with index corresponding to the constellation number of the constellation
74+ * @return array with the average value with index corresponding to the constellation number of the constellation
3475 */
3576 public GNSSEWValues [] getAverageMeasurementsByConstellation () {
3677 GNSSEWValues [] values = new GNSSEWValues [Constellation .size ()];
3778
79+ if ((measurements != null ) && !measurements .isEmpty ()) {
80+ Constellation con ;
81+ ArrayList <SatMeasurement > conMeas ;
82+ for (int i =0 ;i <values .length ;i ++) {
83+ con = Constellation .get (i );
84+ conMeas = getMeasurementsByConstellation (con );
85+ values [i ] = SatMeasurement .getAverage (conMeas );
86+ }
87+ }
88+
89+ return values ;
90+ }
91+
92+ public float getAllBaselinesCN0SD () {
93+ if ((measurements != null ) && !measurements .isEmpty ()) {
94+ ArrayList <GNSSEWValues > valuesWithCN0s = new ArrayList <>();
95+ for (SatMeasurement measurement :measurements ) {
96+ if ((measurement .getValues () != null ) && !Float .isNaN (measurement .getValues ().getCn0 ()))
97+ valuesWithCN0s .add (measurement .getValues ());
98+ }
99+ if (!valuesWithCN0s .isEmpty ()) {
100+ double [] values = new double [valuesWithCN0s .size ()];
101+ for (int i =0 ;i <values .length ;i ++) {
102+ values [i ] = valuesWithCN0s .get (i ).getCn0 ();
103+ }
104+ StandardDeviation devCal = new StandardDeviation ();
105+ float stdDev = (float )devCal .evaluate (values );
106+ Log .d (TAG ,"C/N0 stdDev across all satellites == " +Float .toString (stdDev ));
107+ return stdDev ;
108+ }
109+ }
110+ Log .d (TAG ,"Could not compute C/N0 stdDev across all satellites" );
111+ return Float .NaN ;
112+ }
113+
114+ /**
115+ * Gets the difference between baseline and current GNSSEWValues for each constellation
116+ * @return array with the average difference between value and baseline with index corresponding to the constellation number of the constellation
117+ */
118+ public GNSSEWValues [] getAverageDifferenceFromBaselineByConstellation () {
119+ GNSSEWValues [] values = new GNSSEWValues [Constellation .size ()];
120+
38121 if ((measurements != null ) && !measurements .isEmpty ()) {
39122 Constellation con ;
40123 ArrayList <SatMeasurement > conMeas ;
@@ -48,7 +131,7 @@ public GNSSEWValues[] getAverageMeasurementsByConstellation() {
48131 conMeas .add (measurement );
49132 }
50133 }
51- values [i ] = SatMeasurement .getAverage (conMeas );
134+ values [i ] = SatMeasurement .getAverageDifference (conMeas );
52135 }
53136 }
54137
0 commit comments