예제 #1
0
def find_guess(mb_data):

    nx = 200
    bed_h = np.linspace(3400, 1400, nx)
    map_dx = 100
    widths = np.zeros(nx) + 3.

    init_flowline = VerticalWallFlowline(surface_h=measured.fls[-1].surface_h,
                                         bed_h=bed_h,
                                         widths=widths,
                                         map_dx=map_dx)
    # with random ELA
    mb_model = LinearMassBalanceModel(mb_data[0], grad=4)
    # The model requires the initial glacier bed, a mass-balance model, and an initial time (the year y0)
    model = FlowlineModel(init_flowline, mb_model=mb_model, y0=150)
    model.run_until(300)

    mb_model_orig = LinearMassBalanceModel(3000, grad=4)
    end_model = FlowlineModel(model.fls, mb_model=mb_model_orig, y0=150)
    end_model.run_until(300)

    f = abs(end_model.fls[-1].surface_h - measured.fls[-1].surface_h)+\
        abs(end_model.length_m-measured.length_m)+\
        abs(end_model.area_km2-measured.area_km2)+\
        abs(end_model.volume_km3-measured.volume_km3)
    print(sum(f))
    return f
예제 #2
0
def objfunc(surface_h):
    nx = 200
    bed_h = np.linspace(3400, 1400, nx)
    # At the begining, there is no glacier so our glacier surface is at the bed altitude

    # Let's set the model grid spacing to 100m (needed later)
    map_dx = 100

    # The units of widths is in "grid points", i.e. 3 grid points = 300 m in our case
    widths = np.zeros(nx) + 3.
    # Define our bed
    init_flowline = VerticalWallFlowline(surface_h=surface_h,
                                         bed_h=bed_h,
                                         widths=widths,
                                         map_dx=map_dx)
    mb_model = LinearMassBalanceModel(3000, grad=4)
    model = FlowlineModel(init_flowline, mb_model=mb_model, y0=150)
    model.run_until(300)

    f = abs(model.fls[-1].surface_h - measured.fls[-1].surface_h)+\
        abs(model.length_m-measured.length_m)+\
        abs(model.area_km2-measured.area_km2)+\
        abs(model.volume_km3-measured.volume_km3)
    print(sum(f))
    return f
예제 #3
0
def objfunc(x):

    nx = 200
    # set the model grid spacing to 100m
    map_dx = 100
    # The units of widths is in "grid points", i.e. 3 grid points = 300 m in our case
    widths = np.zeros(nx) + 3.

    surface_h = make_surface_h(x)
    flowline = VerticalWallFlowline(surface_h=surface_h, bed_h=bed_h,
                                         widths=widths, map_dx=map_dx)
    #plt.plot(flowline.surface_h)
    #plt.plot(np.linspace(0,x[0],10),x[1::],'o')
    #plt.plot(bed_h)
    #plt.show()
    # ELA at 3000m a.s.l., gradient 4 mm m-1
    mb_model = LinearMassBalanceModel(3000, grad=4)

    # The model requires the initial glacier bed, a mass-balance model, and an initial time (the year y0)
    model = FlowlineModel(flowline, mb_model=mb_model, y0=150)
    model.run_until(300)
    #plt.plot(model.fls[-1].surface_h)
    measured = pickle.load(
        open('/home/juliaeis/PycharmProjects/find_inital_state/fls_300.pkl',
             'rb'))
    #plt.plot(measured.fls[-1].surface_h)
    #plt.show()

    f = abs(model.fls[-1].surface_h - measured.fls[-1].surface_h)+\
        abs(model.length_m-measured.length_m)+\
        abs(model.area_km2-measured.area_km2)+\
        abs(model.volume_km3-measured.volume_km3)
    print('objective:',sum(f))
    return f
def target(ela,time):
    mb_model = LinearMassBalanceModel(ela, grad=4)
    bed_h = np.linspace(3400, 1400, 200)
    # model = FlowlineModel(final_flowline.fls[-1], mb_model=mb_model, y0=0)
    model = FlowlineModel(VerticalWallFlowline(surface_h=bed_h, bed_h=bed_h,
                                               widths=np.zeros(200) + 3.,
                                               map_dx=100), mb_model=mb_model,
                                               y0=0)
    model.run_until(time)
    flowline = model.fls[-1]

    new_mb_model = LinearMassBalanceModel(3000, grad=4)
    new_model = FlowlineModel(flowline, mb_model=new_mb_model, y0=0)
    new_model.run_until(150)
    return -sum(
        abs(final_flowline.fls[-1].surface_h - new_model.fls[-1].surface_h))
예제 #5
0
def objfunc(mb_data):
    mb_model = LinearMassBalanceModel(mb_data[0], grad=4)
    bed_h = np.linspace(3400, 1400, 200)
    model = FlowlineModel(VerticalWallFlowline(
        surface_h=final_flowline.fls[-1].surface_h,
        bed_h=bed_h,
        widths=np.zeros(200) + 3.,
        map_dx=100),
                          mb_model=mb_model,
                          y0=0)
    #model = FlowlineModel(VerticalWallFlowline(surface_h=bed_h, bed_h=bed_h, widths=np.zeros(200) + 3., map_dx=100),mb_model=mb_model,y0=0)
    model.run_until(mb_data[1])
    flowline = model.fls[-1]

    new_mb_model = LinearMassBalanceModel(3000, grad=4)
    new_model = FlowlineModel(flowline, mb_model=new_mb_model, y0=0)
    new_model.run_until(150)
    #print(mb_data,sum(abs(final_flowline.fls[-1].surface_h-new_model.fls[-1].surface_h)))
    return sum(
        abs(final_flowline.fls[-1].surface_h -
            new_model.fls[-1].surface_h)) + sum(abs(final_flowline.volume_m3))
