Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
MarliesA committed Jan 23, 2025
2 parents 35d7629 + f018954 commit 075372c
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions xbTools/xbeachpost.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ def __init__(self, fname, model_path):
"""
self.fname = fname
self.model_path = model_path
self.get_params()
self.get_metadata()


# self.params = None
self.grd = {}
Expand All @@ -60,8 +59,12 @@ def __init__(self, fname, model_path):
'u_max', 'v_max', 'ue_max', 've_max', 'Subg_max', 'Svbg_max', 'Susg_max', 'Svsg_max',
'u_min', 'v_min', 'ue_min', 've_min', 'Subg_min', 'Svbg_min', 'Susg_min', 'Svsg_min']

self.get_params()
self.get_metadata()
self.load_grid()
self._cross_offset = 0

self.load_output_coordinates()

def get_metadata(self):
'''
function to print metadata from XBlog.txt
Expand Down Expand Up @@ -267,8 +270,9 @@ def load_grid(self):
assert self.grd['y'].shape == (self.params['ny'] + 1, self.params['nx'] + 1), 'y grid not of correct size'
# struct
if ('struct' in self.params) == 1:
self.grd['ne'] = np.loadtxt(os.path.join(self.model_path, self.params['ne_layer']))
assert np.atleast_2d(self.grd['ne']).shape == (self.params['ny'] + 1, self.params['nx'] + 1), 'ne grid not of correct size'
if self.params['struct']==1:
self.grd['ne'] = np.loadtxt(os.path.join(self.model_path, self.params['ne_layer']))
assert np.atleast_2d(self.grd['ne']).shape == (self.params['ny'] + 1, self.params['nx'] + 1), 'ne grid not of correct size'

def get_waves(self):
"""_summary_
Expand Down Expand Up @@ -335,7 +339,7 @@ def get_tide(self):
else:
loctime = dat[:, 0]
globtime = np.array([np.timedelta64(int(x), 's') for x in loctime]) + self.globalstarttime
self.waves_boundary['time'] = globtime
self.tide['time'] = globtime

return self.tide

Expand Down Expand Up @@ -602,12 +606,10 @@ def fig_check_tide_bc(self):
zs0_tide = self.tide['zs0']
if self.globalstarttime is None:
t_tide = self.tide['time'] / 3600
t = self.var['globaltime'] / 3600
t = self.var['meantime'] / 3600
else:
t_tide = np.array(
[np.timedelta64(int(x), 's') for x in self.tide['time']]) \
+ self.globalstarttime
t = self.var['globaltime']
t_tide = self.tide['time']
t = self.var['meantime']

lent = min([len(zs), len(t)])
tideloc = self.params['tideloc']
Expand Down

0 comments on commit 075372c

Please sign in to comment.