def m_dFdT(v_pos_dL_b, v_dL_cap_i, v_v_sat_i, q, t, dL): qi = qnv.quatInv(q) v_pos_dL_i = qnv.quatRotate(q, v_pos_dL_b) height = np.linalg.norm(v_pos_dL_i) - R height = height / 1e3 v_pos_dL_e = fs.ecif2ecef(v_pos_dL_i, t) lat, lon = fs.latlon(v_pos_dL_e.reshape((3, ))) B = runigrf12(day, 0, 1, height, lat, lon) v_B_n = np.vstack((B[0], B[1], B[2])) v_B_n = v_B_n * 1e-9 #convert from nT to T v_B_e = fs.ned2ecef(v_B_n.reshape((3, )), lat, lon) v_dL_cap_e = fs.ecif2ecef(v_dL_cap_i, t) v_v_sat_e = fs.ecif2ecef(v_v_sat_i, t) e = qnv.dot1(qnv.cross1(v_v_sat_e, v_B_e), v_dL_cap_e) i = e / mu_r v_dF_e = dL * i * qnv.cross1(v_dL_cap_e, v_B_e) v_dF_i = fs.ecef2ecif(v_dF_e, t) v_dF_b = qnv.quatRotate(qi, v_dF_i) v_dL_cap_b = v_L_b / np.linalg.norm(v_L_b) v_dT_b = qnv.cross1(v_dL_cap_b, v_dF_b) return v_dF_i, dL * v_dT_b
def test_independnt_of_radius(self, radius): x1 = np.array([1., 2., -3.]) self.assertAlmostEqual(fr.latlon(radius * x1)[0], fr.latlon(x1)[0]) self.assertAlmostEqual(fr.latlon(radius * x1)[1], fr.latlon(x1)[1])
def test_z_symmetry_lat(self, value): #self.assertEqual(2,2) x1 = np.array([sin(value), cos(value), 13.]) self.assertAlmostEqual( fr.latlon(x1)[0], fr.latlon(np.array([1., 0., 13.]))[0])
def test_cases_file(self, value): given, expected = np.asarray( value[0]), value[1] #asarray to convert list to array result = fr.latlon(given) self.assertTrue(np.allclose([result[0], result[1]], expected)) self.assertEqual(type(result), tuple)
This code generates csv file for latitude, longitude, altitude (LLA) corresponding to time data. ECI frame position is provided from sgp_output.csv Time: (since epoch) in seconds latitude: -90 to 90 degrees longitude: -180 to 180 degrees (-180 excluded) altitude: in meters ''' m_sgp_output_i = np.genfromtxt('sgp_output.csv', delimiter=",") N = m_sgp_output_i.shape[0] m_sgp_ecef = np.zeros([N,4]) m_LLA = np.zeros([N,4]) for k in range(0,N): if math.fmod(k,N/100) == 0: print (int(100.*k/N)) v_i = m_sgp_output_i[k,1:4] #iniertial frame position time = m_sgp_output_i[k,0] #time in sec #get position in ecef v_ecef = fs.ecif2ecef(v_i,time) #get latitude and longitude and altitude v_latlon = fs.latlon(v_ecef.copy()) alt = np.linalg.norm(v_i.copy()) - R_EARTH #in meters m_sgp_ecef[k,0] = time m_LLA[k,0] = time m_sgp_ecef[k,1:4] = v_ecef m_LLA[k,1:4] = np.append(v_latlon,alt) np.savetxt('LLA.csv',m_LLA, delimiter=",") print("LLA done")