Skip to main content

Configuring an FWI Run

Reference for the JSON configuration passed to devitohorizon-fwi --config. For the concepts behind these settings see the Overview; for worked runs see Examples.

A minimal config:

{
  "model": {"vp": "model.sgy"},
  "data_path": "shots.segy",
  "output_dir": "out",
  "run_name": "fwi_run",
  "parameters": ["m"],
  "bounds": {"vp": [1.2, 5.5]},
  "optimizer": {"method": "SPG", "maxiter": 10, "batch_size": 128}
}

Preprocessing

preprocess is applied to every shot before the misfit sees it. Sections run in a fixed order (filter, differentiate, integrate, mute, offset, gain) unless a steps list reorders them or adds custom steps; see Custom Data Preprocessing.

"preprocess": {
  "filter": {"type": "bandpass", "fmin": 2.0, "fmax": 12.0},
  "mute": {"type": "direct", "v": 2.5, "t0": 0.0, "taper": 0.1}
}

Normalization is not a preprocessing step: it belongs to the misfit, whose normalization ("trace" or "shot") differentiates through it. A normalize section is refused.

Mutes

Two types, complementary to each other, both defined against the linear moveout boundary tcut = max(t0 + offset / v, tmin):

type keeps removes
direct samples after tcut the early arrivals
reflections samples before tcut everything after tcut

v is in m/s; a value below 10 is read as km/s. taper is in seconds; a value above 1 is read as milliseconds.

mute also accepts a list, applied in order, which is how a window bounded on both sides is built:

"mute": [
  {"type": "direct",      "v": 2.5},
  {"type": "reflections", "v": 0.6}
]

Here the first mute removes everything arriving faster than 2.5 km/s and the second everything slower than 0.6 km/s, leaving the window between them. On land data that is the usual way to drop the direct and turning arrivals at one end and the ground roll at the other.

Note that a mute only acts where its boundary falls inside the record: at offset x the reflections line sits at x / v, so on far offsets a low-velocity mute may cut nothing at all.

"v": "surface" bounds a mute by each trace’s direct-wave time through the starting model’s velocity along the acquisition surface instead of x / v, computed once per band and held fixed through the line search. As a reflections mute it keeps the turning waves that arrive before the direct wave, the usual turning-wave window on land:

"mute": [
  {"type": "reflections", "v": 0.5, "t0": 1.0, "taper": 1000},
  {"type": "reflections", "v": "surface", "t0": 0.0, "taper": 0.5}
]

When the mutes leave every trace zero after some time, the misfit and the gradient model each shot only to 0.5 s past it instead of to tn.

Choosing the window

The mute decides which arrivals drive the inversion, and with it the depth range the data can constrain. Keeping only the early arrivals gives a transmission inversion driven by diving waves, which turn at roughly x_max / 3 for a smooth gradient — no information below that, whatever the frequency. Keeping the reflections constrains deeper, at the cost of needing a model good enough to predict them.

Geometry and statics

Land data usually arrives referenced to a survey datum rather than to the model’s z axis. Nothing in the config reconciles them: the loader reads the headers and places the geometry itself.

Which convention a dataset’s z uses is read from the file: the header word the coordinates came from is the answer, since SourceSurfaceElevation and RecGroupElevation are elevations while SourceDepth and the water-depth words are depths. The source key is the one trusted — a receiver key can be an elevation word carrying depths, which is what data whose geometry was already moved onto the datum looks like.

A file whose z is an elevation then needs the elevation those depths are measured from, and that is a header too: RecDatumElevation, in the same trace header as the elevations. It is read from the dataset, falls back to the model files with a warning, and raises listing every vertical word when neither records one. That fallback is the only reason the loader is given the model at all — it is the one question a dataset cannot answer about itself.

The datum static the processor already applied to the traces is undone the same way. TotalStaticApplied (bytes 103-104) records how much the data was shifted to bring it onto a flat datum; a simulation on the true geometry does not know that, so its events sit that much later than the recorded ones and the imaging correlation compares the wrong times. It fires the source earlier by that amount, per shot at runtime — the value tracks source elevation and varies along the line, so a run-wide wavelet delay cannot carry it. Always read: the word is zero on a file that never had a static, and undoing zero is the identity, so nothing has to be declared.

Neither is a setting. They describe the file, not the run, so a config key asserting them would be right for one dataset and silently wrong for the next — on one survey the difference between reading z as an elevation and as a depth was 480 m, which puts every source in the vacuum above the topography and returns an exactly-zero forward. Its migration file and its FWI file use opposite conventions and now place to within 11 m of each other, unconfigured.

Misfit

"misfit": {"misfit": "phase", "normalization": "trace"}

A bare string is also accepted ("misfit": "l2").

Optimizer

