Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a minimalistic implementation of Euler Deconvolution #268

Open
dragger21 opened this issue Oct 22, 2021 · 9 comments · May be fixed by #493
Open

Add a minimalistic implementation of Euler Deconvolution #268

dragger21 opened this issue Oct 22, 2021 · 9 comments · May be fixed by #493
Labels
enhancement Idea or request for a new feature

Comments

@dragger21
Copy link

Greetings from Indonesia.

Bringing the Euler Deconvolution back like in previous version (Python 2.7) should be interesting. It can predict/detect the depth of source anomaly in potential field (like gravity and magnetic).

@dragger21 dragger21 added the enhancement Idea or request for a new feature label Oct 22, 2021
@santisoler
Copy link
Member

Hi @dragger21! Thanks for opening this issue!

Adding an Euler deconvolution implementation is in our future plans for Harmonica.
As I remember, @leouieda was having some ideas for it.

@santisoler santisoler changed the title Euler Deconvolution Add Euler Deconvolution Oct 26, 2021
@leouieda
Copy link
Member

leouieda commented Oct 26, 2021

Well, to start it would be great to have a minimalistic implementation: only the inversion solution, no moving windows and all that.

This should be less work to code and can then be used as a basis for more elaborate methods.

@dragger21 would be interested in implementing this? We're always happy to have more people involved in development 🙂

@dragger21
Copy link
Author

To @leouieda and @santisoler, I'm sorry for the late reply.

I think that is very interesting to minimise implementation!
Quick question, how are we going to do that without any moving windows? Based on Reid et al. (1990) this work should include moving windows. Do you have any other literature that's pointed out that?

I actually very interested to implement this in your code. I feel very happy to be involved in the development.

@leouieda leouieda changed the title Add Euler Deconvolution Add a minimalistic implementation of Euler Deconvolution Nov 1, 2021
@leouieda
Copy link
Member

leouieda commented Nov 1, 2021

@dragger21 no worries, we're all busy and can relate to taking a while to respond 🙂 We'd be glad to have you involved in the development 🎉

The moving window strategy is a way to try to deal with multiple sources (in my opinion, it kind of fails to do so but that is for another discussion). But it's not intrinsic to the method and really not required if you have already isolated the target anomaly. If there is 1 anomaly in your data, it's actually worse if you do a moving window because the solutions for most windows are completely meaningless (as Alan Reid himself pointed out in several papers).

From a coding perspective, this is what I had in mind:

  1. Implement a function or a class that does the inversion of Euler's homogeneity equation (no windows, only solve the equation and calculate the source position and base level). Let's call this EulerDeconv for example.
  2. Implement a strategy that selects the anomalies and runs EulerDeconv on each anomaly. This could be a moving window strategy or something else entirely. But it will depend on the implementation in step 1.

So to get started, I would recommend implementing step 1 only. We can later add windows etc on top of this. It helps to break down the coding work into smaller tasks like this because:

  1. Each step is quicker to implement and less code for us to review and give feedback on.
  2. It's less code for you to write and more importantly, less documentation and tests (which is what most people struggle with the most when first starting out).
  3. If you get busy later, someone else can continue the work and you still get credit for adding one piece of the code.

@leouieda
Copy link
Member

leouieda commented Nov 1, 2021

What I had in mind for the EulerDeconv class is something like this:

class EulerDeconv:
    """
    ...
    """
    def __init__(self, structural_index):
        self.structural_index = structural_index
        # The estimated parameters. Start them with None
        self.location_ = None
        self.base_level_ = None

    def fit(self, coordinates, data):
        # This function runs the inversion on the input data
        # data = (field, east_deriv, north_deriv, up_deriv)
        self.location_ =  the estimated location
        self.base_level_ = the estimated base level

This class runs the inversion and stores the estimated source position and base level. It would be used like this:

# Load some data. I'm assuming that they've been projected already.
data = pandas.read_csv("some-data-file.csv")

# Calculate derivatives with equivalent sources
eqs = hm.EquivalentSources(depth=..., damping=...)
eqs.fit((data.easting, data.northing, data.height), data.total_field_anomaly)
delta = 1  # finite difference step in meters
data["east_deriv"] = (
    eqs.predict((data.easting + delta, data.northing, data.height))
    - eqs.predict((data.easting - delta, data.northing, data.height))
) / 2 * delta
data["north_deriv"] = (
    eqs.predict((data.easting, data.northing + delta, data.height))
    - eqs.predict((data.easting, data.northing - delta, data.height))
) / 2 * delta
data["up_deriv"] = (
    eqs.predict((data.easting, data.northing, data.height + delta))
    - eqs.predict((data.easting, data.northing, data.height))
) / delta

# Run Euler deconvolution. Let's say the data is a dipole anomaly of an intrusion.
euler = hm.EulerDeconv(structural_index=3)
euler.fit(
    coordinates=(data.easting, data.northing, data.height), 
    data=(data.total_field_anomaly, data.east_deriv, data.north_deriv, data.up_deriv),
)
print(euler.location_)
print(euler.base_level_)

@dragger21
Copy link
Author

I apologize again for the long reply. Thanks for the insight, Leo & Santiago. I'm trying to seek and simplify the code as soon as possible. I'll notify you later.

@leouieda
Copy link
Member

@dragger21 no rush! Please reach out if you need any help

@AnthonyDunk
Copy link

Has there been any progress made on adding Euler Deconvolution to Harmonica yet? I'm interested in using it to run this example, but since I have Python 3.10, I'm out of luck at the moment: https://legacy.fatiando.org/gallery/gravmag/euler_moving_window.html
Thanks.

@nikita-k0v
Copy link

bump, any progress on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Idea or request for a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants