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

lower case augment support for get_channel() struct.error: unpack requires a buffer of 369664 bytes #24

Closed GilesLuo closed 2 years ago

GilesLuo commented 2 years ago

Hi, I'm not sure whether it was just me. I was intending to load and plot a .sxm file and here's the code:

import pySPM
from matplotlib import pyplot as plt
scan = pySPM.SXM('sxm/unnamed166.sxm')
print(scan.list_channels())
z = scan.get_channel('z')
print(z.pixels)
z.show()
plt.show()

It doesn't work and produce an error: struct.error: unpack requires a buffer of 369664 bytes It is fixed by changing 'z' to capital 'Z', which is aligned with the channel name Z.

For anyone who gets this error as I did, make sure you use exactly the same channel name as in scan.list_channels(). It couldn't be better if the dev team can make lower case augment work. Thanks!

scholi commented 2 years ago

Hi, Thank you for the info. However it is not a bug and it is on purpose that the channel name is case sensitive.