Skip to content

Commit

Permalink
Merge branch 'release/18.03.00'
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvierjahn committed Mar 29, 2018
2 parents c7fe9ee + 8a548c2 commit 289956a
Show file tree
Hide file tree
Showing 89 changed files with 3,658 additions and 795 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ build*
BUILD*
.dir-locals.el
*.pyc
TAGS
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ include(GenerateExportHeader)

include(py.test)

include(python_module)

include(WarningLevels)

find_package(Conduit)
Expand Down
93 changes: 93 additions & 0 deletions cmake/python_module.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#-------------------------------------------------------------------------------
# nest in situ vis
#
# Copyright (c) 2017-2018 RWTH Aachen University, Germany,
# Virtual Reality & Immersive Visualisation Group.
#-------------------------------------------------------------------------------
# License
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#-------------------------------------------------------------------------------

function(ADD_PYTHON_MODULE)
# parse arguments
set(options )
set(oneValueArgs NAME OUTPUT_DIRECTORY)
set(multiValueArgs
SOURCES HEADERS PYTHON_SOURCES INCLUDE_DIRECTORIES LINK_LIBRARIES)
cmake_parse_arguments(ADD_PYTHON_MODULE
"${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

python_add_module(${ADD_PYTHON_MODULE_NAME}
${ADD_PYTHON_MODULE_SOURCES}
${ADD_PYTHON_MODULE_HEADERS}
)

target_include_directories(${ADD_PYTHON_MODULE_NAME}
PRIVATE ${Boost_INCLUDE_DIRS}
PRIVATE ${PYTHON_INCLUDE_DIRS}
${ADD_PYTHON_MODULE_INCLUDE_DIRECTORIES}
)

target_link_libraries(${ADD_PYTHON_MODULE_NAME}
${Boost_LIBRARIES}
${PYTHON_LIBRARIES}
${ADD_PYTHON_MODULE_LINK_LIBRARIES}
)

set_warning_levels_RWTH(${ADD_PYTHON_MODULE_NAME}
SUPPRESS_WARNINGS_HEADER ${CMAKE_CURRENT_BINARY_DIR}/include/pyniv/suppress_warnings.hpp
)

add_test_cpplint(NAME "${ADD_PYTHON_MODULE_NAME}--cpplint"
${ADD_PYTHON_MODULE_SOURCES}
${ADD_PYTHON_MODULE_HEADERS}
)

add_custom_command(TARGET ${ADD_PYTHON_MODULE_NAME}
POST_BUILD
#OUTPUT ${ADD_PYTHON_MODULE_OUTPUT_DIRECTORY}/$<TARGET_FILE_NAME:${ADD_PYTHON_MODULE_NAME}>
#DEPENDS $<TARGET_FILE:${ADD_PYTHON_MODULE_NAME}>
COMMAND ${CMAKE_COMMAND}
-E copy_if_different
$<TARGET_FILE:${ADD_PYTHON_MODULE_NAME}>
${ADD_PYTHON_MODULE_OUTPUT_DIRECTORY}/$<TARGET_FILE_NAME:${ADD_PYTHON_MODULE_NAME}>
)

foreach (ADD_PYTHON_MODULE_PYTHON_INPUT ${ADD_PYTHON_MODULE_PYTHON_SOURCES})
get_filename_component(ADD_PYTHON_MODULE_PYTHON_INPUT_NAME
${ADD_PYTHON_MODULE_PYTHON_INPUT}
NAME)
set(ADD_PYTHON_MODULE_PYTHON_OUTPUT
"${ADD_PYTHON_MODULE_OUTPUT_DIRECTORY}/${ADD_PYTHON_MODULE_PYTHON_INPUT_NAME}"
)
set(ADD_PYTHON_MODULE_CUSTOM_TARGET_NAME
"${ADD_PYTHON_MODULE_NAME}_COPY_${ADD_PYTHON_MODULE_PYTHON_INPUT_NAME}"
)
add_custom_command(
OUTPUT ${ADD_PYTHON_MODULE_PYTHON_OUTPUT}
DEPENDS ${ADD_PYTHON_MODULE_PYTHON_INPUT}
COMMAND ${CMAKE_COMMAND}
-E copy_if_different
${ADD_PYTHON_MODULE_PYTHON_INPUT}
${ADD_PYTHON_MODULE_PYTHON_OUTPUT}
)
add_custom_target(${ADD_PYTHON_MODULE_CUSTOM_TARGET_NAME}
DEPENDS
${ADD_PYTHON_MODULE_PYTHON_OUTPUT}
)
add_dependencies(${ADD_PYTHON_MODULE_NAME}
${ADD_PYTHON_MODULE_CUSTOM_TARGET_NAME}
)
endforeach(ADD_PYTHON_MODULE_PYTHON_INPUT)
endfunction()
3 changes: 2 additions & 1 deletion demo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
# limitations under the License.
#-------------------------------------------------------------------------------

add_subdirectory(nest_python_vis)
add_subdirectory(arbor_miniapp-niv)
add_subdirectory(brunel_example)
add_subdirectory(nest_python_vis)
35 changes: 35 additions & 0 deletions demo/arbor_miniapp-niv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#-------------------------------------------------------------------------------
# nest in situ vis
#
# Copyright (c) 2017-2018 RWTH Aachen University, Germany,
# Virtual Reality & Immersive Visualisation Group.
#-------------------------------------------------------------------------------
# License
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#-------------------------------------------------------------------------------

set(PYTHON_DUMP_SOURCE dump_to_stdout.py)
set(PYTHON_VIS_SOURCE vis.py)

if(NOT CMAKE_MAKE_PROGRAM STREQUAL "/usr/bin/xcodebuild")

file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/run_dump.sh
CONTENT "PYTHONPATH=${PYNIV_OUTPUT_DIR}/..:$<TARGET_FILE_DIR:pytest_utilities> ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${PYTHON_DUMP_SOURCE}"
)

file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/run_vis.sh
CONTENT "PYTHONPATH=${PYNIV_OUTPUT_DIR}/..:$<TARGET_FILE_DIR:pytest_utilities> ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${PYTHON_VIS_SOURCE}"
)

endif()
92 changes: 92 additions & 0 deletions demo/arbor_miniapp-niv/dump_to_stdout.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#-------------------------------------------------------------------------------
# nest in situ vis
#
# Copyright (c) 2017-2018 RWTH Aachen University, Germany,
# Virtual Reality & Immersive Visualisation Group.
#-------------------------------------------------------------------------------
# License
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#-------------------------------------------------------------------------------

import sys

import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns

import pyniv

from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QGridLayout, QPushButton
from PyQt5.QtCore import QTimer

class MainWindow:
def __init__(self):
self.SetupStreaming()
self.SetupWindow()
self.SetupUpdateTimer()

def SetupStreaming(self):
self.receiver = pyniv.consumer.Receiver()

self.multimeter = pyniv.consumer.ArborMultimeter("multimeter")

self.backend = pyniv.consumer.Backend();
self.backend.Connect(self.receiver);
self.backend.Connect(self.multimeter);

def SetupWindow(self):
self.print_button = QPushButton("Print")
self.print_button.clicked.connect(self.PrintButtonClicked)

def SetupUpdateTimer(self):
self.update_timer = QTimer()
self.update_timer.timeout.connect(self.Receive)
self.update_timer.start(1)

def PrintButtonClicked(self):
print 60 * '='
timesteps = self.multimeter.GetTimestepsString()
for t in timesteps:
print 't = {}'.format(t)
attributes = self.multimeter.GetAttributes(t)
for a in attributes:
values = self.multimeter.GetTimestepData(t, a)
print a + ': ' + ', '.join(['{}'.format(v) for v in values])
print 40 * '-'

def Show(self):
self.print_button.show()
button_geometry = self.print_button.geometry()
self.print_button.setGeometry(
0, 0,
button_geometry.width(),
button_geometry.height())

def Receive(self):
self.backend.Receive()

def Dump(self):
print("DUMP")


def main(argv):
app = QApplication(argv)

w = MainWindow()
w.Show()

return app.exec_()

