def gdir_from_prepro(entity, from_prepro_level=None, prepro_border=None, prepro_rgi_version=None, check_demo_glacier=False): if prepro_border is None: prepro_border = int(cfg.PARAMS['border']) if prepro_rgi_version is None: prepro_rgi_version = cfg.PARAMS['rgi_version'] try: rid = entity.RGIId except AttributeError: rid = entity demo_url = False if check_demo_glacier: demo_id = utils.demo_glacier_id(rid) if demo_id is not None: rid = demo_id entity = demo_id demo_url = True tar_base = utils.get_prepro_gdir(prepro_rgi_version, rid, prepro_border, from_prepro_level, demo_url=demo_url) from_tar = os.path.join(tar_base.replace('.tar', ''), rid + '.tar.gz') return oggm.GlacierDirectory(entity, from_tar=from_tar)