0

I am trying to open some 18 h5 files from the local directory by using datetime function in python. I have access some data inside those files and so, I use numpy arrays. I am getting this type error while trying to access one of the temperature arrays in the h5 files. can I have any solution? thanks in advance

indir = os.chdir('H:\INSAT-3D\may12')
dt = datetime.datetime(2016,5,12,0,0,0,tzinfo=pytz.UTC)
tdelta = datetime.timedelta(minutes=60)
dt = dt+tdelta
f= dt.strftime('3DSND_%d%b%Y_%H%M_L1B_SA1.h5')
f=f.upper()
print f

new = []
abc=0
for names in range(0,24):
    tdelta = datetime.timedelta(minutes=60)
    dt = dt+tdelta
    f = dt.strftime('3DSND_%d%b%Y_%H%M_L1B_SA1.h5')
    f= f.upper()
    if os.path.isfile(f):
        read = h5py.File(f, 'r')
        temp = np.array(f['SND_MWIR1_TEMP'])

here is the error I am getting,

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-62-2fe7a4d4ceb7> in <module>()
     22     if os.path.isfile(f):
     23         read = h5py.File(f, 'r')
---> 24         temp = np.array(f['SND_MWIR1_TEMP'])
     25 
     26 

TypeError: string indices must be integers, not str
Thomas K
  • 39,200
  • 7
  • 84
  • 86
talullah
  • 21
  • 1
  • 3
  • See [this explanation](http://stackoverflow.com/a/6077692/4391450) – AxelH Apr 20 '17 at 13:55
  • It looks like you possibly want to use `read['SND_MWIR1_TEMP']` instead of `f['SND_MWIR1_TEMP']`. – Thomas K Apr 20 '17 at 15:30
  • Thanx for the help. Though it eliminates the error, doesn't show the MWIR1_TEMP as an array like numpy array does. Is there any approach helps me to get it as an array itself? – talullah Apr 20 '17 at 16:16

0 Answers0