Skip to content
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

Incorrect prefix with recyprocal units when it needs to convert #28

Closed
din14970 opened this issue Apr 9, 2020 · 4 comments
Closed

Incorrect prefix with recyprocal units when it needs to convert #28

din14970 opened this issue Apr 9, 2020 · 4 comments

Comments

@din14970
Copy link
Contributor

din14970 commented Apr 9, 2020

I noticed that the scalebar incorrectly handles the prefix for reciprocal units, I noticed this when I was trying to measure distances in a Fourrier transform of an image. My original image has a pixel size of 0.007 nm/pixel, but everything is stored in meters, so 7e-12 m. The scalebar has no problem interpreting this value and puts a scalebar in nm on the image.

To calculate the scale of my Fourrier transform, I take the meters value and convert. My image is 4096x4096 pixels so the scale in the FFT is 1/(7e-12 * 4096)=3.4e7 m^-1/pixel. This is equivalent to 0.034 nm^-1/pixel. When I pass the scale in nm^-1 to the scalebar, it uses the correct nm^-1 units. However, when I pass the scale in m^-1, the scalebar uses Gm^-1.

@din14970
Copy link
Contributor Author

din14970 commented Apr 9, 2020

Might be easily fixed if you associate the reciprical factor with the prefix, line 124 in dimensions.py

@din14970
Copy link
Contributor Author

din14970 commented Apr 9, 2020

Edited it on my own computer and seems to work

@din14970
Copy link
Contributor Author

din14970 commented Apr 9, 2020

the tests in test_dimension were also wrong:
0.02 1/m = 0.0002 1/cm or 20 1/km
0.002 1/m = 2 1/km
Updated them in a second commit

@ppinard
Copy link
Owner

ppinard commented Apr 11, 2020

Thank you for finding and fixing the issue. I know release version 0.6.2 with the fix.

@ppinard ppinard closed this as completed Apr 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants