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()

    fn = bname + '3_fls.png'
    if not os.path.exists(fn):
        graphics.plot_centerlines(gd, title_comment=demsource,
                                  use_flowlines=True, add_downstream=True)
        plt.savefig(fn)
예제 #2
0
def test_domain():
    fig, ax = plt.subplots()
    gdir = init_hef()
    graphics.plot_domain(gdir, ax=ax)
    fig.tight_layout()
    return fig
예제 #3
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()
예제 #4
0
    cbar_location="right",
    cbar_mode="edge",
    cbar_size="7%",
    cbar_pad=0.15,
)

llkw = {'interval': 0}
letkm = dict(color='black',
             ha='left',
             va='top',
             fontsize=20,
             bbox=dict(facecolor='white', edgecolor='black'))

graphics.plot_domain(gdir,
                     ax=axs[0],
                     title='',
                     add_colorbar=False,
                     lonlat_contours_kwargs=llkw)
xt, yt = 4.5, 4.5
axs[0].text(xt, yt, 'a', **letkm)

im = graphics.plot_centerlines(gdir,
                               ax=axs[1],
                               title='',
                               add_colorbar=True,
                               lonlat_contours_kwargs=llkw,
                               cbar_ax=axs[1].cax,
                               add_scalebar=False)
axs[1].text(xt, yt, 'b', **letkm)

graphics.plot_catchment_width(gdir,
예제 #5
0
파일: run_rgi_region.py 프로젝트: OGGM/oggm
    tasks.optimize_inversion_params(gdirs)
    execute_entity_task(tasks.volume_inversion, gdirs)

if RUN_DYNAMICS:
    # Random dynamics
    execute_entity_task(tasks.init_present_time_glacier, gdirs)
    execute_entity_task(tasks.random_glacier_evolution, gdirs)

# Plots (if you want)
PLOTS_DIR = ''
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()
예제 #6
0
파일: test.py 프로젝트: Nirav11/oggm
rgi_ids = ['RGI60-11.01328', 'RGI60-11.00897']

#graphics.plot_domain(gdirs, figsize=(8, 7))
#gdir = rgi_ids[1]

# Plotting the glacier over the DEM file
for rgi in rgi_ids:

    f, axs = plt.subplots(2, 2, figsize=(8, 6))
    for ax, border in zip(np.array(axs).flatten(), [10, 80, 160, 250]):
        gdir = workflow.init_glacier_directories(rgi,
                                                    from_prepro_level=1,prepro_border=border)

        graphics.plot_domain(gdir, ax=ax, title='Border: {}'.format(border),
                                add_colorbar=False,
                                lonlat_contours_kwargs={'add_tick_labels':False})
    print("dir==",gdir)


gdirs = workflow.init_glacier_directories(rgi_ids, from_prepro_level=2, prepro_border=80)


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

#gdir = gdirs[1]
#print('Path to the DEM:', gdir.get_filepath('dem'))


#    print('Path to the masks:', gdir.get_filepath('gridded_data'))  
예제 #7
0
log.info('Number of glaciers: {}'.format(len(rgidf)))

# Go - initialize working directories
# gdirs = workflow.init_glacier_regions(rgidf, reset=True, force=True)
gdirs = workflow.init_glacier_regions(rgidf)

# Prepro tasks
task_list = [
    tasks.glacier_masks,
]
for task in task_list:
    execute_entity_task(task, gdirs)

# 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') + ')'

    # graphics.plot_googlemap(gd)
    # plt.savefig(bname + 'ggl.png')
    # plt.close()
    graphics.plot_domain(gd, title_comment=demsource)
    plt.savefig(bname + 'dom.png')
    plt.close()
예제 #8
0
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()

    fn = bname + '3_fls.png'
    if not os.path.exists(fn):
        graphics.plot_centerlines(gd, title_comment=demsource,
                                  use_flowlines=True, add_downstream=True,
                                  reset = True)
예제 #9
0
# We prepare for the plot, which needs our own map to proceed.
# Lets do a local mercator grid
g = salem.mercator_grid(center_ll=(-19.61, 63.63),
                        extent=(18000, 14500))
# And a map accordingly
sm = salem.Map(g, countries=False)
sm.set_lonlat_contours(add_xtick_labels=False)
z = sm.set_topography('/home/mowglie/disk/OGGM_INPUT/tmp/ISL.tif')
sm.set_data(z)

# Figs
f = 0.9
f, axs = plt.subplots(2, 1, figsize=(7*f, 10*f))

graphics.plot_domain(gdirs, ax=axs[0], smap=sm)


sm.set_data()
sm.set_lonlat_contours()
sm.set_geometry()
sm.set_text()
graphics.plot_inversion(gdirs, ax=axs[1], smap=sm,
                        linewidth=1, add_scalebar=False,
                              title='', vmax=250)
plt.tight_layout()
plt.savefig(PLOT_DIR + 'iceland.pdf', dpi=150, bbox_inches='tight')
exit(0)

lw = 1
graphics.plot_modeloutput_map(gdirs, smap=sm, filesuffix='_tbias',