Skip to content

Commit

Permalink
Merge pull request #6 from digitalearthpacific/update-s2-harmonize-old
Browse files Browse the repository at this point in the history
Update s2 harmonize old
  • Loading branch information
alexgleith authored Feb 13, 2024
2 parents ce4be4e + ba7b75b commit 58efa6f
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 10 deletions.
5 changes: 3 additions & 2 deletions Test_GeoMAD_Landsat.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -238,7 +239,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.11.6"
}
},
"nbformat": 4,
Expand Down
42 changes: 36 additions & 6 deletions Test_GeoMAD_Sentinel2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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

--no-binary gdal
--no-binary rasterio
6 changes: 5 additions & 1 deletion src/run_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 58efa6f

Please sign in to comment.