Skip to content

Commit

Permalink
fascinating feature πŸͺ„ - kamangir/bolt#746
Browse files Browse the repository at this point in the history
  • Loading branch information
kamangir committed Jul 16, 2024
1 parent 3a42f8b commit c7dcf6e
Show file tree
Hide file tree
Showing 9 changed files with 317 additions and 1 deletion.
2 changes: 1 addition & 1 deletion blue_geo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

DESCRIPTION = f"{ICON} AI for precise geospatial data analysis and visualization."

VERSION = "4.43.1"
VERSION = "4.44.1"

REPO_NAME = "blue-geo"

Expand Down
3 changes: 3 additions & 0 deletions blue_geo/firms/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from blue_geo import NAME

NAME = f"{NAME}.firms"
3 changes: 3 additions & 0 deletions blue_geo/firms/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from blue_geo.firms import NAME

NAME = f"{NAME}.api"
5 changes: 5 additions & 0 deletions blue_geo/firms/api/area/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from blue_geo.firms.api import NAME

NAME = f"{NAME}.area"

REFERENCE = "https://firms.modaps.eosdis.nasa.gov/api/area/"
26 changes: 26 additions & 0 deletions blue_geo/firms/api/area/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import argparse
from blue_geo import VERSION
from blue_geo.firms.api.area import NAME
from blue_geo.ukraine_timemap.functions import ingest
from blue_geo.logger import logger
from blueness.argparse.generic import sys_exit

parser = argparse.ArgumentParser(NAME, description=f"{NAME}-{VERSION}")
parser.add_argument(
"task",
type=str,
help="get_url",
)
parser.add_argument(
"--object_name",
type=str,
)
args = parser.parse_args()

success = False
if args.task == "ingest":
success, _ = ingest(object_name=args.object_name)
else:
success = None

sys_exit(logger, NAME, args.task, success)
25 changes: 25 additions & 0 deletions blue_geo/firms/api/area/classes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from . import NAME
from .enums import Area, Source
from blue_geo.logger import logger


class APIRequest:
def __init__(
self,
source: Source = Source.MODIS_NRT,
area: Area = Area.WORLD,
):
self.area: Area = area
self.source: Source = source

def as_str(self) -> str:
return "{}.{}, area:{}, source: {} ({})".format(
NAME,
self.__class__.__name__,
self.area.name.lower(),
self.source.name,
self.source.description,
)

def get_url(self) -> str:
return ""
43 changes: 43 additions & 0 deletions blue_geo/firms/api/area/enums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from enum import Enum, auto


class Area(Enum):
EAST = auto()
NORTH = auto()
SOUTH = auto()
WEST = auto()
WORLD = auto()


class Source(Enum):
LANDSAT_NRT = (
auto(),
"LANDSAT Near Real-Time, Real-Time and Ultra Real-Time [US/Canada only]",
)
MODIS_NRT = (
auto(),
"MODIS Near Real-Time, Real-Time and Ultra Real-Time",
)
MODIS_SP = (
auto(),
"(MODIS Standard Processing)",
)
VIIRS_NOAA20_NRT = (
auto(),
"VIIRS NOAA-20 Near Real-Time, Real-Time and Ultra Real-Time",
)
VIIRS_NOAA21_NRT = (
auto(),
"VIIRS NOAA-21 Near Real-Time, Real-Time and Ultra Real-Time",
)
VIIRS_SNPP_NRT = (
auto(),
"VIIRS Suomi-NPP Near Real-Time, Real-Time and Ultra Real-Time",
)
VIIRS_SNPP_SP = (
auto(),
"VIIRS Suomi-NPP Standard Processing",
)

def __init__(self, _, description):
self.description = description
21 changes: 21 additions & 0 deletions blue_geo/tests/test_firms_api_area.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import pytest
from blue_geo.firms.api.area import enums
from blue_geo.firms.api.area.classes import APIRequest


@pytest.mark.parametrize(
["area", "source"],
[
[
enums.Area.WORLD,
enums.Source.MODIS_NRT,
],
],
)
def test_blue_geo_firms_api_area(
area: enums.Area,
source: enums.Source,
):
api_request = APIRequest(area=area, source=source)

assert api_request.as_str()
190 changes: 190 additions & 0 deletions notebooks/firms-area-api.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# FIRMS Area API\n",
"\n",
"https://firms.modaps.eosdis.nasa.gov/api/area/\n",
"\n",
"map-key: https://firms.modaps.eosdis.nasa.gov/api/map_key/"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"os.environ[\"abcli_path_bash\"] = \"{}/git/awesome-bash-cli/bash\".format(os.getenv(\"HOME\"))"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"🌐 abcli-9.163.1, built on 15 July 2024, 20:24:50\n"
]
}
],
"source": [
"from abcli import fullname\n",
"from abcli import string\n",
"from abcli.modules import objects\n",
"from abcli.plugins import seed\n",
"from blue_geo.firms.api.area.classes import APIRequest\n",
"from blue_geo.logger import logger\n",
"\n",
"logger.info(f\"{fullname()}, built on {string.pretty_date()}\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"🌐 blue_geo.firms.api.area.APIRequest, area:world, source: MODIS_NRT (MODIS Near Real-Time, Real-Time and Ultra Real-Time)\n"
]
}
],
"source": [
"api_request = APIRequest()\n",
"logger.info(api_request.as_str())"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"object_name = f\"firms-{string.timestamp()}\"\n",
"object_path = objects.object_path(object_name)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"---"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"🌐 Hello World! πŸͺ„\n"
]
}
],
"source": [
"logger.info(\"Hello World! πŸͺ„\")"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"---"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"πŸŒ€ blueness-3.64.1\n",
"πŸŒ€ blue_options-4.35.1\n",
"\u001b[0;36mπŸ“œ awesome-bash-cli: .env: 24 env var(s)\u001b[0m\n",
"\u001b[0;36mπŸ“œ awesome-bash-cli: abcli/config.env: 13 env var(s)\u001b[0m\n",
"\u001b[0;36mπŸ”‹ gpu: not found.\u001b[0m\n",
"\u001b[0;36mπŸš€ abcli-9.163.1.current\u001b[0m\n",
"\u001b[0;36mconfirmed: firms-2024-07-15-20-24-50-40562 does not exist.\u001b[0m\n",
"\u001b[0;36mfirms-2024-07-15-20-24-50-40562 open upload started.\u001b[0m\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
":: firms-2024-07-15-20-24-50-40562 += #open.\n"
]
}
],
"source": [
"%%bash -s $object_name\n",
"source ~/git/awesome-bash-cli/abcli/.abcli/abcli.sh in_notebook\n",
"\n",
"object_name=$1\n",
" \n",
"abcli upload - $object_name"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"# END"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.19"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit c7dcf6e

Please sign in to comment.