Skip to content

Commit 5d453fc

Browse files
committed
Fixed TPXO environment variables issue in #118
1 parent 445ea19 commit 5d453fc

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

examples/Bctides/gen_bctides.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
from pyschism.mesh import Hgrid
1111
from pyschism.forcing.bctides import Bctides
1212

13+
##Optional: set up environment variable for TPXO files
14+
#os.environ['TPXO_ELEVATION'] = '/path-to-your-hfile/h_tpxo9.v1.nc'
15+
#os.environ['TPXO_VELOCITY'] = '/path-to-your-ufile/u_tpxo9.v1.nc'
16+
1317
logging.basicConfig(
1418
format = "[%(asctime)s] %(name)s %(levelname)s: %(message)s",
1519
force=True,

pyschism/forcing/bctides/tpxo.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,11 @@ def h(self):
101101
if self._h_file is None:
102102
self._h_file = pathlib.Path(
103103
appdirs.user_data_dir('tpxo')) / TPXO_ELEVATION
104+
elif type(self._h_file) is str:
105+
self._h_file = pathlib.Path(self._h_file)
104106
if not self._h_file.exists():
105107
raise_missing_file(self._h_file, TPXO_ELEVATION)
108+
logger.info(f'h_file is {self._h_file}')
106109
self._h = Dataset(self._h_file)
107110
return self._h
108111

@@ -114,8 +117,11 @@ def uv(self):
114117
if self._u_file is None:
115118
self._u_file = pathlib.Path(
116119
appdirs.user_data_dir('tpxo')) / TPXO_VELOCITY
120+
elif type(self._u_file) is str:
121+
self._u_file = pathlib.Path(self._u_file)
117122
if not self._u_file.exists():
118123
raise_missing_file(self._u_file, TPXO_VELOCITY)
124+
logger.info(f'u_file is {self._u_file}')
119125
self._uv = Dataset(self._u_file)
120126
return self._uv
121127

0 commit comments

Comments
 (0)