Skip to content

Add bandmath tool to order_request #876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 22, 2023

Conversation

kevinlacaille
Copy link
Contributor

@kevinlacaille kevinlacaille commented Mar 16, 2023

Related Issue(s):

Closes #853

Proposed Changes:

For inclusion in changelog (if applicable):

  1. Added bandmath tool to order_request.

Not intended for changelog:

  1. Took most of the code from subscription_request and associated tests. Had to change any reference to the band math tool being called band_math and change it to bandmath, as the Orders API didn't accept band_math. For instance, when we asked for band_math the server returned:
Error: {"field":null,"general":[{"message":"Unable to accept order: Operation 'band_math' not found for 'scenes'"}]}

Diff of User Interface

Old behavior:

New behavior:

tools.json:

[
  {
    "clip": {
      "aoi": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              -91.198465,
              42.893071
            ],
            [
              -91.121931,
              42.893071
            ],
            [
              -91.121931,
              42.946205
            ],
            [
              -91.198465,
              42.946205
            ],
            [
              -91.198465,
              42.893071
            ]
          ]
        ]
      }
    }
  },
  {
    "bandmath": {
      "b1": "b1",
      "b2": "arctan(b1)",
      "pixel_type": "AUTO"
    }
  }
]

CLI commands:

planet orders request --item-type PSScene --bundle analytic_udm2 --name 'No STAC' --no-stac 20200925_161029_69_2223 --tools tools.json | planet orders create -

{"_links": {"_self": "https://api.planet.com/compute/ops/orders/v2/0fbfdad8-b146-4d97-9fee-ed6d10c39cac"}, "created_on": "2023-03-22T16:22:33.819Z", "error_hints": [], "id": "0fbfdad8-b146-4d97-9fee-ed6d10c39cac", "last_message": "Preparing order", "last_modified": "2023-03-22T16:22:33.819Z", "name": "No STAC", "products": [{"item_ids": ["20200925_161029_69_2223"], "item_type": "PSScene", "product_bundle": "analytic_udm2"}], "state": "queued", "tools": [{"clip": {"aoi": {"coordinates": [[[-91.198465, 42.893071], [-91.121931, 42.893071], [-91.121931, 42.946205], [-91.198465, 42.946205], [-91.198465, 42.893071]]], "type": "Polygon"}}}, {"bandmath": {"b1": "b1", "b2": "arctan(b1)", "pixel_type": "AUTO"}}]}planet orders wait 0fbfdad8-b146-4d97-9fee-ed6d10c39cac
00:00 - order 0fbfdad8-b146-4d97-9fee-ed6d10c39cac - state: runningplanet orders download 0fbfdad8-b146-4d97-9fee-ed6d10c39cac
/Users/kevin.lacaille/code/repos/planet/planet-client-python/0fbfdad8-b146-4d97-9fee-ed6d10c39cac/PSScene/20200925_161029_69_2223_3B_AnalyticMS_metadata_clip.xml:
/Users/kevin.lacaille/code/repos/planet/planet-client-python/0fbfdad8-b146-4d97-9fee-ed6d10c39cac/PSScene/20200925_161029_69_2223_metadata.json: 100%|█| 0.00k/0.0
/Users/kevin.lacaille/code/repos/planet/planet-client-python/0fbfdad8-b146-4d97-9fee-ed6d10c39cac/PSScene/20200925_161029_69_2223_3B_AnalyticMS_clip_bandmath.tif:
/Users/kevin.lacaille/code/repos/planet/planet-client-python/0fbfdad8-b146-4d97-9fee-ed6d10c39cac/PSScene/20200925_161029_69_2223_3B_udm2_clip.tif: 100%|█| 0.32k/
/Users/kevin.lacaille/code/repos/planet/planet-client-python/0fbfdad8-b146-4d97-9fee-ed6d10c39cac/manifest.json: 100%|███████| 0.00k/0.00k [00:00<00:00, 1.08MB/s]

PR Checklist:

  • This PR is as small and focused as possible
  • If this PR includes proposed changes for inclusion in the changelog, the title of this PR summarizes those changes and is ready for inclusion in the Changelog.
  • [] I have updated docstrings for function changes and docs in the 'docs' folder for user interface / behavior changes
  • This PR does not break any examples or I have updated them

(Optional) @mentions for Notifications:

@kevinlacaille kevinlacaille self-assigned this Mar 16, 2023
@kevinlacaille kevinlacaille changed the base branch from main to rc3dev-fixes March 16, 2023 21:12
@kevinlacaille kevinlacaille marked this pull request as ready for review March 22, 2023 16:30
Copy link
Contributor

@jreiberkyle jreiberkyle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks great and can be merged as-is. +1 for reusing the globals and pulling from specs.

someday we may want to pre-validate bandmath entries, as invalid entries result in the order running for several minutes before failing, proposal

@kevinlacaille kevinlacaille merged commit b93f4f1 into rc3dev-fixes Mar 22, 2023
@kevinlacaille kevinlacaille deleted the add_bandmath_tool_orders_request-853 branch March 22, 2023 19:48
@jreiberkyle jreiberkyle mentioned this pull request Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add bandmath tool support to orders_request
2 participants