Skip to content

Commit

Permalink
Netcdf support (#337)
Browse files Browse the repository at this point in the history
* add netcdf support for troposphere

* reformat for pre-commit

* remove unnecessary lines

* avoid internal `opera_utils` function

* add xarray for atmosphere test reqs

* review suggestions for optional dependencies

* remove comment

---------

Co-authored-by: mirzaees <[email protected]>
Co-authored-by: Scott Staniewicz <[email protected]>
Co-authored-by: Scott Staniewicz <[email protected]>
  • Loading branch information
4 people authored Jul 16, 2024
1 parent d8cddda commit 8dd0149
Show file tree
Hide file tree
Showing 13 changed files with 3,046 additions and 65 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ ignore = [
exclude = ["scripts"]

[tool.ruff.lint.per-file-ignores]
"**/__init__.py" = ["F403"]
"**/__init__.py" = ["F401", "F403"]
"tests/**" = ["D", "N", "PTH"]
"benchmarks/**" = ["D", "N", "PTH", "RUF", "ARG002"]

Expand Down
1 change: 1 addition & 0 deletions src/dolphin/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class ReferencePoint(NamedTuple):
class TropoModel(str, Enum):
"""Enumeration representing different tropospheric models."""

ECMWF = "ECMWF"
ERA5 = "ERA5"
HRES = "HRES"
ERAINT = "ERAINT"
Expand Down
35 changes: 32 additions & 3 deletions src/dolphin/atmosphere/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,33 @@
"""Atmospheric corrections."""
from typing import Any

from .ionosphere import *
from .troposphere import *
from .ionosphere import estimate_ionospheric_delay
from .troposphere import estimate_tropospheric_delay

__all__ = [
"estimate_ionospheric_delay",
"estimate_tropospheric_delay",
]


def __getattr__(name: str) -> Any:
if name == "delay_from_netcdf":
# let's load this module lazily to avoid an ImportError
# for when we don't use netcdf
from ._netcdf import delay_from_netcdf

return delay_from_netcdf

if name in __all__:
return globals()[name]

errmsg = f"module {__name__!r} has no attribute {name!r}"
raise AttributeError(errmsg)


def __dir__() -> list[str]:
try:
from ._netcdf import delay_from_netcdf
except ModuleNotFoundError:
return __all__
else:
return sorted([*__all__, "delay_from_netcdf"])
Loading

0 comments on commit 8dd0149

Please sign in to comment.