• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python nest.sli_run函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nest.sli_run函数的典型用法代码示例。如果您正苦于以下问题:Python sli_run函数的具体用法?Python sli_run怎么用?Python sli_run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sli_run函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _setup_music

    def _setup_music(self):
        """
        Setup music connection.
        """
        _nest.sli_run('statusdict/have_music ::')
        if not _nest.spp():
            print('NEST was not compiled with support for MUSIC, not running.')
            _sys.exit()

        # Setup music spike output.
        self._music_spike_output = _nest.Create('music_event_out_proxy', 1)
        _nest.SetStatus(self._music_spike_output,
                        {'port_name': self._spike_port_name})

        # Connecting neurons to music event channels. In case of the BBP
        # circuit, each channel corresponds to a gid.
        for gid, neuron in self._gid_to_neuron_map.items():
            _nest.Connect([neuron], self._music_spike_output, 'one_to_one',
                          {'music_channel': gid})

        # Connecting the last music channel (value specified in the
        # configuration file) to a dummy neuron
        dummy = _nest.Create('iaf_neuron', 1)
        _nest.Connect(dummy, self._music_spike_output, 'one_to_one',
                      {'music_channel': 10000000})

        # Setup music steering input.
        self._music_steering_input = _nest.Create('music_message_in_proxy', 1)
        _nest.SetStatus(self._music_steering_input,
                        {'port_name': self._steering_port_name,
                         'acceptable_latency': 40.0})
开发者ID:uahic,项目名称:Monsteer,代码行数:31,代码来源:Nesteer.py


示例2: sli_run

def sli_run(parameters=object(),
            fname='microcircuit.sli',
            verbosity='M_ERROR'):
    '''
    Takes parameter-class and name of main sli-script as input, initiating the
    simulation.
    
    Parameters
    ----------
    parameters : object
        parameter class instance
    fname : str
        path to sli codes to be executed
    verbosity : str,
        nest verbosity flag
    
    Returns
    -------
    None
    
    '''
    # Load parameters from params file, and pass them to nest
    # Python -> SLI
    send_nest_params_to_sli(vars(parameters))
    
    #set SLI verbosity
    nest.sli_run("%s setverbosity" % verbosity)
    
    # Run NEST/SLI simulation
    nest.sli_run('(%s) run' % fname)
开发者ID:torbjone,项目名称:hybridLFPy,代码行数:30,代码来源:example_microcircuit.py


示例3: load_libraries

 def load_libraries(self, name, url, **kwargs):  # @UnusedVariable
     install_dir = self.get_install_dir(name, url)
     lib_dir = os.path.join(install_dir, 'lib')
     add_lib_path(lib_dir)
     # Add module install directory to NEST path
     nest.sli_run(
         '({}) addpath'.format(os.path.join(install_dir, 'share', 'sli')))
     # Install nest module
     nest.Install(name + 'Module')
开发者ID:CNS-OIST,项目名称:PyPe9,代码行数:9,代码来源:base.py


示例4: get_help_text

    def get_help_text(self, name):

        nest.sli_run("statusdict /prgdocdir get")
        docdir = nest.sli_pop()

        helptext = "No documentation available"

        for subdir in ["cc", "sli"]:
            filename = os.path.join(docdir, "help", subdir, name + ".hlp")
            if os.path.isfile(filename):
                helptext = open(filename, 'r').read()

        return helptext
开发者ID:DimitriPlotnikov,项目名称:nest-simulator,代码行数:13,代码来源:neuronview.py


示例5: prepare_simulation

