Skip to main content

Hello,


We found a notebook to be able to get processing unit estimates for a request. See the following link:


github.com

sentinel-hub/sentinelhub-py/blob/master/examples/reading_pu_from_headers.ipynb




{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Retrieving information about processing units of requests\n",
"\n",
"In this example notebook we show how to retrieve **DownloadResponse** and **download headers** at the same time, which can be used to approximate the use of processing units.\n",
"\n",
"The tutorial assumes knowledge of [Sentinel Hub Process API](https://github.com/sentinel-hub/sentinelhub-py/blob/master/examples/process_request.ipynb) and [Sentinel Hub Statistical API](https://github.com/sentinel-hub/sentinelhub-py/blob/master/examples/statistical_request.ipynb) examples.\n",
"\n",
"For more information about the service please check the [official service documentation](https://docs.sentinel-hub.com/api/latest/api/process/)."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],




This file has been truncated. show original




We want to be able to get the processing units in a similar manner, but we are using the Sentinel Hub Statistical Download Client. I looked at the documentation for this, and it did not appear that we could use the same method to get the estimated Processing Units (sentinelhub.download.sentinelhub_statistical_client — Sentinel Hub 3.8.0 documentation).


Do you have a recommendation for getting the processing units while using the Statistical Download Client?

Hi @sentinel_hub_user ,


When using SentinelHubStatisticalDownloadClient, you could set decode_data to False while calling the download method to get the encoded result with headers.


client = SentinelHubStatisticalDownloadClient(config=config)

ndvi_stats = client.download(download_requests, decode_data=False)

Then you could call headers to retrieve the estimated processing units as shown in the example you provided. To decode the data after having the processing units retrieved, you could simply call the decode method, e.g., ndvi_stats[0].decode().


Is it possible to retrieve other information from the headers such as retry-after or x-ratelimit-remaining?


According to the documentation, retry-after should also be available. Unfortunately, the only headers I can see, following your example code, are:


  • Date

  • Content-Type

  • Content-Length

  • Connection

  • access-control-allow-origin

  • access-control-allow-headers

  • access-control-allow-credentials

  • access-control-allow-methods

  • access-control-max-age

  • x-processingunits-spent


Hi @ksnn ,


retry-after only appears when you reach the rate limit, i.e., when the response having a status of 429. To find out the rate limit of your account, please refer to the Sentinel Hub pricing page.


Reply