예제 #6
0
def run_model(surface_h):
    nx = 200
    bed_h = np.linspace(3400, 1400, nx)
    # At the begining, there is no glacier so our glacier surface is at the bed altitude

    # Let's set the model grid spacing to 100m (needed later)
    map_dx = 100

    # The units of widths is in "grid points", i.e. 3 grid points = 300 m in our case
    widths = np.zeros(nx) + 3.
    # Define our bed
    init_flowline = VerticalWallFlowline(surface_h=rescale(surface_h, nx),
                                         bed_h=bed_h,
                                         widths=widths,
                                         map_dx=map_dx)
    # ELA at 3000m a.s.l., gradient 4 mm m-1
    mb_model = LinearMassBalanceModel(3000, grad=4)
    annual_mb = mb_model.get_mb(surface_h) * SEC_IN_YEAR

    # The model requires the initial glacier bed, a mass-balance model, and an initial time (the year y0)
    model = FlowlineModel(init_flowline, mb_model=mb_model, y0=150)
    return model
예제 #7
0
                   'maxiter': 5000,
                   'rhobeg': 400
               })

nx = 200
bed_h = np.linspace(3400, 1400, nx)
# At the begining, there is no glacier so our glacier surface is at the bed altitude

# Let's set the model grid spacing to 100m (needed later)
map_dx = 100

# The units of widths is in "grid points", i.e. 3 grid points = 300 m in our case
widths = np.zeros(nx) + 3.
mb_model = LinearMassBalanceModel(res.x, grad=4)
init_flowline = VerticalWallFlowline(surface_h=measured.fls[-1].surface_h,
                                     bed_h=bed_h,
                                     widths=widths,
                                     map_dx=map_dx)
# The model requires the initial glacier bed, a mass-balance model, and an initial time (the year y0)
model = FlowlineModel(init_flowline, mb_model=mb_model, y0=150)
model.run_until(300)

start_guess = model.fls[-1].surface_h
print('####### beginn optimization######')


#------------------------------optimization---------------------------------
def objfunc(surface_h):
    nx = 200
    bed_h = np.linspace(3400, 1400, nx)
    # At the begining, there is no glacier so our glacier surface is at the bed altitude
예제 #8
0

#glacier  bed
# This is the bed rock, linearily decreasing from 3000m altitude to 1000m, in 200 steps
nx = 200
bed_h = np.linspace(3400, 1400, nx)
# At the begining, there is no glacier so our glacier surface is at the bed altitude
surface_h = bed_h
# Let's set the model grid spacing to 100m (needed later)
map_dx = 100

# The units of widths is in "grid points", i.e. 3 grid points = 300 m in our case
widths = np.zeros(nx) + 3.

# Define our bed
init_flowline = VerticalWallFlowline(surface_h=surface_h, bed_h=bed_h, widths=widths, map_dx=map_dx)

# ELA at 3000m a.s.l., gradient 4 mm m-1
mb_model = LinearMassBalanceModel(3000, grad=4)
annual_mb = mb_model.get_mb(surface_h) * SEC_IN_YEAR


# The model requires the initial glacier bed, a mass-balance model, and an initial time (the year y0)
model = FlowlineModel(init_flowline, mb_model=mb_model, y0=0)
model.run_until(150)
print(model.length_m, model.area_km2, model.volume_km3)
d= model.fls[-1].to_dataset()
pickle.dump(model,open('/home/juliaeis/PycharmProjects/find_inital_state/fls_150.pkl','wb'))

model.run_until(300)
print(model.length_m, model.area_km2, model.volume_km3)
예제 #9
0

x0 = [3000, 150]
cons = ({'type': 'ineq', 'fun': con1}, {'type': 'ineq', 'fun': con2})
res = minimize(objfunc,
               x0,
               method='COBYLA',
               tol=1e-10,
               constraints=cons,
               options={
                   'maxiter': 5000,
                   'rhobeg': 100
               })
bed_h = np.linspace(3400, 1400, 200)
model = FlowlineModel(VerticalWallFlowline(surface_h=bed_h,
                                           bed_h=bed_h,
                                           widths=np.zeros(200) + 3.,
                                           map_dx=100),
                      mb_model=LinearMassBalanceModel(res.x[0], grad=4),
                      y0=0)
model.run_until(res.x[1])

#inital flowline
plt.figure(0)
plt.plot(initial_flowline.fls[-1].bed_h, color='k', label='Bedrock')
plt.plot(initial_flowline.fls[-1].surface_h, label='Initial flowline')
plt.plot(model.fls[-1].surface_h, label='optimized intial flowline ')
plt.xlabel('Grid points')
plt.ylabel('Altitude (m)')
plt.legend(loc='best')

orig_mb = LinearMassBalanceModel(3000, grad=4)