welly icon indicating copy to clipboard operation
welly copied to clipboard

Implement an approach to make well plotting polymorphic and extensible

Open fraserkeppie opened this issue 9 years ago • 0 comments

The goal here is to formalize a method to make it easy to add different ways to plot a well such as: (1) different views of the data (e.g., petrophysics, a data existence scorecard, well location on a map, etc.), or (2) using different output target libraries or assumptions (e.g., matplotlib with or without a pre-created figure or subplot, chaco, etc.).

Basic options to do this include: (1) multiple logic switches within a single well.plot() function, (2) multiple functions within a single Well class definition, or (3) use of a design pattern which separates the details of plotting from the Well class itself and allows the plotting details to be overridden, thus making plotting in welly polymorphic and extensible by developers and users alike.

The proposed solution is to: (1) implement the well.plot() function as follows: class Well: def plot(self, plotter=None): if plotter is None: DefaultWellyPlotter().plot(self) else: plotter.plot(self)

(2) implement plotters as subclasses of an abstract WellyPlotter base class, each with their own plotter.plot(well) function. A first idea is to implement these plotting classes in a welly.plotters subpackage in which some default plotting classes can be accumulated.

The proposed solution yields polymorphism and extensibility to well plotting in welly without developers or users needing to touch the well.py module when thinking about new or composite views/plots of a well*.

  • There may be a better design pattern to achieve the same result with better features.

fraserkeppie avatar May 25 '16 19:05 fraserkeppie