pose_estimation/gramian/trajectories.py
def evaluate_all_trajectories():
    '''
    evaluate all candidate trajectories, calculate the Gramian for each, and
    calculate the optimal Gramian over all trajectories
    '''

    # rendering
    save_dir = dirs.trajectories_dir
    # integrated gramian for all trajectories
    gram_all = np.full((6, 6, n_ang), np.nan)
    # loop over semicircles
    for i in range(n_ang):
        gram = np.full((6, 6), 0.0)
        coord, cam_quat = semicircle(rad, n_pts, ang_x[i], ang_z[i],
                                     xyz_cent_col)

        # loop over points along semicircle
        for j in range(n_pts):

            # render
            cam_pos_ij = np.expand_dims(coord[:,j], 1)
            cam_quat_ij = np.expand_dims(cam_quat[:,j], 1)

            # render properties object
            to_render_pkl = os.path.join(save_dir, 'to_render.pkl')
            render_props = RenderProperties()
            render_props.model_name = model_name
            render_props.xyz = xyz_col
            render_props.quat = quat_col
            render_props.cam_xyz = cam_pos_ij
            render_props.cam_quat = cam_quat_ij
            render_props.lens = lens
            render_props.sensor_width = sensor_width
            render_props.sensor_height = sensor_height
            render_props.compute_gramian = True
            render_props.alpha = False
            render_props.image_names=['%03d' % j]

            with open(to_render_pkl, 'wb') as output:
                pickle.dump(render_props, output, pickle.HIGHEST_PROTOCOL)
            br.blender_render(save_dir)
            
            # load gramian
            gram_npz = os.path.join(save_dir, 'gramian.npz')
            gram_data = np.load(gram_npz)
            gram_ij = gram_data['gram']
            gram += gram_ij[:,:,0]

        # save integrated gramian
        gram_all[:,:,i] = gram
        
    # calculate measures of all integrated gramians
    grm = gf.gramian_measures(gram_all)
    det_min_ind = np.argmin(grm['det'])
    det_max_ind = np.argmax(grm['det'])
    trace_min_ind = np.argmin(grm['trace'])
    trace_max_ind = np.argmax(grm['trace'])
    min_eval_min_ind = np.argmin(grm['min_eval'])
    min_eval_max_ind = np.argmax(grm['min_eval'])
    cond_num_min_ind = np.argmin(grm['cond_num'])
    cond_num_max_ind = np.argmax(grm['cond_num'])

    opt_ang = {
        kys[0]: ang_xz[det_min_ind],
        kys[1]: ang_xz[det_max_ind],
        kys[2]: ang_xz[trace_min_ind],
        kys[3]: ang_xz[trace_max_ind],
        kys[4]: ang_xz[min_eval_min_ind],
        kys[5]: ang_xz[min_eval_max_ind],
        kys[6]: ang_xz[cond_num_min_ind],
        kys[7]: ang_xz[cond_num_max_ind]}
    opt_ang_npz = os.path.join(save_dir, 'opt_ang.npz')
    np.savez(opt_ang_npz, xyz=xyz, ang_x=ang_x, ang_z=ang_z, opt_ang=opt_ang)

    evaluate all candidate trajectories, calculate the Gramian for each, and
    calculate the optimal Gramian over all trajectories
    
evaluate all candidate trajectories, calculate the Gramian for each, and
calculate the optimal Gramian over all trajectories
evaluate all candidate trajectories calculate the Gramian for each and calculate the optimal Gramian over all trajectories
def evaluate_all_trajectories():
    save_dir = dirs.trajectories_dir
    gram_all = np.full((6, 6, n_ang), np.nan)
    for i in range(n_ang):
        gram = np.full((6, 6), 0.0)
        coord, cam_quat = semicircle(rad, n_pts, ang_x[i], ang_z[i],
                                     xyz_cent_col)
        for j in range(n_pts):
            cam_pos_ij = np.expand_dims(coord[:,j], 1)
            cam_quat_ij = np.expand_dims(cam_quat[:,j], 1)
             properties object
            to_render_pkl = os.path.join(save_dir, 'to_render.pkl')
            render_props = RenderProperties()
            render_props.model_name = model_name
            render_props.xyz = xyz_col
            render_props.quat = quat_col
            render_props.cam_xyz = cam_pos_ij
            render_props.cam_quat = cam_quat_ij
            render_props.lens = lens
            render_props.sensor_width = sensor_width
            render_props.sensor_height = sensor_height
            render_props.compute_gramian = True
            render_props.alpha = False
            render_props.image_names=['%03d' % j]
            with open(to_render_pkl, 'wb') as output:
                pickle.dump(render_props, output, pickle.HIGHEST_PROTOCOL)
            br.blender_render(save_dir)
            gram_npz = os.path.join(save_dir, 'gramian.npz')
            gram_data = np.load(gram_npz)
            gram_ij = gram_data['gram']
            gram += gram_ij[:,:,0]
        gram_all[:,:,i] = gram
    grm = gf.gramian_measures(gram_all)
    det_min_ind = np.argmin(grm['det'])
    det_max_ind = np.argmax(grm['det'])
    trace_min_ind = np.argmin(grm['trace'])
    trace_max_ind = np.argmax(grm['trace'])
    min_eval_min_ind = np.argmin(grm['min_eval'])
    min_eval_max_ind = np.argmax(grm['min_eval'])
    cond_num_min_ind = np.argmin(grm['cond_num'])
    cond_num_max_ind = np.argmax(grm['cond_num'])
    opt_ang = {
        kys[0]: ang_xz[det_min_ind],
        kys[1]: ang_xz[det_max_ind],
        kys[2]: ang_xz[trace_min_ind],
        kys[3]: ang_xz[trace_max_ind],
        kys[4]: ang_xz[min_eval_min_ind],
        kys[5]: ang_xz[min_eval_max_ind],
        kys[6]: ang_xz[cond_num_min_ind],
        kys[7]: ang_xz[cond_num_max_ind]}
    opt_ang_npz = os.path.join(save_dir, 'opt_ang.npz')
    np.savez(opt_ang_npz, xyz=xyz, ang_x=ang_x, ang_z=ang_z, opt_ang=opt_ang)
def evaluate_all_trajectories ( ) : save_dir = dirs . trajectories_dir gram_all = np . full ( ( 6 , 6 , n_ang ) , np . nan ) for i in range ( n_ang ) : gram = np . full ( ( 6 , 6 ) , 0.0 ) coord , cam_quat = semicircle ( rad , n_pts , ang_x [ i ] , ang_z [ i ] , xyz_cent_col ) for j in range ( n_pts ) : cam_pos_ij = np . expand_dims ( coord [ : , j ] , 1 ) cam_quat_ij = np . expand_dims ( cam_quat [ : , j ] , 1 ) to_render_pkl = os . path . join ( save_dir , 'to_render.pkl' ) render_props = RenderProperties ( ) render_props . model_name = model_name render_props . xyz = xyz_col render_props . quat = quat_col render_props . cam_xyz = cam_pos_ij render_props . cam_quat = cam_quat_ij render_props . lens = lens render_props . sensor_width = sensor_width render_props . sensor_height = sensor_height render_props . compute_gramian = True render_props . alpha = False render_props . image_names = [ '%03d' % j ] with open ( to_render_pkl , 'wb' ) as output : pickle . dump ( render_props , output , pickle . HIGHEST_PROTOCOL ) br . blender_render ( save_dir ) gram_npz = os . path . join ( save_dir , 'gramian.npz' ) gram_data = np . load ( gram_npz ) gram_ij = gram_data [ 'gram' ] gram += gram_ij [ : , : , 0 ] gram_all [ : , : , i ] = gram grm = gf . gramian_measures ( gram_all ) det_min_ind = np . argmin ( grm [ 'det' ] ) det_max_ind = np . argmax ( grm [ 'det' ] ) trace_min_ind = np . argmin ( grm [ 'trace' ] ) trace_max_ind = np . argmax ( grm [ 'trace' ] ) min_eval_min_ind = np . argmin ( grm [ 'min_eval' ] ) min_eval_max_ind = np . argmax ( grm [ 'min_eval' ] ) cond_num_min_ind = np . argmin ( grm [ 'cond_num' ] ) cond_num_max_ind = np . argmax ( grm [ 'cond_num' ] ) opt_ang = { kys [ 0 ] : ang_xz [ det_min_ind ] , kys [ 1 ] : ang_xz [ det_max_ind ] , kys [ 2 ] : ang_xz [ trace_min_ind ] , kys [ 3 ] : ang_xz [ trace_max_ind ] , kys [ 4 ] : ang_xz [ min_eval_min_ind ] , kys [ 5 ] : ang_xz [ min_eval_max_ind ] , kys [ 6 ] : ang_xz [ cond_num_min_ind ] , kys [ 7 ] : ang_xz [ cond_num_max_ind ] } opt_ang_npz = os . path . join ( save_dir , 'opt_ang.npz' ) np . savez ( opt_ang_npz , xyz = xyz , ang_x = ang_x , ang_z = ang_z , opt_ang = opt_ang )
evaluate all candidate trajectories, calculate the Gramian for each, and
calculate the optimal Gramian over all trajectories
evaluate all candidate trajectories calculate the Gramian for each and calculate the optimal Gramian over all trajectories
'''
    evaluate all candidate trajectories, calculate the Gramian for each, and
    calculate the optimal Gramian over all trajectories
    ''' # rendering # integrated gramian for all trajectories # loop over semicircles # loop over points along semicircle # render # render properties object # load gramian # save integrated gramian # calculate measures of all integrated gramians