def compute(results): cartesian = spherical_to_cartesian(np.squeeze(results['theta']), np.squeeze(results['phi'])) if len(cartesian.shape) == 3: return {'vec0': np.mean(cartesian, axis=1), 'vec0.std': np.std(cartesian, axis=1)} else: return {'vec0': np.mean(cartesian, axis=0)[None, :], 'vec0.std': np.std(cartesian, axis=0)[None, :]}
def _get_extra_optimization_map_funcs(self, template, parameter_list): extra_optimization_maps = copy(template.extra_optimization_maps) if all( map(lambda name: name in [p.name for p in parameter_list], ('theta', 'phi'))): extra_optimization_maps.append( lambda results: { 'vec0': spherical_to_cartesian(np.squeeze(results['theta']), np.squeeze(results['phi'])) }) return extra_optimization_maps
def _get_vector_result_maps(self, theta, phi, vector_name='vec0'): """Convert spherical coordinates to cartesian vector in 3d Args: theta (ndarray): the double array with the theta values phi (ndarray): the double array with the phi values vector_name (str): the name for this vector, the common naming scheme is: <model_name>.<vector_name>[_{0,1,2}] Returns: dict: containing the cartesian vector with the main the fibre direction. It returns an element .vec0 and elements vec0_ """ cartesian = spherical_to_cartesian(theta, phi) extra_dict = {'{}.{}'.format(self.name, vector_name): cartesian} for ind in range(3): extra_dict.update({ '{}.{}_{}'.format(self.name, vector_name, ind): cartesian[:, ind] }) return extra_dict
def compute(results): cartesian = spherical_to_cartesian(np.squeeze(results['theta']), np.squeeze(results['phi'])) return {'vec0': np.mean(cartesian, axis=1), 'vec0.std': np.std(cartesian, axis=1)}