In [1]:
import python_subgrid.wrapper

In [2]:
mdu = '../../models/singapore/2D_RainGau_Man55_35down_Int_45_5.mdu'

In [3]:
subgrid = python_subgrid.wrapper.SubgridWrapper(mdu=mdu)

In [4]:
subgrid.start()


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.968:974M, Dec 24 2013, 15:09:24
INFO:python_subgrid.wrapper:Startup complete.
INFO:python_subgrid.wrapper:Loading model ../../models/singapore/2D_RainGau_Man55_35down_Int_45_5.mdu in directory /home/fedor/Checkouts/models/singapore
INFO:python_subgrid.wrapper:Start loadModel for '../../models/singapore/2D_RainGau_Man55_35down_Int_45_5.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/FinalDEM2D_2.tif '...
DEBUG:python_subgrid.wrapper:          15   15.5470324      dps(0:imax+1, 0:jmax+1)
INFO:python_subgrid.wrapper:Completed reading bathymetry file.
INFO:python_subgrid.wrapper:Opened file : polygons/Stamford3Di_network_v4_2.pol
No handlers could be found for logger "progress"
INFO:python_subgrid.wrapper:Start initialization of grid administration.
DEBUG:python_subgrid.wrapper:          21   5.77843189      ip,jp
DEBUG:python_subgrid.wrapper:          21   4.10039984E-02  ls(k)
DEBUG:python_subgrid.wrapper:          21   1.04719996E-02  ls(k)
DEBUG:python_subgrid.wrapper:          21   2.73000007E-03  ls(k)
INFO:python_subgrid.wrapper:Opened file : boundaries/boundary_v3.ext
DEBUG:python_subgrid.wrapper:          21   3.57199996E-03  kce(n2dtot), kez(nx), itpez(nx)
INFO:python_subgrid.wrapper:Opened file : boundaries/2dbound_v4.pli
INFO:python_subgrid.wrapper:waterlevelbnd boundaries/2dbound_v4.pli       1 nr of open bndcells
INFO:python_subgrid.wrapper: Internal 2d nodes =      1828
INFO:python_subgrid.wrapper: Boundary 2d nodes =   1
DEBUG:python_subgrid.wrapper:          21   1.83199998E-03  nodk,nodm,nodn
DEBUG:python_subgrid.wrapper:          21   1.82899996E-03  ks(nodall)
DEBUG:python_subgrid.wrapper:          21   3.65799991E-03  xz,yz
ERROR:python_subgrid.wrapper:No network found, 1d boundaries are ignored.
DEBUG:python_subgrid.wrapper:          21   7.38999993E-03  line
DEBUG:python_subgrid.wrapper:          21   1.47799999E-02  lik,lim,lin,kcu
DEBUG:python_subgrid.wrapper:          21   1.46399997E-02  nru,nrv
INFO:python_subgrid.wrapper:Opened file : boundaries/boundary_v3.ext
INFO:python_subgrid.wrapper:Initializing external forcing 'waterlevelbnd' from file 'boundaries/2dbound_v4.pli'.
INFO:python_subgrid.wrapper:Opened file : boundaries/2dbound_v4.pli
INFO:python_subgrid.wrapper:Opened file : boundaries/2dbound_v4_0001.tim
INFO:python_subgrid.wrapper:Initializing boundaries took:   0.3000D-02 seconds.
DEBUG:python_subgrid.wrapper:          21   3.69499996E-03  flod
DEBUG:python_subgrid.wrapper:          21   3.69499996E-03  flou
DEBUG:python_subgrid.wrapper:          21   1.10849999E-02  dpumin
DEBUG:python_subgrid.wrapper:          21   1.10849999E-02  dpumax
WARNING:python_subgrid.wrapper:File 
ERROR:python_subgrid.wrapper:No 1d network found. Structures are disabled.
INFO:python_subgrid.wrapper:Grid Admin initialisation took:  0.9000D-02 seconds.
INFO:python_subgrid.wrapper:Completed initialization of grid administration.
DEBUG:python_subgrid.wrapper:          21   1.82899996E-03  dmax(1:nodall)
DEBUG:python_subgrid.wrapper:          21   1.82899996E-03  dmin(1:nodall)
DEBUG:python_subgrid.wrapper:          21   1.82799995E-03  sumax(1:nodtot)
DEBUG:python_subgrid.wrapper:          21   7.31199980E-03  dqmin(1:nodtot)
DEBUG:python_subgrid.wrapper:          21   7.31199980E-03  dqmax(1:nodtot)
DEBUG:python_subgrid.wrapper:          21   7.31199980E-03  suqmax(1:nodtot)
DEBUG:python_subgrid.wrapper:          21   7.31199980E-03  ksq(1:nodtot)
DEBUG:python_subgrid.wrapper:          21   5.48999989E-03  s1(0:nodall)
DEBUG:python_subgrid.wrapper:          21   5.48999989E-03  si(0:nodall)
DEBUG:python_subgrid.wrapper:          21   1.10879997E-02  u1(0:linall)
DEBUG:python_subgrid.wrapper:          21   3.69599997E-03  kf(0:linall)
DEBUG:python_subgrid.wrapper:          21   1.82999996E-03  vol1(0:nodall)
DEBUG:python_subgrid.wrapper:          21   3.65999993E-03  vol2(0:nodall)
DEBUG:python_subgrid.wrapper:          21   3.65999993E-03  su(0:nodall)
DEBUG:python_subgrid.wrapper:          21   3.65999993E-03  volErr(0:nodall)
DEBUG:python_subgrid.wrapper:          21   3.69499996E-03  conv(linall)
DEBUG:python_subgrid.wrapper:          21   7.31999986E-03  vq1(0:4*nodall)
DEBUG:python_subgrid.wrapper:          21   1.82999996E-03  implis(0:nodall)
DEBUG:python_subgrid.wrapper:          21   9.15000029E-03  aii,bi,d0,a00,b0(0:nodall)
DEBUG:python_subgrid.wrapper:          21   7.31999986E-03  vol0(0:nodall),vq0(0:4*nodall)
DEBUG:python_subgrid.wrapper:          21   2.92680003E-02  vqt,denom(0:4*nodall),fbq(0:4*nodall),umq(0:4*nodall)
DEBUG:python_subgrid.wrapper:          21   1.09770000E-02  qs,qs1,qs2(0:2*nodall)
DEBUG:python_subgrid.wrapper:          21   1.10879997E-02  u0,uh(0:linall)
DEBUG:python_subgrid.wrapper:          21   1.82999996E-03  uc(0:nodall,2)
DEBUG:python_subgrid.wrapper:          21   1.82999996E-03  vnorm(0:nodall)
DEBUG:python_subgrid.wrapper:          21   1.84749998E-02  cu,ru(linall)
DEBUG:python_subgrid.wrapper:          21   1.10879997E-02  au1(linall,0:2)
DEBUG:python_subgrid.wrapper:          21   1.10879997E-02  au0(linall,0:2)
DEBUG:python_subgrid.wrapper:          21   7.39199994E-03  as0(linall,1:2)
DEBUG:python_subgrid.wrapper:          21   7.39199994E-03  as1(linall,1:2)
DEBUG:python_subgrid.wrapper:          21   3.69499996E-03  cz(linall)
DEBUG:python_subgrid.wrapper:          21   7.39199994E-03  qh1,qh2(0:linall)
DEBUG:python_subgrid.wrapper:          21   7.39199994E-03  ade,adi(0:linall)
INFO:python_subgrid.wrapper:Calculation of bathymetry statistics took:   0.1280D+00 seconds.
INFO:python_subgrid.wrapper:Setting initial water levels  from WaterLevelFile took:   0.0000D+00 seconds.
INFO:python_subgrid.wrapper:Initial floodfill from FloodFill file took:   0.0000D+00 seconds.
INFO:python_subgrid.wrapper:loadModel complete.

