Retrieve Processing Units in Request Header

Hello,

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

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.

1 Like