Skip to content

Commit

Permalink
Merge pull request #66 from aazuspan/opt_dependencies
Browse files Browse the repository at this point in the history
Make plotly and netcdf4 optional #65
  • Loading branch information
aazuspan committed Apr 25, 2023
2 parents e8afa0d + e24ed3d commit 5bcffe2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ classifiers = [
dependencies = [
"earthengine-api",
"joblib",
"netcdf4",
"plotly>=5.2.2",
"rasterio",
"requests",
"rioxarray",
Expand All @@ -56,13 +54,17 @@ dev = [
"requests_mock",
"sphinx",
"sphinx_rtd_theme",
"netcdf4",
"plotly>=5.2.2",
]
doc = [
"nbsphinx",
"sphinx",
"sphinx_rtd_theme",
]
test = [
"netcdf4",
"plotly>=5.2.2",
"hvplot",
"matplotlib",
"mock",
Expand Down Expand Up @@ -97,6 +99,8 @@ view = "python -m webbrowser -t docs/_build/html/index.html"

[tool.hatch.envs.test]
dependencies = [
"netcdf4",
"plotly>=5.2.2",
"hvplot",
"matplotlib",
"mock",
Expand Down
17 changes: 13 additions & 4 deletions wxee/time_series.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
from typing import Any, List, Optional, Union
from typing import TYPE_CHECKING, Any, List, Optional, Union

import ee # type: ignore
import pandas as pd # type: ignore
import plotly.express as px # type: ignore
import plotly.graph_objects as go # type: ignore

from wxee.climatology import Climatology, ClimatologyFrequencyEnum
from wxee.exceptions import MissingPropertyError
from wxee.interpolation import InterpolationMethodEnum
from wxee.params import ParamEnum
from wxee.utils import _millis_to_datetime, _normalize

if TYPE_CHECKING:
import plotly.graph_objects as go # type: ignore


class TimeFrequencyEnum(ParamEnum):
"""Parameters defining generic time frequnecies."""
Expand Down Expand Up @@ -170,14 +171,22 @@ def dataframe(self, props: Union[None, List[str], ee.List] = None) -> pd.DataFra
df.index.id = collection_id
return df

def timeline(self) -> go.Figure: # pragma: no cover
def timeline(self) -> "go.Figure": # pragma: no cover
"""Generate an interactive plot showing the acquisition time of each image in the time series.
Returns
-------
go.Figure
A Plotly graph object interactive plot showing the acquisition time of each image in the time series.
"""
try:
import plotly.express as px # type: ignore
except ImportError:
raise ImportError(
"The `plotly` package is required for this feature. "
"Please install it with `pip install plotly` and try again."
) from None

df = self.dataframe(props=["system:id", "system:time_start"])
df["y"] = 0

Expand Down

0 comments on commit 5bcffe2

Please sign in to comment.