Skip to content

Commit

Permalink
speed up nctoolkit import by dropping geoviews import
Browse files Browse the repository at this point in the history
  • Loading branch information
robertjwilson committed Nov 27, 2023
1 parent c8d736b commit 59882b5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
1 change: 1 addition & 0 deletions nctoolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
open_url,
)


from nctoolkit.unify import unify
from nctoolkit.shape import open_shape

Expand Down
17 changes: 1 addition & 16 deletions nctoolkit/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,7 @@ def custom_formatwarning(msg, *args, **kwargs):
session_info["cdo_methods"] = cdo_methods


def coast_check():
try:
import geoviews
import cartopy
from cartopy import crs
import cartopy.crs as ccrs

projection = ccrs.PlateCarree()
return True
except:
return False


session_info["coast"] = coast_check()
#session_info["coast"] = None
session_info["coast"] = None


session_info["interactive"] = sys.__stdin__.isatty()
Expand Down Expand Up @@ -1935,7 +1921,6 @@ def start(self):

from nctoolkit.phenology import phenology

# from nctoolkit.phenology import initiation

from nctoolkit.plot import plot
from nctoolkit.static_plot import pub_plot
Expand Down
17 changes: 16 additions & 1 deletion nctoolkit/plot.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
import signal
from ncplot import view

from contextlib import contextmanager
from nctoolkit.session import session_info

def coast_check():
try:
import geoviews
import cartopy
from cartopy import crs
import cartopy.crs as ccrs

projection = ccrs.PlateCarree()
return True
except:
return False



class TimeoutException(Exception):
pass
Expand Down Expand Up @@ -59,7 +71,10 @@ def plot(self, vars=None, autoscale=True, out=None, coast=None, **kwargs):
>>> ds.plot("var_of_choice")
"""
from ncplot import view

if session_info["coast"] is None:
session_info["coast"] = coast_check()

if "title" not in kwargs.keys():
kwargs["title"] = ""
Expand Down

0 comments on commit 59882b5

Please sign in to comment.