Skip to content

Instantly share code, notes, and snippets.

@a2ray
Last active July 16, 2021 06:51
Show Gist options
  • Save a2ray/8c2c55c25fee6647501b403886bbe64d to your computer and use it in GitHub Desktop.
Save a2ray/8c2c55c25fee6647501b403886bbe64d to your computer and use it in GitHub Desktop.
Adding a forward or regression method to transD_GP

Adding an inverse (and forward) method using the transD_GP API

A 1D example to help you get along

Here we'll add a module called FooPhysics, which is totally independent of transD_GP. To couple the physics through a misfit function to transD_GP we'll use a helper module FooPhysicsInversion. This helps in code maintenance as the authors of FooPhysics will not have the time to maintain the integration with transD_GP. That's our job!

All the inverse (and forward) physics (e.g., CSEM and AEM) as well as regression methods (e.g., Line and Surface regression) have to be included in the src/GeophysOperator.jl, so this is where I have added FooPhysics.jl and FooPhysicsInversion.jl through includes as follows:

.
.
include("FooPhysics.jl") # example for API
using. FooPhysics # example for API
include("FooPhysicsInversion.jl") # example for API
using .FooPhysicsInversion # example for API
.
.

Have a close look at these two files as they contain all the essential API elements, including descriptive comments for adding your own forward method for transD_GP inference. Note the .using because it implies loading a module from the current namespace.

Run the 1D example

This FooPhysicsInversion module will basically sample the prior, it runs in no time, and does a few plots you need to visualize the sampled posterior (==prior in this case). It will show you how to connect the forward physics, misfit function, data for inference, setting prior options, and plotting the posterior. To run this example, run the scripts in sequence in examples/Foo

All the inferences problems in transD_GP whether 1D, 2D or spatially 3D follow the same recipe -- you don't need to change the sampler code!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment