Skip to content

Commit

Permalink
initial changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsantana11 committed Jul 19, 2024
1 parent 079ae36 commit 3166863
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
4 changes: 3 additions & 1 deletion clouddrift/adapters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import clouddrift.adapters.gdp6h as gdp6h
import clouddrift.adapters.glad as glad
import clouddrift.adapters.hurdat2 as hurdat2
import clouddrift.adapters.ibtracs as ibtracs
import clouddrift.adapters.mosaic as mosaic
import clouddrift.adapters.subsurface_floats as subsurface_floats
import clouddrift.adapters.utils as utils
Expand All @@ -21,9 +22,10 @@
__all__ = [
"andro",
"gdp1h",
"hurdat2",
"gdp6h",
"glad",
"hurdat2",
"ibtracs",
"mosaic",
"subsurface_floats",
"yomaha",
Expand Down
38 changes: 38 additions & 0 deletions clouddrift/adapters/ibtracs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from typing import Literal, TypeAlias

from fsspec.implementations.http import HTTPFileSystem

SOURCE_BASE_URI = "https://www.ncei.noaa.gov/data/international-best-track-archive-for-climate-stewardship-ibtracs"

SOURCE_URL_FMT = "{base_uri}/{version}/access/netcdf/IBTrACS.{kind}.{version}.nc"

_Version: TypeAlias = Literal["v03r09"] | Literal["v04r00"] | Literal["v04r01"]

_Kind: TypeAlias = (
Literal["ACTIVE"]
| Literal["ALL"]
| Literal["EP"]
| Literal["NA"]
| Literal["NI"]
| Literal["SA"]
| Literal["SI"]
| Literal["SP"]
| Literal["WP"]
| Literal["LAST_3_YEARS"]
| Literal["SINCE_1980"]
)


def download(version: _Version, kind: _Kind):
fs = HTTPFileSystem()
return fs.open(_get_source_url(version, kind), callback=lambda: print("what"))


def _kind_map(kind: _Kind):
return {"LAST_3_YEARS": "last3years", "SINCE_1980": "since1980"}.get(kind, kind)


def _get_source_url(version: _Version, kind: _Kind):
return SOURCE_URL_FMT.format(
base_uri=SOURCE_BASE_URI, version=version, kind=_kind_map(kind)
)
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ dependencies = [
"scipy>=1.11.2",
"xarray>=2023.5.0",
"zarr>=2.14.2",
"tenacity>=8.2.3"
"tenacity>=8.2.3",
"fsspec>=2024.3.1"
]

[project.optional-dependencies]
Expand Down

0 comments on commit 3166863

Please sign in to comment.