Skip to content

Commit

Permalink
[python] Add geometry module
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashienzsch committed Sep 3, 2024
1 parent 090f527 commit 9ba6978
Show file tree
Hide file tree
Showing 26 changed files with 33 additions and 113 deletions.
2 changes: 1 addition & 1 deletion data/models/Diffusor/Diffusor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from pffdtd.common.myfuncs import to_ixy, point_on_circle
from pffdtd.geometry.math import to_ixy, point_on_circle
from pffdtd.diffusor.design import diffusor_bandwidth
from pffdtd.diffusor.qrd import quadratic_residue_diffuser
from pffdtd.diffusor.prd import primitive_root_diffuser
Expand Down
2 changes: 1 addition & 1 deletion data/models/Modes2D/Modes2D.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pffdtd.common.myfuncs import to_ixy
from pffdtd.geometry.math import to_ixy
from pffdtd.sim2d.setup import sim_setup_2d


Expand Down
2 changes: 1 addition & 1 deletion src/python/pffdtd/absorption/air.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from scipy.fft import rfft, irfft
from tqdm import tqdm

from pffdtd.common.myfuncs import iceil, iround
from pffdtd.geometry.math import iceil, iround

def air_absorption(frequencies,temperature_celsius,rel_humidity_pnct,pressure_atmospheric_kPa=101.325):
"""This is an implementation of formulae in the ISO9613-1 standard for air absorption
Expand Down
2 changes: 1 addition & 1 deletion src/python/pffdtd/absorption/air_abs_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import matplotlib.pyplot as plt
import numpy as np

from pffdtd.common.myfuncs import iround
from pffdtd.geometry.math import iround
from pffdtd.absorption.air import (
apply_modal_filter,
apply_ola_filter,
Expand Down
2 changes: 1 addition & 1 deletion src/python/pffdtd/analysis/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from matplotlib.ticker import ScalarFormatter

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


def fractional_octave_smoothing(magnitudes, fs, nfft, fraction=3):
Expand Down
2 changes: 1 addition & 1 deletion src/python/pffdtd/analysis/room_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from scipy.signal import find_peaks
from scipy.io import wavfile

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


Expand Down
9 changes: 0 additions & 9 deletions src/python/pffdtd/common/check_version.py

This file was deleted.

71 changes: 0 additions & 71 deletions src/python/pffdtd/common/timer.py

This file was deleted.

Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
from numpy import array as npa
import numpy.random as npr
from pffdtd.common.myfuncs import mydefault,rotmatrix_ax_ang
from pffdtd.geometry.math import mydefault,rotmatrix_ax_ang

class Box:
"""This is a class for a box. Used in a few places (vox_grid, tri_box).
Expand Down
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 pffdtd.common.myfuncs import dotv
from pffdtd.common.tris_precompute import tris_precompute
from pffdtd.geometry.math import dotv
from pffdtd.geometry.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 pffdtd.common.box import Box
from pffdtd.geometry.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 pffdtd.common.myfuncs import dotv,normalise,vecnorm
from pffdtd.geometry.math import dotv,normalise,vecnorm
from pffdtd.common.myasserts import assert_np_array_float
from pffdtd.common.tris_precompute import tris_precompute
from pffdtd.geometry.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 pffdtd.common.myfuncs import normalise,dot2,vecnorm
from pffdtd.geometry.math 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
2 changes: 1 addition & 1 deletion src/python/pffdtd/sim2d/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np
from scipy.signal import lfilter

from pffdtd.common.myfuncs import to_ixy
from pffdtd.geometry.math import to_ixy
from pffdtd.sim3d.sim_constants import SimConstants


Expand Down
2 changes: 1 addition & 1 deletion src/python/pffdtd/sim3d/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from tqdm import tqdm

from pffdtd.common.timerdict import TimerDict
from pffdtd.common.myfuncs import ind2sub3d,rel_diff,get_default_nprocs
from pffdtd.geometry.math import ind2sub3d,rel_diff,get_default_nprocs

MMb = 12 #max allowed number of branches

Expand Down
2 changes: 1 addition & 1 deletion src/python/pffdtd/sim3d/process_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from pffdtd.absorption.air import apply_visco_filter
from pffdtd.absorption.air import apply_modal_filter
from pffdtd.absorption.air import apply_ola_filter
from pffdtd.common.myfuncs import wavwrite,iceil,iround
from pffdtd.geometry.math import wavwrite,iceil,iround
from pffdtd.common.plot import plot_styles

#class to process sim_outs.h5 file
Expand Down
4 changes: 2 additions & 2 deletions src/python/pffdtd/sim3d/room_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import numpy as np
import json as json
from numpy import array as npa
from pffdtd.common.myfuncs import dotv,rotate_az_el_deg
from pffdtd.common.tris_precompute import tris_precompute
from pffdtd.geometry.math import dotv,rotate_az_el_deg
from pffdtd.geometry.tris_precompute import tris_precompute

