Comments (1)
I also stumbled on this.
The shape is now [ky, kx, scanY, scanX] making the diffraction patterns the fastest data to access according to C-ordering.
Actually, it is the other way around: in numpy, the rightmost axis is the fastest to access. You can easily check this using the strides
attribute on the array, or even by benchmarking:
>>> image0.strides # image0 from your code snippet above, applied to some sample data
(143654400, 74820)
This means, between each pixel in image0
, we need to jump 74820 bytes in the input data. In case of fast access, this should be a number corresponding to the dtype, for example 4 for float32
data.
>>> b = np.random.randn(128, 128, 128, 128)
>>> b.strides
(16777216, 131072, 1024, 8)
%timeit np.copy(b[..., 0, 0]) # on my system: 534 µs ± 25.8 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
>>> b[..., 0, 0].strides
(16777216, 131072)
%timeit np.copy(b[0, 0, ...]) # on my system: 7.02 µs ± 1.14 µs per loop (mean ± std. dev. of 7 runs, 100000 loops each)
>>> b[0, 0, ...].strides
(1024, 8)
Or, from your example above, compare the timing of np.copy(data[:, :, 0, 0])
with np.copy(data[0, 0, ...])
. The np.copy
is needed to actually evaluate the performance - without it, numpy
just creates a view into the memory map, without accessing the underlying data.
So sadly, in this new format, while it is fast to access all scan positions for a single pixel of a diffraction pattern, accessing a whole diffraction pattern is very expensive.
from openncem.
Related Issues (20)
- SER array size backwards HOT 3
- ser tab complete infinite loop HOT 1
- Submodule name io clobbers built in python3 module io HOT 1
- Could not build ncempy. Cannot load backend 'Qt5Agg' which requires the 'qt5' HOT 34
- Change genfire import line HOT 1
- dm data not accessible after file closed using on_memory option HOT 2
- RingDiff tool and PyQT HOT 1
- module 'ncempy' has no attribute 'io' HOT 4
- EMD `memmap`s can lose their file handles prematurely HOT 1
- DM import can't read newest-version files HOT 1
- DM reader fails in `__del__` on current Python 3.9 HOT 1
- need to handle bad TagOffSetArray HOT 8
- `BufferError` caused by eager closing of DM file handles HOT 3
- emd import does not support default dim attributes HOT 3
- DM3 class HOT 8
- Unit tests HOT 4
- Example code HOT 2
- Matlab Code Location HOT 1
- ser.py and import ncempy.io.emd HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openncem.