From 66e9a51c440466ddcf87bcc1b795e35d5a62f4e1 Mon Sep 17 00:00:00 2001 From: Kevin Lacaille Date: Thu, 17 Nov 2022 14:15:38 -0800 Subject: [PATCH 1/6] Updated harmonize tool for more generalized use-case and its docstring. --- planet/order_request.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/planet/order_request.py b/planet/order_request.py index 34b4cbb26..611e6f01d 100644 --- a/planet/order_request.py +++ b/planet/order_request.py @@ -429,10 +429,13 @@ def toar_tool(scale_factor: Optional[int] = None, ) -> dict: return _tool('toar', parameters) -def harmonize_tool() -> dict: +def harmonize_tool(target_sensor: str) -> dict: '''Create the API spec representation of a harmonize tool. - Currently, only "PS2" (Dove Classic) is supported as a target sensor, and - it will transform only items captured by “PS2.SD” (Dove-R). + Currently, only "PS2" (Dove Classic) and "Sentinel-2" are supported as + target sensors. The Sentinel-2 target only harmonizes PSScene + surface reflectance bundle types (analytic_8b_sr_udm2, analytic_sr_udm2). + The PS2 target only works on analytic bundles + from Dove-R (PS2.SD). ''' - return _tool('harmonize', {'target_sensor': 'PS2'}) + return _tool('harmonize', {'target_sensor': target_sensor}) \ No newline at end of file From 7c3ec89830244a11d2b61ecea6bef62166d61b5b Mon Sep 17 00:00:00 2001 From: Kevin Lacaille Date: Thu, 17 Nov 2022 14:16:02 -0800 Subject: [PATCH 2/6] Added new test for harmonize tool. --- tests/unit/test_order_request.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/unit/test_order_request.py b/tests/unit/test_order_request.py index 01633571e..f6807e272 100644 --- a/tests/unit/test_order_request.py +++ b/tests/unit/test_order_request.py @@ -251,3 +251,9 @@ def test_toar_tool(): tt_empty = order_request.toar_tool() expected_empty = {'toar': {}} assert tt_empty == expected_empty + +@pytest.mark.parametrize("target_sensor", ["PS2", "Sentinel-2"]) +def test_harmonization_tool(target_sensor): + ht = order_request.harmonize_tool(target_sensor) + expected = {'harmonize': {'target_sensor': target_sensor}} + assert ht == expected From 7dcbc9ce37ff585942292b7e4595ffbee4a51f4d Mon Sep 17 00:00:00 2001 From: Kevin Lacaille Date: Thu, 17 Nov 2022 14:58:01 -0800 Subject: [PATCH 3/6] Added a Harmonize section to the docs. --- docs/cli/cli-orders.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/cli/cli-orders.md b/docs/cli/cli-orders.md index 7804dff75..7465fb5d6 100644 --- a/docs/cli/cli-orders.md +++ b/docs/cli/cli-orders.md @@ -467,7 +467,23 @@ curl -s https://raw.githubusercontent.com/planetlabs/planet-client-python/main/d ### Harmonize -TODO +The harmonize tool allows you to compare data to different generations of satellites by radiometrically harmonizing imagery captured by one satellite instrument type to imagery captured by another. To harmonize with a sensor put the following in your `tools.json`. + +```json +[ + { + "harmonize": { + "target_sensor": "PS2" + } + } +] +``` + +Then you may create your order request by calling your `tools.json` with `--tools`. + +```console +planet orders request psscene analytic_udm2 --name "Harmonized data" --id 20200925_161029_69_2223 --tools tools.json +``` ### STAC Metadata From c1b6b8aff7316711fbc79415704d5d7540cfa609 Mon Sep 17 00:00:00 2001 From: Kevin Lacaille Date: Thu, 17 Nov 2022 15:03:36 -0800 Subject: [PATCH 4/6] Linting. --- planet/order_request.py | 11 +++++------ tests/unit/test_order_request.py | 1 + 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/planet/order_request.py b/planet/order_request.py index 611e6f01d..586c44f7d 100644 --- a/planet/order_request.py +++ b/planet/order_request.py @@ -432,10 +432,9 @@ def toar_tool(scale_factor: Optional[int] = None, ) -> dict: def harmonize_tool(target_sensor: str) -> dict: '''Create the API spec representation of a harmonize tool. - Currently, only "PS2" (Dove Classic) and "Sentinel-2" are supported as - target sensors. The Sentinel-2 target only harmonizes PSScene - surface reflectance bundle types (analytic_8b_sr_udm2, analytic_sr_udm2). - The PS2 target only works on analytic bundles - from Dove-R (PS2.SD). + Currently, only "PS2" (Dove Classic) and "Sentinel-2" are supported as + target sensors. The Sentinel-2 target only harmonizes PSScene + surface reflectance bundle types (analytic_8b_sr_udm2, analytic_sr_udm2). + The PS2 target only works on analytic bundles from Dove-R (PS2.SD). ''' - return _tool('harmonize', {'target_sensor': target_sensor}) \ No newline at end of file + return _tool('harmonize', {'target_sensor': target_sensor}) diff --git a/tests/unit/test_order_request.py b/tests/unit/test_order_request.py index f6807e272..49e3554f6 100644 --- a/tests/unit/test_order_request.py +++ b/tests/unit/test_order_request.py @@ -252,6 +252,7 @@ def test_toar_tool(): expected_empty = {'toar': {}} assert tt_empty == expected_empty + @pytest.mark.parametrize("target_sensor", ["PS2", "Sentinel-2"]) def test_harmonization_tool(target_sensor): ht = order_request.harmonize_tool(target_sensor) From e5f3e7bde214d4275e4a306b4ebe0e7a17c0fa36 Mon Sep 17 00:00:00 2001 From: Kevin Lacaille Date: Fri, 18 Nov 2022 10:26:55 -0800 Subject: [PATCH 5/6] Updated wording in docs. --- docs/cli/cli-orders.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/cli/cli-orders.md b/docs/cli/cli-orders.md index 7465fb5d6..f658a63a5 100644 --- a/docs/cli/cli-orders.md +++ b/docs/cli/cli-orders.md @@ -467,7 +467,7 @@ curl -s https://raw.githubusercontent.com/planetlabs/planet-client-python/main/d ### Harmonize -The harmonize tool allows you to compare data to different generations of satellites by radiometrically harmonizing imagery captured by one satellite instrument type to imagery captured by another. To harmonize with a sensor put the following in your `tools.json`. +The harmonize tool allows you to compare data to different generations of satellites by radiometrically harmonizing imagery captured by one satellite instrument type to imagery captured by another. To harmonize your data to a sensor you must define the sensor you wish to harmonize with in your `tools.json`. Currently, only "PS2" (Dove Classic) and "Sentinel-2" are supported as target sensors. The Sentinel-2 target only harmonizes PSScene surface reflectance bundle types (`analytic_8b_sr_udm2`, `analytic_sr_udm2`). The PS2 target only works on analytic bundles from Dove-R (`PS2.SD`). ```json [ @@ -479,10 +479,10 @@ The harmonize tool allows you to compare data to different generations of satell ] ``` -Then you may create your order request by calling your `tools.json` with `--tools`. +You may create an order request by calling `tools.json` with `--tools`. ```console -planet orders request psscene analytic_udm2 --name "Harmonized data" --id 20200925_161029_69_2223 --tools tools.json +planet orders request psscene analytic_sr_udm2 --name "Harmonized data" --id 20200925_161029_69_2223 --tools tools.json ``` ### STAC Metadata From 2dfab6ece6a386e1da8af54f3139edb3fc83eea7 Mon Sep 17 00:00:00 2001 From: Kevin Lacaille Date: Fri, 18 Nov 2022 11:37:02 -0800 Subject: [PATCH 6/6] Changed target sensor from PS2 to Sentinel-2 Co-authored-by: Chris Holmes --- docs/cli/cli-orders.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cli/cli-orders.md b/docs/cli/cli-orders.md index f658a63a5..f2561c7bc 100644 --- a/docs/cli/cli-orders.md +++ b/docs/cli/cli-orders.md @@ -473,7 +473,7 @@ The harmonize tool allows you to compare data to different generations of satell [ { "harmonize": { - "target_sensor": "PS2" + "target_sensor": "Sentinel-2" } } ]