class RoomGeometry:
"""Class for room geometry, source/receiver positions, and materials (labels)
Expand Down
2 changes: 1 addition & 1 deletion src/python/pffdtd/sim3d/rotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from pathlib import Path
import time
import h5py
from pffdtd.common.myfuncs import ind2sub3d
from pffdtd.geometry.math import ind2sub3d
from pffdtd.common.timerdict import TimerDict
import shutil

Expand Down
2 changes: 1 addition & 1 deletion src/python/pffdtd/sim3d/sim_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from scipy.signal import lfilter

from pffdtd.common.timerdict import TimerDict
from pffdtd.common.myfuncs import iceil
from pffdtd.geometry.math import iceil
class SimSignals:
def __init__(self,save_folder):
#will read h,xv,yv,zv from h5 data
Expand Down
2 changes: 1 addition & 1 deletion src/python/pffdtd/voxelizer/vox_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from numpy import array as npa
from tqdm import tqdm

from pffdtd.common.myfuncs import get_default_nprocs,iceil
from pffdtd.geometry.math import get_default_nprocs,iceil
from pffdtd.sim3d.room_geometry import RoomGeometry
from pffdtd.voxelizer.cart_grid import CartGrid
from pffdtd.voxelizer.vox_grid_base import VoxGridBase,VoxBase
Expand Down
6 changes: 3 additions & 3 deletions src/python/pffdtd/voxelizer/vox_grid_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
from tqdm import tqdm

from pffdtd.common.timerdict import TimerDict
from pffdtd.common.tri_box_intersection import tri_box_intersection_vec
from pffdtd.common.myfuncs import clear_dat_folder, get_default_nprocs
from pffdtd.geometry.tri_box_intersection import tri_box_intersection_vec
from pffdtd.geometry.math import clear_dat_folder, get_default_nprocs

#base class for a voxel
class VoxBase:
Expand Down Expand Up @@ -199,7 +199,7 @@ def print_stats(self):

#draws non-empty boxes only
def draw_boxes(self,tube_radius,backend='mayavi'):
from pffdtd.common.box import Box
from pffdtd.geometry.box import Box
Nvox = self.Nvox
self.print('drawing boxes..')
boxtris = np.zeros((Nvox*12,3))
Expand Down
10 changes: 5 additions & 5 deletions src/python/pffdtd/voxelizer/vox_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@

from pffdtd.sim3d.room_geometry import RoomGeometry
from pffdtd.common.timerdict import TimerDict
from pffdtd.common.tri_ray_intersection import tri_ray_intersection_vec
from pffdtd.geometry.tri_ray_intersection import tri_ray_intersection_vec
from pffdtd.voxelizer.cart_grid import CartGrid
from pffdtd.voxelizer.vox_grid import VoxGrid
from pffdtd.common.myfuncs import clear_dat_folder
from pffdtd.common.myfuncs import yes_or_no,ind2sub3d
from pffdtd.common.myfuncs import dotv
from pffdtd.common.myfuncs import get_default_nprocs
from pffdtd.geometry.math import clear_dat_folder
from pffdtd.geometry.math import yes_or_no,ind2sub3d
from pffdtd.geometry.math import dotv
from pffdtd.geometry.math import get_default_nprocs

F_EPS = np.finfo(np.float64).eps
R_EPS = 1e-6 #relative eps (to grid spacing) for near hits
Expand Down
2 changes: 1 addition & 1 deletion src/python/test/test_sim2d_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np
import pytest

from pffdtd.common.myfuncs import to_ixy
from pffdtd.geometry.math import to_ixy
from pffdtd.cli import main as cli
from pffdtd.sim2d.setup import sim_setup_2d

Expand Down
4 changes: 2 additions & 2 deletions src/python/test/test_sim3d_infinite_baffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import numpy as np
import pytest

from pffdtd.common.myfuncs import wavread
from pffdtd.common.myfuncs import point_on_circle
from pffdtd.geometry.math import wavread
from pffdtd.geometry.math import point_on_circle
from pffdtd.materials.adm_funcs import write_freq_ind_mat_from_Yn, convert_Sabs_to_Yn
from pffdtd.sim3d.sim_setup import sim_setup
from pffdtd.sim3d.testing import run_engine, skip_if_native_engine_unavailable
Expand Down
2 changes: 1 addition & 1 deletion src/python/test/test_sim3d_locate_sound_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
import pytest

from pffdtd.common.myfuncs import wavread
from pffdtd.geometry.math import wavread
from pffdtd.materials.adm_funcs import write_freq_ind_mat_from_Yn, convert_Sabs_to_Yn
from pffdtd.sim3d.room_builder import RoomBuilder
from pffdtd.sim3d.sim_setup import sim_setup
Expand Down

0 comments on commit 9ba6978

Please sign in to comment.