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.
fascinating feature πͺ - kamangir/bolt#746
- Loading branch information
Showing
9 changed files
with
317 additions
and
1 deletion.
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
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,3 @@ | ||
from blue_geo import NAME | ||
|
||
NAME = f"{NAME}.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,3 @@ | ||
from blue_geo.firms import NAME | ||
|
||
NAME = f"{NAME}.api" |
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,5 @@ | ||
from blue_geo.firms.api import NAME | ||
|
||
NAME = f"{NAME}.area" | ||
|
||
REFERENCE = "https://firms.modaps.eosdis.nasa.gov/api/area/" |
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,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) |
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,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 "" |
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,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 |
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,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() |
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,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 | ||
} |