# Configuration file for OGGM parameters

### Input/Output paths. Set to ~ to default to home directory

# Where OGGM will write its output
working_dir =

# Users can specify their own topography file if they want to.
# This is useful for testing, or if you
# are simulating a single region with better data.
# the empty default is what most users should do
dem_file =

# Users can specify their own climate dataset if they want to.
# This is useful for testing, or if you
# are simulating a single region with better data.
# The format of the file is not (yet) very flexible. See the HISTALP data
# in the sample-data folder for an example:
# https://github.com/OGGM/oggm-sample-data/tree/master/test-workflow
climate_file =

# RGI Version (5, 6, 61, or 62)
rgi_version = 70C

# Multiprocessing
use_multiprocessing = False
# Number of processors to use (-1 = all available)
mp_processes = -1
# To avoid race issues when using GDAL, it might be necessary to set this
# to "true". It makes the initialisation of the pool slower, which is
# why it is false per default
use_mp_spawn = False

# Continue on error?
continue_on_error = False

# Skip the entity tasks which have already been applied?
# It is set to False per default but can be set to True for operational runs
# (works only for entity tasks)
auto_skip_task = False

# Apply a timeout check to entity tasks?
# 0 means no timeout, positive values give timeout threshold in seconds
task_timeout = 0

# Use compression for the intermediate pickles? (might slow down I/O a bit)
# Both the performance loss (0% ?) and the space gain (-10%) seem to be low
use_compression = True

# Store shapefiles in glacier directories as .tar files instead of the multiple
# files format? If use_compression is True, use tar.gz instead.
use_tar_shapefiles = True

# If we should keep MultiPolygon Outlines or just use the larges part,
# MultiPolygon Outlines are only supported for elevation band flowlines
keep_multipolygon_outlines = False

# MPI recv buffer size
# If you receive "Message truncated" errors from MPI, increase this
mpi_recv_buf_size = 131072

# Check for the integrity of the files OGGM downloads at run time
dl_verify = False

# Default number of files to be cached in the temporary directory
lru_maxsize = 100

### Glacier map and grid determination

# Map projection: 'tmerc' or 'utm'
map_proj = 'utm'

# Decision on grid spatial resolution for each glacier
# 'fixed': dx (meters) = fixed_dx
# 'by_bin': dx (meters) = dx, chosen by bins
# 'linear':  dx (meters) = d1 * AREA (km) + d2 ; clipped to dmax (e.g.: 5, 10, 200)
# 'square':  dx (meters) = d1 * sqrt(AREA) (km) + d2 ; clipped to dmax (e.g.: 20, 10, 200)

# Defaults
grid_dx_method = 'by_bin'
d1 = 14.
d2 = 10.
dmax = 200.

# Ignored if grid_dx_method != 'fixed'
fixed_dx = 50.

# Ignored if grid_dx_method != 'by_bin'
# size_bins should be of len(by_bin_dx)+1 and given in km2.
# The first and last bin range should be chosen so that all glaciers are included
# by_bin_dx = 25, 50, 100, 200
# by_bin_bins = 0, 8, 80, 300, 1e12
by_bin_dx = 25, 50, 100
by_bin_bins = 0, 16, 300, 1e12

# Which algorithm to use for interpolating the topography to the local grid
# 'bilinear' or 'cubic'
topo_interp = cubic

# Grid border buffer around the glacier (in pixels)
# Make it large if you want to do past simulations.
border = 80

# For tidewater glaciers it doesn't make sense to have large maps
# if for some reason you still want this, set to false
clip_tidewater_border = True

# The glacier area, CenLon and CenLat are usually taken from the RGI
# shapefile, which is a good thing for default RGI files. If you use your
# own inventory, however, it might be a good idea to let OGGM compute these
# attributes at runtime: set to `False` in this case.
use_rgi_area = True

# Head determination: (approx) size in meters of the half-size window
# where to look for maxima
localmax_window = 500.

# DEM smoothing: (approx) size in meters of the smoothing window.
# Set to 0 for no smoothing
smooth_window = 251.

# DEM clipping: we usually clip to 0 m a.s.l, but sometimes if you
# want to be super robust it might be good to not do that
clip_dem_to_zero = True

### Centerline / flowline options

# Use multiple flowlines?
use_multiple_flowlines = True

# Kienholz et al eq (1)
q1 = 2e-6
q2 = 500.
rmax = 1000.