method picks the optimizer (SPG, the default, PQN, TMP or BREGMAN); the other keys are its constructor arguments, plus the shot sampling (batch_size).

Batches are drawn by patch by default ("batch_draw": "patches"): the survey is split into batch_size compact spatial patches of equal shot count and each iteration draws one shot from each, without repeating a shot in its patch until all of its shots have been used; "random" draws batch_size shots anywhere. Drawn by patch, every iteration covers the survey evenly, the patches are written to <run>_patches.json, and the iteration figures show each patch’s relative misfit change over the step: on the velocity panel of a 2-D model, as <run>_iter_NNNN_patches.png for 3-D. Every evaluation’s shots and per-shot misfits are in <run>_shot_misfits.json.

"optimizer": {"method": "PQN", "maxiter": 20, "memory": 5, "max_step_frac": 0.05}

max_step_frac caps how far one iteration moves the model: no cell changes by more than that fraction of its own value. SPG caps at 0.2 by default; PQN is uncapped unless it is set, and its quasi-Newton steps can otherwise reach the bounds in one iteration. See Optimizers for every argument.

Frequency continuation

"continuation": {
  "fmax": [6.0, 9.0, 12.0],
  "fmin": [2.0, 2.0, 2.0],
  "ppw": 6,
  "sweeps": 2
}

fmax defines the bands; sweeps repeats the whole schedule, each sweep restarting at the lowest frequency from the model the previous one produced.

With ppw set, each band derives its grid spacing from points-per-wavelength; band_spacings sets them explicitly. Every band’s grid is derived from the original model’s extent rather than from the previous band’s, so a sweep returns to exactly the grid it started from and per-shot crops stay aligned with the full model.

The model is smoothed on the way into a band only when that band asks for less resolution than the one before — a coarser grid or a lower fmax, as at the start of a new sweep. Control with model_smoothing and smoothing_factor.

Per-band and per-sweep settings

A continuation has two schedules. Keys directly under continuation are indexed by band; keys under continuation.sweep are indexed by sweep. Both use the same names, so preprocess means per band at the top level and per sweep inside sweep.

"misfit": {"misfit": "phase", "normalization": "trace"},
"continuation": {
  "fmax": [6.0, 9.0, 12.0],
  "sweeps": 2,

  "preprocess": [{"mute": {"type": "direct", "v": 2.0}}, null, null],
  "iters": [5, 5, 10],

  "sweep": {
    "misfits": ["phase", "l2"],
    "preprocess": [null, {"mute": {"type": "reflections", "v": 2.25}}]
  }
}
under continuation (per band) under continuation.sweep (per sweep)
preprocess, iters, band_spacings preprocess, misfits, normalization, labels

A band-level preprocess wins over a sweep-level one where both apply, and both win over the top-level preprocess.

A bare misfit name in misfits keeps the settings alongside it in misfit – above, the second sweep runs l2 with the same trace normalization rather than dropping it. Spell out a mapping to change those too.

The flat sweep_misfits, sweep_preprocess, sweep_normalization and sweep_labels keys are still accepted.

Convergence output

Each band’s per-iteration misfit is written at the end of the run, as <run>_convergence.json and <run>_convergence.png. Bands are plotted as separate segments: each changes the data being fitted, so the objective is discontinuous at every boundary and values either side are not comparable.

Migration (RTM)

{
  "rtm": true,
  "rtm_fmax": 20.0
}

In a continuation the migration runs on the last band only, once the model is final, and also migrates the model the run started from — same shots, same preprocessing — so the pair differs only by the model.

Outputs, alongside the inversion results:

file contents
<run>_rtm.segy / .png image from the final model
<run>_rtm_initial.segy / .png image from the starting model
<run>_rtm_compare.png both, on one shared clip

Also on the result object as result.rtm_image and result.rtm_image_initial. A migration failure is logged and skipped; the model and convergence history are still written.

Band and preprocessing

Everything a migration does differently from the inversion that produced it lives in one rtm block:

Key Meaning
tn Recording window for the migration, when it needs to be longer than the inversion’s
spacing Grid spacing in metres for the migration
fmin / fmax The migration band
preprocess Data conditioning for the imaging adjoint source

The same key says whether to migrate at all, so there is one answer to “does this run make an image, and how”: a mapping means yes with these settings, true means yes with the inversion’s own, false or no key means no.

fmax alone applies a lowpass, with fmin a bandpass; it can also be given under continuation as rtm_fmax. preprocess replaces the inversion’s preprocessing for the migration, and the band is applied on top of it, so mutes and normalization are kept and only the filter is set. Without either, the imaging path falls back to the inversion’s preprocessing, which in a continuation carries the current band’s filter and will limit the image to that band — so set the band explicitly for any run where the image matters.

