nsidc / NSIDC-Data-Tutorials

Jupyter notebook-based tutorials to learn how to access and work with select NSIDC DAAC data.
MIT License
81 stars 39 forks source link

error running 02_read_and_plot_smap_data.ipynb #83

Closed victoriaeh closed 3 months ago

victoriaeh commented 3 months ago

In the notebooks/SMAP/folder while running in conda and after successfully running 01_download_smap_data.ipynb

In the code cell:

sm_data_3d = np.empty([sm_data.shape[0],sm_data.shape[1],len(flist)])
times = []
print('sm_data_3d has dimensions '+str(sm_data_3d.shape))
i=0
for fName in flist:
    sm_data_3d[:,:,i],time_i = read_SML3P(fName)
    times.append(time_i)
    i+=1

This error is returned:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[16], [line 6](vscode-notebook-cell:?execution_count=16&line=6)
      [4](vscode-notebook-cell:?execution_count=16&line=4) i=0
      [5](vscode-notebook-cell:?execution_count=16&line=5) for fName in flist:
----> [6](vscode-notebook-cell:?execution_count=16&line=6)     sm_data_3d[:,:,i],time_i = read_SML3P(fName)
      [7](vscode-notebook-cell:?execution_count=16&line=7)     times.append(time_i)
      [8](vscode-notebook-cell:?execution_count=16&line=8)     i+=1

Cell In[14], [line 17](vscode-notebook-cell:?execution_count=14&line=17)
     [15](vscode-notebook-cell:?execution_count=14&line=15) var_id_am = 'soil_moisture'
     [16](vscode-notebook-cell:?execution_count=14&line=16) flag_id_am = 'retrieval_qual_flag'
---> [17](vscode-notebook-cell:?execution_count=14&line=17) soil_moisture_am = f[group_id_am][var_id_am][:,:]
     [18](vscode-notebook-cell:?execution_count=14&line=18) flag_am = f[group_id_am][flag_id_am][:,:]
     [19](vscode-notebook-cell:?execution_count=14&line=19) soil_moisture_am[soil_moisture_am==-9999.0]=np.nan;

File h5py/_objects.pyx:54, in h5py._objects.with_phil.wrapper()

File h5py/_objects.pyx:55, in h5py._objects.with_phil.wrapper()

File ~/miniconda3/envs/smap/lib/python3.10/site-packages/h5py/_hl/group.py:357, in Group.__getitem__(self, name)
    [355](https://file+.vscode-resource.vscode-cdn.net/Users/tori1/Library/CloudStorage/OneDrive-Personal/Documents/STC_CRREL/SMAP/~/miniconda3/envs/smap/lib/python3.10/site-packages/h5py/_hl/group.py:355)         raise ValueError("Invalid HDF5 object reference")
    [356](https://file+.vscode-resource.vscode-cdn.net/Users/tori1/Library/CloudStorage/OneDrive-Personal/Documents/STC_CRREL/SMAP/~/miniconda3/envs/smap/lib/python3.10/site-packages/h5py/_hl/group.py:356) elif isinstance(name, (bytes, str)):
--> [357](https://file+.vscode-resource.vscode-cdn.net/Users/tori1/Library/CloudStorage/OneDrive-Personal/Documents/STC_CRREL/SMAP/~/miniconda3/envs/smap/lib/python3.10/site-packages/h5py/_hl/group.py:357)     oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
    [358](https://file+.vscode-resource.vscode-cdn.net/Users/tori1/Library/CloudStorage/OneDrive-Personal/Documents/STC_CRREL/SMAP/~/miniconda3/envs/smap/lib/python3.10/site-packages/h5py/_hl/group.py:358) else:
    [359](https://file+.vscode-resource.vscode-cdn.net/Users/tori1/Library/CloudStorage/OneDrive-Personal/Documents/STC_CRREL/SMAP/~/miniconda3/envs/smap/lib/python3.10/site-packages/h5py/_hl/group.py:359)     raise TypeError("Accessing a group is done with bytes or str, "
    [360](https://file+.vscode-resource.vscode-cdn.net/Users/tori1/Library/CloudStorage/OneDrive-Personal/Documents/STC_CRREL/SMAP/~/miniconda3/envs/smap/lib/python3.10/site-packages/h5py/_hl/group.py:360)                     "not {}".format(type(name)))

File h5py/_objects.pyx:54, in h5py._objects.with_phil.wrapper()

File h5py/_objects.pyx:55, in h5py._objects.with_phil.wrapper()

File h5py/h5o.pyx:241, in h5py.h5o.open()

KeyError: "Unable to open object (object 'Soil_Moisture_Retrieval_Data_AM' doesn't exist)"
asteiker commented 3 months ago

Hi @victoriaeh Thank you for reporting this error. I was not able to reproduce your error however, after also running the full 01_download_smap_data.ipynb notebook without any alterations. Can you confirm which granule you are working with? In the first code block below the library imports, under the Read SMAP data and navigate metadata heading, you will see the printed output of the first granule found in the list of downloads. I see SMAP_L3_SM_P_20170316_R18290_001.h5.

victoriaeh commented 3 months ago

Hi @asteiker, thank you for looking into it. I actually solved the error earlier, but forgot to update this. It was something I was doing on my end unrelated to the tutorial code.