Skip to content
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# RAVEN related stuff
raven/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
28 changes: 28 additions & 0 deletions examples/raven_project_definition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# %% Import Raven
import pyraven as raven
import os

# %% [markdown] Set Project file
# The path to the Raven project file to be used
# Note that the path handling needs to be compliant with Winodws directory
# conventions. Using the absolute path to the project file is recommended.
# %%
project = raven.RavenProject(
os.path.abspath('../raven/RavenInput/Classroom/Classroom.rpf'))
# %% [markdown]
# Set the path to the RavenConsole binary, that is the main Raven application.
# Required since the RavenConsole is usually not located in the path directory.
# %%
project._set_binary('../raven/bin64/RavenConsole64.exe')

# %% Properties
# Check if Raven will generate an omnidirecitonal room impulse response.
project.generate_rir

# %% CAD Model
# Check the path to the CAD model.
project.model
# %% Run
# Start the simulation by using the run method
project.run()
# %%
91 changes: 60 additions & 31 deletions pyraven/pyraven.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

"""Main module."""

import sys
import os
from subprocess import call
import subprocess
import shutil
import platform
from configparser import ConfigParser
Expand Down Expand Up @@ -38,7 +39,8 @@ def center_frequencies_octaves():
frequencies : ndarray, float
The eleven octave center frequencies
"""
frequencies = np.array([31.5, 63, 125, 250, 500, 1e3, 2e3, 4e3, 8e3, 16e3])
frequencies = np.array([
31.5, 63, 125, 250, 500, 1e3, 2e3, 4e3, 8e3, 16e3])
return frequencies


Expand All @@ -50,9 +52,10 @@ def center_frequencies_third_octaves():
frequencies : ndarray, float
The 31 third octave center frequencies
"""
frequencies = np.array([20, 25, 31.5, 40, 50, 63, 80, 100, 125, 160, 200, 250,
315, 400, 500, 630, 800, 1000, 1250, 1600, 2000, 2500,
3150, 4000, 5000, 6300, 8e3, 10e3, 12.5e3, 16e3, 20e3])
frequencies = np.array([
20, 25, 31.5, 40, 50, 63, 80, 100, 125, 160, 200, 250,
315, 400, 500, 630, 800, 1000, 1250, 1600, 2000, 2500,
3150, 4000, 5000, 6300, 8e3, 10e3, 12.5e3, 16e3, 20e3])
return frequencies


Expand Down Expand Up @@ -145,9 +148,9 @@ def generate_rir(self):
@generate_rir.setter
def generate_rir(self, value):
if value:
value = 1
value = '1'
else:
value = 0
value = '0'
self._config.set('Global', 'generaterir', value)

@property
Expand All @@ -157,9 +160,9 @@ def generate_brir(self):
@generate_brir.setter
def generate_rir(self, value):
if value:
value = 1
value = '1'
else:
value = 0
value = '0'
self._config.set('Global', 'generateabrir', value)

# export Filter ( 1 yes 0 no) =
Expand All @@ -183,9 +186,9 @@ def export_wall_hit_log(self):
@export_wall_hit_log.setter
def export_wall_hit_log(self, value):
if value:
value = 1
value = '1'
else:
value = 0
value = '0'
self._config.set('Global', 'exportwallhitlist', value)

# export plane wave lists =
Expand All @@ -200,9 +203,9 @@ def keep_output_files(self):
@keep_output_files.setter
def keep_output_files(self, value):
if value:
value = 1
value = '1'
else:
value = 0
value = '0'
self._config.set('Global', 'keepoutputfiles', value)

# generateISHOA = 0
Expand All @@ -213,9 +216,9 @@ def generate_image_sources_ambisonics(self):
@generate_image_sources_ambisonics.setter
def generate_image_sources_ambisonics(self, value):
if value:
value = 1
value = '1'
else:
value = 0
value = '0'
self._config.set('Global', 'generateishoa', value)

