merlin.support

merlin.support.chip_spec_queries(url)[source]

A map of pyccd spectra to chip-spec queries

Parameters:url (str) – full url (http://host:port/resource) for chip-spec endpoint
Returns:map of spectra to chip spec queries
Return type:dict

Example:

>>> chip_spec_queries('http://host/v1/landsat/chip-specs')
{'reds':     'http://host/v1/landsat/chip-specs?q=tags:red AND sr',
 'greens':   'http://host/v1/landsat/chip-specs?q=tags:green AND sr'
 'blues':    'http://host/v1/landsat/chip-specs?q=tags:blue AND sr'
 'nirs':     'http://host/v1/landsat/chip-specs?q=tags:nir AND sr'
 'swir1s':   'http://host/v1/landsat/chip-specs?q=tags:swir1 AND sr'
 'swir2s':   'http://host/v1/landsat/chip-specs?q=tags:swir2 AND sr'
 'thermals': 'http://host/v1/landsat/chip-specs?q=tags:thermal AND ta'
 'quality':  'http://host/v1/landsat/chip-specs?q=tags:pixelqa'}
merlin.support.data_config()[source]

Default configuration for retrieving and serving test data

Returns:x, y, acquired, dataset_name, chips_dir, specs_dir
Return type:dict

merlin.support.data

Functions for working with local data. This module allows merlin functions to test using local data rather than requiring external systems such as aardvark to be available.

Mock servers (such as aardvark) live in other modules, not here.

There are functions contained for updating the data that lives under merlin/support/data. The locations of this data is controlled by values in merlin/support/__init__.py

merlin.support.data.chips(spectra, support.data_config()['chips_dir'])[source]

Return chips for named spectra

Parameters:
  • spectra (str) – red, green, blue, nir, swir1, swir2, thermal or cfmask
  • root_dir (str) – directory where chips are located
Returns:

sequence of chips

merlin.support.data.chip_specs(spectra, root_dir=support.data_config()['specs_dir'])[source]

Returns chip specs for the named spectra.

Parameters:
  • spectra (str) – red, green, blue, nir, swir1, swir2, thermal or cfmask
  • root_dir (str) – directory where chip specs are located
Returns:

sequence of chip specs

merlin.support.data.chip_ids(root_dir=support.data_config()['chips_dir'])[source]

Returns chip ids for available chip data in root_dir

Parameters:root_dir – directory where chips are located
Returns:tuple of tuples of chip ids (UL coordinates)
merlin.support.data.spectra_from_queryid(queryid, root_dir=support.data_config()['specs_dir'])[source]

Returns the spectra name for a chip spec from the supplied queryid

Parameters:
  • queryid (str) – query identifier
  • root_dir (str) – directory where chip specs are located
Returns:

spectra names associated with the query identifier

Return type:

list

merlin.support.data.test_specs(root_dir=support.data_config()['specs_dir'])[source]

Returns a dict of all test chip specs keyed by spectra

Parameters:root_dir (str) – directory where chip specs are located
Returns:spectra: [chip_spec1, chip_spec2, ...]
Return type:dict
merlin.support.data.update_specs(specs_url, conf=support.data_config())[source]

Updates the spec test data

Parameters:
  • specs_url (str) – chip spec query
  • conf (dict) – key:values for data_config
Returns:

True or Exception

Return type:

bool

merlin.support.data.update_chips(chips_url, specs_url, conf=support.data_config())[source]

Updates the chip test data

Parameters:
  • chips_url (str) – chips url
  • specs_url (str) – chip spec query
  • conf (dict) – key:values for data_config
Returns:

True or Exception

Return type:

bool

merlin.support.data.live_specs(specs_url)[source]

Returns a dict of all chip specs defined by the driver.chip_spec_urls keyed by spectra

Parameters:specs_url (str) – chip spec query
Returns:spectra: [chip_spec1, chip_spec2, ...]
Return type:dict
merlin.support.data.spec_query_ids(specs_url)[source]

Returns a dictionary of key: query from a specs_url

Parameters:specs_url (str) – URL to chip specs
Returns:key:query for all the queries associated with specs_url
Return type:dict
merlin.support.data.spec_query_id(url)[source]

Generates identifier for spec query url based on the querystring

Parameters:url (str) – url containing a querystring
Returns:query identifier
Return type:str
merlin.support.data.spectra_from_specfile(filename)[source]

Returns the spectra the named chip spec file is associated with

Parameters:filename (str) – File to obtain spectra from
Returns:spectra associated with file
Return type:str
merlin.support.data.spectra_index(specs)[source]

Returns a dict keyed by ubid that maps to the spectra name

Parameters:specs (dict) – A dict of spectra: chip_specs
Returns:spectra
Return type:A dict of ubid

merlin.support.aardvark

Filesystem based local aardvark operations.

merlin.support.aardvark.chip_specs(url)[source]

Return chip specs from local disk

Parameters:url (str) – chip spec query
Returns:sequence of chip specs matching query
Return type:tuple
merlin.support.aardvark.chips(x, y, acquired, url, ubids)[source]

Return chips from local disk

Parameters:
  • x (number) – x coordinate
  • y (number) – y coordinate
  • acquired (str) – ISO8601 date range string
  • url (str) – Not used. Necessary to support chips interface
  • ubids (sequence) – universal band ids
Returns:

sequence of chips

Return type:

tuple