ContactEngineering / SurfaceTopography

Read and analyze surface topographies
https://contactengineering.github.io/SurfaceTopography/
MIT License
17 stars 10 forks source link

Loading npy files with 1d data #43

Open mcrot opened 4 years ago

mcrot commented 4 years ago

Is loading of 1D data from an npy file supposed to work like this?

In [33]: from SurfaceTopography import open_topography

In [34]: import numpy as np

In [35]: arr = np.arange(0,10)

In [36]: np.save("test.npy", arr)

In [37]: r = open_topography("test.npy")

In [38]: r.topography(physical_sizes=(10,))
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-38-9ad2a6e19994> in <module>
----> 1 r.topography(physical_sizes=(10,))

~/miniconda3/envs/topobank/lib/python3.7/site-packages/SurfaceTopography/IO/NPY.py in topography(self, channel_index, physical_sizes, height_scale_factor, info, periodic, subdomain_locations, nb_subdomain_grid_pts)
    112                 heights=self.mpi_file.read(
    113                     subdomain_locations=subdomain_locations,
--> 114                     nb_subdomain_grid_pts=nb_subdomain_grid_pts),
    115                 physical_sizes=physical_sizes,
    116                 periodic=periodic,

~/miniconda3/envs/topobank/lib/python3.7/site-packages/NuMPI/IO/MPIFileIO.py in read(self, subdomain_locations, nb_subdomain_grid_pts)
    286             # number of blocks  : length of data in the non-contiguous
    287             # direction
--> 288             nb_subdomain_grid_pts[iy],
    289             # length of block : length of data in contiguous direction
    290             self.nb_grid_pts[iy]

IndexError: tuple index out of range
pastewka commented 3 years ago

This seems to be a bug in NuMPI - @AntoineSIMTEK any thoughts?

sannant commented 3 years ago

I wrote it only with 2D in mind. I should at least state this in the docstring.

Could we simply fall back to numpy in the serial case ?

pastewka commented 3 years ago

Okay, we should probably make the NuMPI reader more general at some point.

sannant commented 3 years ago

I open an issue. This could be a task for a HiWi

pastewka commented 3 years ago

Sounds good

pastewka commented 3 years ago

So we'll revert here to the serial reader

mcrot commented 3 years ago

I open an issue. This could be a task for a HiWi https://github.com/IMTEK-Simulation/NuMPI/issues/49