Ocean and electric field modelling¶
Package
Module scubas.models
Class OceanModel, Preprocess
Method / Function _validate_frequency_limits
Frequency limits are validated
OceanModel requires valid flim=(f_min, f_max) values with
positive, ordered frequencies.
The scubas.models module orchestrates the conversion between magnetic and
electric fields using the modernised OceanModel class. The refactor
introduced tighter validation (e.g. positive frequency limits), better error
handling when reading IAGA/CSV data, and a typed Preprocess helper that
encapsulates detrending and tapering.
Highlights:
OceanModelnow requires aSiteinstance and validates the frequency range (flim) at construction time.- Transfer functions are cached after a call to
calcTF, and the optionalcompile_omlflow used by transmission lines leverages these helpers. read_Bfield_datareads both IAGA text files and simple CSV exports, returning a single time-aligned dataframe ready for FFT conversion.to_Efieldshandles time stamps expressed either as datetimes or seconds, storing the results inself.Efieldfor downstream usage.
Quick start¶
import pandas as pd
import numpy as np
from scubas.datasets import PROFILES
from scubas.models import OceanModel
model = OceanModel(PROFILES.CS, flim=(1e-4, 1e-2))
# Create a synthetic B-field dataframe (two components, 1-second cadence)
times = pd.date_range("2024-01-01", periods=32, freq="s")
bfield = pd.DataFrame(
{
"X": np.sin(np.linspace(0, 2 * np.pi, len(times))),
"Y": np.cos(np.linspace(0, 2 * np.pi, len(times))),
},
index=times,
)
# Convert to electric fields using the cached transfer functions
model.to_Efields(bfield)
print(model.Efield.head())
API reference¶
scubas.models.OceanModel
¶
Emulates electric and magnetic fields for a layered ocean profile.
Source code in scubas/models.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
calcZ(freqs=None)
¶
Compute ocean and seabed impedances for the provided frequencies.
Source code in scubas/models.py
calcTF(kinds=('E2B', 'B2B'), freqs=None)
¶
Calculate transfer functions for the supplied kind(s) and frequency grid.
Source code in scubas/models.py
get_TFs(key='E2B', freqs=None)
¶
Retrieve the specified transfer function as a dataframe.
Source code in scubas/models.py
read_iaga(file, return_xyzf=True, return_header=False)
¶
Parse an IAGA-2002 geomagnetic file into a dataframe.
Source code in scubas/models.py
read_Bfield_data(files, return_xyzf=True, csv_file_date_name='Date', check_for_gaps=True)
¶
Aggregate B-field data from IAGA or CSV files.
Source code in scubas/models.py
to_Efields(Bfield=None, components=('X', 'Y'), p=None)
¶
Transform B-field measurements into E-field estimates.
Source code in scubas/models.py
scubas.models.Preprocess
dataclass
¶
Preprocessing helper for tapering and detrending field data.
Source code in scubas/models.py
get_tapering_function(p=None)
¶
Construct the tapering window applied during detrending.
Source code in scubas/models.py
detrend_magnetic_field(p=None)
¶
Remove bias and taper magnetic field data to reduce spectral leakage.