Skip to content

Commit

Permalink
[python] Restructure source folder
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashienzsch committed Aug 22, 2024
1 parent fe4ff63 commit 7e415b1
Show file tree
Hide file tree
Showing 61 changed files with 100 additions and 101 deletions.
2 changes: 1 addition & 1 deletion data/models/ProStudio/model.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions run_2d.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ duration=0.050
rm -rf "$sim_dir"

# Generate model
cd "$python_dir"
python -m sim2d.fdtd --verbose --save --data_dir="$sim_dir" --duration="$duration" --fmax="$fmax"
python -m pffdtd.sim2d.fdtd --verbose --save --data_dir="$sim_dir" --duration="$duration" --fmax="$fmax"

# Run sim
DPCPP_CPU_PLACES=cores DPCPP_CPU_CU_AFFINITY=spread DPCPP_CPU_NUM_CUS=16 "$engine_exe" -s "$sim_dir/sim.h5"
24 changes: 12 additions & 12 deletions run_3d.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ python "$sim_model_gen"

# Generate sim data
cd "$python_dir"
python -m materials.build "$materials_dir"
python -m pffdtd.materials.build "$materials_dir"
python "$sim_setup"

# Run sim
cd "$sim_dir"
$engine_exe

# Post-process
cd "$python_dir"
python -m sim3d.process_outputs --data_dir="$sim_dir" --fcut_lowpass "$fmax" --N_order_lowpass=8 --symmetric --fcut_lowcut "$fmin" --N_order_lowcut=4 --air_abs_filter="none" --save_wav --plot
python -m analysis.response --fmin=10 --target="-7.4" --smoothing=$smoothing --fmax=$fmax ../../data/sim_data/$sim_name/cpu/R001_out_normalised.wav ../../data/sim_data/$sim_name/cpu/R002_out_normalised.wav
python -m analysis.response --fmin=10 --target="-7.1" --smoothing=$smoothing --fmax=$fmax ../../data/sim_data/$sim_name/cpu/R001_out_normalised.wav ../../data/sim_data/$sim_name/cpu/R003_out_normalised.wav
python -m analysis.response --fmin=10 --target="-7.3" --smoothing=$smoothing --fmax=$fmax ../../data/sim_data/$sim_name/cpu/R001_out_normalised.wav ../../data/sim_data/$sim_name/cpu/R004_out_normalised.wav
python -m analysis.response --fmin=10 --target="-7.6" --smoothing=$smoothing --fmax=$fmax ../../data/sim_data/$sim_name/cpu/R001_out_normalised.wav ../../data/sim_data/$sim_name/cpu/R005_out_normalised.wav
python -m analysis.response --fmin=10 --target="-8.0" --smoothing=$smoothing --fmax=$fmax ../../data/sim_data/$sim_name/cpu/R001_out_normalised.wav ../../data/sim_data/$sim_name/cpu/R006_out_normalised.wav
# python -m analysis.waterfall ../../data/sim_data/$sim_name/cpu/R001_out_normalised.wav
# python -m analysis.t60 --fmin=$fmin --fmax="$fmax" --target=0.3 ../../data/sim_data/$sim_name/cpu/R001_out_normalised.wav
# python -m analysis.t60 --data_dir="$sim_dir" --fmin=$fmin --fmax="$fmax" --target=0.25
# python -m analysis.room_modes --data_dir="$sim_dir" --fmin=$fmin --fmax=$fmax --modes=20
# cd "$python_dir"
python -m pffdtd.sim3d.process_outputs --data_dir="$sim_dir" --fcut_lowpass "$fmax" --N_order_lowpass=8 --symmetric --fcut_lowcut "$fmin" --N_order_lowcut=4 --air_abs_filter="none" --save_wav --plot
python -m pffdtd.analysis.response --fmin=10 --target="-7.4" --smoothing=$smoothing --fmax=$fmax $sim_dir/R001_out_normalised.wav $sim_dir/R002_out_normalised.wav
python -m pffdtd.analysis.response --fmin=10 --target="-7.1" --smoothing=$smoothing --fmax=$fmax $sim_dir/R001_out_normalised.wav $sim_dir/R003_out_normalised.wav
python -m pffdtd.analysis.response --fmin=10 --target="-7.3" --smoothing=$smoothing --fmax=$fmax $sim_dir/R001_out_normalised.wav $sim_dir/R004_out_normalised.wav
python -m pffdtd.analysis.response --fmin=10 --target="-7.6" --smoothing=$smoothing --fmax=$fmax $sim_dir/R001_out_normalised.wav $sim_dir/R005_out_normalised.wav
python -m pffdtd.analysis.response --fmin=10 --target="-8.0" --smoothing=$smoothing --fmax=$fmax $sim_dir/R001_out_normalised.wav $sim_dir/R006_out_normalised.wav
# python -m pffdtd.analysis.waterfall $sim_dir/R001_out_normalised.wav
# python -m pffdtd.analysis.t60 --fmin=$fmin --fmax="$fmax" --target=0.3 $sim_dir/R001_out_normalised.wav
# python -m pffdtd.analysis.t60 --data_dir="$sim_dir" --fmin=$fmin --fmax="$fmax" --target=0.25
# python -m pffdtd.analysis.room_modes --data_dir="$sim_dir" --fmin=$fmin --fmax=$fmax --modes=20
2 changes: 1 addition & 1 deletion src/python/CTK_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@
)

# then run with python and 3D visualization:
# python3 -m sim3d.sim_fdtd --data_dir='../../data/sim_data/ctk_cart/viz' --plot --draw_backend='mayavi' --json_model='../../data/models/CTK_Church/model_export.json'
# python3 -m pffdtd.sim3d.sim_fdtd --data_dir='../../data/sim_data/ctk_cart/viz' --plot --draw_backend='mayavi' --json_model='../../data/models/CTK_Church/model_export.json'
2 changes: 1 addition & 1 deletion src/python/LivingRoom_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from common.room_builder import RoomBuilder
from pffdtd.common.room_builder import RoomBuilder

L = 6.0
W = 3.65
Expand Down
2 changes: 1 addition & 1 deletion src/python/LivingRoom_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
)

# then run with python and 3D visualization:
# python3 -m sim3d.sim_fdtd --data_dir='../../data/sim_data/LivingRoom/viz' --plot --draw_backend='mayavi' --json_model='../../data/models/LivingRoom/model.json'
# python3 -m pffdtd.sim3d.sim_fdtd --data_dir='../../data/sim_data/LivingRoom/viz' --plot --draw_backend='mayavi' --json_model='../../data/models/LivingRoom/model.json'
2 changes: 1 addition & 1 deletion src/python/MV_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@
)

# then run with python and 3D visualization:
# python3 -m sim3d.sim_fdtd --data_dir='../../data/sim_data/mv_fcc/viz' --plot --draw_backend='mayavi' --json_model='../../data/models/Musikverein_ConcertHall/model_export.json'
# python3 -m pffdtd.sim3d.sim_fdtd --data_dir='../../data/sim_data/mv_fcc/viz' --plot --draw_backend='mayavi' --json_model='../../data/models/Musikverein_ConcertHall/model_export.json'
2 changes: 1 addition & 1 deletion src/python/Modes_model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from common.room_builder import RoomBuilder
from pffdtd.common.room_builder import RoomBuilder

S = 0.9
L = 7.00*S
Expand Down
2 changes: 1 addition & 1 deletion src/python/Modes_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
)

# then run with python and 3D visualization:
# python3 -m sim3d.sim_fdtd --data_dir='../../data/sim_data/Modes/viz' --plot --draw_backend='polyscope' --json_model='../../data/models/Modes/model.json'
# python3 -m pffdtd.sim3d.sim_fdtd --data_dir='../../data/sim_data/Modes/viz' --plot --draw_backend='polyscope' --json_model='../../data/models/Modes/model.json'
2 changes: 1 addition & 1 deletion src/python/ProStudio_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import numpy as np

from common.room_builder import find_third_vertex
from pffdtd.common.room_builder import find_third_vertex


def load_mesh(obj_file, reverse=False):
Expand Down
2 changes: 1 addition & 1 deletion src/python/ProStudio_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
)

# then run with python and 3D visualization:
# python3 -m sim3d.sim_fdtd --data_dir='../../data/sim_data/ProStudio/viz' --plot --draw_backend='mayavi' --json_model='../../data/models/ProStudio/model.json'
# python3 -m pffdtd.sim3d.sim_fdtd --data_dir='../../data/sim_data/ProStudio/viz' --plot --draw_backend='mayavi' --json_model='../../data/models/ProStudio/model.json'
2 changes: 1 addition & 1 deletion src/python/Studio_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from common.room_builder import RoomBuilder, find_third_vertex
from pffdtd.common.room_builder import RoomBuilder, find_third_vertex

S = 0.90
L = 7.00*S
Expand Down
2 changes: 1 addition & 1 deletion src/python/Studio_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
)