if __name__ == "__main__":
main(sys.argv)
112 changes: 112 additions & 0 deletions demo/arbor_miniapp-niv/vis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#-------------------------------------------------------------------------------
# nest in situ vis
#
# Copyright (c) 2017-2018 RWTH Aachen University, Germany,
# Virtual Reality & Immersive Visualisation Group.
#-------------------------------------------------------------------------------
# License
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#-------------------------------------------------------------------------------

import sys

import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns

import pyniv

from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QGridLayout, QPushButton
from PyQt5.QtCore import QTimer

class MainWindow:
def __init__(self):
self.SetupStreaming()
self.SetupWindow()
self.SetupPlot()
self.SetupUpdateTimer()

def SetupStreaming(self):
self.receiver = pyniv.consumer.Receiver()

self.multimeter = pyniv.consumer.ArborMultimeter("multimeter")

self.backend = pyniv.consumer.Backend();
self.backend.Connect(self.receiver);
self.backend.Connect(self.multimeter);

def SetupWindow(self):
self.visualize_button = QPushButton("Visualize")
self.visualize_button.clicked.connect(self.VisualizeButtonClicked)

def SetupUpdateTimer(self):
self.update_timer = QTimer()
self.update_timer.timeout.connect(self.Visualize)

def SetupPlot(self):
sns.set_style("darkgrid")
self.fig = plt.figure()
self.ax1 = self.fig.add_subplot(1,1,1)


def VisualizeButtonClicked(self):
self.visualize_button.setEnabled(False)
self.update_timer.start(250)
self.Visualize()

def Show(self):
self.visualize_button.show()
button_geometry = self.visualize_button.geometry()
self.visualize_button.setGeometry(
0, 0,
button_geometry.width(),
button_geometry.height())

def Visualize(self):
self.backend.Receive()
self.Plot();

def Plot(self):
timesteps = self.multimeter.GetTimestepsString()
attribute = 'v'
neuron_ids = []
if len(timesteps) > 0:
neuron_ids = self.multimeter.GetNeuronIds(timesteps[0], attribute)

self.ax1.clear()

for neuron_id in neuron_ids:
values = self.multimeter.GetTimeSeriesData(attribute, neuron_id)
times = [float(t) for t in timesteps]
self.ax1.plot(times, values)

self.ax1.set_title("Arbor Miniapp Niv Example")
self.ax1.set_xlabel("Time")
self.ax1.set_ylabel("v")
self.ax1.set_ylim([-80,50])

plt.show(block=False)
self.fig.canvas.draw()


def main(argv):
app = QApplication(argv)

w = MainWindow()
w.Show()

return app.exec_()

if __name__ == "__main__":
main(sys.argv)
9 changes: 7 additions & 2 deletions demo/brunel_example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,25 @@
#-------------------------------------------------------------------------------

set(NEST_PYTHON_VIS_SOURCE nest_python_vis.py)
set(NEST_PYTHON_DUMP_SOURCE dump_to_stdout.py)
set(NEST_SIM_SOURCE nest_sim.py)

if(NOT CMAKE_MAKE_PROGRAM STREQUAL "/usr/bin/xcodebuild")

file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/run_vis.sh
CONTENT "PYTHONPATH=$<TARGET_FILE_DIR:pyniv>:$<TARGET_FILE_DIR:pytest_utilities> ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${NEST_PYTHON_VIS_SOURCE}"
CONTENT "PYTHONPATH=${PYNIV_OUTPUT_DIR}/..:$<TARGET_FILE_DIR:pytest_utilities> ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${NEST_PYTHON_VIS_SOURCE}"
)

file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/run_dump.sh
CONTENT "PYTHONPATH=${PYNIV_OUTPUT_DIR}/..:$<TARGET_FILE_DIR:pytest_utilities> ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${NEST_PYTHON_DUMP_SOURCE}"
)

set(NEST_DIR
CACHE PATH "Path to installed nest")
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/run_sim.sh
CONTENT
"source ${NEST_DIR}/bin/nest_vars.sh
PYTHONPATH=$<TARGET_FILE_DIR:pyniv>:$PYTHONPATH ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${NEST_SIM_SOURCE}"
PYTHONPATH=${PYNIV_OUTPUT_DIR}/..:$PYTHONPATH ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${NEST_SIM_SOURCE}"
)

endif()
Loading

0 comments on commit 289956a

Please sign in to comment.