anemone_forward

anemone (PyTorch) 1D TDEM forward modelling backend. Requires the optional anemone package; see Installation.

anemone (PyTorch) 1D TDEM forward modelling as an alternative to GA-AEM.

Public API mirrors forward_gaaem / prior_data_gaaem in integrate.integrate. anemone and torch are imported lazily so importing integrate never requires them.

See docs/superpowers/specs/2026-09-10-anemone-forward-backend-design.md

integrate.anemone_forward.forward_anemone(M=array([], dtype=float64), thickness=array([], dtype=float64), file_gex=None, GEX=None, tx_height=array([], dtype=float64), altitude_bin_width=1.0, is_log=False, device='cpu', calibration='auto', calibration_reference=None, calibration_factor=None, calibration_tol=0.05, doCompress=True, showtime=False, showInfo=0, progress_callback=None, batch_size=1000, file_sr2=None, sr_filters=False, n_previous_pulses=0, rx_coil_filter='two_pole', gate_integration='centre', tolerance=1e-06, rescale_height=False, **kwargs)

Forward TDEM data for one or more resistivity models with anemone.

rescale_heightbool, optional

Only used when tx_height varies between soundings (default False). anemone bakes the flight height into its setup, which takes about 1 s per distinct height, so the default (one setup per altitude_bin_width bin) is slow for a wide height range. With rescale_height=True one setup is made at the lowest height and the kernel is rescaled to each model’s exact height (exp(-2*dh*lmb)), so altitude_bin_width is ignored. This is an approximation whose error grows with the height spread: small for a spread of a few metres, a few percent of the peak signal at 45 m; a UserWarning is given above 30 m. The reference setup uses tolerance / 10 (about 20% more kernel terms) to keep the rescaling accurate. Has no effect for a fixed height.

batch_sizeint, optional

Number of soundings sent through anemone per call (default 1000). Bounds peak (GPU) memory; 0/None forwards everything at once.

file_sr2, sr_filters, n_previous_pulses

System-response / pulse options, see gex_to_anemone_system(). A GEX with SystemResponseConvolution=1 picks up <gex stem>.sr2 automatically.

rx_coil_filter, gate_integration

Receiver-coil filter model and gate integration, see gex_to_anemone_system().

tolerancefloat or None

Kernel pruning tolerance (default 1e-6); larger is faster and less accurate, see gex_to_anemone_system().

integrate.anemone_forward.gex_to_anemone_system(gex, showInfo=0, file_sr2=None, sr_filters=False, n_previous_pulses=0, rx_coil_filter='two_pole', gate_integration='centre', tolerance=1e-06)

Build the anemone system description from a GEX (+ optional SR2).

rx_coil_filter{‘two_pole’, ‘damped2’, ‘cascade’}

How the GEX RxCoilLPFilter entries are modelled. All readings but 'cascade' use only the entry of the channel’s RxCoilNumber, zeta fcut, as the second-order coil response 1/(1 + 2 zeta s + s^2) (see ISSUE_rx_coil_filter.md):

  • 'two_pole' (default): two first-order poles at fcut/zeta (rx_coil_lowpass in integrate.em_system), the same filters GA-AEM and SimPEG use;

  • 'damped2': the exact second-order response;

  • 'cascade': the earlier reading, every entry as a Butterworth filter of order round(first value); kept for comparisons.

gate_integration{‘centre’, ‘boxcar’}

'centre' (default) evaluates dB/dt at the gate centre time; 'boxcar' averages it over the gate (open to close), using anemone’s built-in gating.

tolerancefloat or None

anemone’s kernel pruning (default 1e-6). At setup, for each gate the (frequency, wavenumber) terms are ranked by their contribution for a 100 ohm-m half-space, and the smallest terms adding up to at most tolerance of the gate’s total absolute contribution are dropped. Fewer terms = faster evaluation (tTEM GEX, GPU: 1e-5 ~1.4x, 1e-4 ~1.7x faster than 1e-6). On rough random 8-layer models, the share of gates within 1 % of the unpruned result is 99.4 % for 1e-6, 96 % for 1e-5, 86 % for 1e-4 and 76 % for 1e-3; the large errors are on gates far below the sounding’s peak. None keeps all terms (~70x more; needs a small batch_size on GPU). See FORWARD_MODELS.md.

file_sr2str, optional

Workbench .sr2 system-response file. If omitted and the GEX sets SystemResponseConvolution=1, <gex stem>.sr2 next to the GEX is used (error if missing). Channels with an SR block use it instead of the GEX waveform.

sr_filtersbool

Also apply the GEX Butterworth low-pass filters to SR channels. Off by default: the measured system response already contains the system’s filtering.

n_previous_pulsesint

Number of earlier bipolar pulses (RepFreq/SignPattern from the GEX channel) superposed on the waveform (default 0 = single pulse).

integrate.anemone_forward.prior_data_anemone(f_prior_h5, file_gex=None, N=0, doMakePriorCopy=True, im=1, id=1, im_height=0, is_log=False, altitude_bin_width=1.0, device='cpu', calibration='auto', calibration_reference=None, calibration_factor=None, calibration_tol=0.05, doCompress=True, force_replace=False, f_prior_data_h5='', batch_size=1000, randomize=True, file_sr2=None, sr_filters=False, n_previous_pulses=0, rx_coil_filter='two_pole', gate_integration='centre', tolerance=1e-06, rescale_height=False, **kwargs)

Generate prior data /D{id} for the anemone TDEM forward backend.

Mirrors integrate.gaaem_forward.prior_data_gaaem() but loads M{im} as resistivity (no 1/) and forwards it through forward_anemone(). batch_size soundings are forwarded per anemone call (bounds peak GPU memory; 0 forwards all N at once). randomize controls whether a copy with N < N_in draws N random realizations (default) or the first N sequentially. rx_coil_filter, gate_integration and tolerance are passed to forward_anemone(). rescale_height=True (varying M{im_height} only) does one anemone setup and rescales it to each model’s height instead of one setup per altitude_bin_width bin; much faster for varying flight height, see forward_anemone(). Returns the path to the prior-data h5 (always the return value).

integrate.anemone_forward.read_sr2(file_sr2)

Read a Workbench/AarhusInv .sr2 system-response file.

Format: // comment lines, then one or more blocks of a header line channel# #repetitions #npts t_begin(yyyy mm dd hh nn ss zzz) t_end(...) followed by npts rows time [s]  dSR/dt. The samples are the second time-derivative of the (unit-current) transmitter waveform with the system’s own filtering folded in, i.e. they take the place of anemone’s Waveform.d2wdt2 (after multiplying by the sample spacing).

Returns:

{channel: {"time", "dsrdt", "n_rep", "header"}} with numpy arrays.

Return type:

dict