0

I have a h5 file which contains a large number of data of arrays. I can read the h5 file in python and able to see the array of values. But, I can't see all values of arrays in the output. Is it possible to see all values of arrays in python?

Here is my code:

import numpy as np   
import h5py
import matplotlib.pyplot as plt
f = h5py.File('k.h5', 'r')  
list(f.keys())
dset = f[u'data']
dset.shape
dset.value.shape
s=dset[0:64,0:64,0:64]
print(s)

Here is my sample output:

[[[-2.89660161e-05 -2.55907859e-05 -2.26706938e-05 ... -3.17377055e-05
   -3.19882377e-05 -3.11190429e-05]
  [-2.79035096e-05 -2.42448566e-05 -2.08823974e-05 ... -3.05330241e-05
   -3.07284066e-05 -2.99954101e-05]
  [-2.64130475e-05 -2.34394543e-05 -2.03711989e-05 ... -2.76314902e-05
   -2.82685520e-05 -2.80147175e-05]...

The h5 file can be downloaded from https://drive.google.com/open?id=1cpnZBGDgbijAH0kJchcecTM5lKasiflp this link.

hpaulj
  • 201,845
  • 13
  • 203
  • 313
M Cosmo
  • 19
  • 4
  • 1
    People don't usually want their screen flooded with hundreds of thousands of numbers that usually make very little sense unless you analyse specific slices or truncate the meat, like numpy does. – cs95 Jan 30 '19 at 23:58
  • It probably is just a `numpy` array underneath so you can probably use [`numpy.set_printoptions()`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.set_printoptions.html) to change the behaviour. – AChampion Jan 31 '19 at 00:02
  • In fact [How to print the full NumPy array, without truncation?](https://stackoverflow.com/questions/1987694/how-to-print-the-full-numpy-array-without-truncation) is the best close-target, but I can't change my vote now. – smci Jan 31 '19 at 01:00
  • Your `s` array has 64**3 elements. `numpy` starts using the ellipsis at 1000 elements. While you can play the print threshhold, it might be more useful to display slices of the whole thing, such as `s[0,:,:]` panel. Or run other tests such as `max` or `min` or `mean`. – hpaulj Jan 31 '19 at 01:21
  • thanks all! my problem is solved – M Cosmo Jan 31 '19 at 01:49

1 Answers1

1

Try:

import numpy as np
np.set_printoptions(threshold=np.nan)
Learning is a mess
  • 5,905
  • 5
  • 30
  • 64