| 166 | | # manner to speed up the thing. The only problem that will arise is the headers, |
|---|
| 167 | | # that should be taken into account to be really clean. Otherwise, if the # symbol |
|---|
| 168 | | # is escaped while reading the file, there is no problem |
|---|
| | 166 | # manner to speed up the thing. The only problem that will arise is the headers, |
|---|
| | 167 | # that should be taken into account to be really clean. Otherwise, if the # symbol |
|---|
| | 168 | # is escaped while reading the file, there is no problem |
|---|
| 173 | | if gather == True and num_processes()> 1: |
|---|
| 174 | | root_file = file or self.filename |
|---|
| 175 | | for node in xrange(num_processes()): |
|---|
| 176 | | if rank()==0: |
|---|
| 177 | | node_file = root_file + '.%d' % node |
|---|
| 178 | | if os.path.exists(node_file): |
|---|
| 179 | | system_line = 'cat %s >> %s' % (node_file, root_file) |
|---|
| 180 | | os.system(system_line) |
|---|
| 181 | | system_line = 'rm %s' %node_file |
|---|
| 182 | | os.system(system_line) |
|---|
| | 173 | if gather == True and num_processes() > 1: |
|---|
| | 174 | root_file = file or self.filename |
|---|
| | 175 | for node in xrange(num_processes()): |
|---|
| | 176 | if rank()==0: |
|---|
| | 177 | node_file = root_file + '.%d' % node |
|---|
| | 178 | if os.path.exists(node_file): |
|---|
| | 179 | system_line = 'cat %s >> %s' % (node_file, root_file) |
|---|
| | 180 | os.system(system_line) |
|---|
| | 181 | system_line = 'rm %s' % node_file |
|---|
| | 182 | os.system(system_line) |
|---|
| 879 | | |
|---|
| 880 | | ## Routine to give an average firing rate over all the threads/nodes |
|---|
| 881 | | ## This is a rough approximation, because in fact each nodes is only multiplying |
|---|
| 882 | | ## the frequency of the recorders by the number of processes. To do better, we need a MPI |
|---|
| 883 | | ## package to send informations to node 0. Nevertheless, it works for threaded mode |
|---|
| 884 | | node_list = range(nest.GetStatus([0], "total_num_virtual_procs")[0]) |
|---|
| 885 | | n_spikes = 0 |
|---|
| 886 | | for node in node_list: |
|---|
| 887 | | nest.sps(self.recorders['spikes']._device[0]) |
|---|
| 888 | | nest.sr("%d GetAddress %d append" %(self.recorders['spikes']._device[0], node)) |
|---|
| 889 | | nest.sr("GetStatus /n_events get") |
|---|
| 890 | | n_spikes += nest.spp() |
|---|
| | 879 | |
|---|
| | 880 | ## Routine to give an average firing rate over all the threads/nodes |
|---|
| | 881 | ## This is a rough approximation, because in fact each nodes is only multiplying |
|---|
| | 882 | ## the frequency of the recorders by the number of processes. To do better, we need a MPI |
|---|
| | 883 | ## package to send informations to node 0. Nevertheless, it works for threaded mode |
|---|
| | 884 | node_list = range(nest.GetStatus([0], "total_num_virtual_procs")[0]) |
|---|
| | 885 | n_spikes = 0 |
|---|
| | 886 | for node in node_list: |
|---|
| | 887 | nest.sps(self.recorders['spikes']._device[0]) |
|---|
| | 888 | nest.sr("%d GetAddress %d append" %(self.recorders['spikes']._device[0], node)) |
|---|
| | 889 | nest.sr("GetStatus /n_events get") |
|---|
| | 890 | n_spikes += nest.spp() |
|---|