Exemplo n.º 1
0
def DDSFromSymbolic(resolution, symdiffeosystem):  # @UnusedVariable
    """ 
        Creates a DiffeoSystem from synthetic diffeomorphisms. 
    """
    diffeo2s_config = get_diffeo2s_config()
    diffeo2dds_config = get_diffeo2dds_config()

    _, symdds = diffeo2dds_config.symdds.instance_smarter(symdiffeosystem)

    logger.info('Creating symbolic diffeomorphism (resolution = %d)' %
                resolution)

    diffeoactions = []
    for _, action in enumerate(symdds.actions):

        id_diffeo, diffeo = parse_diffeo_spec(diffeo2s_config,
                                              action['diffeo'])
        label = action.get('label', id_diffeo)

        original_cmd = np.array(action['original_cmd'])

        logger.info('Getting symbolic diffeomorphism %r' % id_diffeo)

        shape = (resolution, resolution)
        viewport = SquareDomain([[-1, +1], [-1, +1]])
        manifold = diffeo.get_topology()
        D, Dinfo = diffeo_from_function_viewport(diffeo, manifold, viewport,
                                                 shape)
        D2d = Diffeomorphism2D(D, Dinfo)

        diffeo_inv = diffeo.get_inverse()
        D_inv, Dinfo_inv = \
            diffeo_from_function_viewport(diffeo_inv, manifold, viewport, shape)
        D2d_inv = Diffeomorphism2D(D_inv, Dinfo_inv)

        action = DiffeoAction(label=label,
                              diffeo=D2d,
                              diffeo_inv=D2d_inv,
                              original_cmd=original_cmd)
        diffeoactions.append(action)

    dds = DiffeoSystem('unnamed', actions=diffeoactions)
    return dds
Exemplo n.º 2
0
def DDSFromSymbolic(resolution, symdiffeosystem):  # @UnusedVariable
    """ 
        Creates a DiffeoSystem from synthetic diffeomorphisms. 
    """  
    diffeo2s_config = get_diffeo2s_config()
    diffeo2dds_config = get_diffeo2dds_config()
    
    _, symdds = diffeo2dds_config.symdds.instance_smarter(symdiffeosystem)
    
    logger.info('Creating symbolic diffeomorphism (resolution = %d)' % 
                resolution)
    
    diffeoactions = []
    for _, action in enumerate(symdds.actions):
        
        id_diffeo, diffeo = parse_diffeo_spec(diffeo2s_config, action['diffeo'])
        label = action.get('label', id_diffeo)
        
        original_cmd = np.array(action['original_cmd'])
        
        logger.info('Getting symbolic diffeomorphism %r' % id_diffeo)
        
        shape = (resolution, resolution)
        viewport = SquareDomain([[-1, +1], [-1, +1]])
        manifold = diffeo.get_topology()
        D, Dinfo = diffeo_from_function_viewport(diffeo, manifold, viewport, shape)    
        D2d = Diffeomorphism2D(D, Dinfo)
        
        diffeo_inv = diffeo.get_inverse()
        D_inv, Dinfo_inv = \
            diffeo_from_function_viewport(diffeo_inv, manifold, viewport, shape)    
        D2d_inv = Diffeomorphism2D(D_inv, Dinfo_inv) 

        action = DiffeoAction(label=label,
                              diffeo=D2d,
                              diffeo_inv=D2d_inv,
                              original_cmd=original_cmd)
        diffeoactions.append(action)
        
    dds = DiffeoSystem('unnamed', actions=diffeoactions)
    return dds
Exemplo n.º 3
0
def repeat(id_diffeo, times):
    symdiffeos = get_diffeo2s_config().symdiffeos 
    diffeo = symdiffeos.instance(id_diffeo)
    chain = [diffeo] * times
    return SymDiffeoComposition(chain)
Exemplo n.º 4
0
def make_inverse(id_diffeo):
    symdiffeos = get_diffeo2s_config().symdiffeos 
    return symdiffeos.instance(id_diffeo).get_inverse()     
Exemplo n.º 5
0
def make_chain(diffeos):
    symdiffeos = get_diffeo2s_config().symdiffeos
    chain = map(symdiffeos.instance, diffeos) 
    return SymDiffeoComposition(chain)     
Exemplo n.º 6
0
def repeat(id_diffeo, times):
    symdiffeos = get_diffeo2s_config().symdiffeos
    diffeo = symdiffeos.instance(id_diffeo)
    chain = [diffeo] * times
    return SymDiffeoComposition(chain)
Exemplo n.º 7
0
def make_inverse(id_diffeo):
    symdiffeos = get_diffeo2s_config().symdiffeos
    return symdiffeos.instance(id_diffeo).get_inverse()
Exemplo n.º 8
0
def make_chain(diffeos):
    symdiffeos = get_diffeo2s_config().symdiffeos
    chain = map(symdiffeos.instance, diffeos)
    return SymDiffeoComposition(chain)