datetime_difference#

geodesic.boson.datetime_difference(datetime1, datetime2, asset, band, asset_name, band_name=None)[source]#

Creates a new asset by calculating the difference between two datetime bands.

The difference is calculated as (datetime1 - datetime2)

Note: This middleware will override the datetime field in any request to the new asset.

Parameters:
  • datetime1 (List[datetime | str] | Tuple[datetime | str]) – first datetime range

  • datetime2 (List[datetime | str] | Tuple[datetime | str]) – second datetime range

  • asset (str) – asset to apply the difference to

  • band (int | str) – band to apply the difference to

  • asset_name (str) – name of the asset to create

  • band_name (str | None) – name of the band to create. Defaults to “{band}_datetime_difference”

Returns:

middleware to calculate the difference between two datetime bands

Return type:

Middleware

Examples

>>> # Calculate the difference on the B8 (red) band between January 2021 and 2022
>>> transform = datetime_difference(
...     datetime1=[datetime.datetime(2021, 1, 1), datetime.datetime(2021, 1, 31)],
...     datetime2=[datetime.datetime(2022, 1, 1), datetime.datetime(2022, 1, 31)],
...     asset="B8",
...     band=0,
...     asset_name="datetime_difference",
... )