Skip to content

Instantly share code, notes, and snippets.

@aronnem
Created November 25, 2023 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aronnem/583ee5892b410f1c3b625ba4f294c2e7 to your computer and use it in GitHub Desktop.
Save aronnem/583ee5892b410f1c3b625ba4f294c2e7 to your computer and use it in GitHub Desktop.
Error when accessing certain types of NASA data with HTTPSFileSystem
import datetime as dt
import earthaccess, h5py
earthaccess.login()
# first DOI succeeds: netCDF4 file, CLIMCAPS Level-2 retrievals
# second DOI fails: hdf5 file, OCO-2 Level-1B radiance
# h5py.File() fails in AbstractBufferedFile.seek, TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
dois = ["10.5067/LESQUBLWS18H",
"10.5067/H93644NLXWX9"]
timerange = ("2022-02-01", "2022-02-02")
for doi in dois:
granule_list = earthaccess.search_data(doi=doi, temporal=timerange)
fs_object = earthaccess.open(granule_list[:1])[0]
print(fs_object.fs.info(fs_object.path))
h5File = h5py.File(fs_object, mode="r")
print(f"h5File has {len(h5File)} items")
h5File.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment