def init_columbia(reset=False): from oggm.core import gis, climate, centerlines import geopandas as gpd # test directory testdir = os.path.join(get_test_dir(), 'tmp_columbia') if not os.path.exists(testdir): os.makedirs(testdir) reset = True # Init cfg.initialize() cfg.PATHS['working_dir'] = testdir cfg.PARAMS['use_intersects'] = False cfg.PATHS['dem_file'] = get_demo_file('dem_Columbia.tif') cfg.PARAMS['border'] = 10 entity = gpd.read_file(get_demo_file('01_rgi60_Columbia.shp')).iloc[0] gdir = oggm.GlacierDirectory(entity, reset=reset) if gdir.has_file('climate_historical'): return gdir gis.define_glacier_region(gdir) gis.glacier_masks(gdir) centerlines.compute_centerlines(gdir) centerlines.initialize_flowlines(gdir) centerlines.compute_downstream_line(gdir) centerlines.catchment_area(gdir) centerlines.catchment_intersections(gdir) centerlines.catchment_width_geom(gdir) centerlines.catchment_width_correction(gdir) tasks.process_dummy_cru_file(gdir, seed=0) return gdir
def init_columbia_eb(dir_name, reset=False): from oggm.core import gis, centerlines import geopandas as gpd # test directory testdir = os.path.join(get_test_dir(), dir_name) mkdir(testdir, reset=reset) # Init cfg.initialize() cfg.PATHS['working_dir'] = testdir cfg.PARAMS['use_intersects'] = False cfg.PATHS['dem_file'] = get_demo_file('dem_Columbia.tif') cfg.PARAMS['border'] = 10 entity = gpd.read_file(get_demo_file('01_rgi60_Columbia.shp')).iloc[0] gdir = oggm.GlacierDirectory(entity) if gdir.has_file('climate_historical'): return gdir gis.define_glacier_region(gdir) gis.simple_glacier_masks(gdir) centerlines.elevation_band_flowline(gdir) centerlines.fixed_dx_elevation_band_flowline(gdir) centerlines.compute_downstream_line(gdir) tasks.process_dummy_cru_file(gdir, seed=0) return gdir
def test_run(self): entity = gpd.read_file(self.rgi_file).iloc[0] gdir = oggm.GlacierDirectory(entity, base_dir=self.testdir) gis.define_glacier_region(gdir) gis.glacier_masks(gdir) centerlines.compute_centerlines(gdir) centerlines.initialize_flowlines(gdir) centerlines.compute_downstream_line(gdir) centerlines.compute_downstream_bedshape(gdir) centerlines.catchment_area(gdir) centerlines.catchment_intersections(gdir) centerlines.catchment_width_geom(gdir) centerlines.catchment_width_correction(gdir) # Climate tasks -- only data IO and tstar interpolation! tasks.process_dummy_cru_file(gdir, seed=0) tasks.local_t_star(gdir) tasks.mu_star_calibration(gdir) # Inversion tasks tasks.find_inversion_calving(gdir) # Final preparation for the run tasks.init_present_time_glacier(gdir) # check that calving happens in the real context as well tasks.run_constant_climate(gdir, bias=0, nyears=200, temperature_bias=-0.5) with xr.open_dataset(gdir.get_filepath('model_diagnostics')) as ds: assert ds.calving_m3[-1] > 10
def setup_cache(self): setattr(full_workflow.setup_cache, "timeout", 360) utils.mkdir(self.testdir, reset=True) self.cfg_init() entity = gpd.read_file(get_demo_file('01_rgi60_Columbia.shp')).iloc[0] gdir = oggm.GlacierDirectory(entity, base_dir=self.testdir) tasks.define_glacier_region(gdir) 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_dummy_cru_file(gdir, seed=0) # Test default k (it overshoots) df1 = tasks.find_inversion_calving(gdir) # Test with smaller k (it doesn't overshoot) cfg.PARAMS['inversion_calving_k'] = 0.2 df2 = tasks.find_inversion_calving(gdir) return (df1['calving_flux'], df1['calving_mu_star'], df2['calving_flux'], df2['calving_mu_star'])