scholi / pySPM

Python library to handle Scanning Probe Microscopy Images. Can read nanoscan .xml data, Bruker AFM images, Nanonis SXM files as well as iontof images(ITA, ITM and ITS).
Apache License 2.0
58 stars 33 forks source link

SPM_image.get_extent() fails for a Bruker AFM image #8

Closed ezatterin closed 5 years ago

ezatterin commented 5 years ago

The following:

scan = pySPM.Bruker(filename)
chan = scan.get_channel()
chan.get_extent()

Results in an error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-365-32333116e5f9> in <module>
----> 1 chan.get_extent()

c:\python37\lib\site-packages\pySPM\SPM.py in get_extent(self)
    464         Get the image extent in real data
    465         """
--> 466         W = self.size['recorded']['real']['x']
    467         H = self.size['recorded']['real']['y']
    468         return (0, W, 0, H)

KeyError: 'recorded'
scholi commented 5 years ago

This should be fixed now. Can you test it?

ezatterin commented 5 years ago

Different error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-37-32333116e5f9> in <module>
----> 1 chan.get_extent()

c:\python37\lib\site-packages\pySPM\SPM.py in get_extent(self)
    464 
    465     def inv_calc_flat(self, d, l=0.1):
--> 466         """
    467         Function used for inverse MFM calculation (inspired from http://qmfm.empa.ch/qmfm/)
    468         The function is in its early devlopment stage as not used by the developed.

KeyError: 'recorded'
scholi commented 5 years ago

This works for me

scan = pySPM.Bruker(os.path.expanduser("~/Dropbox/e17089.0_00001.spm"))
chan = scan.get_channel()
print(chan.get_extent())
chan.pixels -= np.min(chan.pixels)
fig, ax = plt.subplots(1,1)
p = chan.show();
plt.colorbar(p);

(0, 500.0, 0, 500.0) image

ezatterin commented 5 years ago

My bad, I messed up with the pySPM versions. Thanks, closing!