Skip to main content

client library to easily access the SeDAS API

Project description

sedas_pyapi

A small collection of useful functions to get data from SeDAS. Works with the API documented here

Requires python 3+ has been tested with 3.7

Installing

Currently you will need to manually install the wheel generated by this project. Run

make dist 
pip install dist/sedas_pyapi-0.2.0-py3-none-any.whl

Soon we should have a copy of this in PyPI so you will be able to list it as a dependency.

Usage

Create an instance of sedas_pyapi.sedas_api.SeDASAPI passing in your username and password.

Then call search_optical, search_sar or search_product to find the details of a product.

Once you have a list of things you want to download you can use the sedas_pyapi.bulk_download.SeDASBulkDownload to download all of them. There are also download methods on the SeDASAPI if you need to do something a bit different.

Due to the way the SeDAS system works sometimes when you do a search you will not get a download url in the result object. If this happens it means that the data is available but in the long term archive (lta) and must be requested first. Use the request and is_request_ready methods to make a request and then wait for it to be fulfilled. If you use the SeDASBulkDownload this will take care of LTA requests for you.

For more details see the examples below

Examples

Creating a client

from sedas_pyapi.sedas_api import SeDASAPI
from getpass import getpass

# This is a suggestion for how to get your username and password
_username = input("Please enter your username:")
__password = getpass("Please enter your password:")

sedas = SeDASAPI(_username, __password)

The SeDASAPI object can then be used to access the rest of the api.

Search for an optical AOI with cloud cover filters

import json
from sedas_pyapi.sedas_api import SeDASAPI
from getpass import getpass

wkt = "POLYGON ((-1.3295 51.5881," \
          "-1.3013 51.5872," \
          "-1.3020 51.5621," \
          "-1.3300 51.5622," \
          "-1.3295 51.5881))"
startDate = "2019-04-30T00:00:00Z"
endDate = "2019-05-12T23:59:59Z"

_username = input("Please enter your username:")
__password = getpass("Please enter your password:")

sedas = SeDASAPI(_username, __password)
result_optical = sedas.search_optical(wkt, startDate, endDate, maxCloudPercent=50)
print(json.dumps(result_optical, sort_keys=True, indent=4, separators=(',', ': ')))

Returns a SeDAS search result object. See more

Search for a SAR AOI

import json
from sedas_pyapi.sedas_api import SeDASAPI
from getpass import getpass

wkt = "POLYGON ((-1.3295 51.5881," \
          "-1.3013 51.5872," \
          "-1.3020 51.5621," \
          "-1.3300 51.5622," \
          "-1.3295 51.5881))"
startDate = "2019-04-30T00:00:00Z"
endDate = "2019-05-12T23:59:59Z"

_username = input("Please enter your username:")
__password = getpass("Please enter your password:")

sedas = SeDASAPI(_username, __password)
result_sar = sedas.search_sar(wkt, startDate, endDate)
print(json.dumps(result_sar, sort_keys=True, indent=4, separators=(',', ': ')))

Returns a SeDAS search result object. See more

Search for a single product

import json
from sedas_pyapi.sedas_api import SeDASAPI
from getpass import getpass

_username = input("Please enter your username:")
__password = getpass("Please enter your password:")

sedas = SeDASAPI(_username, __password)
singleProduct = sedas.search_product("S1B_IW_GRDH_1SDV_20190528T105030_20190528T105055_016443_01EF3E_5E4F")
print(json.dumps(singleProduct, sort_keys=True, indent=4, separators=(',', ': ')))

This returns an array containing SeDAS products. See more

Download a single product

from sedas_pyapi.sedas_api import SeDASAPI
from getpass import getpass

_username = input("Please enter your username:")
__password = getpass("Please enter your password:")

sedas = SeDASAPI(_username, __password)
singleProduct = sedas.search_product("S1B_IW_GRDH_1SDV_20190528T105030_20190528T105055_016443_01EF3E_5E4F")

sedas.download(singleProduct, "/output/path/")

Bulk download many products

Note with historical request this can take a while to recover the images from the archive.

from sedas_pyapi.bulk_download import SeDASBulkDownload
from sedas_pyapi.sedas_api import SeDASAPI
from getpass import getpass
import time

wkt = "POLYGON ((-1.3295 51.5881," \
          "-1.3013 51.5872," \
          "-1.3020 51.5621," \
          "-1.3300 51.5622," \
          "-1.3295 51.5881))"
startDate = "2019-04-30T00:00:00Z"
endDate = "2019-05-12T23:59:59Z"

_username = input("Please enter your username:")
__password = getpass("Please enter your password:")

sedas = SeDASAPI(_username, __password)

# Search for some images.
result_sar = sedas.search_sar(wkt, startDate, endDate, sarProductType="SLC")
# Create a downloader. This will spawn a number of background threads to actually do the downloading and waiting for 
# the long term archive requests.
downloader = SeDASBulkDownload(sedas, "/output/path/", parallel=3)

# Add the things we want to download to the queue
downloader.add(result_sar['products'])

# Wait for the downloader to be finished.
while not downloader.is_done():
    time.sleep(5)

# clean up the background threads.
downloader.shutdown()

History

0.0.1 (2019-06-04)

  • Initial code release without packaging.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sedas_pyapi-0.2.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sedas_pyapi-0.2.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file sedas_pyapi-0.2.0.tar.gz.

File metadata

  • Download URL: sedas_pyapi-0.2.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.7

File hashes

Hashes for sedas_pyapi-0.2.0.tar.gz
Algorithm Hash digest
SHA256 be4434eb25cb65403fae8405b084231f8ad1b55e7a606caaad08820d3497b112
MD5 11f51b2b0ffb36428ab065672bddd902
BLAKE2b-256 3d565d76bd288f03ca25e56caad3fe4e5117fac1ddbaa65c165bafa00d63a61e

See more details on using hashes here.

File details

Details for the file sedas_pyapi-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: sedas_pyapi-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.7

File hashes

Hashes for sedas_pyapi-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cec728553730e0279c5c3a21863426a4dbe408518e1f4326df3ee834a138d7aa
MD5 7708d1b98157c826e8dc48fe3cf58d27
BLAKE2b-256 f7340799242a77e5fde30f2cacd58d7bf08820a8c1df7d50c343d8c089c5a1cb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page