python h5py 讀取hdf 數據


#Env dependent extension packages
#pip install h5py -i https://pypi.tuna.tsinghua.edu.cn/simple
#pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple
#pip install pandus -i https://pypi.tuna.tsinghua.edu.cn/simple

#ruiY 

hdfFile = 'Z_SATE_C_BAWX_20201020DF'


import h5py

hdf5File = h5py.File(hdfFile)
#print(hdf5File.attrs['ProductID'])
#print(hdf5File.attrs.keys())

#FY4 hdf5文件屬性數據
for i in range(len(hdf5File.attrs.keys())):
    #print(i)
    #print(list(hdf5File.attrs.keys())[i])
    attrsName = list(hdf5File.attrs.keys())[i]
    attrsValue = hdf5File.attrs[attrsName]
    #print(attrimport time
time.sleep(3)
  
#FY4 hdf5文件科學數據集數據讀取
#print(list(hdf5File.keys()))
datasets = list(hdf5File.keys())
#print(datasets)
for i in range(len(datasets)):
    #print(i)
    #hdf5File[]
    #print(datasets[i])
    dsetsName = datasets[i]
    #print(dsetsName)
    #time.sleep(2)
    #dsetsDtype = dsetsName.dtype
    #dsetsShape = dsetsName.shape
    #print(dsetsName)
    #print(dsetsName.dtype)
    #print('{}:{}:{}'.format(dsetsName,dsetsDtype,dsetsShape))
    #print(dsetsName.shape)
    #print('{}:{}:{}'.format(dsetsName,dsetsDtype,dsetsShape))
    #print('{}:{}'.format(dsetsName,dsetsShape))
    #print(type(dsetsShape)) #數據集類型
    #print(len(dsetsShape))  #數據集緯度
    
    #print(dsetsDimsX)
    #print(dsetsShape[0])
    dsetsDimsX = dsetsShape[0]
    #dsetsDims = len(dsetsShape)#判讀緯度,一維數組就不用獲取Yi列值
    #print('{},{},{}'.format(dsetsName,dsetsDimsX,dsetsDimsY))
    '''
    for Xi in range(dsetsDimsX):
        #print(Xi)
        #for Yi in range(dsetsDimsY):
            #print('{},{}'.format(Xi,Yi))
        #   pass
        if len(dsetsShape) == 2:
            #dsetsDimsXY = dsetsShape[1]
            #print(dsetsDimsXY)
            #///////print('{},{}'.format('二維',dsetsName))
            dsetsDimsY = dsetsShape[1]  #獲取二維列數值
            #print(dsetsDimsY)
            for Yi in range(dsetsDimsY):
                #print('{}:{},{}'.format(dsetsName,Xi,Yi))  #輸出二維數據集對應的數據集名稱及二維排列
                #print()
                pass
                #//////二維列值
        else:
            #print('{},{}'.format('一維',dsetsName))
            #DimOneSetValues = list(dsetsName[Xi - 1])
            #print(DimOneSetValues)
            DimOneSetValues = list(dsetsName)
            print(DimOneSetValues)
    '''
    if len(dsetsShape) == 2:
        print('{},{}'.format('二維數集',dsetsName))
        dsetsDimsY = e,Xi,Yi,dimTwosSetValues))
    else:
        print('{},{}'.format('一維數集',dsetsName))
        
        for Xi in range(dsetsDimsX):
            dimOneSetValues = ''
            #DimOneSetValues = dsetsName[Xi - 1]
            #print(DimOneSetValues)
            #print(Xi)
            #print(typat(dsetsName,Xi,dimOneSetValues))
    

 

 hdfExplorer  hdfviewer


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM