Esempio n. 1
0
def test_single_flowline_glacier_directory():

    rid = 'RGI60-15.03473'
    gdir = oggm_compat.single_flowline_glacier_directory(rid)
    assert gdir.rgi_area_km2 == 61.054

    if do_plot:
        from oggm import graphics
        import matplotlib.pyplot as plt
        f, (ax1, ax2) = plt.subplots(1, 2)
        graphics.plot_googlemap(gdir, ax=ax1)
        graphics.plot_inversion(gdir, ax=ax2)
        plt.show()
Esempio n. 2
0
def test_googlemap():
    fig, ax = plt.subplots()
    gdir = init_hef()
    graphics.plot_googlemap(gdir, ax=ax)
    fig.tight_layout()
    return fig
                             nyears=5000, seed=0,
                             filesuffix='_fromtoday_newparams')

# Plots (if you want)
if PLOTS_DIR == '':
    exit()

utils.mkdir(PLOTS_DIR)
for gd in gdirs:

    bname = os.path.join(PLOTS_DIR, gd.rgi_id + '_')
    demsource = ' (' + gd.read_pickle('dem_source') + ')'

    fn = bname + '0_ggl.png'
    if not os.path.exists(fn):
        graphics.plot_googlemap(gd)
        plt.savefig(fn)
        plt.close()

    fn = bname + '1_dom.png'
    if not os.path.exists(fn):
        graphics.plot_domain(gd, title_comment=demsource)
        plt.savefig(fn)
        plt.close()
        plt.close()

    fn = bname + '2_cls.png'
    if not os.path.exists(fn):
        graphics.plot_centerlines(gd, title_comment=demsource)
        plt.savefig(fn)
        plt.close()
Esempio n. 4
0
# While the above should work always, this here is no piece of fun
execute_entity_task(tasks.random_glacier_evolution, gdirs)

# Write out glacier statistics
df = utils.glacier_characteristics(gdirs)
fpath = os.path.join(cfg.PATHS['working_dir'], 'glacier_char.csv')
df.to_csv(fpath)

# Plots (if you want)
if PLOTS_DIR == '':
    exit()

utils.mkdir(PLOTS_DIR)
for gd in gdirs:
    bname = os.path.join(PLOTS_DIR, gd.name + '_' + gd.rgi_id + '_')
    graphics.plot_googlemap(gd)
    plt.savefig(bname + 'ggl.png')
    plt.close()
    graphics.plot_domain(gd)
    plt.savefig(bname + 'dom.png')
    plt.close()
    graphics.plot_centerlines(gd)
    plt.savefig(bname + 'cls.png')
    plt.close()
    graphics.plot_catchment_width(gd, corrected=True)
    plt.savefig(bname + 'w.png')
    plt.close()
    graphics.plot_inversion(gd)
    plt.savefig(bname + 'inv.png')
    plt.close()
Esempio n. 5
0
#    print('Calving results:')
#    for k in ['calving_front_width', 'calving_flux', 'calving_thick',
#              'calving_free_board']:
#        print(k + ':', diags[k])
#    if do_plot:
#        from oggm import graphics
#        import matplotlib.pyplot as plt
#        f, (ax1, ax2) = plt.subplots(1, 2)
#        graphics.plot_googlemap(gdir, ax=ax1)
#        graphics.plot_inversion(gdir, ax=ax2)
#        plt.show()

rid = 'RGI60-01.03622'
gdir = oggm_compat.single_flowline_glacier_directory_with_calving(rid,
                                                                  k_calving=2)
diags = gdir.get_diagnostics()
print('Calving results:')
for k in [
        'calving_front_width', 'calving_flux', 'calving_thick',
        'calving_free_board'
]:
    print(k + ':', diags[k])

do_plot = True
if do_plot:
    from oggm import graphics
    import matplotlib.pyplot as plt
    f, (ax1, ax2) = plt.subplots(1, 2)
    graphics.plot_googlemap(gdir, ax=ax1)
    graphics.plot_inversion(gdir, ax=ax2)
    plt.show()
Esempio n. 6
0
def test_googlemap():
    if not internet_on():
        print('Internet is off, couldnt test for googlemaps')
        return
    gdir = init_hef()
    graphics.plot_googlemap(gdir)
Esempio n. 7
0
def test_googlemap():

    gdir = init_hef()
    graphics.plot_googlemap(gdir)
Esempio n. 8
0
def test_googlemap():

    gdir = init_hef()
    graphics.plot_googlemap(gdir)
Esempio n. 9
0
h, m = divmod(m, 60)
log.info("OGGM is done! Time needed: %d:%02d:%02d" % (h, m, s))

# Plots (if you want)
if PLOTS_DIR == '':
    exit()

utils.mkdir(PLOTS_DIR)
for gd in gdirs:

    bname = os.path.join(PLOTS_DIR, gd.rgi_id + '_')
    demsource = ' (' + gd.read_pickle('dem_source') + ')'

    fn = bname + '0_ggl.png'
    if not os.path.exists(fn):
        graphics.plot_googlemap(gd, reset=True)
        plt.savefig(fn)
        plt.close()

    fn = bname + '1_dom.png'
    if not os.path.exists(fn):
        graphics.plot_domain(gd, title_comment=demsource, reset=True)
        plt.savefig(fn)
        plt.close()
        plt.close()

    fn = bname + '2_cls.png'
    if not os.path.exists(fn):
        graphics.plot_centerlines(gd, title_comment=demsource, reset=True)
        plt.savefig(fn)
        plt.close()
Esempio n. 10
0
gdirs = workflow.init_glacier_regions(shape, from_prepro_level=1, prepro_border=80, prepro_rgi_version='61', from_tar=True)

# look contents of gdirs
type(gdirs)

# access item on the gdirs list
gdir = gdirs[0]  # 
print('Path to the DEM:', gdir.get_filepath('dem'))

# look at the attributes of the glacier
gdir
gdir.rgi_date # date at which the outlines are valid

# plot the glacier location and outline
from oggm import graphics
graphics.plot_googlemap(gdir, figsize=(8, 7))

""" Tasks """
from oggm import tasks

# run the glacier_masks task on all gdirs
workflow.execute_entity_task(tasks.glacier_masks, gdirs);

# the command wrote a new file in our glacier directory, providing raster masks of the glaciers
print('Path to the masks:', gdir.get_filepath('gridded_data'))

# It is also possible to apply several tasks sequentially (i.e. one after an other) on our glacier list:
list_talks = [
         tasks.compute_centerlines,
         tasks.initialize_flowlines,
         tasks.compute_downstream_line,
Esempio n. 11
0
def test_googlemap():
    fig, ax = plt.subplots()
    gdir = init_hef()
    graphics.plot_googlemap(gdir, ax=ax)
    fig.tight_layout()
    return fig