def setup_cache(self): utils.mkdir(self.testdir, reset=True) self.cfg_init() hef_file = get_demo_file('Hintereisferner_RGI5.shp') entity = gpd.read_file(hef_file).iloc[0] gdir = oggm.GlacierDirectory(entity, base_dir=self.testdir) tasks.define_glacier_region(gdir, entity=entity) tasks.glacier_masks(gdir) tasks.compute_centerlines(gdir) tasks.initialize_flowlines(gdir) tasks.compute_downstream_line(gdir) tasks.compute_downstream_bedshape(gdir) tasks.catchment_area(gdir) tasks.catchment_intersections(gdir) tasks.catchment_width_geom(gdir) tasks.catchment_width_correction(gdir) tasks.process_custom_climate_data(gdir) tasks.mu_candidates(gdir) mbdf = gdir.get_ref_mb_data()['ANNUAL_BALANCE'] res = climate.t_star_from_refmb(gdir, mbdf) tasks.local_mustar(gdir, tstar=res['t_star'], bias=res['bias']) tasks.apparent_mb(gdir) tasks.prepare_for_inversion(gdir) tasks.mass_conservation_inversion(gdir) return gdir
cfg.PARAMS['prcp_scaling_factor'] = pcp_fac base_dir = os.path.join(os.path.expanduser('~'), 'Climate') entity = gpd.read_file(get_demo_file('Hintereisferner.shp')).iloc[0] gdir = oggm.GlacierDirectory(entity, base_dir=base_dir) tasks.define_glacier_region(gdir, entity=entity) tasks.glacier_masks(gdir) tasks.compute_centerlines(gdir) tasks.initialize_flowlines(gdir) tasks.catchment_area(gdir) tasks.catchment_width_geom(gdir) tasks.catchment_width_correction(gdir) cfg.PATHS['climate_file'] = get_demo_file('histalp_merged_hef.nc') tasks.process_custom_climate_data(gdir) tasks.mu_candidates(gdir) mbdf = gdir.get_ref_mb_data() res = t_star_from_refmb(gdir, mbdf.ANNUAL_BALANCE) local_mustar_apparent_mb(gdir, tstar=res['t_star'][-1], bias=res['bias'][-1], prcp_fac=res['prcp_fac']) # For plots mu_yr_clim = gdir.read_pickle('mu_candidates')[pcp_fac] years, temp_yr, prcp_yr = mb_yearly_climate_on_glacier(gdir, pcp_fac, div_id=0) # which years to look at selind = np.searchsorted(years, mbdf.index)
base_dir = os.path.join(os.path.expanduser('~'), 'Climate') entity = gpd.read_file(get_demo_file('Hintereisferner.shp')).iloc[0] gdir = oggm.GlacierDirectory(entity, base_dir=base_dir) tasks.define_glacier_region(gdir, entity=entity) tasks.glacier_masks(gdir) tasks.compute_centerlines(gdir) tasks.compute_centerlines(gdir) tasks.initialize_flowlines(gdir) tasks.catchment_area(gdir) tasks.catchment_width_geom(gdir) tasks.catchment_width_correction(gdir) cfg.PATHS['climate_file'] = get_demo_file('histalp_merged_hef.nc') tasks.process_custom_climate_data(gdir) tasks.mu_candidates(gdir) # For plots mu_yr_clim = gdir.read_pickle('mu_candidates')[pcp_fac] mbdf = gdir.get_ref_mb_data() years, temp_yr, prcp_yr = mb_yearly_climate_on_glacier(gdir, pcp_fac, div_id=0) # which years to look at selind = np.searchsorted(years, mbdf.index) temp_yr = np.mean(temp_yr[selind]) prcp_yr = np.mean(prcp_yr[selind]) # Average oberved mass-balance ref_mb = mbdf.ANNUAL_BALANCE.mean() mb_per_mu = prcp_yr - mu_yr_clim * temp_yr