# Kienholz et al eq (2)
f1 = 1000.
f2 = 3000.
a = 4.25
b = 3.7

# Kienholz et al eq (8) but modified here
# Buffer in pixels where to cut the incoming centerlines
kbuffer = 2.5

# For water-terminating glaciers, use the percentile instead of minimum h?
# Set to zero if no special treatment for water terminating glaciers should be
# used, and to an integer > 0 to specify the percentile
terminus_search_percentile = 10
terminus_search_altitude_range = 100

### FLOWLINES definition parameters
# Whether the model should use the glacier intersects information
# given by the user
use_intersects = True
# Grid spacing of a flowline in pixel coordinates
flowline_dx = 2
# Number of pixels to arbitrarily remove at junctions
flowline_junction_pix = 3
# Gaussian smooth of the altitude along a flowline
# sigma, in pixel coordinates (sigma=1 -> smooth around a -4:+4 window)
flowline_height_smooth = 1
# Prevent too small slopes? (see also min_slope param below)
filter_min_slope = True

### Elevation band flowlines (or "collapsed flowlines") parameters
# Only used if using the alternative flowline definition
# The elevation binsize in m - it was 10m in Huss&Farinotti2012, 30m in Werder 2019
elevation_band_flowline_binsize = 30

### CATCHMENT WIDTHS computation parameters
# altitude range threshold for filtering
# This stuff has not been really optimized, it's also not very critical
width_alt_range_thres = 250.
# Minimum number of elements per bin for altitude-binsize definition
min_n_per_bin = 2
# Baseline binsize for the altitude-area distribution
base_binsize = 50.
# Smoothing of the widths after altitude-area matching? 0 means no smoothing,
# 1 means default (i.e. kernel size 9).
smooth_widths_window_size = 1

### DOWNSTREAM LINE
# define which bed shape should be used for the ice free downstream line, the
# options are 'parabola' or 'trapezoidal'. Trapezoidal is probably less
# accurate but allows to use the semi-implicit ice dynamical numerical scheme
downstream_line_shape = 'trapezoidal'
# defines the minimum bottom width of a potential trapezoidal downstream line
# in meters
trapezoid_min_bottom_width = 50.

### CLIMATE params

# Baseline climate is the reference climate data to use for this workflow.
# Options: CRU, HISTALP, ERA5, ERA5L, CERA+ERA5, CERA+ERA5L, W5E5, GSWP3_W5E5
# Leave empty if you want to do your own cuisine.
baseline_climate = GSWP3_W5E5

# Hydrological year definition
# We use this for date conversion and stuff - this is by far not
# as important as it used to be in versions pre 1.6
hydro_month_nh = 10
hydro_month_sh = 4

# which temperature gradient?
temp_default_gradient = -0.0065

# other parameters
temp_all_solid = 0.
temp_all_liq = 2.
temp_melt = -1.

# Melt factor calibration
# These values are based on Schuster et al. (submitted). Using ~100 models
# and the "best possible calibration" for the MB models, min, default and max
# represent the 5, 50 and 95 percentiles (approx.) of the monthly models
# calibration, using tmelt = -1 and W5E5 as data.
# These values are given in kg m-2 K-1 day-1, for both the daily and
# monthly models. We convert them back to monthly values where needed
# (monthly = daily * 365 / 12)
melt_f = 5
melt_f_min = 1.5
melt_f_max = 17

# Temperature bias calibration
# The default range is very large and should be used with caution
temp_bias_min = -15
temp_bias_max = 15
# For W5E5 and calibration on geodetic data from Hugonnet, use the precomputed
# bias values based on grid point analysis (see documentation)
use_temp_bias_from_file = True

# precipitation correction: set to a float for a constant scaling factor
# Needs to be set empty if use_winter_prcp_fac is True
prcp_fac =
# For calibration - set a range
prcp_fac_min = 0.1
prcp_fac_max = 10

# Use a precipitation dependent factor (unique per glacier)
# The values below have been calibrated on W5E5 data and currently
# we enforce using it with these parameters. Note that the
# prcp range above is used to constrain this
use_winter_prcp_fac = True
winter_prcp_fac_ab = -1.0614, 3.9200

# When matching geodetic MB on a glacier per glacier basis, which period
# to use. Available in the current data are:
# '2000-01-01_2010-01-01', '2010-01-01_2020-01-01', '2000-01-01_2020-01-01'
geodetic_mb_period = 2000-01-01_2020-01-01

# Reference data from WGMS is available since the 50s for some glaciers
# The default is to use all the data when asked to read it (as long as there is
# climate data for it), but it could be that you prefer to limit this space
# as well: either because your data is of bad quality, or to allow more
# meaningful comparisons. Only used when reading WGMS data.
ref_mb_valid_window = 0, 0

# Use compression for climate files?
# Can be set to `False` if you have to read the data a lot, i.e. for the
# cross-validation experiment
compress_climate_netcdf = True

### Ice dynamics params
## ice density in kg m-3
ice_density = 900.
## Glen's flow law exponent
glen_n = 3.
## Glen's creep parameter
# For the thickness inversion physics
inversion_glen_a = 2.4e-24
# For the forward run physics
glen_a = 2.4e-24
## Oerlemans "sliding" factor
## In the 1997 paper, it is  5.7e-20 (OUTDATED)
# For the thickness inversion physics
inversion_fs = 0.
# For the forward run physics
fs = 0.

### INVERSION params
# Clip the flowline slope, in degrees
# This will crop the slope during the ice thickness inversion.
# This is quite a sensitive parameter!
min_slope = 1.5
min_slope_ice_caps = 1.5
# When converting the centerlines to flowlines, we prevent negative slopes.
# Ideally, this value should be set to `min_slope` for physical consistency,
# but it turns that many flat glaciers will have weird flowlines with this
# setting. Using zero works ok, and was the default in OGGM for long
min_slope_flowline_filter = 0

# This is for the interpolation of the 1D inversion back to 2D
# It should be higher than min_slope
distributed_inversion_min_slope = 6

### FLOWLINE MODEL params
# Which evolution model to use.
# One of 'SemiImplicit', 'FluxBased', 'MassRedistributionCurve'
# - SemiImplicit: most accurate and faster solver. Works only on trapezoid
#   bed shapes and single flowlines (requires downstream_line_shape to be
#   trapezoidal). Does not have calving capability (yet)
# - FluxBased: most versatile model, but sometimes unstable. Traditionally
#   the default model in OGGM, and the only one able to run in all cases
#   (multiple flowlines, calving, all bedshapes).
# - MassRedistributionCurve : the "Huss dh/dt" model. Simplified but extremely
#   fast glacier retreat model (but unable to simulate long term glacier
#   advances).
evolution_model = 'SemiImplicit'

# below this threshold bedshapes are considered trapezoidal
mixed_min_shape = 0.001
default_parabolic_bedshape = 0.003

# Sometimes the parabola fits in flat areas are very good, implying very
# flat parabolas. This sets a minimum to what the parabolas are allowed to be
# This value could need more tuning
downstream_min_shape = 0.0001
# Angle defining the trapezoid bed shapes
# https://docs.oggm.org/en/stable/ice-dynamics.html#bed-shapes
# Lambda = 1 means an angle of 63° (so quite steep)
# Lambda = 2 means an angle of 45°
trapezoid_lambdas = 2
# Numerics and time stepping options
# Factor to to us in the CFL criterion to choose the time step
# (should be much smaller than 1). 0.02 is OK, but 0.01 is more stable
# (and a bit slower)
cfl_number = 0.02
# Time step threshold (in seconds): the numerical model will raise an error
# if the adaptive time step falls below that value
cfl_min_dt = 60
# Allow the glacier to grow larger than domain?
error_when_glacier_reaches_boundaries = True
# Glacier length computation
# Glacier "length" is not as unambiguously done as glacier volume or area
# Our defaults might not be the best for your use case. Here we provide
# some options to the user.
# This option sets an arbitrary limit on how thick (m) a glacier should be
# to be defined as "glacier" (https://github.com/OGGM/oggm/issues/914)
min_ice_thick_for_length = 0
# How to calculate the length of a glacier?
# - 'naive' (the default) computes the length by summing the number of
#   grid points with an ice thickness above min_ice_thick_for_length
# - 'consecutive' computes the length by summing the number of grid
#   points that are dynamically connected to the top of the glacier
# 'consecutive' better corresponds to what we would intuitively
# define as glacier length, but it can create large steps in the
# length record in melt scenarios where the tongue gets disconnected
# (dead ice) or when tributaries are providing ice to the
# main branch at lower altitudes than the main branch's ice flow.
glacier_length_method = naive
# This option makes sure that dynamical runs realized with
# oggm.core.flowline.flowline_model_run (i.e. all "run_*" tasks in the
# flowline module) are realized with the same parameters as for the inversion
# It's a good idea for operational runs.
use_inversion_params_for_run = True

### Dynamic spinup params
# Defines the minimum ice thickness which is used during the dynamic spinup to
# match area or volume. Only grid points with a larger thickness are considered
# to the total area. This is needed to filter out area changes due to climate
# variability around the rgi year (spikes).
dynamic_spinup_min_ice_thick = 10.

### Tidewater glaciers options

# What is considered a "tidewater glacier" for the model runs, etc?
# 1: Marine-terminating
# 2: Marine-terminating, Shelf-terminating
# 3: Marine-terminating, Lake-terminating
# 4: Marine-terminating, Lake-terminating, Shelf-terminating
tidewater_type = 2

# Should we switch on the k-calving parameterisation for tidewater glaciers?
use_kcalving_for_inversion = False
# Its possible to use kcalving_for_run but not during the inversion.
# This is useful for example for advancing glaciers scenarios, where
# mass is lost by calving instead of unrealistic advance.
use_kcalving_for_run = False
# calving constant of proportionality k after Oerlemans and Nick (2005)
# units yr-1. This one is for the ice thickness inversion
# Oerlemans and Nick (2005) use 2.4 yr-1, but qualitative tests and
# Recinos et al., (2019) indicate that is should be much smaller.
# We set it to 0.6 according to Recinos et al 2019 for a start
inversion_calving_k = 0.6
# And this one is for the forward model
calving_k = 0.6
# Should we use a flux limiter for the calving model? It creates
# quite high frontal thicknesses, but helps to keep the numerics stable
calving_use_limiter = True
# Limit the front slope to a fraction of the calving front. "3" means 1/3.
# Setting to 0 limits the max slope to read sea-level.
calving_limiter_frac = 0
# Sometimes DEMs are bad, and the glacier terminus has unrealistic
# heights: this defines min and max bounds for the glacier free board
# during the thickness inversion, i.e. how far it can reach out of water (in m)
# The DEM and flowlines won't be changed, but the water level will be
# artificially changed and kept throughout the simulation
free_board_marine_terminating = 10, 50
# For lake terminating glaciers, we have no way to know the water level,
# so we set an arbitrary free board value
free_board_lake_terminating = 10
# We extend the calving glaciers by an arbitrary number of grid points,
# and following an arbitrary slope.
# How many grid points should we extend the calving front with?
calving_line_extension = 30
# What is the slope of the ocean floor there? Defined as tan alpha, i.e
# deepening / distance (example 0.1: deepening of 100m over 1000m)
calving_front_slope = 0.05

### File output options

# Whether to store the model geometry files during operational runs
# This can be useful for advanced applications needing the retrieval
# of glacier geometries after the run, but is not necessary if you
# are interested in diagnostics only (volume, length, etc.)
store_model_geometry = False

# What variables would you like to store in the diagnostics files
# Currently available in standard files:
#   volume, volume_bsl, volume_bwl, area, area_min_h, length, calving,
#   calving_rate, terminus_thick_i (with i in 0..9).
# And with additional hydro output:
#   off_area, on_area,
#   melt_off_glacier, melt_on_glacier,
#   liq_prcp_off_glacier, liq_prcp_on_glacier, snowfall_off_glacier, snowfall_on_glacier,
# Probably useful for debugging only
#   melt_residual_off_glacier, melt_residual_on_glacier
#   model_mb, residual_mb, snow_bucket,
# You need to keep all variables in one line unfortunately
store_diagnostic_variables =  volume, volume_bsl, volume_bwl, area, length, calving, calving_rate, off_area, on_area, melt_off_glacier, melt_on_glacier, liq_prcp_off_glacier, liq_prcp_on_glacier, snowfall_off_glacier, snowfall_on_glacier

# Whether to store the model flowline diagnostic files during operational runs
# This can be useful for advanced diagnostics along the flowlines but is
# costly in space (get_filepath('fl_diagnostics'))
store_fl_diagnostics = False
# What variables would you like to store in the flowline diagnostics files
# Note: area and volume are mandatory
# You need to keep all variables in one line unfortunately
store_fl_diagnostic_variables =  area, thickness, volume, volume_bsl, volume_bwl, calving_bucket, ice_velocity, dhdt, climatic_mb, flux_divergence