clawpack / geoclaw

Version of Clawpack for geophysical waves and flows
http://www.clawpack.org/geoclaw
BSD 3-Clause "New" or "Revised" License
76 stars 87 forks source link

Add `x` and `y` input to `Topography.__init__` #306

Open mandli opened 6 years ago

mandli commented 6 years ago

Also probably should look more closely at the logic in generate_2d_coordinates and generate_2d_topo to fix a couple of things and allow the coordinate arrays to be forced to be regenerated.

rjleveque commented 6 years ago

I suggest also adding Z and rearranging the arguments so topo_type is second to agree with e.g. read and write. (unless this will break old code where the position of topo_func is used)

So maybe...

    def __init__(self, path=None,  topo_type=None, topo_func=None,
                       x=None, y=None, Z=None, unstructured=False):

Of course this might lead to confusion if a user specifies bothpath and x,y,Z.

Another option is to have a bare bones __init__ function

    def __init__(self):

and force the user to do

    topo = Topography()
    topo.read(path, topo_type)

for example to read a file (which is what I usually do anyway for clarity), and not have path and topo_type be attributes of the object at all (since this often doesn't make sense).

Then we might also provide a function that allows setting x,y,Z to specified values more easily than setting topo._x etc. separately as must now be done, e.g.

    topo = Topography()
    topo.setxyZ(x,y,Z)

with possibly other optional arguments such as unstructured or topo_func.