def test_plot_model(): gdir = init_hef() flowline.init_present_time_glacier(gdir) model = flowline.FlowlineModel(gdir.read_pickle('model_flowlines')) graphics.plot_modeloutput_section(gdir, model=model) graphics.plot_modeloutput_map(gdir, model=model)
def test_random_mb_run(): rid = 'RGI60-15.03473' gdir = oggm_compat.single_flowline_glacier_directory(rid, prepro_border=80) mbmod = oggm_compat.RandomLinearMassBalance(gdir, seed=1, sigma_ela=300, h_perc=55) from oggm.core.flowline import robust_model_run flmodel = robust_model_run(gdir, mb_model=mbmod, ys=0, ye=700) # Check that "something" is computed import xarray as xr ds = xr.open_dataset(gdir.get_filepath('model_diagnostics')) assert ds.isel(time=-1).volume_m3 > 0 if do_plot: import matplotlib.pyplot as plt from oggm import graphics graphics.plot_modeloutput_section(flmodel) f, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(12, 4)) (ds.volume_m3 * 1e-9).plot(ax=ax1) ax1.set_ylabel('Glacier volume (km$^{3}$)') (ds.area_m2 * 1e-6).plot(ax=ax2) ax2.set_ylabel('Glacier area (km$^{2}$)') (ds.length_m * 1e3).plot(ax=ax3) ax3.set_ylabel('Glacier length (km)') plt.tight_layout() plt.show()
def test_plot_model(): gdir = init_hef() flowline.init_present_time_glacier(gdir) fls = flowline.convert_to_mixed_flowline(gdir.read_pickle("model_flowlines")) model = flowline.FlowlineModel(fls) graphics.plot_modeloutput_section(gdir, model=model) graphics.plot_modeloutput_map(gdir, model=model)
def test_modelsection(): gdir = init_hef() flowline.init_present_time_glacier(gdir) fls = gdir.read_pickle('model_flowlines') model = flowline.FlowlineModel(fls) fig = plt.figure(figsize=(12, 6)) ax = fig.add_axes([0.07, 0.08, 0.7, 0.84]) graphics.plot_modeloutput_section(ax=ax, model=model) return fig
def test_modelsection(): gdir = init_hef() flowline.init_present_time_glacier(gdir) fls = gdir.read_pickle('model_flowlines') model = flowline.FlowlineModel(fls) fig = plt.figure(figsize=(12, 6)) ax = fig.add_axes([0.07, 0.08, 0.7, 0.84]) graphics.plot_modeloutput_section(gdir, ax=ax, model=model) return fig
def test_random_mb_run(): rid = 'RGI60-15.03473' gdir = oggm_compat.single_flowline_glacier_directory(rid, prepro_border=80) # This initializes the mass balance model, but does not run it mbmod = oggm_compat.RandomLinearMassBalance(gdir, seed=1, sigma_ela=300, h_perc=55) # HERE CAN BE THE LOOP SUCH THAT EVERYTHING IS ALREADY LOADED for i in [1, 2, 3, 4]: # Change the model parameter mbmod.param1 = i # Run the mass balance model with fixed geometry ts_mb = mbmod.get_specific_mb(years=[2000, 2001, 2002]) # Run the glacier flowline model with a mass balance model from oggm.core.flowline import robust_model_run flmodel = robust_model_run(gdir, mb_model=mbmod, ys=0, ye=700) # Check that "something" is computed import xarray as xr ds = xr.open_dataset(gdir.get_filepath('model_diagnostics')) assert ds.isel(time=-1).volume_m3 > 0 if do_plot: import matplotlib.pyplot as plt from oggm import graphics graphics.plot_modeloutput_section(flmodel) f, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(12, 4)) (ds.volume_m3 * 1e-9).plot(ax=ax1) ax1.set_ylabel('Glacier volume (km$^{3}$)') (ds.area_m2 * 1e-6).plot(ax=ax2) ax2.set_ylabel('Glacier area (km$^{2}$)') (ds.length_m * 1e3).plot(ax=ax3) ax3.set_ylabel('Glacier length (km)') plt.tight_layout() plt.show()