Skip to content

Commit 0a2a57c

Browse files
author
hrfuller
committed
add derived_bands methods
1 parent b684b13 commit 0a2a57c

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

descarteslabs/services/metadata.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def sources(self):
5959
return r.json()
6060

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

85+
def derived_bands(self, bands=None, limit=None, offset=None):
86+
"""Search for predefined derived bands that you have access to.
87+
88+
:param list(str) bands: A list of source bands that must be part of
89+
the derived band i.e ["nir"]
90+
:param int limit: Number of results to return.
91+
:param int offset: Index to start at when returning results.
92+
"""
93+
params = ['bands', 'limit', 'offset']
94+
95+
args = locals()
96+
kwargs = {
97+
param: args[param]
98+
for param in params
99+
if args[param] is not None
100+
}
101+
102+
r = self.session.post('/bands/derived/search', json=kwargs)
103+
return r.json()
104+
85105
def products(self, bands=None, limit=None, offset=None):
86106
"""Search products that are available on the platform.
87107
@@ -119,7 +139,7 @@ def available_products(self):
119139

120140
return r.json()
121141

122-
def translate(const_id):
142+
def translate(self, const_id):
123143
"""Translate a deprecated constellation identifier
124144
into a new-style product identifier.
125145
@@ -525,3 +545,12 @@ def get_band(self, band_id):
525545
"""
526546
r = self.session.get('/bands/%s' % band_id)
527547
return r.json()
548+
549+
def get_derived_band(self, derived_band_id):
550+
"""Get information about a single product.
551+
552+
:param str derived_band_id: Derived band identifier.
553+
554+
"""
555+
r = self.session.get('/bands/derived/%s' % derived_band_id)
556+
return r.json()

0 commit comments

Comments
 (0)