Skip to content

Commit

Permalink
Added averaging check for API to convert y/n to True/False
Browse files Browse the repository at this point in the history
  • Loading branch information
craig-warren committed May 16, 2024
1 parent 18eed3c commit 23c88ce
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions gprMax/cmds_geometry/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import gprMax.config as config

from ..cython.geometry_primitives import build_box
from ..hash_cmds_geometry import check_averaging
from ..materials import Material
from .cmds_geometry import UserObjectGeometry, rotate_2point_object

Expand Down Expand Up @@ -87,6 +88,7 @@ def build(self, grid, uip):
try:
# Try user-specified averaging
averagebox = self.kwargs["averaging"]
averagebox = check_averaging(averagebox)
except KeyError:
# Otherwise go with the grid default
averagebox = grid.averagevolumeobjects
Expand Down
8 changes: 5 additions & 3 deletions gprMax/cmds_geometry/cone.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import numpy as np

from ..cython.geometry_primitives import build_cone
from ..hash_cmds_geometry import check_averaging
from ..materials import Material
from .cmds_geometry import UserObjectGeometry

Expand Down Expand Up @@ -61,10 +62,11 @@ def build(self, grid, uip):
# Check averaging
try:
# Try user-specified averaging
averagecylinder = self.kwargs["averaging"]
averagecone = self.kwargs["averaging"]
averagecone = check_averaging(averagecone)
except KeyError:
# Otherwise go with the grid default
averagecylinder = grid.averagevolumeobjects
averagecone = grid.averagevolumeobjects

# Check materials have been specified
# Isotropic case
Expand Down Expand Up @@ -106,7 +108,7 @@ def build(self, grid, uip):

# Isotropic case
if len(materials) == 1:
averaging = materials[0].averagable and averagecylinder
averaging = materials[0].averagable and averagecone
numID = numIDx = numIDy = numIDz = materials[0].numID

# Uniaxial anisotropic case
Expand Down
2 changes: 2 additions & 0 deletions gprMax/cmds_geometry/cylinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import numpy as np

from ..cython.geometry_primitives import build_cylinder
from ..hash_cmds_geometry import check_averaging
from ..materials import Material
from .cmds_geometry import UserObjectGeometry

Expand Down Expand Up @@ -59,6 +60,7 @@ def build(self, grid, uip):
try:
# Try user-specified averaging
averagecylinder = self.kwargs["averaging"]
averagecylinder = check_averaging(averagecylinder)
except KeyError:
# Otherwise go with the grid default
averagecylinder = grid.averagevolumeobjects
Expand Down
2 changes: 2 additions & 0 deletions gprMax/cmds_geometry/cylindrical_sector.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import numpy as np

from ..cython.geometry_primitives import build_cylindrical_sector
from ..hash_cmds_geometry import check_averaging
from ..materials import Material
from .cmds_geometry import UserObjectGeometry

Expand Down Expand Up @@ -74,6 +75,7 @@ def build(self, grid, uip):
try:
# Try user-specified averaging
averagecylindricalsector = self.kwargs["averaging"]
averagecylindricalsector = check_averaging(averagecylindricalsector)
except KeyError:
# Otherwise go with the grid default
averagecylindricalsector = grid.averagevolumeobjects
Expand Down
2 changes: 2 additions & 0 deletions gprMax/cmds_geometry/ellipsoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import numpy as np

from ..cython.geometry_primitives import build_ellipsoid
from ..hash_cmds_geometry import check_averaging
from ..materials import Material
from .cmds_geometry import UserObjectGeometry

Expand Down Expand Up @@ -60,6 +61,7 @@ def build(self, grid, uip):
try:
# Try user-specified averaging
averageellipsoid = self.kwargs["averaging"]
averageellipsoid = check_averaging(averageellipsoid)
except KeyError:
# Otherwise go with the grid default
averageellipsoid = grid.averagevolumeobjects
Expand Down
2 changes: 2 additions & 0 deletions gprMax/cmds_geometry/sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import numpy as np

from ..cython.geometry_primitives import build_sphere
from ..hash_cmds_geometry import check_averaging
from ..materials import Material
from .cmds_geometry import UserObjectGeometry

Expand Down Expand Up @@ -55,6 +56,7 @@ def build(self, grid, uip):
try:
# Try user-specified averaging
averagesphere = self.kwargs["averaging"]
averagesphere = check_averaging(averagesphere)
except KeyError:
# Otherwise go with the grid default
averagesphere = grid.averagevolumeobjects
Expand Down
2 changes: 2 additions & 0 deletions gprMax/cmds_geometry/triangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import numpy as np

from ..cython.geometry_primitives import build_triangle
from ..hash_cmds_geometry import check_averaging
from ..materials import Material
from .cmds_geometry import UserObjectGeometry, rotate_point

Expand Down Expand Up @@ -80,6 +81,7 @@ def build(self, grid, uip):
try:
# Try user-specified averaging
averagetriangularprism = self.kwargs["averaging"]
averagetriangularprism = check_averaging(averagetriangularprism)
except KeyError:
# Otherwise go with the grid default
averagetriangularprism = grid.averagevolumeobjects
Expand Down

0 comments on commit 23c88ce

Please sign in to comment.