@@ -33,18 +33,24 @@ def __init__(self, filename=None, datatype=None, path=None):
3333 self .datatype = datatype
3434 self .path = path
3535
36- def z (self ): # noqa: D102
36+ def z (self , seaLevel = 0.0 ): # noqa: D102
3737 if self .datatype == 'xyz' :
3838 if self .path != None : # noqa: E711
3939 if self .filename == None : # noqa: E711
4040 self .filename = 'test_curve.xyz'
4141 return np .loadtxt (os .path .join (self .path , self .filename )) # noqa: PTH118
4242 return np .loadtxt (self .filename )
43+ if self .datatype == 'xz' :
44+ if self .path != None :
45+ return np .loadtxt (os .path .join (self .path , self .filename ))
46+ else :
47+ return np .loadtxt (self .filename )
4348 if self .datatype == 'celeris' or self .datatype == 'txt' : # noqa: PLR1714
4449 if self .path != None : # noqa: E711
4550 if self .filename == None : # noqa: E711
4651 self .filename = 'bathy.txt'
4752 bathy = np .loadtxt (os .path .join (self .path , self .filename )) # noqa: PTH118
53+ bathy = bathy - seaLevel
4854 return bathy * - 1
4955 return 'No supported format'
5056
@@ -58,10 +64,10 @@ def __init__( # noqa: C901
5864 self ,
5965 celeris = True , # noqa: FBT002
6066 precision = ti .f32 ,
61- North = None , # noqa: N803
62- South = None , # noqa: N803
63- East = None , # noqa: N803
64- West = None , # noqa: N803
67+ North = 10 , # noqa: N803
68+ South = 10 , # noqa: N803
69+ East = 10 , # noqa: N803
70+ West = 10 , # noqa: N803
6571 WaveType = - 1 , # noqa: N803
6672 Amplitude = 0.5 , # noqa: N803
6773 Period = 10.0 , # noqa: N803
@@ -256,6 +262,8 @@ def __init__( # noqa: C901, PLR0913
256262 self .seaLevel = float (self .configfile ['seaLevel' ])
257263 elif checjson ('sea_level' , self .configfile ) == 1 :
258264 self .seaLevel = float (self .configfile ['sea_level' ])
265+ elif checjson ('swl' , self .configfile ) == 1 :
266+ self .seaLevel = float (self .configfile ['swl' ])
259267 else :
260268 self .seaLevel = 0.0
261269
@@ -303,6 +311,15 @@ def __init__( # noqa: C901, PLR0913
303311 self .Courant = Courant
304312 self .base_depth_ = base_depth
305313
314+ if self .topodata .datatype == 'xz' :
315+ self .Ny = 1
316+ self .dy = 1.0
317+ self .dx = (self .x2 - self .x1 )/ self .Nx
318+ self .isManning = isManning
319+ self .friction = friction
320+ self .Courant = Courant
321+ self .base_depth_ = base_depth
322+
306323 self .pixels = ti .field (float , shape = (self .Nx , self .Ny ))
307324
308325 def topofield (self ): # noqa: D102
@@ -311,7 +328,7 @@ def topofield(self): # noqa: D102
311328 np .arange (0.0 , self .Nx * self .dx , self .dx ),
312329 np .arange (0 , self .Ny * self .dy , self .dy ),
313330 )
314- foo = self .topodata .z ()
331+ foo = self .topodata .z (seaLevel = self . seaLevel )
315332 return x_out , y_out , foo .T
316333 if self .topodata .datatype == 'xyz' : # noqa: RET503
317334 dum = self .topodata .z ()
@@ -321,10 +338,19 @@ def topofield(self): # noqa: D102
321338 )
322339 dem = griddata (dum [:, :2 ], dum [:, 2 ], (x_out , y_out ), method = 'nearest' )
323340 return x_out .T , y_out .T , dem .T
341+ if self .topodata .datatype == 'xz' :
342+ dum = self .topodata .z ()
343+ x_out = np .arange ( self .x1 , self .x2 , self .dx )
344+ dem = np .interp (x_out ,dum [:,0 ],dum [:,1 ])
345+ return x_out , dem
324346
325347 def bottom (self ): # noqa: D102
326348 nbottom = np .zeros ((4 , self .Nx , self .Ny ), dtype = ti2np (self .precision ))
327- nbottom [2 ] = - 1.0 * self .topofield ()[2 ]
349+ if self .topodata .datatype == 'xz' :
350+ # VERSION 1D
351+ nbottom [2 ,:,0 ] = - 1.0 * self .topofield ()[1 ]
352+ else :
353+ nbottom [2 ] = - 1.0 * self .topofield ()[2 ]
328354 nbottom [3 ] = 99.0 # To be used in neardry
329355
330356 bottom = ti .field (self .precision , shape = (4 , self .Nx , self .Ny ))
@@ -339,11 +365,20 @@ def grid(self): # noqa: D102
339365
340366 def maxdepth (self ): # noqa: D102
341367 if self .base_depth_ == None : # noqa: E711
342- return np .max (self .topofield ()[2 ])
343- return self .base_depth_
368+ # VERSION 1D
369+ if self .topodata .datatype == 'xz' :
370+ return np .max (self .topofield ()[1 ])
371+ else :
372+ return np .max (self .topofield ()[2 ])
373+ else :
374+ return self .base_depth_
344375
345376 def maxtopo (self ): # noqa: D102
346- return np .min (self .topofield ()[2 ])
377+ # VERSION 1D
378+ if self .topodata .datatype == 'xz' :
379+ return np .min (self .topofield ()[1 ])
380+ else :
381+ return np .min (self .topofield ()[2 ])
347382
348383 def dt (self ): # noqa: D102
349384 maxdepth = self .maxdepth () # noqa: F841
0 commit comments