Coverage for python/bellhop/constants.py: 100%
46 statements
« prev ^ index » next coverage.py v7.10.7, created at 2025-09-23 13:34 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2025-09-23 13:34 +0000
2from enum import Enum
4class _Strings(str, Enum):
5 """String definitions to avoid hard-coding magic strings in the source code
7 This helps prevent typos and permits autocomplete (if your editor is smart enough).
8 """
10 # interpolation
11 linear = "linear"
12 spline = "spline"
13 curvilinear = "curvilinear"
14 quadrilateral = "quadrilateral"
15 pchip = "pchip"
16 hexahedral = "hexahedral"
17 arrivals = "arrivals"
18 nlinear = "nlinear"
20 # tasks
21 eigenrays = "eigenrays"
22 rays = "rays"
23 coherent = "coherent"
24 incoherent = "incoherent"
25 semicoherent = "semicoherent"
27 # boundaries
28 vacuum = "vacuum"
29 acousto_elastic = "acousto-elastic"
30 rigid = "rigid"
32 # bathymetry
33 from_file = "from-file"
34 flat = "flat"
36 # sources
37 line = "line"
38 point = "point"
40 # grid
41 rectilinear = "rectilinear"
42 irregular = "irregular"
44 # volume attenuation
45 thorp = "thorp"
46 francois_garrison = "francois-garrison"
47 biological = "biological"
50class _Maps:
51 """Mappings from Bellhop single-char input file options to readable Python options
53 These are also defined with reverse mappings in the form:
55 >>> _Maps.interp["S"]
56 "spline"
58 >>> _Maps.interp_rev["spline"]
59 "S"
61 """
63 interp = {
64 "S":_Strings.spline,
65 "C":_Strings.linear,
66 "Q":_Strings.quadrilateral,
67 "P":_Strings.pchip,
68 "H":_Strings.hexahedral,
69 "N":_Strings.nlinear,
70 " ": "default",
71 }
72 bty_interp = {
73 "L":_Strings.linear,
74 "C":_Strings.curvilinear,
75 }
76 boundcond = {
77 "V":_Strings.vacuum,
78 "A":_Strings.acousto_elastic,
79 "R":_Strings.rigid,
80 "F":_Strings.from_file,
81 " ": "default",
82 }
83 attunits = {
84 "N": "nepers per meter",
85 "F": "frequency dependent",
86 "M": "dB per meter",
87 "m": "frequency scaled dB per meter",
88 "W": "dB per wavelength",
89 "Q": "quality factor",
90 "L": "loss parameter",
91 " ": "default",
92 }
93 volatt = {
94 "": "none",
95 "T": "thorp",
96 "F": "francois-garrison",
97 "B": "biological",
98 " ": "default",
99 }
100 bottom = {
101 "_":_Strings.flat,
102 "~":_Strings.from_file,
103 "*":_Strings.from_file,
104 " ": "default",
105 }
106 source = {
107 "R":_Strings.point,
108 "X":_Strings.line,
109 " ": "default",
110 }
111 grid = {
112 "R":_Strings.rectilinear,
113 "I":_Strings.irregular,
114 " ": "default",
115 }
116 beam = {
117 "G": "hat-cartesian",
118 "^": "hat-cartesian",
119 "g": "hat-ray",
120 "B": "gaussian-cartesian",
121 "b": "gaussian-ray",
122 " ": "default",
123 }
125 # reverse maps
126 interp_rev = {v: k for k, v in interp.items()}
127 bty_interp_rev = {v: k for k, v in bty_interp.items()}
128 boundcond_rev = {v: k for k, v in boundcond.items()}
129 attunits_rev = {v: k for k, v in attunits.items()}
130 volatt_rev = {v: k for k, v in volatt.items()}
131 bottom_rev = {v: k for k, v in bottom.items()}
132 source_rev = {v: k for k, v in source.items()}
133 grid_rev = {v: k for k, v in grid.items()}
134 beam_rev = {v: k for k, v in beam.items()}