cmr.ous.common

Documentation forthcoming

apply-bounding-conditions

(apply-bounding-conditions search-endpoint user-token coll {:keys [bounding-box variables], :as params})

This function is where variable queries to the CMR are made. There are several conditions that apply when extracting variables, all related to spatial subsetting (bounding box), and these determine which variables are returned.

The conditions are as follows:

  • no spatial subsetting and no variables - return no query string in OPeNDAP URL; this will give users (by default) all variables for the entire extent defined in the granule metadata.
  • variables but no spatial subsetting - return a query string with just the variables requested; a spatial subsetting for the granule’s extent (e.g., Latitude,Longitude) will also be appended to the OPeNDAP URL; this will give users just these variables, but for the entire extent defined in the granule metadata.
  • variables and spatial subsetting - return a query string with the variables requested as well as the subsetting requested; this will give users just these variables, with data limited to the specified spatial range.
  • spatial subsetting but no variables - this is a special case that needs to do a little more work: spatial subsetting without variables will link to an essentially empty OPeNDAP file; as such, we need to iterate through all the variables in the metadata and create an OPeNDAP URL query string that includes all of the variables.

For each of those conditions, a different value of vars will be returned, allowing for the desired result. Respective to the bullet points above:

  • vars - empty vector
  • vars - metadata for all the specified variable ids
  • vars - metadata for all the specified variable ids
  • vars - metadata for all the variables associated in the collection

apply-gridded-conditions

(apply-gridded-conditions vars params bounding-box)

This function is responsible for identifying whether data is girdded or not. Originally, the plan was to use processing level to make this determination, but due to issues with bad values in the metadata (for processing level), that wasn’t practical. Instead, we decided to use the presence or absence of dimensional metadata that includes latitude and longitude references (new as of UMM-Var 1.2).

This function is thus responsible for:

  • examining each variable for the presence or absence of lat/lon dimensional metadata
  • flagging the granule as gridded when all vars have this metadata
  • implicitly flagging the granule as non-gridded when some vars don’t have this metadata
  • removing bounding information from params when the granule is non-gridded
  • adding a warning to API consumers that the spatial subsetting parameters have been stripped due to non-applicability.

bounding-infos->opendap-query

(bounding-infos->opendap-query bounding-infos)(bounding-infos->opendap-query bounding-infos bounding-box)

Documentation forthcoming

data-file->opendap-url

(data-file->opendap-url data-file tag-data)

Converts a data-file to an OPeNDAP URL.

data-files->opendap-urls

(data-files->opendap-urls params data-files tag-data query-string)

Documentation forthcoming

fallback-datafile-support

Note that the keys are the regex’s and the values are what to replace with.

fallback-matches

(fallback-matches data-url)

Documentation forthcoming

fallback-patterns

This is for use in error messages.

format-opendap-lat-lon

(format-opendap-lat-lon bounding-infos bounding-box)

Documentation forthcoming

gridded-dim?

(gridded-dim? dim)

Variables have a collection of dims; this function tests just one.

gridded-dims?

(gridded-dims? dims)

This function is intended to test all the dims in a var. To count as gridded data, the dimensions of a variable must contain both a latitude and longitude value.

gridded-vars?

(gridded-vars? vars)

Given a collection of vars, extract the dims and test those. To count as gridded, all vars must be gridded.

has-fallback-replacement?

(has-fallback-replacement? data-url matched-data)

Documentation forthcoming

lat-dim?

(lat-dim? dim)

Documentation forthcoming

lon-dim?

(lon-dim? dim)

Documentation forthcoming

match-data

(match-data match regex)

Documentation forthcoming

matches-fallback?

(matches-fallback? matched-data)

Documentation forthcoming

process-results

(process-results results start errs)(process-results {:keys [params data-files tag-data query]} start errs warns)

Documentation forthcoming

process-tag-datafile-replacement

(process-tag-datafile-replacement data-url tag-data)

Takes a data file URL and replaces part of the URL based on the passed in tag data.

replace-double-slashes

(replace-double-slashes url)

Documentation forthcoming

replace-with-first-matching-fallback

(replace-with-first-matching-fallback data-url matched-data)

Documentation forthcoming

stage1

(stage1 component {:keys [endpoint token params]})

Documentation forthcoming

stage2

(stage2 component coll-promise grans-promise {:keys [endpoint token params]})

Note that this function is different for versions before v2.1 and versions after that. As such, no common implementation is provided.

stage3

(stage3 component service-ids vars bounding-box {:keys [endpoint token]})

Documentation forthcoming

stage4

(stage4 _component services-promise bounding-box bounding-infos _options)

Documentation forthcoming

strip-spatial

(strip-spatial params)

Documentation forthcoming