This repository has been archived by the owner on Dec 22, 2021. It is now read-only.
Rewrote the Moulder class for interactive 2D gravity modeling #143
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Allows editing points, setting densities, selecting/deleting polygons and points, etc.
Reload the predicted data from file as well. Set animated=False before saving so that all polygons are plotted on reload.
Was having trouble under windows to pickle the matplotlib.patches.Polygon. So storing the vertices in the pickle and recreating the polygons and lines in __init__.
Moved the Moulder class to gravmag.interactive. Deleted the other classes and their respective cookbook recipes. Updated docs accordingly.
Conflicts: README.md
When the plot window was resized during modeling, the 'plot' method was drawing polygons out of the modelax borders. The same was happening when calling 'run' again. Fixed by recreating the polygon and line objects on figure_setup.
I have made a tutorial notebook using the new Moulder class: http://nbviewer.ipython.org/github/fatiando/tutorials/blob/master/Interactive_gravmag_modeling.ipynb |
So in the end I've deleted the |
Conflicts: doc/changelog.rst
leouieda
added a commit
that referenced
this pull request
Nov 24, 2014
Rewrote the Moulder class for interactive 2D gravity modeling
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
fatiando.gui.simple.Moulder
class created an interactive matplotlib window for drawing polygons and calculating their gravitational effect (usingfatiando.gravmag.talwani
). The functionality was very limited: could not edit polygons after they were drawn, orresume the app once the window was closed, or save the app state for loading later, etc.I have rewritten the
Moulder
class to allow all of this. You can now:Moulder.save
)Moulder.save_predicted
)Moulder
from the pickled state (Moulder.load
)You can see this class in action in the 5th practical class of Geofísica 1: pratica5.ipynb. You'll to have this branch active on your local clone to run the notebook.
Here is a screenshot of the GUI window.
Problems and discussion
The new code breaks the
BasinTri
andBasinTrap
classes that relied on the oldMoulder
.I'm inclined to delete these classes (and the
Lasagne
class as well) because they can be easily replaced (and improved) by IPython widgets.This raises the question: Should we even keep the
fatiando.gui
package? It is a tiny and virtually unused package. Things in it could easily be moved to other packages (Moulder
could go into afatiando.gravmag
).I think a better package structure would be to have
interactive
modules in the method packages (e.g.,gravmag.interactive
) where the GUIs and widgets could live.I'd like some input on this, please, @birocoles, @eusoubrasileiro, @hbueno.
TODO
Polygons get left out of the scene. Maybe make a "window close" callback that
removes the
animate
flags and redraws the scene?Checklist