# generateRTHOA = 0
Expand All @@ -226,9 +229,9 @@ def generate_rt_ambisonics(self):
@generate_rt_ambisonics.setter
def generate_rt_ambisonics(self, value):
if value:
value = 1
value = '1'
else:
value = 0
value = '0'
self._config.set('Global', 'generaterthoa', value)

# ----------------------------------------------------------------------- #
Expand Down Expand Up @@ -328,39 +331,51 @@ def source_positions(self, source_position):

@property
def receiver_positions(self):
receiver_pos_string = self._config.get('Receiver',
'receiverpositions')
receiver_pos_string = self._config.get(
'Receiver',
'receiverpositions')
receiver_positions = coordinate_string_to_array(receiver_pos_string)
return receiver_positions

@receiver_positions.setter
def receiver_positions(self, receiver_positions):
receiver_pos_string = coordinate_array_to_string(receiver_positions)
self._config.set('Receiver', 'receiverpositions', receiver_pos_string)
self._config.set(
'Receiver',
'receiverpositions',
receiver_pos_string)

@property
def receiver_up_vector(self):
string = self._config.get('Receiver',
'receiverupvector')
string = self._config.get(
'Receiver',
'receiverupvector')
value = coordinate_string_to_array(string)
return value

@receiver_up_vector.setter
def receiver_up_vector(self, value):
string = coordinate_array_to_string(value)
self._config.set('Receiver', 'receiverupvector', string)
self._config.set(
'Receiver',
'receiverupvector',
string)

@property
def receiver_view_vector(self):
string = self._config.get('Receiver',
'receiverviewvector')
string = self._config.get(
'Receiver',
'receiverviewvector')
value = coordinate_string_to_array(string)
return value

@receiver_view_vector.setter
def receiver_view_vector(self, value):
string = coordinate_array_to_string(value)
self._config.set('Receiver', 'receiverviewvector', string)
self._config.set(
'Receiver',
'receiverviewvector',
string)

# number of receivers =
# numberReceivers = 1
Expand Down Expand Up @@ -457,21 +472,24 @@ def filter_length_detection_sphere(self, value):
def time_resolution_detection_sphere(self):
"""Time resolution of the detection sphere in milliseconds
"""
return self._config.get('RayTracing', 'timeresolution_detectionsphere')
return self._config.get(
'RayTracing', 'timeresolution_detectionsphere')

@time_resolution_detection_sphere.setter
def time_resolution_detection_sphere(self, value):
if (not isinstance(value, int)) or value <= 0:
raise ValueError(
"Input has to be a natural number bigger than zero")

self._config.set('RayTracing', 'timeresolution_detectionsphere', value)
self._config.set(
'RayTracing', 'timeresolution_detectionsphere', value)

@property
def resolution_azimuth_detection_sphere(self):
"""Resolution of the detection sphere in azimuth."""
return self._config.get('RayTracing',
'resolutionAzimuth_DetectionSphere')
return self._config.get(
'RayTracing',
'resolutionAzimuth_DetectionSphere')

@resolution_azimuth_detection_sphere.setter
def resolution_azimuth_detection_sphere(self, value):
Expand Down Expand Up @@ -568,7 +586,18 @@ def run(self):
binary_dir = os.path.dirname(os.path.realpath(self._binary))
os.chdir(binary_dir)
try:
call([self._binary, self._filename])
print("Running RAVEN")
print('Project file: ' + self._filename)
with subprocess.Popen(
[self._binary, self._filename],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
bufsize=1,
universal_newlines=True) as process:

for line in process.stdout:
print(line, end='')

except OSError:
print('Error calling RAVEN. Simulation failed.')
os.chdir(cwd)
18 changes: 9 additions & 9 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
numpy
pandas
h5py
pip==9.0.1
bumpversion==0.5.3
wheel==0.30.0
watchdog==0.8.3
flake8==3.5.0
tox==2.9.1
coverage==4.4.2
Sphinx==1.6.5
twine==1.9.1
pip
bumpversion
wheel
watchdog
flake8
tox
coverage
Sphinx
twine