diff --git a/Test_GeoMAD_Landsat.ipynb b/Test_GeoMAD_Landsat.ipynb index ba45edc..264a393 100644 --- a/Test_GeoMAD_Landsat.ipynb +++ b/Test_GeoMAD_Landsat.ipynb @@ -75,7 +75,7 @@ " dask_chunksize=dict(time=1, x=4096, y=4096),\n", " odc_load_kwargs=dict(\n", " fail_on_error=False,\n", - " resolution=30,\n", + " resolution=90,\n", " # bands=[\"qa_pixel\", \"red\", \"green\", \"blue\", \"nir08\", \"swir16\", \"swir22\"],\n", " groupby=\"solar_day\",\n", " bands=[\"qa_pixel\", \"red\", \"green\", \"blue\"]\n", @@ -102,6 +102,7 @@ "# Set up a data processor\n", "processor = GeoMADLandsatProcessor(\n", " scale_and_offset=False,\n", + " harmonize_to_old=True,\n", " geomad_options=dict(\n", " work_chunks=(601, 601),\n", " num_threads=10,\n", @@ -238,7 +239,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.11.6" } }, "nbformat": 4, diff --git a/Test_GeoMAD_Sentinel2.ipynb b/Test_GeoMAD_Sentinel2.ipynb index 1dca30a..84e396b 100644 --- a/Test_GeoMAD_Sentinel2.ipynb +++ b/Test_GeoMAD_Sentinel2.ipynb @@ -33,7 +33,7 @@ "outputs": [], "source": [ "# Optionally set up a local dask cluster\n", - "client = start_local_dask(threads_per_worker=64, n_workers=2, mem_safety_margin=\"2GB\")\n", + "client = start_local_dask(threads_per_worker=64, n_workers=1, mem_safety_margin=\"2GB\")\n", "client.dashboard_link" ] }, @@ -51,9 +51,9 @@ "# 111,24\n", "\n", "# Study site configuration\n", - "# item_id = \"63,20\" # West viti levu\n", + "item_id = \"63,20\" # West viti levu\n", "# item_id = \"65,22\" # Near the anti-meridian\n", - "item_id = \"66,22\" # Right of the anti-meridian\n", + "# item_id = \"66,22\" # Right of the anti-meridian\n", "datetime = \"2023\"\n", "\n", "# And get the study site\n", @@ -71,13 +71,13 @@ "# Set up a data loader\n", "loader = Sentinel2OdcLoader(\n", " epsg=3832,\n", - " datetime=datetime,\n", + " datetime=\"2023\",\n", " dask_chunksize=dict(time=1, x=4096, y=4096),\n", " odc_load_kwargs=dict(\n", " fail_on_error=False,\n", - " resolution=10,\n", + " resolution=100,\n", " # bands=[\"SCL\", \"B02\", \"B03\", \"B04\", \"B05\", \"B06\", \"B07\", \"B08\", \"B8A\", \"B11\", \"B12\"],\n", - " bands=[\"SCL\", \"red\", \"green\", \"blue\"],\n", + " bands=[\"SCL\", \"B04\", \"B03\", \"B02\"],\n", " groupby=\"solar_day\",\n", " ),\n", " nodata_value=0,\n", @@ -99,6 +99,7 @@ "# Set up a data processor\n", "processor = GeoMADSentinel2Processor(\n", " scale_and_offset=False,\n", + " harmonize_to_old=True,\n", " geomad_options=dict(\n", " work_chunks=(601, 601),\n", " num_threads=10,\n", @@ -113,6 +114,35 @@ "output_data" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "output_data.B04.plot.imshow()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "output_data.odc.to_rgba(bands=[\"B04\", \"B03\", \"B02\"], vmin=0, vmax=3000).odc.explore()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import xarray as xr\n", + "\n", + "xr.__version__" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/requirements.txt b/requirements.txt index 261ca27..83dbe4b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ typer -git+https://github.com/digitalearthpacific/dep-tools.git@05b13b2 +git+https://github.com/digitalearthpacific/dep-tools.git@rename-s2-offset-to-harmonize git+https://github.com/opendatacube/odc-algo.git@57316a8 odc-stac==0.3.8 diff --git a/src/run_task.py b/src/run_task.py index 4021c02..99e8421 100644 --- a/src/run_task.py +++ b/src/run_task.py @@ -50,6 +50,7 @@ def __init__( self, send_area_to_processor: bool = False, scale_and_offset: bool = False, + harmonize_to_old: bool = True, mask_clouds: bool = True, load_data_before_writing: bool = True, geomad_options: dict = { @@ -67,6 +68,8 @@ def __init__( mask_clouds, mask_clouds_kwargs={"filters": filters, "keep_ints": keep_ints}, ) + self.scale_and_offset = scale_and_offset + self.harmonize_to_old = harmonize_to_old self.load_data_before_writing = load_data_before_writing self.geomad_options = geomad_options self.drop_vars = drop_vars @@ -195,7 +198,8 @@ def main( log.info("Configuring processor") processor = ProcessorClass( - scale_and_offset=False, + scale_and_offset=False, # Don't want to work with floats + harmonize_to_old=True, # This only applies to S-2 filters=[("closing", 5), ("opening", 5)], keep_ints=True, load_data_before_writing=True,