landlab.bmi.bmi_bridge
)¶Section author: Eric Hutton
The wrap_as_bmi function wraps a landlab component class so that it exposes a Basic Modelling Interface.
TimeStepper
(start=0.0, stop=None, step=1.0)[source]¶Bases: object
Step through time.
Parameters: | start : float, optional
stop : float, optional
step : float, optional
|
---|
Examples
>>> from landlab.bmi import TimeStepper
>>> time_stepper = TimeStepper()
>>> time_stepper.start
0.0
>>> time_stepper.stop is None
True
>>> time_stepper.step
1.0
>>> time_stepper.time
0.0
>>> for _ in range(10): time_stepper.advance()
>>> time_stepper.time
10.0
>>> time_stepper = TimeStepper(1., 13., 2.)
>>> [time for time in time_stepper]
[1.0, 3.0, 5.0, 7.0, 9.0, 11.0]
start
¶Start time.
step
¶Time Step.
stop
¶Stop time.
time
¶Current time.
wrap_as_bmi
(cls)[source]¶Wrap a landlab class so it exposes a BMI.
Parameters: | cls : class
|
---|---|
Returns: | class
|
Examples
>>> from landlab.bmi import wrap_as_bmi
>>> from landlab.components.flexure import Flexure
>>> BmiFlexure = wrap_as_bmi(Flexure)
>>> flexure = BmiFlexure()
>>> config = """
... eet: 10.e+3
... method: flexure
... clock:
... start: 0.
... stop: 10.
... step: 2.
... grid:
... type: raster
... shape: [20, 40]
... spacing: [1000., 2000.]
... """
>>> flexure.initialize(config)
>>> flexure.get_output_var_names()
('lithosphere_surface__elevation_increment',)
>>> flexure.get_var_grid('lithosphere_surface__elevation_increment')
0
>>> flexure.get_grid_shape(0)
(20, 40)
>>> dz = flexure.get_value('lithosphere_surface__elevation_increment')
>>> dz.shape == (800, )
True
>>> np.all(dz == 0.)
True
>>> flexure.get_current_time()
0.0
>>> flexure.get_input_var_names()
('lithosphere__overlying_pressure_increment',)
>>> load = np.zeros((20, 40), dtype=float)
>>> load[0, 0] = 1.
>>> flexure.set_value('lithosphere__overlying_pressure_increment', load)
>>> flexure.update()
>>> flexure.get_current_time()
2.0
>>> dz = flexure.get_value('lithosphere_surface__elevation_increment')
>>> np.all(dz == 0.)
False