From 4162310a36982c653fb7f4783f008786bb23bf4e Mon Sep 17 00:00:00 2001 From: thomasarsouze Date: Fri, 14 Jun 2024 11:28:37 +0200 Subject: [PATCH 1/3] Change multiprocessing to multiprocess --- geefcc/get_fcc.py | 2 +- requirements.txt | 1 + setup.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/geefcc/get_fcc.py b/geefcc/get_fcc.py index 09f763c..64caf80 100644 --- a/geefcc/get_fcc.py +++ b/geefcc/get_fcc.py @@ -1,7 +1,7 @@ """Get forest cover change data.""" import os -import multiprocessing as mp +import multiprocess as mp from .get_extent_from_aoi import get_extent_from_aoi from .misc import make_dir diff --git a/requirements.txt b/requirements.txt index f0a89c4..a0794e6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ numpy gdal xarray xee +multiprocess \ No newline at end of file diff --git a/setup.py b/setup.py index 463dee5..f70ca6d 100644 --- a/setup.py +++ b/setup.py @@ -63,7 +63,7 @@ def find_version(pkg_name): packages=["geefcc", "geefcc/misc"], package_dir={"geefcc": "geefcc", "misc": "geefcc/misc"}, entry_points={"console_scripts": ["geefcc = geefcc.geefcc:main"]}, - install_requires=["numpy", "gdal", "xarray", "xee"], + install_requires=["numpy", "gdal", "xarray", "xee", "multiprocess"], extras_require={ "interactive": ["cartopy", "rioxarray", "matplotlib", "geopandas"]}, From ee41f9c418825024fe285cd4b77ed6ec4698f239 Mon Sep 17 00:00:00 2001 From: thomasarsouze Date: Tue, 18 Jun 2024 11:19:10 +0200 Subject: [PATCH 2/3] Remove warnings on grid generation --- geefcc/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/geefcc/__init__.py b/geefcc/__init__.py index 0575992..d7ea6cf 100644 --- a/geefcc/__init__.py +++ b/geefcc/__init__.py @@ -17,7 +17,9 @@ from .sum_raster_bands import sum_raster_bands from .misc import make_dir -# GDAL exceptions +# Stop GDAL printing both warnings and errors to STDERR +gdal.PushErrorHandler('CPLQuietErrorHandler') +# GDAL exceptions for errors (warnings won't raise an exception) gdal.UseExceptions() # End From 3e2465ae4b7ecff54a637831b259f150f35ed343 Mon Sep 17 00:00:00 2001 From: thomasarsouze Date: Tue, 18 Jun 2024 11:28:43 +0200 Subject: [PATCH 3/3] Ensure tiles are not empty files --- geefcc/geeic2geotiff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geefcc/geeic2geotiff.py b/geefcc/geeic2geotiff.py index 674fdb6..7386b37 100644 --- a/geefcc/geeic2geotiff.py +++ b/geefcc/geeic2geotiff.py @@ -180,7 +180,7 @@ def geeic2geotiff(index, extent, ntiles, forest, proj, scale, out_dir): """ ofile = os.path.join(out_dir, f"forest_{index}.tif") - if not os.path.isfile(ofile): + if (not os.path.isfile(ofile)) or (os.path.getsize(ofile) == 0): # Open dataset ds = ( xr.open_dataset(