def prepare_simulation(master_seed, n_populations):
    """Prepare random generators with master seed."""
    nest.ResetKernel()
    # set global kernel parameters
    nest.SetKernelStatus(
        {"communicate_allgather": sim.allgather,
        "print_time": True, 
        "overwrite_files": False,
        "resolution": sim.dt,
        "total_num_virtual_procs": sim.n_vp})
   
    # Set random seeds
    nest.sli_run('0 << /rngs [%i %i] Range { rngdict/gsl_mt19937 :: exch CreateRNG } Map >> SetStatus'%(
                 master_seed, master_seed + sim.n_vp - 1))
    #nest.SetKernelStatus({"rng_seeds" : range(master_seed, master_seed + sim.n_vp)})
    nest.sli_run('0 << /grng rngdict/gsl_mt19937 :: %i CreateRNG >> SetStatus'%(master_seed + sim.n_vp))
    #nest.SetKernelStatus({"grng_seed" : master_seed + sim.n_vp})
    pyrngs = [np.random.RandomState(s) for s in 
                range(master_seed + sim.n_vp + 1, master_seed + 2 * sim.n_vp + 1)]
    return pyrngs
开发者ID:alfred-s,项目名称:microcircuit,代码行数:20,代码来源:brunel_functions.py


示例6: load_libraries

 def load_libraries(cls, name, install_dir):
     lib_dir = os.path.join(install_dir, 'lib', 'nest')
     if (sys.platform.startswith('linux') or
         sys.platform in ['os2', 'os2emx', 'cygwin', 'atheos',
                          'ricos']):
         lib_path_key = 'LD_LIBRARY_PATH'
     elif sys.platform == 'darwin':
         lib_path_key = 'DYLD_LIBRARY_PATH'
     elif sys.platform == 'win32':
         lib_path_key = 'PATH'
     if lib_path_key in os.environ:
         os.environ[lib_path_key] += os.pathsep + lib_dir
     else:
         os.environ[lib_path_key] = lib_dir
     # Add module install directory to NEST path
     nest.sli_run(
         '({}) addpath'.format(os.path.join(install_dir, 'share', 'nest',
                                            'sli')))
     # Install nest module
     nest.Install(name + 'Module')
开发者ID:tclose,项目名称:PyPe9,代码行数:20,代码来源:base.py


示例7: send_nest_params_to_sli

def send_nest_params_to_sli(p):
    '''
    Read parameters and send them to SLI
    
    Parameters
    ----------
    p : dict
        sli parameter name and value as dictionary key and value pairs
    
    Returns
    -------
    None
    '''
    for name in p.keys():
        value = p[name]
        if type(value) == np.ndarray:
            value = value.tolist()
        if type(value) == dict:
            value = dict_of_numpyarray_to_dict_of_list(value)
        if name == 'neuron_model': # special case as neuron_model is a
                                   # NEST model and not a string
            try:
                nest.sli_run('/'+name)
                nest.sli_push(value)
                nest.sli_run('eval')
                nest.sli_run('def')
            except: 
                print 'Could not put variable %s on SLI stack' % (name)
                print type(value)
        else:
            try:
                nest.sli_run('/'+name)
                nest.sli_push(value)
                nest.sli_run('def')
            except: 
                print 'Could not put variable %s on SLI stack' % (name)
                print type(value)
    return
开发者ID:torbjone,项目名称:hybridLFPy,代码行数:38,代码来源:example_microcircuit.py


示例8: prepare_simulation

def prepare_simulation(master_seed, n_populations):
    """Prepare random generators with master seed."""
    nest.ResetKernel()
    # set global kernel parameters
    nest.SetKernelStatus(
        {"communicate_allgather": sim.allgather,
        "overwrite_files": sim.overwrite_existing_files,
        "resolution": sim.dt,
        "total_num_virtual_procs": sim.n_vp})
    if sim.to_text_file:
        nest.SetKernelStatus({"data_path": data_path_test})
   
    # Set random seeds
    
    # PYNEST
    #nest.sli_run('0 << /rngs [%i %i] Range { rngdict/gsl_mt19937 :: exch CreateRNG } Map >> SetStatus'%(
    #             master_seed, master_seed + sim.n_vp - 1))
    #nest.SetKernelStatus({"rng_seeds" : range(master_seed, master_seed + sim.n_vp)})
    #nest.sli_run('0 << /grng rngdict/gsl_mt19937 :: %i CreateRNG >> SetStatus'%(master_seed + sim.n_vp))
    #nest.SetKernelStatus({"grng_seed" : master_seed + sim.n_vp})
    #pyrngs = [np.random.RandomState(s) for s in 
    #            range(master_seed + sim.n_vp + 1, master_seed + 2 * sim.n_vp + 1)]

    # SLI VERSION
    sli_str  = "0 << \n"
    #sli_str += "/rngs %i [0 %i 1 sub] add Range { rngdict/gsl_mt19937 :: exch CreateRNG } Map\n"%(master_seed, sim.n_vp) # local RNG, seeded
    #sli_str += "/grng rngdict/gsl_mt19937 :: %i %i add CreateRNG\n"%(master_seed, sim.n_vp) # global RNG
    sli_str += "/rng_seeds %i [0 %i 1 sub] add Range\n"%(master_seed, sim.n_vp) # local RNG seeds
    sli_str += "/grng_seed %i %i add\n"%(master_seed, sim.n_vp) # global RNG seed
    sli_str += ">> SetStatus"
    nest.sli_run(sli_str)
    sli_str2  = "/script_rngs [%i]\n"%sim.n_vp
    sli_str2 += "{%i add rngdict /gsl_mt19937 get exch CreateRNG } Table def\n"%(master_seed + sim.n_vp)
    sli_str2 += "/normal_rdvs script_rngs { rdevdict /normal get CreateRDV } Map def"
    nest.sli_run(sli_str2)
    pyrngs = None
    return pyrngs
开发者ID:alfred-s,项目名称:microcircuit,代码行数:37,代码来源:functions_test.py


示例9: _set_verbosity

 def _set_verbosity(self, verbosity):
     nest.sli_run("M_%s setverbosity" % verbosity.upper())
开发者ID:tclose,项目名称:PyPe9,代码行数:2,代码来源:controller.py


示例10: LambertWm1

def LambertWm1(x):
    nest.sli_push(x)
    nest.sli_run('LambertWm1')
    y = nest.sli_pop()
    return y
开发者ID:apeyser,项目名称:nest-simulator,代码行数:5,代码来源:brunel_alpha_nest.py


示例11: test_libcsa_cgnext

    def test_libcsa_cgnext(self):
        """cgnext"""

        nest.ResetKernel()

        w = 10000.0
        d = 1.0
        cs = libcsa.cset(libcsa.oneToOne, w, d)

        nest.sli_push(cs)
        nest.sli_run('dup')
        nest.sli_push(numpy.array([0, 1, 2, 3]))
        nest.sli_push(numpy.array([0, 1, 2, 3]))
        nest.sli_run('cgsetmask')
        nest.sli_run('dup')
        nest.sli_run('cgstart')
        for i in range(4):
            nest.sli_run('dup')
            nest.sli_run('cgnext')
            self.assertEqual(nest.sli_pop(), True)
            self.assertEqual(nest.sli_pop(), d)
            self.assertEqual(nest.sli_pop(), w)
            self.assertEqual(nest.sli_pop(), i)
            self.assertEqual(nest.sli_pop(), i)
        nest.sli_run('cgnext')
        self.assertEqual(nest.sli_pop(), False)
开发者ID:Silmathoron,项目名称:nest-simulator,代码行数:26,代码来源:test_libcsa.py


示例12: libcsaTestCase

from . import compatibility

try:
    import libcsa
    HAVE_LIBCSA = True
except ImportError:
    HAVE_LIBCSA = False

try:
    import numpy
    HAVE_NUMPY = True
except ImportError:
    HAVE_NUMPY = False

nest.sli_run("statusdict/have_libneurosim ::")
HAVE_LIBNEUROSIM = nest.sli_pop()


@nest.check_stack
@unittest.skipIf(not HAVE_LIBCSA, 'Python libcsa package is not available')
@unittest.skipIf(
    not HAVE_LIBNEUROSIM,
    'PyNEST was built without the libneurosim library'
)
class libcsaTestCase(unittest.TestCase):
    """libcsa tests"""

    def test_libcsa_OneToOne_subnet_1d(self):
        """One-to-one connectivity with 1-dim subnets"""
开发者ID:Silmathoron,项目名称:nest-simulator,代码行数:29,代码来源:test_libcsa.py


示例13: len

Create one subdir per number of MPI processes, then move into each subdir, run there.
Afterwards, diff subdirs. Diff should output nothing.

Hans Ekkehard Plesser, 2010-11-03, 2012-11-23
"""

import nest 
import nest.topology as topo
import os
import sys

assert len(sys.argv) == 2, "Usage: topo_mpi_test.py convergent|divergent"

direction = sys.argv[1]

nest.sli_run('M_ERROR setverbosity')
nest.SetKernelStatus({'total_num_virtual_procs': 4})

l1 = topo.CreateLayer({'rows': 10,
                       'columns': 20,
                       'elements': ['iaf_neuron', 2],
                       'edge_wrap': True})

l2 = topo.CreateLayer({'rows': 10,
                       'columns': 20,
                       'elements': ['iaf_neuron', 2],
                       'edge_wrap': True})

topo.ConnectLayers(l1, l2, {'connection_type': direction,
                            'mask': {'circular': {'radius': 0.4}},
                            'weights': {'linear': {'c': 1., 'a': -5.}}})
开发者ID:QJonny,项目名称:CyNest,代码行数:31,代码来源:topo_mpi_test.py


示例14: print

# NEST is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# NEST is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NEST.  If not, see <http://www.gnu.org/licenses/>.

import nest

nest.sli_run("statusdict/have_music ::")
if not nest.spp():
    import sys

    print("NEST was not compiled with support for MUSIC, not running.")
    sys.exit()

mmip = nest.Create('music_message_in_proxy')
nest.SetStatus(mmip, {'port_name': 'msgdata'})

# Simulate and get message data with a granularity of 10 ms:
time = 0
while time < 1000:
    nest.Simulate(10)
    data = nest.GetStatus(mmip, 'data')
    print(data)
开发者ID:apeyser,项目名称:nest-simulator,代码行数:31,代码来源:msgtest.py


示例15: empty_stack

 def empty_stack():
     nest.sli_run('clear')
开发者ID:apeyser,项目名称:nest-simulator,代码行数:2,代码来源:test_helper_functions.py


示例16: setup

def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params):
    """
    Should be called at the very beginning of a script.
    extra_params contains any keyword arguments that are required by a given
    simulator but not by others.
    """
    global tempdir
    
    common.setup(timestep, min_delay, max_delay, **extra_params)
    
    if 'verbosity' in extra_params:
        nest_verbosity = extra_params['verbosity'].upper()
    else:
        nest_verbosity = "WARNING"
    nest.sli_run("M_%s setverbosity" % nest_verbosity)
    
    if "spike_precision" in extra_params:
        simulator.state.spike_precision = extra_params["spike_precision"]
        if extra_params["spike_precision"] == 'off_grid':
            simulator.state.default_recording_precision = 15
    nest.SetKernelStatus({'off_grid_spiking': simulator.state.spike_precision=='off_grid'})
    if "recording_precision" in extra_params:
        simulator.state.default_recording_precision = extra_params["recording_precision"]
    
    
    # clear the sli stack, if this is not done --> memory leak cause the stack increases
    nest.sr('clear')
    
    # reset the simulation kernel
    nest.ResetKernel()
    
    # all NEST to erase previously written files (defaut with all the other simulators)
    nest.SetKernelStatus({'overwrite_files' : True})
    
    # set tempdir
    tempdir = tempfile.mkdtemp()
    tempdirs.append(tempdir) # append tempdir to tempdirs list
    nest.SetKernelStatus({'data_path': tempdir,})

    # set kernel RNG seeds
    num_threads = extra_params.get('threads') or 1
    if 'rng_seeds' in extra_params:
        rng_seeds = extra_params['rng_seeds']
    else:
        rng_seeds_seed = extra_params.get('rng_seeds_seed') or 42
        rng = NumpyRNG(rng_seeds_seed)
        rng_seeds = (rng.rng.uniform(size=num_threads*num_processes())*100000).astype('int').tolist() 
    logger.debug("rng_seeds = %s" % rng_seeds)
    nest.SetKernelStatus({'local_num_threads': num_threads,
                          'rng_seeds'        : rng_seeds})

    # set resolution
    nest.SetKernelStatus({'resolution': float(timestep)})

    # Set min_delay and max_delay for all synapse models
    for synapse_model in NEST_SYNAPSE_TYPES:
        nest.SetDefaults(synapse_model, {'delay'    : float(min_delay),
                                         'min_delay': float(min_delay),
                                         'max_delay': float(max_delay)})
    simulator.reset()
    
    return rank()
开发者ID:agravier,项目名称:pynn,代码行数:62,代码来源:__init__.py


示例17:

import nest
import nest.topology as topo
## Initialising module
nest.sli_run("topology using")
## Create layers
layer = topo.CreateLayer({"rows": 3,
"columns": 4,
"extent": [1.0, 1.0],
"elements": "iaf_neuron"})
nest.PrintNetwork(1, layer)

layer_settings = {"rows": 9,
"columns": 8,
"extent": [4.0, 5.0],
"center": [1.0, -1.0],
"elements": "iaf_neuron",
"edge_wrap": False}
source = topo.CreateLayer(layer_settings)
layer_settings["extent"] = [2.0, 2.0]
target = topo.CreateLayer(layer_settings)
## Connect layers
connection_settings = {"connection_type": "convergent",
"mask": {"circular": {"radius": 2.0}},
"weights": 1.0,
"synapse_model": "static_synapse"}
topo.ConnectLayer(source, target, connection_settings)

开发者ID:animesh,项目名称:scripts,代码行数:26,代码来源:nest_topo_ex.py


示例18: len

Create one subdir per number of MPI processes, then move into each subdir,
run there. Afterwards, diff subdirs. Diff should output nothing.

Hans Ekkehard Plesser, 2010-11-03, 2012-11-23
"""

