How to use the oggm.cfg.initialize function in oggm

To help you get started, we’ve selected a few oggm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OGGM / oggm / benchmarks / track_model_results.py View on Github external
def cfg_init(self):

        # Initialize OGGM and set up the default run parameters
        cfg.initialize(logging_level='ERROR')
        cfg.PATHS['working_dir'] = self.testdir
        cfg.PARAMS['use_multiprocessing'] = True
        cfg.PARAMS['border'] = 100
        cfg.PARAMS['continue_on_error'] = False
github OGGM / oggm / docs / run_examples / _code / run_rgi_region.py View on Github external
import geopandas as gpd
import shapely.geometry as shpg

# Locals
import oggm.cfg as cfg
from oggm import utils, workflow, tasks

# For timing the run
import time
start = time.time()

# Module logger
log = logging.getLogger(__name__)

# Initialize OGGM and set up the default run parameters
cfg.initialize(logging_level='WORKFLOW')
rgi_version = '61'
rgi_region = '11'  # Region Central Europe

# Here we override some of the default parameters
# How many grid points around the glacier?
# Make it large if you expect your glaciers to grow large:
# here, 80 is more than enough
cfg.PARAMS['border'] = 80

# Local working directory (where OGGM will write its output)
WORKING_DIR = utils.gettempdir('OGGM_Rofental')
utils.mkdir(WORKING_DIR, reset=True)
cfg.PATHS['working_dir'] = WORKING_DIR

# RGI file
path = utils.get_rgi_region_file(rgi_region, version=rgi_version)
github OGGM / oggm / docs / run_examples / _code / mb_crossval.py View on Github external
import geopandas as gpd

# Locals
import oggm
from oggm import cfg, workflow, tasks, utils
from oggm.core.massbalance import PastMassBalance, MultipleFlowlineMassBalance
import matplotlib.pyplot as plt

# RGI Version
rgi_version = '61'

# CRU or HISTALP?
baseline = 'CRU'

# Initialize OGGM and set up the run parameters
cfg.initialize()

if baseline == 'HISTALP':
    # Other params: see https://oggm.org/2018/08/10/histalp-parameters/
    cfg.PARAMS['prcp_scaling_factor'] = 1.75
    cfg.PARAMS['temp_melt'] = -1.75

# Local paths (where to find the OGGM run output)
dirname = 'OGGM_ref_mb_{}_RGIV{}_OGGM{}'.format(baseline, rgi_version,
                                                oggm.__version__)
WORKING_DIR = utils.gettempdir(dirname, home=True)
cfg.PATHS['working_dir'] = WORKING_DIR

# Read the rgi file
rgidf = gpd.read_file(os.path.join(WORKING_DIR, 'mb_ref_glaciers.shp'))

# Go - initialize glacier directories
github OGGM / oggm / oggm / sandbox / run_alaska.py View on Github external
import oggm.cfg as cfg
from oggm import workflow
from oggm.utils import get_demo_file
from oggm import tasks
from oggm.workflow import execute_entity_task, reset_multiprocessing
from oggm import graphics, utils
# Time
import time
start = time.time()

# Regions:
# Alaska
rgi_reg = '01'

# Initialize OGGM
cfg.initialize()

# Compute a calving flux or not
No_calving = False
With_calving = True

# Set's where is going to run PC or Cluster
Cluster = False
PC = True

# Local paths (where to write output and where are the input files)
if PC:
    MAIN_PATH = '/home/beatriz/Documents/'
    WORKING_DIR = os.path.join(MAIN_PATH,'OGGM_Alaska_run/work_dir/')
    RGI_PATH = os.path.join(MAIN_PATH,
        'global_data_base/RGI_inventory/All_alaska_glacier_goodformat/')
    RGI_FILE = os.path.join(RGI_PATH,'01_rgi50_Alaska.shp')
github OGGM / oggm / oggm / sandbox / gmd_paper / plot_workflow.py View on Github external
import os
import zipfile
import geopandas as gpd
import matplotlib.pyplot as plt
import numpy as np

import oggm
from oggm import cfg, tasks, graphics
from oggm.sandbox.gmd_paper import PLOT_DIR, LCMAP
from oggm import utils

cfg.initialize()
cfg.PARAMS['border'] = 20
cfg.PARAMS['auto_skip_task'] = True

base_dir = os.path.join(os.path.expanduser('~/tmp'), 'OGGM_GMD', 'Workflow')
cfg.PATHS['working_dir'] = base_dir
utils.mkdir(base_dir)

