generated from kamangir/blue-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from kamangir/catalogs-2024-07-24
+= catalogs
- Loading branch information
Showing
73 changed files
with
1,276 additions
and
764 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#! /usr/bin/env bash | ||
|
||
alias @catalog=blue_geo_catalog | ||
alias @datacube=blue_geo_datacube |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#! /usr/bin/env bash | ||
|
||
function blue_geo_catalog() { | ||
local task=$(abcli_unpack_keyword $1 help) | ||
|
||
if [ "$task" == "help" ]; then | ||
blue_geo_catalog_browse "$@" | ||
blue_geo_catalog_get "$@" | ||
blue_geo_catalog_list "$@" | ||
blue_geo_catalog_query "$@" | ||
return | ||
fi | ||
|
||
local function_name=blue_geo_catalog_$task | ||
if [[ $(type -t $function_name) == "function" ]]; then | ||
$function_name "${@:2}" | ||
return | ||
fi | ||
|
||
abcli_log_error "-@catalog: $task: command not found." | ||
return 1 | ||
} | ||
|
||
abcli_source_path - caller,suffix=/catalog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# 🌐 catalog | ||
|
||
`catalog`s can be listed and browsed and queried for [`datacube`](../datacube/)s, | ||
|
||
```bash | ||
> @catalog help | ||
@catalog browse \ | ||
<catalog> \ | ||
[<args>] | ||
. browse <catalog>. | ||
@catalog list \ | ||
[-] \ | ||
[--delim space] \ | ||
[--log 0] | ||
. list catalogs. | ||
@catalog query \ | ||
<catalog> \ | ||
[download,ingest,select,upload] \ | ||
[-|<object-name>] \ | ||
[<query-options>] \ | ||
[<args>] | ||
. <catalog> -query-> <object-name>. | ||
@catalog query read \ | ||
[all,download,len] \ | ||
[.|<object-name>] \ | ||
[--count <count>] \ | ||
[--delim <delim>] \ | ||
[--index <index>] \ | ||
[--prefix <prefix>] \ | ||
[--suffix <suffix>] \ | ||
[--contains <contains>] \ | ||
[--notcontains <not-contains>] | ||
. read query results in <object-name>. | ||
``` | ||
|
||
supported `<catalog>`s: [firms](./firms/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#! /usr/bin/env bash | ||
|
||
function blue_geo_catalog_browse() { | ||
local options=$1 | ||
|
||
local catalog=$(abcli_option "$options" $blue_geo_catalog_list firms) | ||
|
||
if [ $(abcli_option_int "$options" help 0) == 1 ]; then | ||
for catalog in $(echo $blue_geo_catalog_list | tr , " "); do | ||
blue_geo_catalog_browse_${catalog} "$@" | ||
done | ||
return | ||
fi | ||
|
||
abcli_log "@catalog: browsing $catalog ..." | ||
blue_geo_catalog_browse_${catalog} "${@:2}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
..._geo/.abcli/datacube/firms_area/browse.sh → blue_geo/.abcli/catalog/firms/browse.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
#! /usr/bin/env bash | ||
|
||
function blue_geo_datacube_firms_area_browse() { | ||
function blue_geo_catalog_browse_firms() { | ||
local options=$1 | ||
|
||
if [ $(abcli_option_int "$options" help 0) == 1 ]; then | ||
options="|map_key|api" | ||
abcli_show_usage "@datacube browse firms_area$ABCUL$options" \ | ||
"browse firms_area datacubes." | ||
options="map_key|area" | ||
abcli_show_usage "@catalog browse firms$ABCUL[$options]" \ | ||
"browse firms." | ||
return | ||
fi | ||
|
||
local do_map_key=$(abcli_option_int "$options" map_key 0) | ||
local do_area_api=$(abcli_option_int "$options" api 0) | ||
local collection=$(abcli_option_choice "$options" area area) | ||
|
||
local url="https://firms.modaps.eosdis.nasa.gov/" | ||
[[ "$do_map_key" == 1 ]] && | ||
url="https://firms.modaps.eosdis.nasa.gov/api/map_key/" | ||
[[ "$do_area_api" == 1 ]] && | ||
url="https://firms.modaps.eosdis.nasa.gov/api/area/" | ||
[[ ! -z "$collection" ]] && | ||
url="https://firms.modaps.eosdis.nasa.gov/api/$collection/" | ||
|
||
abcli_browse $url | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#! /usr/bin/env bash | ||
|
||
function blue_geo_catalog_query_firms() { | ||
local options=$1 | ||
|
||
blue_geo_catalog_query_generic \ | ||
$options,catalog=firms \ | ||
"${@:2}" | ||
} | ||
|
||
abcli_source_path - caller,suffix=/query |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#! /usr/bin/env bash | ||
|
||
function blue_geo_catalog_query_firms_area() { | ||
local options=$1 | ||
|
||
local catalog="firms" | ||
local collection="area" | ||
|
||
if [ $(abcli_option_int "$options" help 0) == 1 ]; then | ||
options="$collection,dryrun" | ||
local args=$(python3 -m blue_geo.catalog.$catalog.$collection get --what list_of_args) | ||
abcli_show_usage "@catalog query $catalog$ABCUL[$blue_geo_catalog_query_options]$ABCUL[-|<object-name>]$ABCUL[$options]$ABCUL$args" \ | ||
"$catalog/$collection -query-> <object-name>." | ||
return | ||
fi | ||
|
||
local do_dryrun=$(abcli_option_int "$options" dryrun 0) | ||
|
||
local object_name=$(abcli_clarify_object $2 -) | ||
|
||
abcli_log "🌐 query: $catalog/$collection -> $object_name" | ||
|
||
abcli_eval dryrun=$do_dryrun \ | ||
python3 -m blue_geo.catalog.$catalog.$collection \ | ||
query \ | ||
--object_name $object_name \ | ||
"${@:3}" | ||
|
||
return 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#! /usr/bin/env bash | ||
|
||
function blue_geo_catalog_query_generic() { | ||
local options=$1 | ||
|
||
local catalog=$(abcli_option "$options" catalog generic) | ||
|
||
local list_of_collectios=$(blue_geo_catalog get list_of_collections \ | ||
--catalog $catalog \ | ||
--delim , \ | ||
--log 0) | ||
local default_collection=$(blue_geo_catalog get list_of_collections \ | ||
--catalog $catalog \ | ||
--count 1 \ | ||
--delim , \ | ||
--log 0) | ||
|
||
if [ $(abcli_option_int "$options" help 0) == 1 ]; then | ||
local collection | ||
for collection in $(echo $list_of_collectios | tr , " "); do | ||
blue_geo_catalog_query_${catalog}_${collection} "$@" | ||
done | ||
return 0 | ||
fi | ||
|
||
local do_dryrun=$(abcli_option_int "$options" dryrun 0) | ||
local collection=$(abcli_option_choice "$options" $list_of_collectios $default_collection) | ||
|
||
if [[ ",$list_of_collectios," != *",$collection,"* ]]; then | ||
abcli_log_error "-@catalog: query: $catalog: $collection: collection not found." | ||
return 1 | ||
fi | ||
|
||
if [[ "$2" == "help" ]]; then | ||
blue_geo_catalog_query_${catalog}_${collection} help | ||
return | ||
fi | ||
|
||
abcli_log "🌐 query: $catalog/$collection" | ||
|
||
blue_geo_catalog_query_${catalog}_${collection} "$@" | ||
} | ||
|
||
function blue_geo_catalog_query_generic_generic() { | ||
: # no query available. | ||
} | ||
|
||
function blue_geo_catalog_browse_generic() { | ||
: # no browse available. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#! /usr/bin/env bash | ||
|
||
function blue_geo_catalog_get() { | ||
local options=$1 | ||
|
||
if [ $(abcli_option_int "$options" help 0) == 1 ]; then | ||
options="list_of_collections" | ||
local args="[--catalog <catalog>]$ABCUL[--count 1]$ABCUL[--delim ,]$ABCUL[--log 0]" | ||
abcli_show_usage "@catalog get$ABCUL[$options]$ABCUL$args" \ | ||
"get list of collections in <catalog>." | ||
return | ||
fi | ||
|
||
local what=$(abcli_option_choice "$options" list_of_collections list_of_collections) | ||
|
||
python3 -m blue_geo.catalog \ | ||
get \ | ||
--what "$what" \ | ||
"${@:2}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#! /usr/bin/env bash | ||
|
||
function blue_geo_catalog_list() { | ||
local options=$1 | ||
|
||
if [ $(abcli_option_int "$options" help 0) == 1 ]; then | ||
options="-" | ||
local args="[--delim space]$ABCUL[--log 0]" | ||
abcli_show_usage "@catalog list$ABCUL[$options]$ABCUL$args" \ | ||
"list catalogs." | ||
return | ||
fi | ||
|
||
python3 -m blue_geo.catalog \ | ||
list \ | ||
"${@:2}" | ||
} | ||
|
||
function blue_geo_catalog_ls() { | ||
blue_geo_catalog_list "$@" | ||
} | ||
|
||
function blue_geo_catalog_load_all() { | ||
abcli_log_list $blue_geo_catalog_list \ | ||
--delim , \ | ||
--before "🌐 loading" \ | ||
--after "catalog(s)" | ||
|
||
local catalog | ||
for catalog in $(echo $blue_geo_catalog_list | tr , " "); do | ||
abcli_log "🧊 $catalog" | ||
abcli_source_path - caller,civilized,suffix=/$catalog | ||
done | ||
|
||
return 0 | ||
} | ||
|
||
export blue_geo_catalog_list=$(blue_geo_catalog_list - --log 0) | ||
|
||
blue_geo_catalog_load_all |
Oops, something went wrong.