Skip to content

Commit

Permalink
add derived_bands methods
Browse files Browse the repository at this point in the history
  • Loading branch information
hrfuller committed Jul 18, 2017
1 parent b684b13 commit 0a2a57c
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions descarteslabs/services/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def sources(self):
return r.json()

def bands(self, products=None, limit=None, offset=None, wavelength=None, resolution=None, tags=None):
"""Seach for imagery data bands that you have access to.
"""Search for imagery data bands that you have access to.
:param list(str) products: A list of product(s) to return bands for.
:param int limit: Number of results to return.
Expand All @@ -82,6 +82,26 @@ def bands(self, products=None, limit=None, offset=None, wavelength=None, resolut
r = self.session.post('/bands/search', json=kwargs)
return r.json()

def derived_bands(self, bands=None, limit=None, offset=None):
"""Search for predefined derived bands that you have access to.
:param list(str) bands: A list of source bands that must be part of
the derived band i.e ["nir"]
:param int limit: Number of results to return.
:param int offset: Index to start at when returning results.
"""
params = ['bands', 'limit', 'offset']

args = locals()
kwargs = {
param: args[param]
for param in params
if args[param] is not None
}

r = self.session.post('/bands/derived/search', json=kwargs)
return r.json()

def products(self, bands=None, limit=None, offset=None):
"""Search products that are available on the platform.
Expand Down Expand Up @@ -119,7 +139,7 @@ def available_products(self):

return r.json()

def translate(const_id):
def translate(self, const_id):
"""Translate a deprecated constellation identifier
into a new-style product identifier.
Expand Down Expand Up @@ -525,3 +545,12 @@ def get_band(self, band_id):
"""
r = self.session.get('/bands/%s' % band_id)
return r.json()

def get_derived_band(self, derived_band_id):
"""Get information about a single product.
:param str derived_band_id: Derived band identifier.
"""
r = self.session.get('/bands/derived/%s' % derived_band_id)
return r.json()

0 comments on commit 0a2a57c

Please sign in to comment.