Example #1
0
    def test_run(self):

        entity = gpd.read_file(self.rgi_file).iloc[0]

        gdir = oggm.GlacierDirectory(entity, base_dir=self.testdir)
        gis.define_glacier_region(gdir)
        gis.glacier_masks(gdir)
        centerlines.compute_centerlines(gdir)
        centerlines.initialize_flowlines(gdir)
        centerlines.compute_downstream_line(gdir)
        centerlines.compute_downstream_bedshape(gdir)
        centerlines.catchment_area(gdir)
        centerlines.catchment_intersections(gdir)
        centerlines.catchment_width_geom(gdir)
        centerlines.catchment_width_correction(gdir)

        # Climate tasks -- only data IO and tstar interpolation!
        tasks.process_dummy_cru_file(gdir, seed=0)
        tasks.local_t_star(gdir)
        tasks.mu_star_calibration(gdir)

        # Inversion tasks
        tasks.find_inversion_calving(gdir)

        # Final preparation for the run
        tasks.init_present_time_glacier(gdir)

        # check that calving happens in the real context as well
        tasks.run_constant_climate(gdir,
                                   bias=0,
                                   nyears=200,
                                   temperature_bias=-0.5)
        with xr.open_dataset(gdir.get_filepath('model_diagnostics')) as ds:
            assert ds.calving_m3[-1] > 10
Example #2
0
def plot_issue(gdir, plot_dir):
    #plt.style.use('ggplot')

    workflow.gis_prepro_tasks([gdir])
    workflow.climate_tasks([gdir])
    workflow.inversion_tasks([gdir])
    tasks.init_present_time_glacier(gdir)

    # Observed length changes
    df = gdir.get_ref_length_data()
    df = df.loc[1855:2003]['dL']
    df = df - df.iloc[-1]

    tasks.run_from_climate_data(gdir,
                                ys=1855,
                                ye=2003,
                                output_filesuffix='hist_from_current')
    ds = xr.open_dataset(
        gdir.get_filepath('model_diagnostics', filesuffix='hist_from_current'))
    (ds.length_m.to_series().rolling(36, center=True).mean() -
     ds.length_m.to_series().iloc[0]).plot(c='C0', label='OGGM')
    #s = s - s.iloc[-1]
    #print(s)
    ax = df.plot(c='k', label='Observations')
    #s.plot(c='C0', label='OGGM');
    plt.legend()
    ax.set_ylabel('Glacier Length Change [m]')
    plt.title('Hintereisferner length changes Experiment 2')
    plt.tight_layout()
    plt.show()
    '''
    fls = gdir.read_pickle('model_flowlines')
    x = np.arange(fls[-1].nx) *fls[-1].dx * fls[-1].map_dx

    plt.figure(figsize=(13,10))

    rc('axes', linewidth=3)

    plt.plot(x,fls[-1].surface_h,linewidth=3, label='Surface Elevation')
    plt.plot(x,fls[-1].bed_h,'k',linewidth=3,label='Bed Topography')
    plt.ylabel('Altitude (m)',size=30)
    plt.xlabel('Distance along the Flowline (m)',size=30)
    plt.legend(loc='best',fontsize=30)
    #plt.annotate('?', xy=(5000, 2700), fontsize=40)

    plt.tick_params(axis='both', which='major', labelsize=30)


    plt.title(gdir.rgi_id+ ': '+gdir.name,size=35)
    plt.savefig(os.path.join(plot_dir, 'issue_today.png'),dpi=200)
    '''
    #plt.savefig(os.path.join(plot_dir, 'issue_1850.pdf'),dpi=200)
    plt.show()

    return
Example #3
0
tasks.initialize_flowlines(gdir)
tasks.compute_downstream_line(gdir)
tasks.compute_downstream_bedshape(gdir)
tasks.catchment_area(gdir)
tasks.catchment_intersections(gdir)
tasks.catchment_width_geom(gdir)
tasks.catchment_width_correction(gdir)
tasks.process_cru_data(gdir)
tasks.mu_candidates(gdir)
tasks.compute_ref_t_stars([gdir])
tasks.distribute_t_stars([gdir])
tasks.apparent_mb(gdir)
tasks.prepare_for_inversion(gdir)
tasks.volume_inversion(gdir, glen_a=cfg.A, fs=0)
tasks.filter_inversion_output(gdir)
tasks.init_present_time_glacier(gdir)

df = utils.glacier_characteristics([gdir], path=False)

reset = True
seed = 0

tasks.random_glacier_evolution(gdir,
                               nyears=800,
                               seed=0,
                               y0=2000,
                               filesuffix='_2000_def',
                               reset=reset)

tasks.random_glacier_evolution(gdir,
                               nyears=800,