In [1]:
import pandas
import faulthandler
# Now let's generate the same thing from memory
import python_subgrid.wrapper
import numpy as np
import matplotlib.pyplot as plt

In [2]:
subgrid = python_subgrid.wrapper.SubgridWrapper(mdu='../../models/wijdewormer_spatiallite/wijdewormer_spatiallite.mdu')
subgrid.start()
#subgrid.library.initmodel()
subgrid.update(10.0)                           
# We are now at t
print(subgrid.get_nd('t1'))


INFO:python_subgrid.wrapper:Using subgrid fortran library /home/fedor/.local/lib/libsubgrid.so
INFO:python_subgrid.wrapper:Loading library from path /home/fedor/.local/lib/libsubgrid.so
INFO:python_subgrid.wrapper:Current version: Deltares, 3Di - subgrid Version 0.1.1.957:960M, Dec 18 2013, 01:12:00
INFO:python_subgrid.wrapper:Startup complete.
INFO:python_subgrid.wrapper:Loading model ../../models/wijdewormer_spatiallite/wijdewormer_spatiallite.mdu in directory /home/fedor/Checkouts/models/wijdewormer_spatiallite
INFO:python_subgrid.wrapper:Start loadModel for '../../models/wijdewormer_spatiallite/wijdewormer_spatiallite.mdu'.
WARNING:python_subgrid.wrapper:Ignored 'Teta' in MDU file, please use 'IntegrationMethod' instead.
INFO:python_subgrid.wrapper:Wrong NumLayers. Ground water calculations switched off.
INFO:python_subgrid.wrapper:Reading bathmetry file ' subgrid/wijdewormer.tif '...
DEBUG:python_subgrid.wrapper:          28   28.1435680      dps(0:imax+1, 0:jmax+1)
INFO:python_subgrid.wrapper:Completed reading bathymetry file.
INFO:python_subgrid.wrapper:Start initialization of grid administration.
INFO:python_subgrid.wrapper: Coarse grid parameters: kmax=           1 , dxmin=   100.000000
DEBUG:python_subgrid.wrapper:          56   28.1221485      lg(1:imax,1:jmax)
INFO:python_subgrid.wrapper:lg init on coarsest level took:   0.1253D+01 seconds.
INFO:python_subgrid.wrapper:guess dams took:   0.1000D-02 seconds.
INFO:python_subgrid.wrapper:Searching refinement areas for quadtrees generation took:  0.1298D+01 seconds.
INFO:python_subgrid.wrapper:Making quadtrees took:   0.9450D+00 seconds.
INFO:python_subgrid.wrapper:Opened file : boundaries/bc.ext
DEBUG:python_subgrid.wrapper:          56   2.17400002E-03  kce(n2dtot), kez(nx), itpez(nx)
INFO:python_subgrid.wrapper: Internal 2d nodes =      1740
INFO:python_subgrid.wrapper: Boundary 2d nodes =   0
DEBUG:python_subgrid.wrapper:          56   1.67420004E-02  nodm(nodall)
DEBUG:python_subgrid.wrapper:          56   1.67420004E-02  nodn(nodall)
DEBUG:python_subgrid.wrapper:          56   1.67420004E-02  nodk(nodall)
DEBUG:python_subgrid.wrapper:          56   1.67430006E-02  ks(0:nodall)
DEBUG:python_subgrid.wrapper:          56   3.34840007E-02  xz(nodall),yz(nodall)
DEBUG:python_subgrid.wrapper: make_channel_network: k1dmax=          11 , k1dtot=        1509
INFO:python_subgrid.wrapper:Opened file : boundaries/bc.ext
INFO:python_subgrid.wrapper:Opened file : boundaries/gemaal.nod
INFO:python_subgrid.wrapper:waterlevelbnd boundaries/gemaal.nod       1 nr of open bndcells
INFO:python_subgrid.wrapper: Internal 1d nodes =     15001
INFO:python_subgrid.wrapper: Boundary 1d nodes =   1
DEBUG:python_subgrid.wrapper:          56  0.133944005      nru,nrv
INFO:python_subgrid.wrapper:Opened file : boundaries/bc.ext
INFO:python_subgrid.wrapper:Initializing external forcing 'waterlevelbnd' from file 'boundaries/gemaal.nod'.
INFO:python_subgrid.wrapper:Opened file : boundaries/gemaal.nod
INFO:python_subgrid.wrapper:Opened file : boundaries/gemaal_0001.tim
INFO:python_subgrid.wrapper:Initializing boundaries took:   0.6000D-02 seconds.
INFO:python_subgrid.wrapper:Assignment of flooding thresholds took:   0.3146D+02 seconds.
INFO:python_subgrid.wrapper:Grid Admin initialisation took:  0.3148D+02 seconds.
INFO:python_subgrid.wrapper:Completed initialization of grid administration.
DEBUG:python_subgrid.wrapper:          56   1.67420004E-02  dmax(1:nodall)
DEBUG:python_subgrid.wrapper:          56   1.67420004E-02  dmin(1:nodall)
DEBUG:python_subgrid.wrapper:          56   1.67410001E-02  sumax(1:nodtot)
DEBUG:python_subgrid.wrapper:          56   6.69640005E-02  dqmin(1:nodtot)
DEBUG:python_subgrid.wrapper:          56   6.69640005E-02  dqmax(1:nodtot)
DEBUG:python_subgrid.wrapper:          56   6.69640005E-02  suqmax(1:nodtot)
DEBUG:python_subgrid.wrapper:          56   6.69640005E-02  ksq(1:nodtot)
DEBUG:python_subgrid.wrapper:          56   5.02289981E-02  s1(0:nodall)
DEBUG:python_subgrid.wrapper:          56   3.69220003E-02  as0(linall,1:2)
DEBUG:python_subgrid.wrapper:          56   3.69220003E-02  as1(linall,1:2)
DEBUG:python_subgrid.wrapper:          56   1.84599999E-02  cz(linall)
DEBUG:python_subgrid.wrapper:          57   5.02289981E-02  si(0:nodall)
DEBUG:python_subgrid.wrapper:          57   5.53830005E-02  u1(0:linall)
DEBUG:python_subgrid.wrapper:          57   1.84610002E-02  kf(0:linall)
DEBUG:python_subgrid.wrapper:          57   1.67430006E-02  vol1(0:nodall)
DEBUG:python_subgrid.wrapper:          57   3.34860012E-02  vol2(0:nodall)
DEBUG:python_subgrid.wrapper:          57   3.34860012E-02  su(0:nodall)
DEBUG:python_subgrid.wrapper:          57   1.67410001E-02  qrain(nodtot)
DEBUG:python_subgrid.wrapper:          57   3.34860012E-02  volErr(0:nodall)
DEBUG:python_subgrid.wrapper:          57   1.84599999E-02  conv(linall)
DEBUG:python_subgrid.wrapper:          57   6.69720024E-02  vq1(0:4*nodall)
INFO:python_subgrid.wrapper:Calculation of bathymetry statistics took:   0.1710D+00 seconds.
INFO:python_subgrid.wrapper:Setting initial water levels  from WaterLevelFile took:   0.0000D+00 seconds.
INFO:python_subgrid.wrapper:Setting initial water levels on 1d links from WaterLevelFile took:   0.4000D-02 seconds.
INFO:python_subgrid.wrapper:Initial floodfill from FloodFill file took:   0.0000D+00 seconds.
INFO:python_subgrid.wrapper:loadModel complete.
INFO:python_subgrid.wrapper:Start timestep-update.
DEBUG:python_subgrid.wrapper: Trying to use timestep:    10.000000000000000
DEBUG:python_subgrid.wrapper:Start initFlowAdmin, flow_init=              3
DEBUG:python_subgrid.wrapper:          57   3.69199999E-02  tables
DEBUG:python_subgrid.wrapper:          57   6.69640005E-02  tables
DEBUG:python_subgrid.wrapper:          57   6.69640005E-02  tables
DEBUG:python_subgrid.wrapper:          57   6.69640005E-02  tables
DEBUG:python_subgrid.wrapper:          57   3.69199999E-02  tables
DEBUG:python_subgrid.wrapper:          57   6.69640005E-02  tables
DEBUG:python_subgrid.wrapper:          57   6.69640005E-02  tables
DEBUG:python_subgrid.wrapper:          57   1.67410001E-02  tables
DEBUG:python_subgrid.wrapper:          57   1.67410001E-02  tables
DEBUG:python_subgrid.wrapper:          57   1.67410001E-02  ij(nodtot)
DEBUG:python_subgrid.wrapper:          57   1.67410001E-02  noel(nodtot)
DEBUG:python_subgrid.wrapper:          57   1.67410001E-02  noddgr(nodtot)
DEBUG:python_subgrid.wrapper:          57   1.67410001E-02  nodstk(nodtot)
DEBUG:python_subgrid.wrapper:          58   1.67410001E-02  row(nodtot)
DEBUG:python_subgrid.wrapper:          58   1.84589997E-02  ijl(lintot)
DEBUG:python_subgrid.wrapper:          58   1.67410001E-02  ia(nodtot)
INFO:python_subgrid.wrapper:reduce time:       0.097000
INFO:python_subgrid.wrapper: noactive=     16741 nogauss=     16001 nocg       740
DEBUG:python_subgrid.wrapper:          58   1.67410001E-02  pk(nodtot)
DEBUG:python_subgrid.wrapper:          58   1.67410001E-02  rk(nodtot)
DEBUG:python_subgrid.wrapper:          58   1.67410001E-02  zk(nodtot)
DEBUG:python_subgrid.wrapper:          58   1.67410001E-02  apk(nodtot)
DEBUG:python_subgrid.wrapper:          58   3.16129997E-02  aij(ijtot)
DEBUG:python_subgrid.wrapper:          58   3.16129997E-02  aij0(ijtot)
DEBUG:python_subgrid.wrapper:          58   1.84589997E-02  aijl(lintot)
DEBUG:python_subgrid.wrapper:          58   1.67430006E-02  implis(0:nodall)
DEBUG:python_subgrid.wrapper:          58   8.37149993E-02  aii,bi,d0,a00,b0(0:nodall)
DEBUG:python_subgrid.wrapper:          58   6.69720024E-02  vol0(0:nodall),vq0(0:4*nodall)
DEBUG:python_subgrid.wrapper:          58  0.267875999      vqt,denom(0:4*nodall),fbq(0:4*nodall),umq(0:4*nodall)
DEBUG:python_subgrid.wrapper:          58  0.100455001      qs,qs1,qs2(0:2*nodall)
DEBUG:python_subgrid.wrapper:          58   5.53830005E-02  u0,uh(0:linall)
DEBUG:python_subgrid.wrapper:          58   1.67430006E-02  uc(0:nodall,2)
DEBUG:python_subgrid.wrapper:          58   1.67430006E-02  vnorm(0:nodall)
DEBUG:python_subgrid.wrapper:          58   9.22999978E-02  cu,ru(linall)
DEBUG:python_subgrid.wrapper:          58   5.53830005E-02  au1(linall,0:2)
DEBUG:python_subgrid.wrapper:          59   5.53830005E-02  au0(linall,0:2)
DEBUG:python_subgrid.wrapper:          59   3.69220003E-02  qh1,qh2(0:linall)
DEBUG:python_subgrid.wrapper:          59   3.69220003E-02  ade,adi(0:linall)
INFO:python_subgrid.wrapper:Initialization of Flow Values took:   0.8000D-02 seconds.
DEBUG:python_subgrid.wrapper:Completed initFlowAdmin.
INFO:python_subgrid.wrapper:finding rain data for input
INFO:python_subgrid.wrapper:Timestep 1 number of iterations 1 epsmax   0.3553E-14 idthalf 1  np = 1
INFO:python_subgrid.wrapper: Volume error in cell        1742 greater than  0.20000000298023224      :  0.21401041109019409      no further volume errors reported for this timestep
INFO:python_subgrid.wrapper:Timestep complete.
60.0

In [3]:
df = subgrid.get_nd('pumps')

In [6]:
subgrid.set_structure_field('pumps', '3', 'reduction_factor', 2.0)
df = subgrid.get_nd('pumps')
df.head()


Out[6]:
capacity id reduction_factor start_level_suction_side stop_level_suction_side x y
0 0.000000 1 1 1.7 1.0 117855.170958 499418.258535
1 39.742693 2 1 -4.6 -4.7 121069.077409 502331.933606
2 2.054799 3 2 1.7 1.0 120498.893780 501964.366491
3 2.280391 4 1 1.7 1.0 118483.362214 498830.604797
4 2.280391 5 1 1.7 1.0 118323.879714 498727.974894

In [15]:
plt.scatter(df.x, df.y, c=df.capacity, vmax=3, cmap='Greens')
plt.colorbar()


Out[15]:
<matplotlib.colorbar.Colorbar instance at 0x7d87830>

In [ ]: