Changeset 1033 for branches

Show
Ignore:
Timestamp:
12/14/11 10:39:33 (5 months ago)
Author:
apdavison
Message:

In neo_output branch, made some fixes to the nest backend to improve its behaviour on calling reset()

Location:
branches/neo_output
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • branches/neo_output/examples/reset_example.py

    r1032 r1033  
    33""" 
    44 
    5 import pyNN.neuron as sim  # can of course replace `neuron` with `nest`, `brian`, etc. 
     5from pyNN.utility import get_script_args 
     6#import pyNN.neuron as sim  # can of course replace `neuron` with `nest`, `brian`, etc. 
     7simulator_name = get_script_args(1)[0]   
     8exec("import pyNN.%s as sim" % simulator_name) 
    69import matplotlib.pyplot as plt 
    710from quantities import nA 
     
    3134plt.xlabel("Time (%s)" % vm.times.units._dimensionality) 
    3235plt.ylabel("Membrane potential (%s)" % vm.units._dimensionality) 
    33 plt.savefig("reset_example.png") 
     36plt.savefig("reset_example_%s.png" % simulator_name) 
  • branches/neo_output/src/nest/__init__.py

    r1026 r1033  
    189189    assembly_class = Assembly 
    190190 
     191    def __init__(self, size, cellclass, cellparams=None, structure=None, 
     192                 label=None): 
     193        __doc__ = common.Population.__doc__ 
     194        super(Population, self).__init__(size, cellclass, cellparams, structure, label) 
     195        self._simulator.populations.append(self) 
     196     
    191197    def _get_view(self, selector, label=None): 
    192198        return PopulationView(self, selector, label) 
  • branches/neo_output/src/nest/electrodes.py

    r991 r1033  
    4646            amplitude -- pulse amplitude in nA 
    4747        """ 
    48         self.amplitude = amplitude 
     48        self._amplitude = amplitude 
     49        self._start = start 
     50        self._stop = stop 
    4951        self._device = nest.Create('dc_generator') 
    5052        nest.SetStatus(self._device, {'amplitude': 1000.0*self.amplitude, 
     
    5254        if stop: 
    5355            nest.SetStatus(self._device, {'stop': float(stop)}) 
     56 
     57    def _set_amplitude(self, value): 
     58        self._amplitude = value 
     59        nest.SetStatus(self._device, {'amplitude': 1000.0*value}) 
     60    amplitude = property(fget=lambda self: self._amplitude, fset=_set_amplitude) 
     61     
     62    def _set_start(self, value): 
     63        self._start = value 
     64        nest.SetStatus(self._device, {'start': float(value)}) 
     65    start = property(fget=lambda self: self._start, fset=_set_start) 
     66     
     67    def _set_stop(self, value): 
     68        self._stop = value 
     69        if value is not None: 
     70            nest.SetStatus(self._device, {'stop': float(value)}) 
     71    stop = property(fget=lambda self: self._stop, fset=_set_stop) 
    5472 
    5573 
  • branches/neo_output/src/nest/recording.py

    r1032 r1033  
    414414                ids = self.filter_recorded(variable, filter_ids) 
    415415                data = self._multimeter.get_data(variable, ids) 
     416                signal_array = numpy.vstack(data.values()) 
    416417                segment.analogsignalarrays.append( 
    417418                    neo.AnalogSignalArray( 
    418                         data.T, 
     419                        signal_array.T, 
    419420                        units=recording.UNITS_MAP.get(variable, 'dimensionless'), 
    420421                        t_start=simulator.state.t_start*pq.ms, 
     
    422423                        name=variable, 
    423424                        source_population=self.population.label, 
    424                         source_ids=numpy.fromiter(ids, dtype=int)) 
     425                        source_ids=numpy.array(data.keys())) 
    425426                ) 
    426427        return segment 
  • branches/neo_output/src/nest/simulator.py

    r1032 r1033  
    3737recording_devices = [] 
    3838recorders = set([]) 
     39populations = [] # needed for reset 
    3940 
    4041global net 
     
    9091    """Advance the simulation for a certain time.""" 
    9192    for device in recording_devices: 
    92         device.connect_to_cells() 
     93        if not device._connected: 
     94            device.connect_to_cells() 
    9395    if not state.running: 
    9496        simtime += state.dt # we simulate past the real time by one time step, otherwise NEST doesn't give us all the recorded data 
     
    9799     
    98100def reset(): 
     101    global populations 
    99102    nest.ResetNetwork() 
    100103    nest.SetKernelStatus({'time': 0.0}) 
     104    for p in populations: 
     105        for variable, initial_value in p.initial_values.items(): 
     106            p._set_initial_value_array(variable, initial_value) 
    101107    state.running = False 
    102108    state.t_start = 0.0