import nest
import nest.topology as topo
import os
import sys

assert len(sys.argv) == 2, "Usage: topo_mpi_test.py convergent|divergent"

direction = sys.argv[1]

nest.sli_run("M_ERROR setverbosity")
nest.SetKernelStatus({"total_num_virtual_procs": 4})

l1 = topo.CreateLayer({"rows": 10, "columns": 20, "elements": ["iaf_neuron", 2], "edge_wrap": True})

l2 = topo.CreateLayer({"rows": 10, "columns": 20, "elements": ["iaf_neuron", 2], "edge_wrap": True})

topo.ConnectLayers(
    l1,
    l2,
    {"connection_type": direction, "mask": {"circular": {"radius": 0.4}}, "weights": {"linear": {"c": 1.0, "a": -5.0}}},
)

topo.DumpLayerNodes(l1 + l2, "topo_mpi_test.lyr_tmp")
topo.DumpLayerConnections(l1, "static_synapse", "topo_mpi_test.cnn_tmp")
开发者ID:HBPNeurorobotics,项目名称:nest-simulator,代码行数:30,代码来源:topo_mpi_test.py


示例19: create_nodes

def create_nodes(model, pyrngs):
    """
        Creates the following GIDs:
        neuron_GIDs
        ext_poisson
        ext_dc
        th_parrots
        th_poisson
        spike_detectors
        multimeters
        th_spike_detector
    
        Further initializes the neurons" membrane potentials.
    """
    neuron_GIDs     = []
    spike_detectors = []
    multimeters     = []
    ext_poisson     = []
    ext_dc          = []
    print(data_path_test)
    Vm0_file = open(os.path.join(data_path_test, "Vm0_pynest"), "w")
    for pop_index, population in enumerate(model.populations):
        # Neurons
        neuron_GIDs.append(nest.Create(model.neuron_model, model.n_neurons[pop_index], params=model.model_params))
        # Initialize membrane potentials locally
        # drawn from normal distribution with mu=Vm0_mean, sigma=Vm0_std
        neurons_info    = nest.GetStatus(neuron_GIDs[pop_index])
        for ni in neurons_info:                 
            if ni["local"]:                         # only adapt local nodes
                sli_str3 = "%i << /V_m normal_rdvs %i get Random %.1f mul %.1f add >> SetStatus"%(ni["global_id"], ni["vp"], model.Vm0_std, model.Vm0_mean)
                nest.sli_run(sli_str3)
                Vm_init = nest.GetStatus([ni["global_id"]])[0]["V_m"]
                #Vm_init = pyrngs[ni["vp"]].normal(model.Vm0_mean, model.Vm0_std)
                #nest.SetStatus([ni["global_id"]], {"V_m": Vm_init})
                Vm0_file.write(str(ni["global_id"]) + "\t" + str(Vm_init) + "\n")

        # Devices
        if sim.record_cortical_spikes:
            spike_detector_dict = {"label": sim.spike_detector_label + population + "_", 
                                    "to_file": sim.to_text_file}
            spike_detectors.append(nest.Create("spike_detector", 1, params=spike_detector_dict))

        if sim.record_voltage:
            multimeter_dict = {"label": sim.multimeter_label + population + "_", 
                                "to_file": sim.to_text_file, 
                                "start": sim.t_rec_volt_start,   
                                #"stop": sim.t_rec_volt_stop, 
                                "interval": 1.0, # ms
                                "withtime": True, 
                                "record_from": ["V_m"]}
            multimeters.append(nest.Create("multimeter", 1, params=multimeter_dict))
        
        # External input
        # One poisson generator per population. 
        #Rate is determined by base rate times in-degree[population]
        ext_poisson_params = {"rate": model.rate_ext * model.C_aext[pop_index]}
        ext_poisson.append(nest.Create("poisson_generator", 1, params=ext_poisson_params))
        # One dc generator per population. 
        # Amplitude is determined by base amplitude times in-degree[population]
        ext_dc_params = {"amplitude": model.dc_amplitude * model.C_aext[pop_index]}
        ext_dc.append(nest.Create("dc_generator", 1, params=ext_dc_params))
        
    # Thalamic neurons: parrot neurons and Poisson bg
    if not model.n_th == 0:
        th_parrots  = nest.Create("parrot_neuron", model.n_th, params=None)
        th_poisson  = nest.Create("poisson_generator", 1, 
            params={"rate": model.th_rate, 
                "start": model.th_start, 
                "stop": model.th_start + model.th_duration})
        if sim.record_thalamic_spikes:
            th_spike_detector_dict = {"label": sim.th_spike_detector_label, 
                                    "to_file": sim.to_text_file}
            th_spike_detector  = nest.Create("spike_detector", 1, params=th_spike_detector_dict)
        else:
            th_spike_detector = None
    else:
        th_parrots, th_poisson, th_spike_detector = (None, None, None)


    Vm0_file.close()
        
    return (neuron_GIDs, 
            spike_detectors, multimeters,
            ext_poisson, ext_dc, 
            th_parrots, th_poisson, th_spike_detector)
开发者ID:alfred-s,项目名称:microcircuit,代码行数:85,代码来源:functions_test.py



注:本文中的nest.sli_run函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python nester.print_lol函数代码示例发布时间:2022-05-27
下一篇:
Python nest.set_verbosity函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap