Skip to content

Commit

Permalink
Merge pull request #53 from kamangir/global-power-plant-database-2024…
Browse files Browse the repository at this point in the history
…-12-07-58SSQh

global-power-plant-database
  • Loading branch information
kamangir authored Dec 9, 2024
2 parents 0a38aeb + bc39c4d commit 21ff8c9
Show file tree
Hide file tree
Showing 29 changed files with 659 additions and 135 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ pip install blue-geo
| --- | --- | --- |
| 🧊[`copernicus`](https://github.com/kamangir/blue-geo/tree/main/blue_geo/catalog/copernicus) [![image](https://github.com/kamangir/assets/blob/main/blue-geo/copernicus.jpg?raw=true)](https://github.com/kamangir/blue-geo/tree/main/blue_geo/catalog/copernicus) catalog: [Copernicus Data Space Ecosystem - Europe's eyes on Earth](https://dataspace.copernicus.eu/) | 🌐[`SkyFox`](https://github.com/kamangir/blue-geo/tree/main/blue_geo/catalog/SkyFox) [![image](https://earthdaily.github.io/EDA-Documentation/Images/EarthDailyEDS.png)](https://github.com/kamangir/blue-geo/tree/main/blue_geo/catalog/SkyFox) catalog: [Earth Data Store](https://earthdaily.github.io/EDA-Documentation/). | 🌐[`EarthSearch`](https://github.com/kamangir/blue-geo/blob/main/blue_geo/catalog/EarthSearch) [![image](https://github.com/kamangir/assets/blob/main/blue-geo/viewer-aws-element84-com.png?raw=true)](https://github.com/kamangir/blue-geo/blob/main/blue_geo/catalog/EarthSearch) catalog: [Earth Search by Element 84 (earth-search-aws)](https://stacindex.org/catalogs/earth-search#/). |
| 🌐[`firms-area`](https://github.com/kamangir/blue-geo/tree/main/blue_geo/catalog/firms) [![image](https://raw.githubusercontent.com/kamangir/assets/main/blue-geo/datacube-firms_area.jpg)](https://github.com/kamangir/blue-geo/tree/main/blue_geo/catalog/firms) catalog: Fire Information for Resource Management System ([FIRMS](https://firms.modaps.eosdis.nasa.gov)). | 🇺🇦[`ukraine-timemap`](https://github.com/kamangir/blue-geo/blob/main/blue_geo/catalog/ukraine_timemap) [![image](https://github.com/kamangir/assets/blob/main/nbs/ukraine-timemap/QGIS.png?raw=true)](https://github.com/kamangir/blue-geo/blob/main/blue_geo/catalog/ukraine_timemap) catalog: [Bellingcat](https://www.bellingcat.com/) [Civilian Harm in Ukraine TimeMap](https://github.com/bellingcat/ukraine-timemap) dataset, available through [this UI](https://ukraine.bellingcat.com/) and [this API](https://bellingcat-embeds.ams3.cdn.digitaloceanspaces.com/production/ukr/timemap/api.json). | 🌈[`vancouver-watching`](https://github.com/kamangir/Vancouver-Watching) [![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/2024-01-06-20-39-46-73614/2024-01-06-20-39-46-73614-2X.gif?raw=true)](https://github.com/kamangir/Vancouver-Watching) catalog: Vancouver watching with AI, last build: [🔗](https://kamangir-public.s3.ca-central-1.amazonaws.com/test_vancouver_watching_ingest/animation.gif). |
| 🌐[`geo-watch`](https://github.com/kamangir/blue-geo/blob/main/blue_geo/watch) [![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-09-06-Jasper-a/geo-watch-2024-09-06-Jasper-a-2X.gif)](https://github.com/kamangir/blue-geo/blob/main/blue_geo/watch) watch the planet's story unfold. | 🌐[`catalog`](https://github.com/kamangir/blue-geo/tree/main/blue_geo/catalog) [![image](https://github.com/kamangir/assets/raw/main/blue-plugin/marquee.png?raw=true)](https://github.com/kamangir/blue-geo/tree/main/blue_geo/catalog) generalized STAC Catalogs. | 🧊[`datacube`](https://github.com/kamangir/blue-geo/tree/main/blue_geo/datacube) [![image](https://github.com/kamangir/assets/raw/main/blue-plugin/marquee.png?raw=true)](https://github.com/kamangir/blue-geo/tree/main/blue_geo/datacube) generalized STAC Items. |
| 🌐[`QGIS`](https://github.com/kamangir/blue-geo/blob/main/blue_geo/QGIS/README.md) [![image](https://raw.githubusercontent.com/kamangir/assets/main/blue-geo/QGIS.jpg)](https://github.com/kamangir/blue-geo/blob/main/blue_geo/QGIS/README.md) an AI terraform for [QGIS](https://www.qgis.org/). | | |
| 🌐[`geo-watch`](https://github.com/kamangir/blue-geo/blob/main/blue_geo/watch) [![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-09-06-Jasper-a/geo-watch-2024-09-06-Jasper-a-2X.gif)](https://github.com/kamangir/blue-geo/blob/main/blue_geo/watch) watch the planet's story unfold. | 🌐[`global-power-plant-database`](https://github.com/kamangir/blue-geo/tree/main/blue_geo/objects/md/global_power_plant_database.md) [![image](https://github.com/kamangir/assets/blob/main/blue-geo/global_power_plant_database-cover.png?raw=true)](https://github.com/kamangir/blue-geo/tree/main/blue_geo/objects/md/global_power_plant_database.md) The Global Power Plant Database is a comprehensive, open source database of power plants around the world [datasets.wri.org](https://datasets.wri.org/datasets/global-power-plant-database). | 🌐[`QGIS`](https://github.com/kamangir/blue-geo/blob/main/blue_geo/QGIS/README.md) [![image](https://raw.githubusercontent.com/kamangir/assets/main/blue-geo/QGIS.jpg)](https://github.com/kamangir/blue-geo/blob/main/blue_geo/QGIS/README.md) an AI terraform for [QGIS](https://www.qgis.org/). |
| 🌐[`catalog`](https://github.com/kamangir/blue-geo/tree/main/blue_geo/catalog) [![image](https://github.com/kamangir/assets/raw/main/blue-plugin/marquee.png?raw=true)](https://github.com/kamangir/blue-geo/tree/main/blue_geo/catalog) generalized STAC Catalogs. | 🧊[`datacube`](https://github.com/kamangir/blue-geo/tree/main/blue_geo/datacube) [![image](https://github.com/kamangir/assets/raw/main/blue-plugin/marquee.png?raw=true)](https://github.com/kamangir/blue-geo/tree/main/blue_geo/datacube) generalized STAC Items. | |

---

Expand All @@ -22,4 +22,4 @@ pip install blue-geo

[![pylint](https://github.com/kamangir/blue-geo/actions/workflows/pylint.yml/badge.svg)](https://github.com/kamangir/blue-geo/actions/workflows/pylint.yml) [![pytest](https://github.com/kamangir/blue-geo/actions/workflows/pytest.yml/badge.svg)](https://github.com/kamangir/blue-geo/actions/workflows/pytest.yml) [![bashtest](https://github.com/kamangir/blue-geo/actions/workflows/bashtest.yml/badge.svg)](https://github.com/kamangir/blue-geo/actions/workflows/bashtest.yml) [![PyPI version](https://img.shields.io/pypi/v/blue-geo.svg)](https://pypi.org/project/blue-geo/) [![PyPI - Downloads](https://img.shields.io/pypi/dd/blue-geo)](https://pypistats.org/packages/blue-geo)

built by 🌀 [`blue_options-4.173.1`](https://github.com/kamangir/awesome-bash-cli), based on 🌐 [`blue_geo-4.816.1`](https://github.com/kamangir/blue-geo).
built by 🌀 [`blue_options-4.173.1`](https://github.com/kamangir/awesome-bash-cli), based on 🌐 [`blue_geo-4.832.1`](https://github.com/kamangir/blue-geo).
43 changes: 43 additions & 0 deletions blue_geo/.abcli/ingest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#! /usr/bin/env bash

function blue_geo_ingest() {
local options=$1
local do_publish=$(abcli_option_int "$options" publish 0)
local do_upload=$(abcli_option_int "$options" upload 0)

local object_name=${2:-void}

local version=$(python3 -m blue_geo.objects get \
--what version \
--object_name $object_name)
version=$(abcli_option "$options" version $version)

local full_object_name=$object_name-$version

local template_object_name=$(python3 -m blue_geo.objects get \
--what template_name \
--object_name $object_name)
[[ ! -z "$template_object_name" ]] &&
abcli_clone \
- \
$template_object_name \
$full_object_name

abcli_log "ingesting $full_object_name ..."

python3 -m blue_geo.objects ingest \
--object_name $object_name \
--version $version \
"${@:3}"
local status="$?"

[[ "$do_upload" == 1 ]] &&
abcli_upload - $full_object_name

[[ "$do_publish" == 1 ]] &&
abcli_publish \
~download,tar \
$full_object_name

return $status
}
2 changes: 2 additions & 0 deletions blue_geo/.abcli/tests/help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ function test_@geo_help() {
\
"@geo gdal" \
\
"@geo ingest" \
\
"@geo pypi" \
"@geo pypi browse" \
"@geo pypi build" \
Expand Down
19 changes: 19 additions & 0 deletions blue_geo/.abcli/tests/ingest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#! /usr/bin/env bash

function test_blue_geo_ingest() {
local options=$1
local list_of_objects=$(abcli_option "$options" objects global-power-plant-database)

local object_name
for object_name in $(echo $list_of_objects | tr + " "); do

blue_geo_ingest \
upload,publish,$options \
$object_name
[[ $? -ne 0 ]] && return 1

abcli_hr
done

return 0
}
22 changes: 15 additions & 7 deletions blue_geo/README.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from blue_geo.catalog.README import build as build_catalog
from blue_geo.watch.README import items as watch_items, macros as watch_macros
from blue_geo.objects.README import build as build_objects
from blue_geo.watch.targets.README import build as build_targets
from blue_geo.help.functions import help_functions
from blue_geo import NAME, VERSION, ICON, REPO_NAME
Expand Down Expand Up @@ -55,6 +56,18 @@
"thumbnail": f"{ABCLI_PUBLIC_PREFIX}/geo-watch-2024-09-06-Jasper-a/geo-watch-2024-09-06-Jasper-a-2X.gif",
"url": "https://github.com/kamangir/blue-geo/blob/main/blue_geo/watch",
},
"global-power-plant-database": {
"description": "The Global Power Plant Database is a comprehensive, open source database of power plants around the world [datasets.wri.org](https://datasets.wri.org/datasets/global-power-plant-database).",
"icon": ICON,
"thumbnail": "https://github.com/kamangir/assets/blob/main/blue-geo/global_power_plant_database-cover.png?raw=true",
"url": "https://github.com/kamangir/blue-geo/tree/main/blue_geo/objects/md/global_power_plant_database.md",
},
"QGIS": {
"description": "an AI terraform for [QGIS](https://www.qgis.org/).",
"icon": ICON,
"thumbnail": "https://raw.githubusercontent.com/kamangir/assets/main/blue-geo/QGIS.jpg",
"url": "https://github.com/kamangir/blue-geo/blob/main/blue_geo/QGIS/README.md",
},
"catalog": {
"description": "generalized STAC Catalogs.",
"icon": ICON,
Expand All @@ -67,15 +80,9 @@
"thumbnail": default_MARQUEE,
"url": "https://github.com/kamangir/blue-geo/tree/main/blue_geo/datacube",
},
"QGIS": {
"description": "an AI terraform for [QGIS](https://www.qgis.org/).",
"icon": ICON,
"thumbnail": "https://raw.githubusercontent.com/kamangir/assets/main/blue-geo/QGIS.jpg",
"url": "https://github.com/kamangir/blue-geo/blob/main/blue_geo/QGIS/README.md",
},
"template": {
"description": "",
"icon": "",
"icon": ICON,
"thumbnail": default_MARQUEE,
"url": "",
},
Expand Down Expand Up @@ -124,4 +131,5 @@ def build() -> bool:
)
and build_catalog()
and build_targets()
and build_objects()
)
2 changes: 1 addition & 1 deletion blue_geo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

DESCRIPTION = f"{ICON} AI for a Blue Planet."

VERSION = "4.816.1"
VERSION = "4.832.1"

REPO_NAME = "blue-geo"

Expand Down
2 changes: 2 additions & 0 deletions blue_geo/help/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from blue_geo.help.catalog import help_functions as help_catalog
from blue_geo.help.datacube import help_functions as help_datacube
from blue_geo.help.gdal import help_functions as help_gdal
from blue_geo.help.ingest import help_ingest
from blue_geo.help.QGIS import help_functions as help_QGIS
from blue_geo.help.watch import help_functions as help_watch

Expand All @@ -14,6 +15,7 @@
"catalog": help_catalog,
"datacube": help_datacube,
"gdal": help_gdal,
"ingest": help_ingest,
"QGIS": help_QGIS,
"watch": help_watch,
}
Expand Down
41 changes: 41 additions & 0 deletions blue_geo/help/ingest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from typing import List

from blue_options.terminal import show_usage, xtra

from blue_geo.objects import special_objects


def help_ingest(
tokens: List[str],
mono: bool,
) -> str:
options = "".join(
[
"publish,upload",
xtra(",version=<v1>", mono=mono),
]
)

args = [
"[--overwrite 1]",
]

return show_usage(
[
"@geo",
"ingest",
f"[{options}]",
"<object-name>",
]
+ args,
"ingest <object-name>.",
{
"object-name: {}".format(
" | ".join(
"{}[-{}]".format(key, object_module.version)
for key, object_module in special_objects.items()
)
): [],
},
mono=mono,
)
48 changes: 48 additions & 0 deletions blue_geo/objects/README.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import os

from blue_objects import file, README
from blue_objects.env import ABCLI_PUBLIC_PREFIX

from blue_geo import NAME, VERSION, ICON, REPO_NAME
from blue_geo.objects import special_objects


def build() -> bool:
return all(
README.build(
path=os.path.join(
file.path(__file__),
f"md/{suffix}",
),
macros=macros,
ICON=ICON,
NAME=NAME,
VERSION=VERSION,
REPO_NAME=REPO_NAME,
)
for suffix, macros, in [
(
f"{object_name}.md".replace("-", "_"),
{
"--object-name--": [
"💾 [{}-{}]({}/{}-{}.tar.gz)".format(
object_name,
special_objects[object_name].version,
ABCLI_PUBLIC_PREFIX,
object_name,
special_objects[object_name].version,
),
],
"--urls--": sorted(
[
f" - {title}: {url}"
for title, url in special_objects[object_name].url.items()
]
),
},
)
for object_name in [
"global-power-plant-database",
]
]
)
9 changes: 9 additions & 0 deletions blue_geo/objects/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from typing import Dict
from types import ModuleType


from blue_geo.objects import global_power_plant_database

special_objects: Dict[str, ModuleType] = {
"global-power-plant-database": global_power_plant_database,
}
89 changes: 89 additions & 0 deletions blue_geo/objects/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import argparse
from types import ModuleType

from blueness import module
from blueness.argparse.generic import sys_exit

from blue_geo import NAME
from blue_geo.objects import special_objects
from blue_geo.logger import logger

NAME = module.name(__file__, NAME)


parser = argparse.ArgumentParser(NAME)
parser.add_argument(
"task",
type=str,
help="get | ingest",
)
parser.add_argument(
"--object_name",
default="",
type=str,
help=", ".join(special_objects.keys()),
)
parser.add_argument(
"--version",
type=str,
default="",
help="defaults to <object_name>.version",
)
parser.add_argument(
"--what",
default="template_name",
type=str,
help="template_name | version",
)
parser.add_argument(
"--default",
default="void",
type=str,
)
parser.add_argument(
"--overwrite",
default=0,
type=int,
help="0|1",
)

args = parser.parse_args()

success = False
if args.task == "get":
success = True
output = args.default

if args.object_name in special_objects:
object_module: ModuleType = special_objects[args.object_name]

if args.what == "template_name":
output = object_module.template_name
elif args.what == "version":
output = object_module.version

print(output)
elif args.task == "ingest":
if args.object_name in special_objects:
object_module: ModuleType = special_objects[args.object_name]

version = args.version
if not version:
version = object_module.version

success = object_module.ingest(
object_name=args.object_name,
version=version,
overwrite=args.overwrite == 1,
)
else:
logger.error(
"{}: object not found, expected one of {}.".format(
args.object_name,
", ".join(special_objects.keys()),
)
)
else:
success = None

sys_exit(logger, NAME, args.task, success)
Loading

0 comments on commit 21ff8c9

Please sign in to comment.