Skip to content

Commit 6141295

Browse files
committed
More work following on from BenchmarkData changes
1 parent 12cef2b commit 6141295

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

docs/usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ Note that the `parameters()` call does not return all of the parameters needed b
281281

282282
## Benchmark model TS
283283

284-
[Jech et al., (2015)](https://doi.org/10.1121/1.4937607) presented _benchmark_ model runs for the reference models. The TS results from these benchmarks are available in echoSMs via the [`BenchmarkData`](api_reference.md#echosms.BenchmarkData) class. This class reads the CSV-formatted file of benchmark values. Methods in the `BenchmarkData` class provide a list of the benchmark names, access to individual TS and frequency/angle datasets, and also the frequency and angle datasets as Pandas DataFrames.
284+
[Jech et al., (2015)](https://doi.org/10.1121/1.4937607) presented _benchmark_ model runs for the reference models. The TS results from these benchmarks are available in echoSMs via the [`BenchmarkData`](api_reference.md#echosms.BenchmarkData) class. This class reads the CSV-formatted files of benchmark values and provides methods that list the benchmark names, return individual TS and frequency/angle datasets, and also provide the entire datasets as Pandas DataFrames.
285285

286286
```py
287287
from echosms import BenchmarkData

src/echosms/benchmarkdata.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,12 @@ def __init__(self):
6767

6868
self.freq_dataset['frequency (kHz)'] *= 1e3 # want Hz not kHz
6969

70-
self.angle_dataset.set_index('angle (deg)', inplace=True)
71-
self.freq_dataset.set_index('frequency (kHz)', inplace=True)
70+
# Remove units from the column names (we have the echoSMs units convention instead)
71+
self.freq_dataset.rename(columns={'frequency (kHz)': 'frequency'}, inplace=True)
72+
self.angle_dataset.rename(columns={'angle (deg)': 'angle'}, inplace=True)
73+
74+
self.angle_dataset.set_index('angle', inplace=True)
75+
self.freq_dataset.set_index('frequency', inplace=True)
7276

7377
def angle_names(self) -> list:
7478
"""Provide the model names for the angle benchmark data.
@@ -142,6 +146,6 @@ def freq_as_dataframe(self) -> pd.DataFrame:
142146
Returns
143147
-------
144148
:
145-
Dataframe containing the benchmark data.
149+
Dataframe containing the benchmark data.
146150
"""
147151
return self.freq_dataset

src/example_code.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def plot_compare_angle(theta1, ts1, label1, theta2, ts2, label2, title):
106106
bm_f, bm_ts = bm.freq_data(name)
107107
not_nan = ~np.isnan(bm_ts)
108108

109-
m['f'] = bm_f[not_nan]*1e3 # [Hz]
109+
m['f'] = bm_f[not_nan]
110110
bm_ts = bm_ts[not_nan]
111111

112112
# No benchmark TS is available for this model, so add some sensible frequencies in
@@ -186,7 +186,7 @@ def plot_compare_angle(theta1, ts1, label1, theta2, ts2, label2, title):
186186
m_f, bm_ts = bm.freq_data(name)
187187
not_nan = ~np.isnan(bm_ts)
188188

189-
m['f'] = bm_f[not_nan]*1e3 # [Hz]
189+
m['f'] = bm_f[not_nan]
190190
bm_ts = bm_ts[not_nan]
191191

192192
mod = KAModel()
@@ -240,8 +240,7 @@ def plot_compare_angle(theta1, ts1, label1, theta2, ts2, label2, title):
240240
m.pop('b', None)
241241

242242
# Get benchmark model for comparison
243-
bm_f, bm_ts = bm.freq_data(name)
244-
f = bm_f * 1e3
243+
f, bm_ts = bm.freq_data(name)
245244

246245
m |= {'theta': 90, 'phi': 0, 'a': a, 'rv_pos': rv_pos, 'rv_tan': rv_tan, 'f': f}
247246

@@ -455,7 +454,7 @@ def plot_compare_angle(theta1, ts1, label1, theta2, ts2, label2, title):
455454
m['rho'] = [m['medium_rho'], m['target_rho']]
456455
m['c'] = [m['medium_c'], m['target_c']]
457456
bm_f, bm_ts = bm.freq_data(name)
458-
m['f'] = bm_f * 1e3 # [Hz]
457+
m['f'] = bm_f
459458
# remove unneeded parameters
460459
m = {k: v for k, v in m.items()
461460
if k not in ['boundary_type', 'a', 'medium_rho', 'medium_c', 'target_rho', 'target_c']}
@@ -471,7 +470,7 @@ def plot_compare_angle(theta1, ts1, label1, theta2, ts2, label2, title):
471470
mss = MSSModel()
472471
mm = rm.parameters(name)
473472
bm_f, bm_ts = bm.freq_data(name)
474-
mm['f'] = bm_f * 1e3 # [Hz]
473+
mm['f'] = bm_f
475474
mm['theta'] = 90.0
476475

477476
mss_ts = mss.calculate_ts(mm, progress=True)
@@ -494,7 +493,7 @@ def plot_compare_angle(theta1, ts1, label1, theta2, ts2, label2, title):
494493
m['rho'] = [m['medium_rho'], m['target_rho']]
495494
m['c'] = [m['medium_c'], m['target_c']]
496495
bm_f, bm_ts = bm.freq_data(name)
497-
m['f'] = bm_f * 1e3 # [Hz]
496+
m['f'] = bm_f
498497
# remove unneeded parameters
499498
m = {k: v for k, v in m.items()
500499
if k not in ['boundary_type', 'a', 'b', 'medium_rho', 'medium_c', 'target_rho', 'target_c']}

0 commit comments

Comments
 (0)