"rtm": {
  "fmax": 20.0,
  "preprocess": {
    "mute": [{"type": "direct", "v": 2.5},
             {"type": "reflections", "v": 0.6}]
  }
}

The low corner is worth setting deliberately and not leaving at a seismic-band default. Below roughly 10 Hz the imaging correlation is dominated by a low-wavenumber term that builds a blob around each source rather than reflectors, and it can bury the image completely.

Source correction

With source_estimation on, a filter h mapping synthetic to observed is fitted per shot: one complex scalar per frequency, the least-squares fit over every trace of the shot (Pratt, 1999). It carries the shot’s timing as well as its shape, with lags from a quarter period of advance to 1.25 periods of delay at the data’s mean frequency. The adjoint filter goes onto the adjoint source, since \(\langle h u, v\rangle = \langle u, h^{\top} v\rangle\). The inversion and the migration apply the same correction; there is no setting for it.

Grid

rtm.spacing puts the migration on its own grid. The grid an inversion finishes on only ever had to carry its last continuation band; migrating on it disperses the extra frequencies rather than imaging them. Allow about five points per wavelength at the migration’s fmax and the model’s minimum velocity — below that the loss is measurable, not theoretical.

"rtm": {"spacing": 7.0, "fmax": 35.0}

An inversion driven by diving waves and a migration want opposite windows: the inversion keeps the early arrivals, the migration keeps the reflections.

Recording window

rtm.tn gives the migration a longer window than the inversion’s tn:

"tn": 2.5,
"rtm": {"tn": 4.5}

Imaging has to run to the two-way time of the deepest reflector, which the inversion rarely needs — at 4 km depth and an RMS of 2.75 km/s that is about 2.9 s vertical, before moveout. Sharing one tn forces a choice between a migration that stops above the base of the model and an inversion paying for that depth on every iteration, linearly. Both are still capped by the record: asking for more than was recorded gives what was recorded. Unset, the migration uses tn.

Imaging and inversion conditions

Both follow the physics, so neither needs configuring.

Physics Migrates with Inverts with
iso-acoustic Z mZ
tti-fletcher, vti-fletcher Z mZ
tti-zhang, vti-zhang Z mZ
everything else m m

Z is the impedance branch of the ISIC condition: it sums the mass and stiffness correlations, which puts the reflectivity band in the image directly. mZ differences them instead, which drops the migration isochrones and leaves the velocity update the transmission wavepaths — the scale separation that makes it the better FWI kernel: the plain m kernel is a mass-term correlation carrying both. Every recipe that implements the condition uses it for both, so the two columns above only differ for recipes that implement neither.

Set "parameters": ["m"] to put a run back on the standard slowness gradient. mZ shares the squared-slowness model vector with m, so bounds, parameter scaling and the optimizer are unaffected either way.

Joint velocity and reflectivity

A reflection FWI inverts a velocity and a reflectivity together. The method of McLeman et al. (2021) is "vector_reflectivity": true with "parameters": ["mZ", "Z"]:

{
  "parameters": ["mZ", "Z"],
  "vector_reflectivity": true,
  "gradient": {
    "mute": {"type": "datum"},
    "steps": [
      {"kind": "global_smoothing", "parameters": ["mZ"]},
      {"kind": "surface_mute"}
    ]
  },
  "bounds": {"vp": [1.5, 5.0]}
}

The wave equation carries the reflectivity as a free vector, m u_tt - lap(u) + (Z + grad(log m)/2).grad(u) = rho s, and Z is that vector: one component per grid axis (Zx, Zy in 2D), zero unless the model provides them, and boxed per cell to a stable contrast unless bounds names it. mZ is squared slowness at fixed Z, whose gradient keeps the migration isochrones out of the velocity. Smooth the velocity only; the reflectivity has to stay sharp. It is implemented for iso-acoustic, tti-zhang/vti-zhang, which an anisotropic model resolves to, and tti-fletcher, and not under an immersed boundary: a model with an sdf is refused. ["m", "r"] inverts McLeman et al.’s own form, where the scattering vector is the vector r itself. "vector_reflectivity": "scalar" carries the reflectivity as one field, Z or r, whose gradient is that vector: a scalar Z is the log impedance. How to set up a run and read its result is in Reflection FWI, the derivation in Augmented-wave-equation reflection FWI.

Without the vector reflectivity, two variable-density pairs remain, each gradient taken with the other member of its pair held fixed:

parameters Velocity Reflectivity
["mZ", "Z"] squared slowness at fixed impedance impedance at fixed slowness
["m", "b"] squared slowness at fixed density buoyancy at fixed slowness

Mixing the pairs (["m", "Z"], ["mZ", "b"]) is rejected, because the step would move along a different direction from the one the gradient measured. Both need a model with a density field; the impedance without explicit bounds is kept within 20 per cent of its starting range.