# then run with python and 3D visualization:
# python3 -m sim3d.sim_fdtd --data_dir='../../data/sim_data/Studio/viz' --plot --draw_backend='mayavi' --json_model='../../data/models/Studio/model.json'
# python3 -m pffdtd.sim3d.sim_fdtd --data_dir='../../data/sim_data/Studio/viz' --plot --draw_backend='mayavi' --json_model='../../data/models/Studio/model.json'
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from numpy import array as npa
from numpy import exp, sqrt, log, pi, cos
from scipy.fft import dct,idct #default type2
from air_abs.get_air_absorption import get_air_absorption
from common.myfuncs import iround, iceil
from pffdtd.air_abs.get_air_absorption import get_air_absorption
from pffdtd.common.myfuncs import iround, iceil
from tqdm import tqdm

#apply filter, x is (Nchannel,Nsamples) array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from numpy import array as npa
from numpy import exp, sqrt, log2, pi, ceil, cos
from scipy.fft import rfft,irfft
from air_abs.get_air_absorption import get_air_absorption
from common.myfuncs import iround, iceil
from pffdtd.air_abs.get_air_absorption import get_air_absorption
from pffdtd.common.myfuncs import iround, iceil
from tqdm import tqdm

#apply the filter, x is (Nchannels,Nsamples) array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
from numpy import array as npa
from numpy import exp, sqrt, log, pi
import matplotlib.pyplot as plt
from air_abs.get_air_absorption import get_air_absorption
from air_abs.visco_filter import apply_visco_filter
from air_abs.modal_filter import apply_modal_filter
from air_abs.ola_filter import apply_ola_filter
from pffdtd.air_abs.get_air_absorption import get_air_absorption
from pffdtd.air_abs.visco_filter import apply_visco_filter
from pffdtd.air_abs.modal_filter import apply_modal_filter
from pffdtd.air_abs.ola_filter import apply_ola_filter
from numpy.random import random_sample
from common.myfuncs import iround, iceil
from pffdtd.common.myfuncs import iround, iceil

Tc = 20
rh = 60
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import numba as nb
from numpy import array as npa
from numpy import exp, sqrt, log, pi
from common.myfuncs import iround, iceil
from air_abs.get_air_absorption import get_air_absorption
from pffdtd.common.myfuncs import iround, iceil
from pffdtd.air_abs.get_air_absorption import get_air_absorption
from tqdm import tqdm

#function to apply filter, main input being x, np.ndarray (Nchannels,Nsamples)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import numpy as np
from matplotlib.ticker import ScalarFormatter

from common.plot import plot_styles
from common.myfuncs import iceil
from pffdtd.common.plot import plot_styles
from pffdtd.common.myfuncs import iceil


def fractional_octave_smoothing(magnitudes, fs, nfft, fraction=3):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from scipy.signal import find_peaks
import scipy.io.wavfile as wavfile

from common.myfuncs import iceil
from common.plot import plot_styles
from pffdtd.common.myfuncs import iceil
from pffdtd.common.plot import plot_styles


