簡體   English   中英

h5py 的問題-“數據集”object 沒有屬性“值”

[英]Problems with h5py - 'Dataset' object has no attribute 'value'

我目前正在嘗試從 h5py 文件中讀取數據,並在嘗試切片和其中的元數據然后輸入字典時遇到問題。 代碼直接取自NSF Neon 教程,可以在其中找到整個腳本。

我對 function 的這個區域特別有問題;

  #Extract the reflectance & wavelength datasets
    refl = hdf5_file[sitename]['Reflectance']
    reflData = refl['Reflectance_Data']
    reflRaw = refl['Reflectance_Data'].value ##This is causing - Dataset' object has no attribute 'value'
    
   #Create dictionary containing relevant metadata information
    metadata = {}
    metadata['map info'] = refl['Metadata']['Coordinate_System']['Map_Info'].value ##As above
    metadata['wavelength'] = refl['Metadata']['Spectral_Data']['Wavelength'].value 

堆棧上的這個先前的問題來看,似乎.value在最近的 h5py 版本中已被棄用。 引用該帖子,而不是;

reflRaw = refl['Reflectance_Data'].value

我試過了

  • reflRaw = refl['Reflectance_Data'][:]

    對於這個 Python 指責我“標量數據空間的非法切片參數”

  • reflRaw = refl['Reflectance_Data'][()]

    這只會掛起 30 秒,然后最終顯示空白 matplotlib plot

不知道如何在這里進行。 這些教程是相對較新的,所以我不確定如果 .value 在最近的 h5py 版本中已被棄用,他們是如何設法讓.value工作的。

任何幫助表示贊賞

正如您鏈接的答案所示,較新版本的 h5py 的正確語法是將.value替換為[()] 在您的示例中,這樣做對我有用。 I'm not sure what you mean when you say the function returns a blank matplotlib plot, since it's only meant to return 2 arrays - which, again, it does when I run it.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM