Hello everyone,
I am trying to use the second constructor in this class to feed my PV measurements to the BatchLeastSquare method:
PV(AbsoluteDate date, Vector3D position, Vector3D velocity, double[][] covarianceMatrix, double baseWeight, ObservableSatellite satellite)
Well, I believe everything is correct except the covarianceMatrix. I have a numpy array, while the constuctor accepts JArray_double2D. So I need to convert my covarianceMatrix from numpy array to 2 dimensional (6x6) JArray. I am not hundred percent sure but some casting must be done in order to accomplish this.
from orekit.pyhelpers import datetime_to_absolutedate, JArray, JArray_double2D
from org.orekit.estimation.measurements import PV, ObservableSatellite
from org.hipparchus.geometry.euclidean.threed import Vector3D
from orekit import JArray_double
from org.hipparchus.linear import Array2DRowRealMatrix
observableSatellite = ObservableSatellite(0) # Propagator index = 0
covarianceMatrix = np.zeros((6, 6))
for i in range(1000): #4321
pos3D = Vector3D(float(truedata_df['pos_x'][i])*1000,
float(truedata_df['pos_y'][i])*1000,
float(truedata_df['pos_z'][i])*1000) # in [m]
vel3D = Vector3D(float(truedata_df['vel_x'][i])*1000,
float(truedata_df['vel_y'][i])*1000,
float(truedata_df['vel_z'][i])*1000) # in [m/s]
date = AbsoluteDate(truedata_df['date'][i].year,
truedata_df['date'][i].month,
truedata_df['date'][i].day,
truedata_df['date'][i].hour,
truedata_df['date'][i].minute,
float(truedata_df['date'][i].second)+0.566,
UTC)
covarianceMatrix = np.array([[float(df_cov[i][0]), float(df_cov[i][1]), float(df_cov[i][3]), float(df_cov[i][6]), float(df_cov[i][10]), float(df_cov[i][15])],
[float(df_cov[i][1]), float(df_cov[i][2]), float(df_cov[i][4]), float(df_cov[i][7]), float(df_cov[i][11]), float(df_cov[i][16])],
[float(df_cov[i][3]), float(df_cov[i][4]), float(df_cov[i][5]), float(df_cov[i][8]), float(df_cov[i][12]), float(df_cov[i][17])],
[float(df_cov[i][6]), float(df_cov[i][7]), float(df_cov[i][8]), float(df_cov[i][9]), float(df_cov[i][13]), float(df_cov[i][18])],
[float(df_cov[i][10]), float(df_cov[i][11]), float(df_cov[i][12]), float(df_cov[i][13]), float(df_cov[i][14]), float(df_cov[i][19])],
[float(df_cov[i][15]), float(df_cov[i][16]), float(df_cov[i][17]), float(df_cov[i][18]), float(df_cov[i][19]), float(df_cov[i][20])]])
covarianceMatrix_1 = JArray_double.cast_(JArray('double')(covarianceMatrix[0]))
covarianceMatrix_2 = JArray_double.cast_(JArray('double')(covarianceMatrix[1]))
covarianceMatrix_3 = JArray_double.cast_(JArray('double')(covarianceMatrix[2]))
covarianceMatrix_4 = JArray_double.cast_(JArray('double')(covarianceMatrix[3]))
covarianceMatrix_5 = JArray_double.cast_(JArray('double')(covarianceMatrix[4]))
covarianceMatrix_6 = JArray_double.cast_(JArray('double')(covarianceMatrix[5]))
orekitPV_est = PV(date, pos3D, vel3D, covarianceMatrix, baseweight, observableSatellite)
estimator.addMeasurement(orekitPV_est)
Individual elements in numpy covariance matrix can be cast into JArray_double object, but how can I get a 2D JArray using these elements? Below line returns an empty 2D JArray, but how can I assign above casted elements into this 2D JArray?
covarianceMatrix = JArray_double2D(6,6)
Also, after creating JArray_double2D
method we again need another .cast_
right? Do you have any idea how can it be done @petrus.hyvonen?
Basically, I couldn’t add my covariance matrix (np.array) to my estimations and this is my problem in a nutshell Anyone else faced a similar issue before? Any advice is appreciated.
Thanks,
Baris