"t_sub" is the time subsampling of the saved forward wavefield, 5 by default. The gradient is summed on the saved samples only, so t_sub times the time step has to sample the correlation of the forward and adjoint fields; at a critical time step and 15 Hz, 5 is too coarse and the gradients scatter by tens of per cent around the true derivative.

Physics.image takes an explicit params for a deliberate override of the migration parameter. Asking a recipe for a condition it does not implement is not an error and returns an all-zero image, so prefer the defaults.

A complete example

A two-sweep, three-band run on land data: diving waves and a phase misfit on the first sweep, reflections and l2 on the second, then a 20 Hz migration with the final model.

{
  "model": {"vp": "vp_init.sgy", "epsilon": "eps.sgy", "delta": "del.sgy"},
  "data_path": "shots.segy",
  "output_dir": "out/run01",
  "run_name": "land_2sweep",

  "parameters": ["m"],
  "bounds": {"vp": [1.2, 5.5]},
  "tn": 6000.0,

  "misfit": {"misfit": "phase", "normalization": "trace"},

  "preprocess": {
    "mute": {"type": "reflections", "v": 2.7, "t0": 0.7, "taper": 0.1}
  },

  "gradient": {"mute": {"type": "datum"}},

  "continuation": {
    "fmax": [6.0, 9.0, 12.0],
    "fmin": [2.0, 2.0, 2.0],
    "ppw": 6,
    "sweeps": 2,

    "iters": [5, 5, 10],

    "preprocess": [
      {"mute": {"type": "reflections", "v": 3.0, "t0": 0.5, "taper": 0.1}},
      null,
      null
    ],

    "sweep": {
      "misfits": ["phase", "l2"],
      "preprocess": [
        null,
        {"mute": [{"type": "direct", "v": 2.5, "taper": 0.1},
                  {"type": "reflections", "v": 0.6, "taper": 0.1}]}
      ]
    }
  },

  "rtm": true,
  "rtm_fmax": 20.0,
  "rtm_fmin": 2.0,
  "rtm_preprocess": {
    "mute": [{"type": "direct", "v": 2.5, "taper": 0.1},
             {"type": "reflections", "v": 0.6, "taper": 0.1}]
  },

  "optimizer": {"method": "SPG", "batch_size": 512, "save_every": 1},
  "dask": {"workers_per_rank": 16, "worker_nthreads": 1}
}

Reading the schedule this produces:

run sweep band iters misfit preprocessing used
1 1 6 Hz 5 phase continuation.preprocess[0]
2 1 9 Hz 5 phase top-level preprocess
3 1 12 Hz 10 phase top-level preprocess
4 2 6 Hz 5 l2 continuation.preprocess[0]
5 2 9 Hz 5 l2 sweep.preprocess[1]
6 2 12 Hz 10 l2 sweep.preprocess[1]

Every band’s filter comes from fmax/fmin and is merged in on top, and iters gives band 3 ten iterations instead of five in both sweeps.

Note run 4. A band-level preprocess outranks the sweep-level one in every sweep, so band 1 keeps its own mute in sweep 2 and does not pick up the two-mute window the rest of that sweep uses. If a sweep should change the preprocessing for all of its bands, leave continuation.preprocess unset and put the per-band variation inside each sweep entry instead.

Outputs in out/run01: per-band models and figures, land_2sweep_convergence.json and .png, and — from the last band only — land_2sweep_rtm.segy/.png, land_2sweep_rtm_initial.segy/.png and land_2sweep_rtm_compare.png.

Gradient processing

gradient shapes the stacked gradient before it reaches the optimizer: water/datum mutes, cone mutes, smoothing, or an explicit ordered steps pipeline. See Custom Gradient Processing.

Parallel execution

dask configures the cluster; see Dask & HPC.

On a cloud cluster

Naming a cloud provisions the cluster for the run and tears it down after, so a cloud run is devitohorizon-fwi config.json like any other:

"dask": {
  "cloud": "aws",
  "creds": "aws_creds.json",
  "n_workers": 8,
  "instance_type": "m5.4xlarge"
}

creds is the path to the file scripts/make_aws_creds.sh (or make_azure_creds.sh) writes, or the credentials themselves. cloud is aws or azure. Every other key is an argument for the cluster helper, so anything ec2_cluster or azure_vm_cluster takes can be set here: docker_image, local_scheduler, scheduler_instance_type, and the rest. See Cloud Setup for what has to exist in the account first.

The cluster is created inside the run rather than attached to, and that is deliberate: dask-cloudprovider secures it with certificates generated in memory, so a separate process given only the scheduler address has nothing to present and cannot connect. address remains the way to attach to a cluster that is already running and shares its certificates.

Back to top