def states_to_lightcurve(obs_vecs, sun_vecs, attitudes, spacecraft_geometry, Exposure_Time): ''' @param times list of dates at which each observation was taken @param obs_vecs array of vectors from the observer to the spacecraft @param sun_vecs array of vectors from the sun to the spacecraft @param attitudes array of modified rodriguez parameters describing the spacecraft attitude @param spacecraft_geometry a Spacecraft Geometry object describing the spacecraft geometry ''' lightcurve = [] iters = len(obs_vecs) count = 0 for obs_vec, sun_vec, attitude in zip(obs_vecs, sun_vecs, attitudes): dcm_body2eci = CF.mrp2dcm(attitude) sun_vec_body = dcm_body2eci.T @ sun_vec obs_vec_body = dcm_body2eci.T @ obs_vec power = spacecraft_geometry.calc_reflected_power( obs_vec_body, sun_vec_body, Exposure_Time) lightcurve.append(power) count += 1 loading_bar(count / iters, 'Simulating Lightcurve') lightcurve = hstack(lightcurve) return lightcurve
def mrp_measurement_function(state, obsvec, sunvec, exposure_time, Geometry): mrps = state[0:3] dcm_body2eci = CF.mrp2dcm(mrps) obs_vec_body = dcm_body2eci.T @ obsvec sun_vec_body = dcm_body2eci.T @ sunvec return array([ Geometry.calc_reflected_power(obs_vec_body, sun_vec_body, exposure_time) ])
obs_vecs = load(truth_dir + '/obsvec.npy')[::50] sun_vecs = load(truth_dir + '/sunvec.npy')[::50] attitudes = load(truth_dir + '/mrps' + result_num + '.npy')[::50] Exposure_Time = Simulation_Configuration['Exposure Time'] num_frames = len(obs_vecs) START_INDEX = -5000 frames = [] count = 0 max_val = 0 for mrps, obs_vec, sun_vec in zip(attitudes[START_INDEX:], obs_vecs[START_INDEX:], sun_vecs[START_INDEX:]): dcm_eci2body = CF.mrp2dcm(mrps).T #dcm_eci2body = CF.mrp2dcm(mrps).T image = RF.generate_image(Geometry, dcm_eci2body @ obs_vec, dcm_eci2body @ sun_vec, Exposure_Time, win_dim=(6, 6), dpm=20) im_max = amax(image) if im_max > max_val: max_val = im_max frames.append(image) count += 1 loading_bar(count / num_frames, 'Rendering gif') frames = [frame / max_val for frame in frames]
true_lightcurve = load(os.path.join(passfile, 'lightcurve'+run_number+'.npy')) true_mrps = load(os.path.join(passfile, 'mrps'+run_number+'.npy')) true_rates = load(os.path.join(passfile, 'angular_rate'+run_number+'.npy')) obs_vecs = load(os.path.join(passfile, 'obsvec.npy')) sun_vecs = load(os.path.join(passfile, 'sunvec.npy')) est_lightcurve = load(os.path.join(result_dir, 'results'+run_number+'_estimated_curve.npy')) means = load(os.path.join(result_dir, 'results'+run_number+'_raw_means.npy')) covariances = load(os.path.join(result_dir, 'results'+run_number+'_raw_covariance.npy')) residuals = load(os.path.join(result_dir, 'results'+run_number+'_raw_residuals.npy')) stp = int(floor(1/DT)) eci_rate_true = vstack(list([CF.mrp2dcm(m)@rate for m, rate in zip(true_mrps, true_rates)])) eci_rate_ests = [] for est, tru in zip(means, eci_rate_true): eci_rate_est = CF.mrp2dcm(est[0:3])@est[3:6] a = norm(eci_rate_est - tru) b = norm(-eci_rate_est - tru) if b < a: eci_rate_ests.append(-eci_rate_est) else: eci_rate_ests.append(eci_rate_est) eci_rate_ests = vstack(eci_rate_ests) obs_frame_true_rate = [] obs_frame_est_rate = [] for obs, sun, truth, est in zip(obs_vecs, sun_vecs, eci_rate_true, eci_rate_ests):
est_lightcurve = load( os.path.join(result_dir, 'results' + run_number + '_estimated_curve.npy')) means = load( os.path.join(result_dir, 'results' + run_number + '_raw_means.npy')) covariances = load( os.path.join(result_dir, 'results' + run_number + '_raw_covariance.npy')) residuals = load( os.path.join(result_dir, 'results' + run_number + '_raw_residuals.npy')) eci_rate_ests = [] for est in means: eci_rate_est = CF.mrp2dcm(est[0:3]) @ est[3:6] eci_rate_ests.append(eci_rate_est) eci_rate_ests = vstack(eci_rate_ests) obs_frame_est_rate = [] for obs, sun, est in zip(obs_vecs, sun_vecs, eci_rate_ests): x = obs / norm(obs) z = cross(sun, obs) / norm(cross(sun, obs)) y = cross(z, x) eci2obs = vstack([x, y, z]) obs_frame_est_rate.append(eci2obs @ est) obs_frame_est_rate = vstack(obs_frame_est_rate)
'results' + run_number + '_estimated_curve.npy')) means = load( os.path.join(result_dir, 'results' + run_number + '_raw_means.npy')) covariances = load( os.path.join(result_dir, 'results' + run_number + '_raw_covariance.npy')) residuals = load( os.path.join(result_dir, 'results' + run_number + '_raw_residuals.npy')) stp = int(floor(1 / DT)) eci_rate_true = vstack( list([ CF.mrp2dcm(true_mrps[0]) @ true_rates[0] for m, rate in zip(true_mrps, true_rates) ])) eci_rate_ests = [] for est, tru in zip(means, eci_rate_true): eci_rate_est = CF.mrp2dcm(est[0:3]) @ est[3:6] a = norm(eci_rate_est - tru) b = norm(-eci_rate_est - tru) if b < a: eci_rate_ests.append(-eci_rate_est) else: eci_rate_ests.append(eci_rate_est) eci_rate_ests = vstack(eci_rate_ests) obs_frame_true_rate = [] obs_frame_est_rate = []