diff options
| author | Paul Garlick <pgarlick@tourbillion-technology.com> | 2019-10-21 12:24:06 +0100 | 
|---|---|---|
| committer | Paul Garlick <pgarlick@tourbillion-technology.com> | 2019-10-21 12:24:06 +0100 | 
| commit | 56788ce26fb77fe3e427c403e85c24923f4cd46a (patch) | |
| tree | 87556176c12802e81affc58a68073bf5ba31cabf | |
| parent | dbea2a27f0a977305fc68cdeb7a64a0489727098 (diff) | |
| download | fullSWOF-utils-56788ce26fb77fe3e427c403e85c24923f4cd46a.tar.gz | |
add boolean variable to enable or disable plotting.
| -rw-r--r-- | boundaryDefinition.txt | 3 | ||||
| -rwxr-xr-x | makeBoundary.py | 21 | 
2 files changed, 17 insertions, 7 deletions
| diff --git a/boundaryDefinition.txt b/boundaryDefinition.txt index 6123f8b..b537e0d 100644 --- a/boundaryDefinition.txt +++ b/boundaryDefinition.txt @@ -8,6 +8,9 @@ height_data: "../FullSWOF_2D-1.08.00/Examples/Simple/Inputs/topography.txt"  # Boundary location ("top", "bottom", "left", "right"):  location: "top" +# Enable plotting (True or False): +plotting: True +  # Local gradient:  slope: -0.003646 diff --git a/makeBoundary.py b/makeBoundary.py index d2a48a2..59f4dc0 100755 --- a/makeBoundary.py +++ b/makeBoundary.py @@ -23,6 +23,7 @@ definition_dict = read_definition('boundaryDefinition.txt')  slope       = abs(definition_dict["slope"])  # slope at top boundary  target_flow = definition_dict["target_flow"] # imposed discharge  location    = definition_dict["location"]    # boundary location +plotting    = definition_dict["plotting"]    # enable or disable plotting  n_co        = definition_dict["n_co"]        # Manning's 'n' coefficients  # TODO: use weighted mean 'n' values.  See  # http://help.floodmodeller.com/isis/ISIS/River_Section.htm (Eq. 4) @@ -33,6 +34,7 @@ panel       = definition_dict["panel"]       # panel fill order  ztol        = definition_dict["ztol"]        # tolerance in overtopping height  numH        = definition_dict["numH"]        # number of height intervals +  # print(len(markers))  # with open('./1D_top.txt', "r") as data: @@ -65,18 +67,22 @@ if location == 'top':      xin = xtp[nrows-1:len(xtp):nrows]      yin = ytp[nrows-1:len(xtp):nrows]      zin = ztp[nrows-1:len(xtp):nrows] +    outputFilename = "BCTop.txt"  elif location == 'bottom':      xin = xtp[0:len(xtp):nrows]      yin = ytp[0:len(xtp):nrows]      zin = ztp[0:len(xtp):nrows] +    outputFilename = "BCBottom.txt"  elif location == 'left':      xin = xtp[:nrows]      yin = ytp[:nrows]      zin = ztp[:nrows] +    outputFilename = "BCLeft.txt"  elif location == 'right':      xin = xtp[nrows*(ncols-1):]      yin = ytp[nrows*(ncols-1):]      zin = ztp[nrows*(ncols-1):] +    outputFilename = "BCRight.txt"  print(xin) @@ -204,12 +210,13 @@ for p in range(num_panels):          zregion[p],          zmin[p],          zmax) -    plot_region( -        h_i[p]-zmin[p], 'maximum depth / m', -        r_h[p], 'hydraulic radius / m', -        K_i[p], r'conveyance / $m^3/s$', -        Q_i[p], r'discharge / $m^3/s$', -        'Panel {}'.format(p)) +    if plotting: +        plot_region( +            h_i[p]-zmin[p], 'maximum depth / m', +            r_h[p], 'hydraulic radius / m', +            K_i[p], r'conveyance / $m^3/s$', +            Q_i[p], r'discharge / $m^3/s$', +            'Panel {}'.format(p))  # sort list of discharge lists according to panel fill order:  sortedQ = [Q_i[i] for i in panel] @@ -269,7 +276,7 @@ for i, p in enumerate(panel):  #print('A_i_west = {} A_i = {} A_i_east = {}'.format(A_extra, A_i[-1], A_i_east[-1]))  def save_bc(): -    with open('BCTop.txt', 'w') as f: +    with open(outputFilename, 'w') as f:          f.write('{:6} {:>2} {:>2} {:>10}\n'.format('#x', 'c', 'q', 'h'))          for ind_z, (xitem, zitem) in enumerate(zip(xin, zin)):              panel_x = bisect.bisect(markers, xitem) | 