In [5]:
subgrid.update(-1)


INFO:python_subgrid.wrapper:Start timestep-update.
DEBUG:python_subgrid.wrapper:Start initFlowAdmin, flow_init=              3
DEBUG:python_subgrid.wrapper:          21   7.38999993E-03  tables
DEBUG:python_subgrid.wrapper:          21   7.31199980E-03  tables
DEBUG:python_subgrid.wrapper:          21   7.31199980E-03  tables
DEBUG:python_subgrid.wrapper:          21   7.31199980E-03  tables
DEBUG:python_subgrid.wrapper:          21   7.38999993E-03  tables
DEBUG:python_subgrid.wrapper:          21   7.31199980E-03  tables
DEBUG:python_subgrid.wrapper:          21   7.31199980E-03  tables
DEBUG:python_subgrid.wrapper:          21   1.82799995E-03  tables
DEBUG:python_subgrid.wrapper:          21   1.82799995E-03  tables
DEBUG:python_subgrid.wrapper:          22  0.948823988      autb
DEBUG:python_subgrid.wrapper:          23   1.07495999      vltb
DEBUG:python_subgrid.wrapper:          26   2.99169588      vq1tb,dentb
INFO:python_subgrid.wrapper:Initialization of Flow Values took:   0.1870D+00 seconds.
DEBUG:python_subgrid.wrapper:          26   1.82799995E-03  ij(nodtot)
DEBUG:python_subgrid.wrapper:          26   1.82799995E-03  noel(nodtot)
DEBUG:python_subgrid.wrapper:          26   1.82799995E-03  noddgr(nodtot)
DEBUG:python_subgrid.wrapper:          26   1.82799995E-03  nodstk(nodtot)
DEBUG:python_subgrid.wrapper:          26   1.82799995E-03  row(nodtot)
DEBUG:python_subgrid.wrapper:          26   3.69399996E-03  ijl(lintot)
DEBUG:python_subgrid.wrapper:          26   1.82799995E-03  ia(nodtot)
INFO:python_subgrid.wrapper:reduce time:       0.011000
INFO:python_subgrid.wrapper: noactive=      1828 nogauss=      1125 nocg       703
DEBUG:python_subgrid.wrapper:          26   1.82799995E-03  pk(nodtot)
DEBUG:python_subgrid.wrapper:          26   1.82799995E-03  rk(nodtot)
DEBUG:python_subgrid.wrapper:          26   1.82799995E-03  zk(nodtot)
DEBUG:python_subgrid.wrapper:          26   1.82799995E-03  apk(nodtot)
DEBUG:python_subgrid.wrapper:          26   8.65199976E-03  aij(ijtot)
DEBUG:python_subgrid.wrapper:          26   8.65199976E-03  aij0(ijtot)
DEBUG:python_subgrid.wrapper:          26   3.69399996E-03  aijl(lintot)
DEBUG:python_subgrid.wrapper:Completed initFlowAdmin.
INFO:python_subgrid.wrapper:Timestep 1 number of iterations 2 epsmax   0.0000E+00 idthalf 1  np = 1
INFO:python_subgrid.wrapper:Timestep complete.
Out[5]:
0

In [6]:
python_subgrid.wrapper.DOCUMENTED_VARIABLES


Out[6]:
{u'LandUse': u'percentage of a crop per node',
 u'MaxInterception': u'max thickness of interception layer on fine base grid',
 u'ade': u'advection',
 u'adi': u'advection',
 u'dps': u'bathymetry pixel values on fine base grid',
 u'ds1d': u'gridsize in 1d channels',
 u'dsnop': u'Dummy missing value for bathymetry pixels, single precision.',
 u'dt': u'delta t',
 u'dtmax': u'maximum delta t',
 u'dtmin': u'minumum delta t',
 u'dx': u'gridsize for all coarse quadtree levels 1:kmax',
 u'dxp': u'pixel dimensions',
 u'dyp': u'pixel dimensions',
 u'imax': u'number of pixels in x directions',
 u'infiltrationRate': u'infiltration rate values on fine base grid',
 u'jmax': u'number of pixels in y directions',
 u'line': u'Flow links/lines between coarse grid cells: line(L,1) = nod1, line(L,2) = nod2',
 u'link_branchid': u'Original link number',
 u'link_chainage': u'Distance along the branch',
 u'link_idx': u'Index in the u vector',
 u'link_type': u'Type of link',
 u'lu1dmx': u'number of u points per channel (for embedded: nr of 2D cell interfaces crossed by 1D channel)',
 u'n1dobc': u'number of  1d boundary points',
 u'n1dtot': u'total number of nodal points in 1d without boundary points',
 u'n2dobc': u'number of nodal points  2d boundary points',
 u'n2dtot': u'number of 2d nodes',
 u'nod_type': u'Type of node',
 u'pumps': u'Pump',
 u'q': u'discharge on full grid on current timestep',
 u'qh1': u'discharge on half grid on current timestep',
 u'qh2': u'discharge on half grid on next timestep',
 u'qrain': u'rainfall',
 u'rain': u'rainfall',
 u's0': u'waterlevel at previous timestep',
 u's1': u'waterlevel at current timestep',
 u's2': u'waterlevel at next timestep',
 u'sg': u'ground water level measured from "ground level" upwards (time dependent)',
 u'si': u'thickness of interception layer per node',
 u'si0': u'thickness of interception layer per node at previous timestep',
 u'soilType': u'soil types on fine grid',
 u't0': u'time at previous timestep',
 u't1': u'time at current timestep',
 u'tend': u'stop time of simulation',
 u'tstart': u'start time of simulation',
 u'u0': u'velocity at previous timestep',
 u'u1': u'velocity at current timestep',
 u'u2': u'velocity at next timestep',
 u'weirs': u'Weir',
 u'x0p': u'origin of pixel grid',
 u'x1p': u'origin of pixel grid',
 u'xbnd': u'List of x points forming flow element',
 u'xu': u'Velocity x coordinate for 1d, 2d, including boundaries',
 u'xz': u'Cell center x coordinate (pressure point) for all quadtree cells (i.e. nodes).',
 u'y0p': u'origin of pixel grid',
 u'y1p': u'origin of pixel grid',
 u'ybnd': u'List of y points forming flow element',
 u'yu': u'Velocity y coordinate for 1d, 2d, including boundaries',
 u'yz': u'Cell center y coordinate (pressure point) for all quadtree cells (i.e. nodes).'}

In [7]:
MaxInterception = subgrid.get_nd('MaxInterception')
si0 = subgrid.get_nd('si0')
si = subgrid.get_nd('si')

In [8]:
missing = subgrid.get_nd('dsnop')

In [9]:
subgrid.get_var_type('MaxInterception')


Out[9]:
'float'

In [10]:
# contains missing values
mi = np.ma.masked_array(MaxInterception, mask=MaxInterception==missing)

In [11]:
plt.imshow(mi)
plt.colorbar()


Out[11]:
<matplotlib.colorbar.Colorbar instance at 0x58bd050>