Skip to content

Commit

Permalink
edit to posdwn plotting in xbeachtools.py and removed the floating po…
Browse files Browse the repository at this point in the history
…int bugfix:

    # prevent very small grid sizes when floating point zero goes wrong for computing var distance!
  • Loading branch information
casvbem committed Mar 7, 2024
1 parent e614f57 commit 2c07697
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 54 deletions.
100 changes: 61 additions & 39 deletions examples/xbeach-setup-1D.ipynb

Large diffs are not rendered by default.

27 changes: 17 additions & 10 deletions examples/xbeach-setup-2D.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions xbTools/grid/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ def seaward_extend(x,y,z,slope=1/20,depth=-20):
## dummy array
x_dummy = np.arange(x[0, 0]-distance, x[0, 0], dx_grid)
# prevent very small grid sizes when floating point zero goes wrong for computing var distance!
if (x_dummy[-1]-x[0, 0])< 0.01:
x_dummy = x_dummy[:-1]
#if (x_dummy[-1]-x[0, 0])< 0.01:
# x_dummy = x_dummy[:-1]

x_extend = np.ones((x.shape[0], len(x_dummy) ))
x_extend = x_extend * x_dummy
Expand Down
6 changes: 3 additions & 3 deletions xbTools/xbeachtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,15 +556,15 @@ def _plotdomain(self,save_path=None):
thetamin_uv, thetamax_uv = self._make_theta_vectors()
if self.fast1D==True:
plt.subplot(2,1,1)
plt.plot(np.squeeze(self.xgr),np.squeeze(self.zgr)*self.posdwn)
plt.plot(np.squeeze(self.xgr),np.squeeze(self.zgr)*-self.posdwn)
plt.ylabel('z')
plt.subplot(2,1,2)
plt.plot(np.squeeze(self.xgr)[1:],np.diff(np.squeeze(self.xgr)))
plt.xlabel('x')
plt.ylabel('dx')
else:
plt.subplot(2,2,1)
plt.pcolor(self.xgr,self.ygr,self.zgr*self.posdwn)
plt.pcolor(self.xgr,self.ygr,self.zgr*-self.posdwn)
plt.ylabel('y')
plt.colorbar()
plt.axis('equal')
Expand All @@ -585,7 +585,7 @@ def _plotdomain(self,save_path=None):

plt.subplot(2,2,3)
[X_world,Y_world] = rotate_grid(self.xgr,self.ygr,np.deg2rad(self.alfa))
plt.pcolor(X_world+self.xori,Y_world+self.yori,self.zgr*self.posdwn)
plt.pcolor(X_world+self.xori,Y_world+self.yori,self.zgr*-self.posdwn)
plt.xlabel('x')
plt.ylabel('y')
plt.axis('equal')
Expand Down

0 comments on commit 2c07697

Please sign in to comment.