# Least Squares Inversion of simulated gravitational field data

**URL:** <https://simpeg.discourse.group/t/least-squares-inversion-of-simulated-gravitational-field-data/151>\
**Category:** Potential Fields\
**Created:** [November 12, 2020, 12:20pm UTC](https://simpeg.discourse.group/t/least-squares-inversion-of-simulated-gravitational-field-data/151 "2020-11-12T12:20:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![RoryPhelan](https://avatars.discourse-cdn.com/v4/letter/r/97f17d/32.png) [@RoryPhelan](https://simpeg.discourse.group/u/RoryPhelan)\
**Post date:** [November 12, 2020, 12:20pm UTC](https://simpeg.discourse.group/t/least-squares-inversion-of-simulated-gravitational-field-data/151/1 "2020-11-12T12:20:44Z")

</div>

I am currently in the middle of a project in which I am looking to invert potential gravitational field data to obtain information on subsurface mass anomalies.

I have been following this tutorial (except using my own gravitational data)

> **[Least-Squares Inversion of Gravity Anomaly Data — SimPEG 0.14.2 documentation](https://docs.simpeg.xyz/content/tutorials/03-gravity/plot_inv_1a_gravity_anomaly.html#sphx-glr-content-tutorials-03-gravity-plot-inv-1a-gravity-anomaly-py)**

However I can’t seem to recover any information other than the visible density contrast the final plot gives out. Is anyone aware of how I could potentially recover the depth or mass of the subsurface anomaly after the inversion?

Thanks

---

<div class="post-metadata">

**Author:** ![domfournier](https://avatars.discourse-cdn.com/v4/letter/d/a3d4f5/32.png) [@domfournier](https://simpeg.discourse.group/u/domfournier)\
**Post date:** [November 13, 2020, 11:26pm UTC](https://simpeg.discourse.group/t/least-squares-inversion-of-simulated-gravitational-field-data/151/2 "2020-11-13T23:26:13Z")

</div>

Hi Rory,  
I am not sure I understand your question.  
The model sections shown after the inversion are vertical depth slices of density contrast: [https://docs.simpeg.xyz/content/tutorials/03-gravity/plot\_inv\_1a\_gravity\_anomaly.html#plotting-true-model-and-recovered-model](https://docs.simpeg.xyz/content/tutorials/03-gravity/plot_inv_1a_gravity_anomaly.html#plotting-true-model-and-recovered-model)

You might want to load the results in a 3D software to interpret? It might be more obvious that way.

---

<div class="post-metadata">

**Author:** ![RoryPhelan](https://avatars.discourse-cdn.com/v4/letter/r/97f17d/32.png) [@RoryPhelan](https://simpeg.discourse.group/u/RoryPhelan)\
**Post date:** [November 18, 2020, 12:12pm UTC](https://simpeg.discourse.group/t/least-squares-inversion-of-simulated-gravitational-field-data/151/3 "2020-11-18T12:12:28Z")

</div>

Hi Dom,

Thank you for getting back to me.  
I wasn’t fully comprehending the purpose of the model but I understand it better now, thanks.

Another question I have, if you or anyone else on here might possibly know the answer, what part of the code is it which sets the value of Y for which the slice of the model is plotted?

For example in this tutorial it is a slice at y =0 [https://docs.simpeg.xyz/content/tutorials/03-gravity/plot\_1a\_gravity\_anomaly.html#sphx-glr-content-tutorials-03-gravity-plot-1a-gravity-anomaly-py](https://docs.simpeg.xyz/content/tutorials/03-gravity/plot_1a_gravity_anomaly.html#sphx-glr-content-tutorials-03-gravity-plot-1a-gravity-anomaly-py)

But here, it is a slice at y = 2.5 [http://docs.simpeg.xyz/content/tutorials/01-models\_mapping/plot\_1\_tensor\_models.html#sphx-glr-content-tutorials-01-models-mapping-plot-1-tensor-models-py](http://docs.simpeg.xyz/content/tutorials/01-models_mapping/plot_1_tensor_models.html#sphx-glr-content-tutorials-01-models-mapping-plot-1-tensor-models-py)

and I cannot seem to see the difference.

Any help is appreciated,  
Thanks, Rory

---

<div class="post-metadata">

**Author:** ![thibaut.astic](https://yyz2.discourse-cdn.com/free1/user_avatar/simpeg.discourse.group/thibaut.astic/32/109_2.png) [@thibaut.astic](https://simpeg.discourse.group/u/thibaut.astic)\
**Post date:** [December 3, 2020, 11:36pm UTC](https://simpeg.discourse.group/t/least-squares-inversion-of-simulated-gravitational-field-data/151/4 "2020-12-03T23:36:50Z")

</div>

Hi Rory,  
in the `mesh.plotSlice` function, the `ind` argument controls which slice you plot (1, 2 …). The y= … just depends on your mesh location. if you look at `mesh.vectorCCy`, you will see all the y-locations of your mesh cells. So for example, choosing `ind=0` will plot the slice at location `y=mesh.vectorCCy[0]`.

---

<div class="post-metadata">

**Author:** ![RoryPhelan](https://avatars.discourse-cdn.com/v4/letter/r/97f17d/32.png) [@RoryPhelan](https://simpeg.discourse.group/u/RoryPhelan)\
**Post date:** [December 4, 2020, 1:31pm UTC](https://simpeg.discourse.group/t/least-squares-inversion-of-simulated-gravitational-field-data/151/5 "2020-12-04T13:31:15Z")

</div>

Ah yes. It seems obvious now haha I should have worked that out.  
Thank you for the help

---

<div class="post-metadata">

**Author:** ![RichardScottOZ](https://avatars.discourse-cdn.com/v4/letter/r/b2d939/32.png) [@RichardScottOZ](https://simpeg.discourse.group/u/RichardScottOZ)\
**Post date:** [May 1, 2021, 1:12am UTC](https://simpeg.discourse.group/t/least-squares-inversion-of-simulated-gravitational-field-data/151/6 "2021-05-01T01:12:45Z")

</div>

Although in each of those cases the example uses int(mesh.nCy / 2)… so not an obvious number?

The 0 slice has a hardcoded heading, whereas the 2.5 uses the variable

Zeros in an axes/origin sense or metres sense.

---

<div class="post-metadata">

**Author:** ![RichardScottOZ](https://avatars.discourse-cdn.com/v4/letter/r/b2d939/32.png) [@RichardScottOZ](https://simpeg.discourse.group/u/RichardScottOZ)\
**Post date:** [May 1, 2021, 1:22am UTC](https://simpeg.discourse.group/t/least-squares-inversion-of-simulated-gravitational-field-data/151/8 "2021-05-01T01:22:39Z")

</div>

E.g. presumably mesh.nCy cannot be zero and this a slice on the above calculation so ind can’t be zero either?

So I suppose a little confusing to the user at first who might assume that 0 works, whereas in this case because it is symmetrical?

e.g. if you had two thirds of your cells below the sea level, so to speak you would want int(mesh.Ncyz/2\*3)) - or just work out which one it was and use that?
