GEMScienceTools / gmpe-smtk

Python and OpenQuake-based Toolkit for Analysis of Strong Motions and Interpretation of GMPEs
GNU Affero General Public License v3.0
43 stars 33 forks source link

Two proposed changes to SMTK methods #59

Closed g-weatherill closed 6 years ago

g-weatherill commented 6 years ago

Two changes are proposed that would modify the calls to specific functions:

  1. Change the smtk.response_spectrum.Response Spectrum class to execute the response spectrum analysis immediate on instantiation

  2. Change the smtk.trellis.trellis_plots.BaseTrellis class so that .create_plot() is not run on instantiation. Instead a simple .plot() function should be added which is called subsequently. This can permit generation of trellis ground motion values without invoking the plotting functionality

rizac commented 6 years ago

Hey,

  1. I see the point of doing that. What about about making the class callable like a function (via __call__ instead of evaluate()?) it basically maintains the current functionality (which might be handy, to postpone calculatation if needed) and adds yours by simply typing "()". Something like:

    obj = NewmarkBeta(...)  # as it is now. Evaluate later
    result = NewmarkBeta(...)()  # evaluate it now
  2. As we already discussed, are there plans to separate plotting stuff from base code, so that if we include the code as backend we might never need to import matplotlib? This might be of great help