worldbank / blackmarblepy

Georeferenced Rasters and Statistics of Nightlights from NASA Black Marble
https://worldbank.github.io/blackmarblepy/
Mozilla Public License 2.0
32 stars 7 forks source link

Issue with `quality_flag_rm` #31

Closed ramarty closed 11 months ago

ramarty commented 11 months ago

It seems there's an issue with removing cells based on quality.

For example, this:

ntl_r = bm_raster(
    gdf,
    product_id="VNP46A2",
    date_range="2023-01-01",
    bearer=bearer,
    variable="DNB_BRDF-Corrected_NTL",
    quality_flag_rm=[2, 255],
)

fig, ax = plt.subplots()

# Plot
ntl_r["DNB_BRDF-Corrected_NTL"].sel(time="2023-01-01").plot(
    ax=ax, cmap=cc.cm.bmy, robust=True
)
cx.add_basemap(ax, crs=gdf.crs.to_string(), source=cx.providers.CartoDB.Positron)

plt.axis("off")
plt.tight_layout()

displays this:

Screen Shot 2023-12-07 at 11 11 56 AM

But when removing "0" as well, it looks the same -- when most of these pixels are good quality (0), so these should be removed / set to na as well.

ntl_r = bm_raster(
    gdf,
    product_id="VNP46A2",
    date_range="2023-01-01",
    bearer=bearer,
    variable="DNB_BRDF-Corrected_NTL",
    quality_flag_rm=[0, 2, 255],
) 

Same plotting code as above, and figure looks the same.

@g4brielvs I'll take a look here, but not sure if you have any quick thoughts?

g4brielvs commented 11 months ago

@ramarty Thanks for reporting this issue! Yeah...It must be because the argument quality_flag_rm is not being passed to h5_to_geotiff.

g4brielvs commented 11 months ago

@ramarty I just pushed https://github.com/worldbank/blackmarblepy/pull/32. If you have the chance, would you mind testing it?

pip install git+https://github.com/worldbank/blackmarblepy.git@hotfix-quality_flag_rm