In [4]:
cd C:\Users\boer_g\Desktop\Webinar\OEM


C:\Users\boer_g\Desktop\Webinar\OEM

In [5]:
import openearthtools.io.delft3d as d3d
dir(d3d)


Out[5]:
['Grid',
 '__builtins__',
 '__doc__',
 '__file__',
 '__name__',
 '__package__',
 '__path__',
 'grid',
 'mdf',
 'read',
 'tekal',
 'tekalblock',
 'write']

In [11]:
help(d3d.Grid)
# example from https://svn.oss.deltares.nl/repos/openearthmodels/trunk/deltares/brazil_patos_lagoon_52S_32E/
G = d3d.Grid.fromfile('lake_and_sea_5_ll.grd')


Help on class Grid in module openearthtools.io.delft3d.grid:

class Grid(__builtin__.object)
 |  Create a Delft3D grid file
 |  # Create an empty grid
 |  grid = Grid()
 |  # Load a grid from file
 |  grid = Grid.read('filename.grd')
 |  # Write grid to file
 |  Grid.read(grid,'filename.grd')
 |  
 |  Methods defined here:
 |  
 |  __init__(self, *args, **kwargs)
 |  
 |  write(self, filename, **kwargs)
 |  
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |  
 |  fromfile(filename, **kwargs)
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |  
 |  __dict__
 |      dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)


In [7]:
# curvilinear grids typically have many invalid matrix positions
# to represent islands, thick dams or cul-de-sacs (estuaries/rivers) 
# therefore the matrices are stored as Masked array type
G.X


Out[7]:
masked_array(data =
 [[-- -- -- ..., -51.21892397029205 -51.25650464051964 -51.28911971484214]
 [-- -- -- ..., -51.25256180611927 -51.274277884869164 -51.29888408312184]
 [-- -- -- ..., -51.26523724097448 -51.288310621047295 -51.31035946306346]
 ..., 
 [-51.92346119182868 -51.94226259182987 -51.96086078342037 ..., -- -- --]
 [-51.92608902265055 -51.94527933494353 -51.96403316815339 ..., -- -- --]
 [-51.928765963284064 -51.948398147668485 -51.967149196828366 ..., -- -- --]],
             mask =
 [[ True  True  True ..., False False False]
 [ True  True  True ..., False False False]
 [ True  True  True ..., False False False]
 ..., 
 [False False False ...,  True  True  True]
 [False False False ...,  True  True  True]
 [False False False ...,  True  True  True]],
       fill_value = 1e+20)

In [ ]:
G.dep = G.z

In [9]:
matplotlib.pyplot.pcolor(G.X,G.Y,G.dep)
gca().set_aspect(1./cos(mean(ylim())/180*pi),adjustable='box') # see Matlab axislat()



In [ ]: