Click here to Skip to main content
15,902,811 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have some 19 hdf5 files(Remote sensing data). i read all of them separately and then i created a data matrix,say buy compiling band 1 from every h5 files and so on. But i did all these manually and now i need a full length program which does everything automatically.

#SND_MWIR1 is a particular band count data, it is a 3D array. I created a 2D array rom each of them. and then made a dictionary out of them.

What I have tried:

Python
import h5py
import numpy as np
import math
import matplotlib.pylab as plt

f = h5py.File("3DSND_12MAY2016_0000_L1B_SA1.h5","r")
ls = list(f.keys())

f1 = h5py.File("3DSND_12MAY2016_0100_L1B_SA1.h5", "r")
ls1 = list(f1.keys())

f2 = h5py.File("3DSND_12MAY2016_0200_L1B_SA1.h5", "r")
ls2 = list(f2.keys())

f3 = h5py.File("3DSND_12MAY2016_0300_L1B_SA1.h5", "r")
ls3 = list(f3.keys())

f4 = h5py.File("3DSND_12MAY2016_0500_L1B_SA1.h5", "r")
ls4 = list(f4.keys())

f5 = h5py.File("3DSND_12MAY2016_0600_L1B_SA1.h5", "r")
ls5 = list(f5.keys())

A = np.array(f1['SND_MWIR1'])[0]
A1 = np.array(f2['SND_MWIR1'])[0]
A2 = np.array(f3['SND_MWIR1'])[0]
A3 = np.array(f4['SND_MWIR1'])[0]
A4 = np.array(f5['SND_MWIR1'])[0]
A5 = np.array(f6['SND_MWIR1'])[0] #SND_MWIR1 is a particular band count data

dict0 = {1:A}
dict1 = {2:A1}
dict2 = {3:A2}
dict3 = {4:A3}
dict4 = {5:A4}
dict5 = {6:A5}

dict_MWIR1 = {}
for d in (dict0, dict1, dict2, dict3, dict4, dict5): dict_MWIR1.update(d)
print dict_MWIR1[1][0][1]
Posted
Updated 21-Mar-17 9:51am
Comments
Richard MacCutchan 21-Mar-17 16:20pm    
What exactly is the problem? You can automate the processing just by adding some code, but it is not clear what you want to automate.
Member 13074943 23-Mar-17 0:43am    
I made a list of all H5 files, what i want is reading all of them together and assigning in to a new list
Richard MacCutchan 23-Mar-17 5:00am    
Then please edit your question and explain exactly what the problem is.
Member 13074943 21-Mar-17 16:29pm    
I want to automate the process of reading h5 files and those dictionaries.
Member 13074943 22-Mar-17 0:12am    
can anybody help me with this?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900