-
Notifications
You must be signed in to change notification settings - Fork 17
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
Interactive buttons for deciding slip character #9
Comments
You can add buttons (from matplotlib.widgets) to a figure window and then you can set a function that is called when it is clicked. See startLinking in the Linker class for an example. Although you'll want to use the on_clicked() function of the button to attach the event handler rather than how I've done it there (https://matplotlib.org/api/widgets_api.html#matplotlib.widgets.Button.on_clicked). You have to be careful with the button you create going out of scope and being discarded as well because then the click will not work and you don't get an error message (very frustrating to figure out and fix). I would suggest having a member function of the grain class that sets the type of slip for that grain from an input argument then call that from some buttons added to the figure that shows individual grains. You might have to use a lambda expression to pass the different argument to the click event function from each button, I'm not sure on that though. Come and see me if you want some more explanation. |
Another quicker(?) solution would be to just ask for keyboard input: c
for coarse, w for wavy, d for diffuse.
And I don't know about an automatic method but a max/min ratio of a
hoop integral of the FFT at a given radius, might be a good way of
distinguishing between the different kinds of slip. And more
reproducible!
João
…On Tue, 2018-05-01 at 05:29 -0700, Michael Atkinson wrote:
You can add buttons (from matplotlib.widgets) to a figure window and
then you can set a function that is called when it is clicked. See
startLinking in the Linker class for an example. Although you'll want
to use the on_clicked() function of the button to attach the event
handler rather than how I've done it there (https://matplotlib.org/ap
i/widgets_api.html#matplotlib.widgets.Button.on_clicked). You have to
be careful with the button you create going out of scope and being
discarded as well because then the click will not work and you don't
get an error message (very frustrating to figure out and fix).
I would suggest having a member function of the grain class that sets
the type of slip for that grain from an input argument then call that
from some buttons added to the figure that shows individual grains.
You might have to use a lambda expression to pass the different
argument to the click event function from each button, I'm not sure
on that though.
Come and see me if you want some more explanation.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
You probably need the autocorrelation array, not the FFT.
…Sent from my iPhone
On 1 May 2018, at 16:56, ***@***.*** wrote:
Another quicker(?) solution would be to just ask for keyboard input: c
for coarse, w for wavy, d for diffuse.
And I don't know about an automatic method but a max/min ratio of a
hoop integral of the FFT at a given radius, might be a good way of
distinguishing between the different kinds of slip. And more
reproducible!
João
> On Tue, 2018-05-01 at 05:29 -0700, Michael Atkinson wrote:
> You can add buttons (from matplotlib.widgets) to a figure window and
> then you can set a function that is called when it is clicked. See
> startLinking in the Linker class for an example. Although you'll want
> to use the on_clicked() function of the button to attach the event
> handler rather than how I've done it there (https://matplotlib.org/ap
> i/widgets_api.html#matplotlib.widgets.Button.on_clicked). You have to
> be careful with the button you create going out of scope and being
> discarded as well because then the click will not work and you don't
> get an error message (very frustrating to figure out and fix).
> I would suggest having a member function of the grain class that sets
> the type of slip for that grain from an input argument then call that
> from some buttons added to the figure that shows individual grains.
> You might have to use a lambda expression to pass the different
> argument to the click event function from each button, I'm not sure
> on that though.
> Come and see me if you want some more explanation.
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub, or mute the thread.
|
Thanks both for your suggestions. I will look into implementing an automatic function before I try this button.. using the FFT may well be the way forward. I will report back when I've given this a go! |
Only just got around to looking at this yesterday and today. I found that automating the routine (using filters to get the slip bands and then an FFT or autocorrelation to get the angles) was unreliable, so I've gone with the manual buttons approach. You need to make sure the Matplotlib backend is in osx and then you can run the following to add these two functions to the Grain class: `def getGrainDefMap(self):
hrdic.Grain.getGrainDefMap = getGrainDefMap` `def analyseSlipCharacter(self):
hrdic.Grain.analyseSlipCharacter = analyseSlipCharacter` Then run the code for, e.g. grain number 30 with:
Once you close the figure the buttons that you press will be appended to the list DicMap.grainList[30].slipCharacter |
Hold on the code for those functions didn't quite post properly... let me try again: `
hrdic.Grain.getGrainDefMap = getGrainDefMap def analyseSlipCharacter(self):
hrdic.Grain.analyseSlipCharacter = analyseSlipCharacter ` |
Ok for some reason the first and last lines of the code aren't formatted properly here but all of the code is there. The only issue with the code is that the buttons are supposed to turn green when you press them but this doesn't seem to work properly. Maybe an issue with the backend. |
Thanks Allan. Do you have some code for what you tried to do automatically? I am all up for the pragmatic approach and getting results but I am just thinking of having something that will scale up in the future.
João
… On 13 Jul 2018, at 11:09, AllanHarte ***@***.***> wrote:
Ok for some reason the first and last lines of the code aren't formatted properly here but all of the code is there. The only issue with the code is that the buttons are supposed to turn green when you press them but this doesn't seem to work properly. Maybe an issue with the backend.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I'll put together a notebook with the things that I've tried |
Looks good. The buttons not changing colour is probably to do with canvas not redrawing. Try adding something like fig.canvas.draw() after you make a change. Although I wouldn't bother past trying that. |
Hello python people...
I would like a function to decide between types of slip character in individual grains. Slip character can be planar, wavy or diffuse. I cannot envisage a way of automating the code to make this distinction (other than using machine learning... which is something that we may want to discuss by the way!) and so I need a function that pops up several buttons that I can click to decide on the slip character myself.
In the DataAnalysisUtilities package there is a function that links grains from one EBSD map to another EBSD map (e.g. maps of the same area but pre- and pos-deformation). This uses a "link" button, but I do not need to do anything as complicated as linking two data sets.
Does anyone know of a simple interactive function for a button that I could use?
Thanks, A
The text was updated successfully, but these errors were encountered: