How to use nml - 10 common examples

To help you get started, we’ve selected a few nml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github payu-org / payu / nml.py View on Github external
def __setitem__(self, key, value):
        super(NmlDict, self).__setitem__(key.lower(), value)
github payu-org / payu / nml.py View on Github external
tokens = iter(f90)

    # Store groups in case-insensitive dictionary
    nmls = NmlDict()

    for t in tokens:

        # Ignore tokens outside of namelist groups
        while t != '&':
            t = tokens.next()

        # Read group name following '&'
        t = tokens.next()

        g_name = t
        g_vars = NmlDict()

        v_name = None
        v_vals = []
        while t != '/':

            prior_t = t
            t = tokens.next()

            if v_name and not t == '=':

                # Test if varname contains a vector index
                # TODO: Do I need regex?
                match = re.search(r'\(\d+\)$', v_name)
                if match:
                    v_index = int(v_name[match.start()+1:-1])
                    v_name = v_name[:match.start()]
github payu-org / payu / nml.py View on Github external
def parse(nml_fname):

    f = open(nml_fname, 'r')

    f90 = shlex.shlex(f)
    f90.commenters = '!'
    f90.wordchars += '.-()'   # Numerical characters
    tokens = iter(f90)

    # Store groups in case-insensitive dictionary
    nmls = NmlDict()

    for t in tokens:

        # Ignore tokens outside of namelist groups
        while t != '&':
            t = tokens.next()

        # Read group name following '&'
        t = tokens.next()

        g_name = t
        g_vars = NmlDict()

        v_name = None
        v_vals = []
        while t != '/':
github NeuralEnsemble / libNeuroML / neuroml / development / components.py View on Github external
#examples:
from nml.nml import Morphology as Morphology

Morphology.__class__ = 'morphy'
github NeuralEnsemble / libNeuroML / neuroml / development / opmorphology.py View on Github external
from nml.nml import Morphology

#what we also need is an SWC class, Optimized morphology can then be passed this.

class OptimizedMorphology(Morphology):
    def __init__(self):
        super(OptimizedMorphology,self).__init__()
github NeuralEnsemble / libNeuroML / neuroml / development / optimized_morphology.py View on Github external
from nml.nml import Morphology

class OptimizedMorphology(Morphology):
    super(OptimizedMorphology,self).__init__()
github neurokernel / neurokernel / neurokernel / neuroml / utils.py View on Github external
Parameters
    ----------
    g : networkx.DiGraph
        Directed graph containing the pattern's ports (nodes) and connections
        (edges).
    id : str
        Pattern identifier.

    Returns
    -------
    pattern : neurokernel.neuroml.Pattern
        pattern instance.
    """

    pattern = Pattern(id=id)
    interface = Interface()
    for p in g.nodes():
        attr_dict = g.node[p]
        port = Port(identifier=attr_dict['identifier'],
                    interface=attr_dict['interface'],
                    io=attr_dict['io'],
                    type=attr_dict['type'])
        interface.ports.append(port)

    pattern.interface = interface
    for c in g.edges():
        connection = PatternConnection(from_=c[0], to=c[1])
        pattern.connections.append(connection)

    return pattern
github neurokernel / neurokernel / neurokernel / neuroml / utils.py View on Github external
gmax=attr_dict['gmax'],
                           reverse=attr_dict['reverse'])
            module.al_synapses.append(al)
        elif attr_dict['model'] == 'power_gpot_gpot':
            pgg = PGGSynapse(id=attr_dict['name'],
                             class_=attr_dict['class'],
                             slope=attr_dict['slope'],
                             threshold=attr_dict['threshold'],
                             power=attr_dict['power'],
                             saturation=attr_dict['saturation'],
                             delay=attr_dict['delay'],
                             reverse=attr_dict['reverse'],
                             conductance=attr_dict['conductance'])
            module.pgg_synapses.append(pgg)

    interface = Interface()
    for p in i.nodes():
        attr_dict = i.node[p]
        port = Port(identifier=p,
                    interface=attr_dict['interface'],
                    io=attr_dict['io'],
                    type=attr_dict['type'])
        interface.ports.append(port)
    module.interface = interface

    return module
github neurokernel / neurokernel / neurokernel / neuroml / utils.py View on Github external
Parameters
    ----------
    g : networkx.DiGraph
        Directed graph containing a module's neurons and synapses
    i : networkx.Graph
        Undirected graph containing a module's interface ports.
    id : str
        Module identifier.

    Returns
    -------
    module : neurokernel.neuroml.Module
        Module instance.
    """

    module = Module(id=id)

    for n in g.nodes():
        attr_dict = g.node[n]
        if attr_dict['model'] == 'MorrisLecar':
            ml = MLNeuron(id=attr_dict['name'],
                          extern=attr_dict['extern'],
                          public=attr_dict['public'],
                          spiking=attr_dict['spiking'],
                          V1=attr_dict['V1'],
                          V2=attr_dict['V2'],
                          V3=attr_dict['V3'],
                          V4=attr_dict['V4'],
                          phi=attr_dict['phi'],
                          offset=attr_dict['offset'],
                          init_v=attr_dict['initV'],
                          initn=attr_dict['initn'])
github neurokernel / neurokernel / neurokernel / neuroml / utils.py View on Github external
Convert a module expressed in Neurokernel NeuroML into NetworkX graphs.

    Parameters
    ----------
    module : neurokernel.neuroml.Module
        Module instance.

    Returns
    -------
    g : networkx.DiGraph
        Directed graph containing a module's neurons and synapses
    i : networkx.Graph
        Undirected graph containing a module's interface ports.
    """

    assert isinstance(module, Module)

    # Ensure that none of the neurons or synapses have duplicate IDs:
    assert len(set([n.id for n in module.ml_neurons])) == \
        len(module.ml_neurons)
    assert len(set([n.id for n in module.lif_neurons])) == \
        len(module.lif_neurons)
    assert len(set([s.id for s in module.al_synapses])) == \
        len(module.al_synapses)
    assert len(set([s.id for s in module.pgg_synapses])) == \
        len(module.pgg_synapses)

    g = nx.DiGraph()
    for n in module.ml_neurons:
        g.add_node(n.id)
        g.node[n.id] = {
            'model': 'MorrisLecar',