def bu_tidewater_bed(gridsize=200, gridlength=6e4, widths_m=600, b_0=260, alpha=0.017, b_1=350, x_0=4e4, sigma=1e4, water_level=0, split_flowline_before_water=None): # Bassis & Ultee bed profile dx_meter = gridlength / gridsize x = np.arange(gridsize+1) * dx_meter bed_h = b_0 - alpha * x + b_1 * np.exp(-((x - x_0) / sigma)**2) bed_h += water_level surface_h = bed_h widths = surface_h * 0. + widths_m / dx_meter if split_flowline_before_water is not None: bs = np.min(np.nonzero(bed_h < 0)[0]) - split_flowline_before_water fls = [RectangularBedFlowline(dx=1, map_dx=dx_meter, surface_h=surface_h[:bs], bed_h=bed_h[:bs], widths=widths[:bs]), RectangularBedFlowline(dx=1, map_dx=dx_meter, surface_h=surface_h[bs:], bed_h=bed_h[bs:], widths=widths[bs:]), ] fls[0].set_flows_to(fls[1], check_tail=False, to_head=True) return fls else: return [ RectangularBedFlowline(dx=1, map_dx=dx_meter, surface_h=surface_h, bed_h=bed_h, widths=widths)]
def objfunc(surface_h): # 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 # 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 = RectangularBedFlowline(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 = LinearMassBalance(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) model.run_until(300) measured = pickle.load( open('/home/juliaeis/PycharmProjects/find_inital_state/fls_300.pkl', 'rb')) f = abs(model.fls[-1].surface_h - measured.fls[-1].surface_h)+\ abs(min_length_m(model.fls)-measured.length_m)+\ abs(model.area_km2-measured.area_km2)+\ abs(model.volume_km3-measured.volume_km3) print(sum(f)) return sum(f)
def _init_flowline(self): # Initialise a RectangularBedFlowline for the glacier. return RectangularBedFlowline( surface_h=self.surface_h, bed_h=self.bed.bed_h, widths=self.bed.widths, map_dx=self.bed.map_dx, )
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 = RectangularBedFlowline(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 = LinearMassBalance(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
def surging_glacier(yrs, init_flowline, mb_model, bed, widths, map_dx, glen_a, fs, fs_surge, model): """Function implements surging events in evolution of glacier. 2 different sliding parameters can be used. Parameters ---------- yrs : int years in which glacier evolution should be calculated init_flowline : flowline mb_model : mass balance model bed : ndarray bed rock widths : ndarray width grid map_dx : int grid spacing (e.g. 100 m) glen_a : float Glen's parameter fs : float sliding parameter for slow motion years fs_surge : float sliding parameter for the surging period model : oggm-model Returns ------- model surging_glacier_h : list outline of glacier length_s3 : ndarray length after each time step vol_s3 : ndarray volume after each time step """ # Array to fill with data nsteps = len(yrs) length_s3 = np.zeros(nsteps) vol_s3 = np.zeros(nsteps) surging_glacier_h = [] # Loop & glacier evolution for i, yr in enumerate(yrs): model.run_until(yr) length_s3[i] = model.length_m vol_s3[i] = model.volume_km3 if i == 0 or i == (nsteps - 1): continue elif (yr - yrs[i - 1]) == 10 and (yrs[i + 1] - yr) == 1: # Save glacier geometry before the surge surging_glacier_h.append(model.fls[-1].surface_h) # Glacier evolution surging_glacier_h_ts = model.fls[-1].surface_h init_flowline = RectangularBedFlowline( surface_h=surging_glacier_h_ts, bed_h=bed, widths=widths, map_dx=map_dx) model = FlowlineModel(init_flowline, mb_model=mb_model, y0=yr, glen_a=glen_a, fs=fs_surge) elif (yr - yrs[i - 1]) == 1 and (yrs[i + 1] - yr) == 10: # Save glacier geometry after the surge surging_glacier_h.append(model.fls[-1].surface_h) # Glacier evolution surging_glacier_h_ts = model.fls[-1].surface_h init_flowline = RectangularBedFlowline( surface_h=surging_glacier_h_ts, bed_h=bed, widths=widths, map_dx=map_dx) model = FlowlineModel(init_flowline, mb_model=mb_model, y0=yr, glen_a=glen_a, fs=fs) return model, surging_glacier_h, length_s3, vol_s3
def linear_mb_equilibrium(bed, surface, accw, elaw, nz, mb_grad, nx, map_dx, idx=None, advance=None, retreat=None, plot=True): """Runs the OGGM FluxBasedModel with a linear mass balance gradient until the glacier reaches equilibrium. Parameters ---------- bed : ndarray the glacier bed surface : ndarray the initial glacier surface accw : int the width of the glacier at the top of the accumulation area elaw : int the width of the glacier at the equilibrium line altitude nz : float fraction of vertical grid points occupied by accumulation area mb_grad : int, float the mass balance altitude gradient in mm w.e. m^-1 yr^-1 nx : int number of grid points map_dx : int grid point spacing idx : int, optional number of vertical grid points to shift ELA down/upglacier advance : bool, optional move the ELA downglacier by idx grid points to simulate a glacier advance retreat : bool, optional move the ELA upglacier by idx grid points to simulate a glacier retreat plot : bool, optional show a pseudo-3d plot of the glacier (default: True) Returns ------- model : oggm.core.flowline.FluxBasedModel OGGM model class of the glacier in equilibrium """ # accumulation area occupies a fraction NZ of the total glacier extent acc_width = np.linspace(accw, elaw, int(nx * nz)) # ablation area occupies a fraction 1 - NZ of the total glacier extent abl_width = np.tile(elaw, nx - len(acc_width)) # glacier widths profile widths = np.hstack([acc_width, abl_width]) # model widths mwidths = np.zeros(nx) + widths / map_dx # define the glacier bed init_flowline = RectangularBedFlowline(surface_h=surface, bed_h=bed, widths=mwidths, map_dx=map_dx) # equilibrium line altitude # in case of an advance scenario, move the ELA downglacier by a number of # vertical grid points idx if advance and idx: ela = bed[np.where(widths == elaw)[0][idx]] # in case of a retreat scenario, move the ELA upglacier by a number of # vertical grid points idx elif retreat and idx: ela = bed[np.where(widths == acc_width[-idx])[0][0]] # in case of no scenario, the ela is the height where the width of the ela # is first reached else: ela = bed[np.where(widths == elaw)[0][0]] # linear mass balance model mb_model = LinearMassBalance(ela, grad=mb_grad) # flowline model model = FluxBasedModel(init_flowline, mb_model=mb_model, y0=0., min_dt=0, cfl_number=0.01) # run until the glacier reaches an equilibrium model.run_until_equilibrium() # show a pseudo-3d plot of the glacier geometry if plot: dis = distance_along_glacier(nx, map_dx) plot_glacier_3d(dis, bed, widths, nx) return model
commit_model = FluxBasedModel(fls, mb_model=past_climate, glen_a=cfg.A, y0=2000, time_stepping='ambitious') ''' 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 = RectangularBedFlowline(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 = LinearMassBalance(3000, grad=4) commit_model = FlowlineModel(init_flowline, mb_model=mb_model, y0=0) commit_model.run_until(300) constant_climate = LinearMassBalance(3000, grad=3) commit_model = FlowlineModel(commit_model.fls, mb_model=constant_climate, y0=200) y_start = copy.deepcopy(commit_model) x = np.arange( y_start.fls[-1].nx) * y_start.fls[-1].dx * y_start.fls[-1].map_dx