def collect_wav_paths(dir, pattern="*.wav"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from matplotlib.axes import Axes
from matplotlib.ticker import ScalarFormatter

from common.plot import plot_styles
from pffdtd.common.plot import plot_styles


def collect_wav_files(directory, pattern="*.wav"):
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from numpy import array as npa
import numpy.random as npr
import numpy.linalg as npl
from common.myfuncs import mydefault,rotmatrix_ax_ang
from pffdtd.common.myfuncs import mydefault,rotmatrix_ax_ang

class Box:
def __init__(self,Lx=None,Ly=None,Lz=None,Rax=None,Rang=None,shift=None,centered=True):
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import numpy.linalg as npl
from numpy import cos,sin,pi
from typing import Any,Optional
from common.myasserts import assert_np_array_float, assert_np_array_complex
from pffdtd.common.myasserts import assert_np_array_float, assert_np_array_complex
from pathlib import Path
import struct
import os
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import numpy as np
import json as json
from numpy import array as npa
from common.tris_precompute import tris_precompute
from common.myfuncs import dotv,vecnorm
from common.myfuncs import rotate_az_el_deg
from pffdtd.common.tris_precompute import tris_precompute
from pffdtd.common.myfuncs import dotv,vecnorm
from pffdtd.common.myfuncs import rotate_az_el_deg

class RoomGeo:
def __init__(self,json=None,az_el=[0.,0.],area_eps=1e-6,bmin=None,bmax=None):
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

import numpy as np
from numpy import array as npa
from common.myfuncs import dotv
from common.tris_precompute import tris_precompute
from pffdtd.common.myfuncs import dotv
from pffdtd.common.tris_precompute import tris_precompute

#p is lower corner of box
#dp is distance to upper corner of box
Expand Down Expand Up @@ -121,7 +121,7 @@ def tri_box_intersection_vec(bbmin,bbmax,tris_pre):

def main():
import numpy.random as npr
from common.box import Box
from pffdtd.common.box import Box
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--nodraw', action='store_true',help='don''t draw')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

import numpy as np
from numpy import array as npa
from common.myfuncs import dotv,normalise,vecnorm
from common.myasserts import assert_np_array_float
from common.tris_precompute import tris_precompute
from pffdtd.common.myfuncs import dotv,normalise,vecnorm
from pffdtd.common.myasserts import assert_np_array_float
from pffdtd.common.tris_precompute import tris_precompute

#d_eps is a distance eps, cp is for coplanarity (non-dimensional)
#pretty standard test: check if coplanar, then check point-on-plane inside edge functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import numpy as np
from numpy import array as npa
from common.myfuncs import normalise,dot2,vecnorm
from pffdtd.common.myfuncs import normalise,dot2,vecnorm

#N.B. careful with slicing tris_pre[idx]['var'] (bad) vs tris_pre['var'][idx] (good)
def tris_precompute(pts=None,tris=None):
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from pathlib import Path

from materials.adm_funcs import fit_to_Sabs_oct_11,write_freq_ind_mat_from_Yn,convert_Sabs_to_Yn
from pffdtd.materials.adm_funcs import fit_to_Sabs_oct_11,write_freq_ind_mat_from_Yn,convert_Sabs_to_Yn

def main():
plot=False
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
from numpy.fft import rfft
from numpy import log10,log2
from resampy import resample
from air_abs.visco_filter import apply_visco_filter
from air_abs.modal_filter import apply_modal_filter
from air_abs.ola_filter import apply_ola_filter
from common.myfuncs import wavwrite,iceil,iround
from common.plot import plot_styles
from pffdtd.air_abs.visco_filter import apply_visco_filter
from pffdtd.air_abs.modal_filter import apply_modal_filter
from pffdtd.air_abs.ola_filter import apply_ola_filter
from pffdtd.common.myfuncs import wavwrite,iceil,iround
from pffdtd.common.plot import plot_styles

#class to process sim_outs.h5 file
class ProcessOutputs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
from pathlib import Path
import time
import h5py
from common.myfuncs import ind2sub3d
from common.timerdict import TimerDict
from pffdtd.common.myfuncs import ind2sub3d
from pffdtd.common.timerdict import TimerDict
import shutil

#NB: we keep cart_grid.h5 untouched and that has original Nx,Ny,Nz if needed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

import numpy as np
from numpy import array as npa
from voxelizer.cart_grid import CartGrid
from pffdtd.voxelizer.cart_grid import CartGrid
from pathlib import Path
from common.timerdict import TimerDict
from common.myfuncs import iceil
from pffdtd.common.timerdict import TimerDict
from pffdtd.common.myfuncs import iceil
import h5py
from scipy.signal import lfilter,bilinear_zpk
from numpy import pi,cos,sin
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
from numpy import array as npa
import numba as nb
from pathlib import Path
from common.timerdict import TimerDict
from pffdtd.common.timerdict import TimerDict
from tqdm import tqdm
import time
import h5py
import json as json
from common.myfuncs import ind2sub3d,rel_diff,get_default_nprocs
from pffdtd.common.myfuncs import ind2sub3d,rel_diff,get_default_nprocs

MMb = 12 #max allowed number of branches

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

import numpy as np
from numpy import array as npa
from voxelizer.cart_grid import CartGrid
from pffdtd.voxelizer.cart_grid import CartGrid
from pathlib import Path
from common.timerdict import TimerDict
from pffdtd.common.timerdict import TimerDict
import h5py

class SimMats:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def power_for_target_spl(SPL_target, SPL_ref, P_ref=1):


def driver_spl_report(df, drivers, SPL_target=None):
from common.plot import plot_styles
from pffdtd.common.plot import plot_styles
plt.rcParams.update(plot_styles)
plt.title("SPL vs. Power")
plt.xlabel("SPL [dB]")
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@

import numpy as np
from numpy import array as npa
from common.room_geo import RoomGeo
from voxelizer.vox_grid_base import VoxGridBase,VoxBase
from voxelizer.cart_grid import CartGrid
from common.timerdict import TimerDict
from pffdtd.common.room_geo import RoomGeo
from pffdtd.voxelizer.vox_grid_base import VoxGridBase,VoxBase
from pffdtd.voxelizer.cart_grid import CartGrid
from pffdtd.common.timerdict import TimerDict
from tqdm import tqdm
from common.myfuncs import get_default_nprocs,iceil
from pffdtd.common.myfuncs import get_default_nprocs,iceil

class Voxel(VoxBase):
#using cubic voxels for simplicity
Expand Down
Loading

0 comments on commit 7e415b1

Please sign in to comment.