Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bm_extract #102

Open
ramarty opened this issue Oct 29, 2024 · 2 comments
Open

bm_extract #102

ramarty opened this issue Oct 29, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@ramarty
Copy link
Contributor

ramarty commented Oct 29, 2024

KeyError: "Unable to open object (object 'Mandatory_Quality_Flag' doesn't exist)”

Here is the function I am using (a similar format to the one available on the BlackMarblePy tutorial page):

lights_data= bm_extract(
gdf,
product_id ="VNP46A1",
date_range = "2024-10-07",
bearer=bearer,
aggfunc=["mean"]
)

Below is the full error message:

File /opt/anaconda3/lib/python3.11/site-packages/blackmarble/raster.py:357, in (.0)
351 filenames = _pivot_paths_by_date(pathnames).get(date)
353 try:
354 # Open each GeoTIFF file as a DataArray and store in a list
355 da = [
356 rioxarray.open_rasterio(
--> 357 h5_to_geotiff(
358 f,
359 variable=variable,
360 drop_values_by_quality_flag=drop_values_by_quality_flag,
361 output_directory=d,
362 ),
363 )
364 for f in filenames
365 ]
366 ds = merge_arrays(da)
367 clipped_dataset = ds.rio.clip(
368 gdf.geometry.apply(mapping), gdf.crs, drop=True
369 )

File /opt/anaconda3/lib/python3.11/site-packages/blackmarble/raster.py:189, in h5_to_geotiff(f, variable, drop_values_by_quality_flag, output_directory)
182 dataset = h5_data[data_field_key][variable]
183 left, bottom, right, top = (
184 attrs.get("WestBoundingCoord"),
185 attrs.get("SouthBoundingCoord"),
186 attrs.get("EastBoundingCoord"),
187 attrs.get("NorthBoundingCoord"),
188 )
--> 189 qf = h5_data[data_field_key]["Mandatory_Quality_Flag"]
190 else:
191 data_field_key = "HDFEOS/GRIDS/VIIRS_Grid_DNB_2d/Data Fields"

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

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

File /opt/anaconda3/lib/python3.11/site-packages/h5py/_hl/group.py:357, in Group.getitem(self, name)
355 raise ValueError("Invalid HDF5 object reference")
356 elif isinstance(name, (bytes, str)):
--> 357 oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
358 else:
359 raise TypeError("Accessing a group is done with bytes or str, "
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:257, in h5py.h5o.open()

KeyError: "Unable to open object (object 'Mandatory_Quality_Flag' doesn't exist)”

@ramarty ramarty added the bug Something isn't working label Oct 29, 2024
@g4brielvs g4brielvs self-assigned this Oct 30, 2024
@g4brielvs g4brielvs moved this from To triage to Backlog in BlackMarblePy & BlackMarbleR Oct 30, 2024
@g4brielvs
Copy link
Contributor

@ramarty Thank you for reporting this issue. I'll push a fix.

@animesh2998
Copy link

@g4brielvs - any idea how to open and work with the h5 file in the meanwhile?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

3 participants