rgif = 'https://www.dropbox.com/s/bvku83j9bci9r3p/rgiv5_tasman.zip?dl=1'
rgif = utils.file_downloader(rgif)
with zipfile.ZipFile(rgif) as zf:
    zf.extractall(base_dir)
rgif = os.path.join(base_dir, 'rgiv5_tasman.shp')
rgidf = gpd.read_file(rgif)
entity = rgidf.iloc[0]

gdir = oggm.GlacierDirectory(entity, base_dir=base_dir)
github OGGM / oggm / oggm / cli / benchmark.py View on Github external
for testing purposes only
    test_topofile : str
        for testing purposes only
    test_crudir : str
        for testing purposes only
    """

    # TODO: temporarily silence Fiona deprecation warnings
    import warnings
    warnings.filterwarnings("ignore", category=DeprecationWarning)

    # Module logger
    log = logging.getLogger(__name__)

    # Initialize OGGM and set up the run parameters
    cfg.initialize(logging_level='WORKFLOW')

    # Local paths
    utils.mkdir(working_dir)
    cfg.PATHS['working_dir'] = working_dir

    # Use multiprocessing?
    cfg.PARAMS['use_multiprocessing'] = True

    # How many grid points around the glacier?
    # Make it large if you expect your glaciers to grow large
    cfg.PARAMS['border'] = border

    # Set to True for operational runs
    cfg.PARAMS['continue_on_error'] = True

    # For statistics
github OGGM / oggm / oggm / sandbox / gmd_paper / plot_mbexample.py View on Github external
import os

import geopandas as gpd
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import xarray as xr

import oggm
from oggm import cfg, tasks
from oggm.core.climate import (mb_yearly_climate_on_glacier,
                               t_star_from_refmb, local_mustar, apparent_mb)
from oggm.sandbox.gmd_paper import PLOT_DIR
from oggm.utils import get_demo_file, mkdir

cfg.initialize()
cfg.PATHS['dem_file'] = get_demo_file('hef_srtm.tif')
pcp_fac = 2.5
cfg.PARAMS['prcp_scaling_factor'] = pcp_fac
cfg.PARAMS['auto_skip_task'] = True

base_dir = os.path.join(os.path.expanduser('~/tmp'), 'OGGM_GMD', 'MB')
mkdir(base_dir, reset=False)

entity = gpd.read_file(get_demo_file('Hintereisferner.shp')).iloc[0]
gdir = oggm.GlacierDirectory(entity, base_dir=base_dir, reset=True)

tasks.define_glacier_region(gdir, entity=entity)
tasks.glacier_masks(gdir)
tasks.compute_centerlines(gdir)
tasks.initialize_flowlines(gdir)
tasks.catchment_area(gdir)
github OGGM / oggm / oggm / sandbox / rgi_tools / scripts.py View on Github external
def intersects_ondivides_script():
    # Download RGI files
    cfg.initialize()
    rgi_dir = ''  # get_rgi_corrected_dir()
    rgi_shps = list(glob(os.path.join(rgi_dir, "*", '*_rgi50_*.shp')))
    rgi_shps = sorted([r for r in rgi_shps if 'Regions' not in r])
    rgi_shps = np.array(rgi_shps)[[3, 16]]
    with mp.Pool() as p:
        p.map(compute_intersects, rgi_shps, chunksize=1)
github OGGM / oggm / oggm / sandbox / itmix / run_itmix_synth.py View on Github external
import oggm.cfg as cfg
from oggm import workflow
from oggm.utils import get_demo_file
from oggm import tasks
from oggm.workflow import execute_entity_task
from oggm import graphics
from oggm.sandbox import itmix
from oggm.core.inversion import distribute_thickness

# ITMIX paths
DATA_DIR = '/home/mowglie/tmp/RUN_SYNTH/'
WORKING_DIR = '/home/mowglie/tmp/RUN_SYNTH/'
PLOTS_DIR = '/home/mowglie/tmp/RUN_SYNTH/'

# Initialize OGGM
cfg.initialize()

# Use multiprocessing?
cfg.PARAMS['use_multiprocessing'] = False
cfg.PARAMS['continue_on_error'] = False

# Working dir
cfg.PATHS['working_dir'] = WORKING_DIR

# Set up the paths and other stuffs
cfg.PATHS['topo_dir'] = os.path.join(DATA_DIR, 'topo')
cfg.PATHS['itmix_divs'] = '/home/mowglie/synthetic_divides.pkl'
cfg.PATHS['dem_file'] = '/home/mowglie/disk/Dropbox/Share/oggm-data/topo/alternate/ETOPO1_Ice_g_geotiff.tif'

# Read in the RGI file(s)
rgidf = pd.read_pickle('/home/mowglie/synthetic_rgi.pkl')