Skip to content

Commit

Permalink
Add example code using JechEtAlData class
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinmacaulay committed Dec 10, 2024
1 parent 024adf6 commit 101d361
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/example_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from echosms import MSSModel, PSMSModel, DCMModel, ESModel, PTDWBAModel, KAModel, DWBAModel
from echosms import HPModel, KRMModel
from echosms import BenchmarkData
from echosms import BenchmarkData, JechEtAlData
from echosms import ReferenceModels
from echosms import as_dataframe, as_dataarray
from echosms import create_dwba_spheroid, create_dwba_cylinder
Expand Down Expand Up @@ -193,6 +193,29 @@ def plot_compare_angle(theta1, ts1, label1, theta2, ts2, label2, title):

plot_compare_freq(m['f'], ts, 'KA', m['f'], bm_ts, 'Benchmark', name)

#############################################################
# Now compare the echoSMs KA to the KA result in the paper
jetal = JechEtAlData()
ka_ts = jetal.data['Figure_01_Rigid-sphere']['Francis_Kirchhoff_TS']
plot_compare_freq(m['f'], ts, 'KA echoSMs', m['f'], ka_ts, 'KA paper', name)

# and again for a finite cylinder
name = 'fixed rigid finite cylinder'
s = rm.specification(name)
ka_ts = jetal.data['Figure_06_Rigid-Cylinder']['Francis_Kirchhoff_TS']

# default cylinder from trimesh lies along the z axis, so need to rotate it to lie along the x axis,
# hence the transform.
mesh = trimesh.creation.cylinder(
radius=s['a'], height=s['b'],
transform=trimesh.transformations.rotation_matrix(np.pi/2, [0, 1, 0], [0, 0, 0]))
mesh = mesh.subdivide().subdivide() # needed for better accuracy at higher frequencies
m['mesh'] = mesh
# m['mesh'].export('cylinder.stl') # to view in a separate package (e.g., MeshLab)

ts = mod.calculate_ts(m)
plot_compare_freq(m['f'], ts, 'KA echoSMs', m['f'], ka_ts, 'KA paper', name)

# %% ###################################################
# Run the DWBA model and compare to the benchmark results

Expand Down Expand Up @@ -249,7 +272,7 @@ def plot_compare_angle(theta1, ts1, label1, theta2, ts2, label2, title):
plot_compare_angle(m['theta'], ts, 'DWBA', m['theta'], bmt[name], 'Benchmark', name)

##########################################################
# And the DWBA on a real shape
# And the DWBA and SDWBA on a real shape
dd = DWBAdata()

krill = dd.model('Generic krill (McGehee 1998)')
Expand Down

0 comments on commit 101d361

Please sign in to comment.