pycroscopy / stemtool

A single package for analyzing atomic resolution STEM, 4D-STEM and STEM-EELS datasets, along with basic STEM simulation functionality
MIT License
16 stars 3 forks source link

problems with running example files #4

Open isikfurkan opened 4 months ago

isikfurkan commented 4 months ago

Hi I am totally new in python, but the stemtool is what I exactly need. I installed it via pip install stemtool. I am trying to play with example files to understand how things work. But I could not make it work, most probably due to my lack of knowledge. For instance when I tried to run afit example I face the error:

Basically, I loaded the image file changing or adding some parts as shown below to the original settings: from PIL import Image st.tic() stem_image = Image.open('stem_image.tif') stem_image = np.array(stem_image) st.toc() atoms = st.afit.atom_fit(stem_image, float('0.027466'), str('nm')) Traceback (most recent call last): File "C:\Users\Furkan\Desktop\pythonfiles\tekstemtool\example.py", line 31, in <module> atoms.peaks_vis(0.1, 0.1) File "C:\Users\Furkan\Desktop\pythonfiles\tekstemtool\.venv\lib\site-packages\stemtool\afit\atom_positions.py", line 1083, in peaks_vis data_peaks = skfeat.peak_local_max( TypeError: peak_local_max() got an unexpected keyword argument 'indices' If I remove the 'indices=False' part then I face:

Choose your points in a clockwise fashion, or else you will get a wrong result Traceback (most recent call last): File "C:\Users\Furkan\Desktop\pythonfiles\tekstemtool\example.py", line 31, in <module> atoms.peaks_vis(0.1, 0.1) File "C:\Users\Furkan\Desktop\pythonfiles\tekstemtool\.venv\lib\site-packages\stemtool\afit\atom_positions.py", line 1091, in peaks_vis self.peaks = (st.afit.remove_close_vals(peaks, pixel_dist)).astype(np.float) File "C:\Users\Furkan\Desktop\pythonfiles\tekstemtool\.venv\lib\site-packages\numpy\__init__.py", line 353, in __getattr__ raise AttributeError(__former_attrs__[attr]) AttributeError: module 'numpy' has no attribute 'float'. np.floatwas a deprecated alias for the builtinfloat. To avoid this error in existing code, usefloatby itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, usenp.float64here. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations When I replace all the 'np.float' with 'np.float64' or just 'float', I got this:

Choose your points in a clockwise fashion, or else you will get a wrong result Traceback (most recent call last): File "C:\Users\Furkan\Desktop\pythonfiles\tekstemtool\example.py", line 33, in <module> atoms.refine_peaks() File "C:\Users\Furkan\Desktop\pythonfiles\tekstemtool\.venv\lib\site-packages\stemtool\afit\atom_positions.py", line 1109, in refine_peaks st.afit.med_dist(self.peaks[0:test, :]) File "C:\Users\Furkan\Desktop\pythonfiles\tekstemtool\.venv\lib\site-packages\stemtool\afit\atom_positions.py", line 829, in med_dist warnings.filterwarnings("ignore") NameError: name 'warnings' is not defined So I added to the atom_positions.py file Import warnings

Finally I got these results presented in the attached pdf document. Atom_Fitting.pdf the exported jupyter code ad python code in txt form: atom_fitting.txt

My TEM image in png form is also attached here: stem_image

And I could not move further, that was the end of my python skills :). And I faced some other problems with other examples aswell and I could not make any of them work I would be more than appreciated if you could help. Best!

dxm447 commented 4 months ago

Hi @isikfurkan , Could you share the full code that led to this error?

isikfurkan commented 4 months ago

Hi I included it in the updated version of my comment