heprom / pymicro

A Python package to work with material microstructures and 3d data sets
http://pymicro.readthedocs.io
MIT License
39 stars 21 forks source link

issue with tutorial "contour_pole_figure.py" #10

Open flo2712 opened 3 years ago

flo2712 commented 3 years ago

Dear Developers,

I'm using python 3.8 and pymicro 0.51 and I'm trying to test the tutorial file "contour_pole_figure.py" but the following error is triggered. I guess the whole "grain" object structure changed and is not addressed correctly anymore in the old tutorial file. Could you please provide assistance?

Many thanks in advance and best regards Florian

fg@ubuntu:~/Programming/pymicro$ /bin/python3 /home/fg/Programming/pymicro/contour_pole_figure.py Traceback (most recent call last): File "/home/fg/.local/lib/python3.8/site-packages/tables/table.py", line 2216, in append iflavor = flavor_of(rows) File "/home/fg/.local/lib/python3.8/site-packages/tables/flavor.py", line 194, in flavor_of raise TypeError( TypeError: objects of type Grain are not supported in this context, sorry; supported objects are: NumPy array, record or scalar; homogeneous list or tuple, integer, float, complex or bytes

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/fg/Programming/pymicro/contour_pole_figure.py", line 14, in micro.grains.append(Grain(i + 1, eulers[i + 1])) File "/home/fg/.local/lib/python3.8/site-packages/tables/table.py", line 2223, in append raise ValueError("rows parameter cannot be converted into a " ValueError: rows parameter cannot be converted into a recarray object compliant with table '/GrainData/GrainDataTable (Table(0,)) '''. The error was: <objects of type Grain are not supported in this context, sorry; supported objects are: NumPy array, record or scalar; homogeneous list or tuple, integer, float, complex or bytes> Closing remaining open files:test_data.h5...done Exception ignored in: <function SampleData.del at 0x7f595c471310> Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/pymicro/core/samples.py", line 230, in del File "/usr/local/lib/python3.8/dist-packages/pymicro/core/samples.py", line 478, in sync File "/usr/local/lib/python3.8/dist-packages/pymicro/core/samples.py", line 973, in add_attributes File "/usr/local/lib/python3.8/dist-packages/pymicro/core/samples.py", line 1100, in get_node File "/usr/local/lib/python3.8/dist-packages/pymicro/core/samples.py", line 1987, in _name_or_node_to_path File "/home/fg/.local/lib/python3.8/site-packages/tables/file.py", line 2049, in contains File "/home/fg/.local/lib/python3.8/site-packages/tables/file.py", line 1628, in get_node File "/home/fg/.local/lib/python3.8/site-packages/tables/file.py", line 2150, in _check_open tables.exceptions.ClosedFileError: the file object is closed

heprom commented 3 years ago

Hi Florian, thank you for reporting this. You are right, this example was not updated for recent changes in how the Microstructure class works. I just fixed it, let me know if you can use the development branch (master). That being said, be careful with this example of a contour plot, as it may not be very accurate (just using matplotlib contour plot function).

flo2712 commented 3 years ago

Hello Henry! Yes it works now. A couple of imports (os and numpy) are missing and the thumbnail image needed a little tweaking with image path/name. Thank you very much, i'll keep the accuracy of the plot in mind. Best regards Florian

heprom commented 3 years ago

Glad it is working, do not hesitate to report any problem, ask for new features, etc. Henry

flo2712 commented 3 years ago

Dear Henry, I hope you are doing well! I´m trying to plot EBSD data (Euler angles) with the help of this tutorial script. For 1000 grains it takes about two minutes to get the contour-plot result, with 2000 grains I must wait six to seven minutes and finally for 18000 grains I stopped the process after three and a half hours. Since I only want to plot the mentioned data, can you think of any method to speed up the plotting process? Many thanks in advance and best regards Florian

heprom commented 1 month ago

Hi Florian, This is indeed a problem with the current implementation of the PoleFigure class which was not designed with performance in mind. It should be rewritten at some point.