def run_model(has_tide, river_flow_rate, N_river, G, P): """ Alias to quickly run the estuary model """ kwargs = copy(model_kwargs) kwargs.update(dict( river_flow_rate=river_flow_rate, N_river=N_river, G=G, P=P )) # Set initial conditions for elem in ['S', 'N', 'O']: kwargs[elem] = kwargs[elem+'0'] del kwargs[elem+'0'] if has_tide: kwargs['tide_func'] = basic_tidal_flow model = EstuaryModel(**kwargs) results = model.run_model(**model_run_kwargs) results['day'] = results.index/24. return results
#!/usr/bin/env python import os from estuary import EstuaryModel, basic_tidal_flow, quick_plot from bokeh import mpl from bokeh.models import ColumnDataSource, Range1d, BoxAnnotation from bokeh.plotting import figure, gridplot, show, output_file model = EstuaryModel(1e9, 35.0, 20.0, 231.2, tide_func=basic_tidal_flow) result = model.run_model(dt=0.5) # Convert index from hours to days result["day"] = result.index / 24.0 def rgb_to_hex(rgb): """ Convert RGB tuple to hex triplet """ rgb = tuple([bit * 256 for bit in rgb]) # (0,1) -> (0, 256) return "#%02x%02x%02x" % rgb def basic_bokeh(out_fn="estuary_out.html"): """ Basic 3-panel plot of output using Bokeh """ if os.path.exists(out_fn): os.remove(out_fn) output_file(out_fn) # Construct Bokeh plot