Beispiel #1
0
                              )


# Optional, if not reset=True and already ran once
# only needed once:
#create_glacier(gdir)
compile_first_guess(gdir)

if os.path.exists(gdir.get_filepath('dem_noise')):
    os.remove(gdir.get_filepath('dem_noise'))
noise = create_perlin_noise(gdir, desired_rmse, octaves=4, base=2, freq=3,
                            glacier_only=True)
add_surface_noise(gdir, noise)

create_case_table(gdir)

idir = InversionDirectory(gdir)

# copy this script to inversion directory for reproducibility
path_to_file = '/home/philipp/COBBI/combine/sandbox/bonus_runs' \
               '/perturbed_surface.py'
fname = os.path.split(path_to_file)[-1]
if not os.path.exists(idir.get_current_basedir()):
    os.makedirs(idir.get_current_basedir(), exist_ok=True)
shutil.copy(path_to_file, os.path.join(idir.get_current_basedir(), fname))

res = idir.run_minimize()
eval_identical_twin(idir)
#dl = data_logging.load_pickle(idir.get_current_basedir() + '/data_logger.pkl')

print('end')
Beispiel #2
0
import matplotlib.pyplot as plt
import salem

from combine2d.core import gis, test_cases
from combine2d.core.utils import NonRGIGlacierDirectory
from combine2d.core.inversion import InversionDirectory
from combine2d.core.data_logging import load_pickle

from oggm import cfg
cfg.initialize()

basedir = '/data/philipp/thesis_test/Giluwe/perfect'

case = test_cases.Giluwe
gdir = NonRGIGlacierDirectory(case, basedir)
idir = InversionDirectory(gdir)
idir.inv_settings['inversion_counter'] = 1001

true_bed = salem.GeoTiff(gdir.get_filepath('dem')).get_vardata()

data_logger = load_pickle(idir.get_subdir_filepath('data_logger'))

plt.figure()
plt.imshow(data_logger.beds[-1] - true_bed)

subsampled_beds = data_logger.beds[-3:]

for i in [3, 4, 5, 6, 7, 8, 9, 10]:
    yfrom = 6
    yend = 8
    y = i
Beispiel #3
0
    if not use_preexisting_fg:
        compile_first_guess(gdir)
    if biased_fg_dict['use']:
        compile_biased_first_guess(gdir, biased_fg_dict['desired_mean_bias'])
    if rmsed_fg_dict['use']:
        # desired_rmse = 5
        # desired_rmse = 20.2038        # results in actual rmse of 20
        noise = create_perlin_noise(gdir, **rmsed_fg_dict)
        take_true_bed_as_first_guess(gdir)
        add_noise_to_first_guess(gdir, noise)

    if use_measurements_in_fg:
        apply_bed_measurements_to_first_guess(gdir)

    # Maybe some surface noise?
    if surface_noise_dict['use']:
        noise = create_perlin_noise(gdir, **surface_noise_dict)
        add_surface_noise(gdir, noise)

    idir = InversionDirectory(gdir)
    res = idir.run_minimize()
    eval_identical_twin(idir)

    # copy this script to inversion directory for reproducibility
    # path_to_file = '/home/philipp/COBBI/combine/sandbox/Giluwe/bed_measurements.py'
    #fname = os.path.split(path_to_file)[-1]
    #if not os.path.exists(idir.get_current_basedir()):
    #    os.makedirs(idir.get_current_basedir(), exist_ok=True)
    #shutil.copy(path_to_file, os.path.join(idir.get_current_basedir(), fname))
    return idir
    # compile_first_guess(gdir)

    noise = create_perlin_noise(gdir,
                                noise_parameters[0],
                                octaves=octaves,
                                base=noise_parameters[2],
                                freq=noise_parameters[1],
                                glacier_only=True)
    #plt.figure()
    #plt.imshow(noise)
    #plt.show()

    take_true_bed_as_first_guess(gdir)
    add_noise_to_first_guess(gdir, noise)

    idir = InversionDirectory(gdir)

    # copy this script to inversion directory for reproducibility
    path_to_file = '/home/philipp/COBBI/combine/sandbox/Giluwe' \
                   '/noisy_first_guess_inversion_run.py'
    fname = os.path.split(path_to_file)[-1]
    dst_dir = idir.get_current_basedir()
    if not os.path.exists(dst_dir):
        os.makedirs(dst_dir, exist_ok=True)
    shutil.copy(path_to_file, os.path.join(dst_dir, fname))

    # Finally run inversion
    try:
        res = idir.run_minimize()
    except MemoryError as merr:
        error_file = os.path.join(idir.get_current_basedir(),