.. currentmodule:: oggm

1. Equilibrium runs on a subset of an RGI Region
================================================

This example shows how to run the OGGM glacier evolution model on
a subset of the Alps (the Rofental catchment in the Austrian Alps).

The first part of the script is related to setting up the run, then to select
certain glaciers out of the RGI file. If you are not familiar with RGI files,
you might want to do our short tutorial first:

.. image:: https://img.shields.io/badge/Launch-RGI%20tutorial-579ACA.svg?style=popout&logo=data:image/png;base64, 
  :target: https://mybinder.org/v2/gh/OGGM/oggm-edu/master?urlpath=lab/tree/notebooks/oggm-tuto/working_with_rgi.ipynb

Then, we download the :ref:`preprodir` for this run. We use the level 4
data, which contain enough files to start a dynamical run, but not much more!

After the download, starting the runs take only one command. We show an example
with a temperature bias as well, illustrating the sensitivity of these
glaciers to temperature change.


Script
------

.. literalinclude:: _code/run_rgi_region.py

If everything went well, you should see an output similar to::


    2019-02-16 17:50:51: oggm.cfg: Using configuration file: /home/mowglie/Documents/git/oggm-fork/oggm/params.cfg
    2019-02-16 17:50:52: __main__: Starting OGGM run
    2019-02-16 17:50:52: __main__: Number of glaciers: 54
    2019-02-16 17:50:52: oggm.workflow: init_glacier_regions from prepro level 4 on 54 glaciers.
    2019-02-16 17:50:52: oggm.workflow: Execute entity task gdir_from_prepro on 54 glaciers
    2019-02-16 17:50:52: oggm.workflow: Multiprocessing: using all available processors (N=8)
    2019-02-16 17:50:54: oggm.workflow: Execute entity task run_random_climate on 54 glaciers
    2019-02-16 17:51:44: oggm.workflow: Execute entity task run_random_climate on 54 glaciers
    2019-02-16 17:52:36: oggm.workflow: Execute entity task run_random_climate on 54 glaciers
    2019-02-16 17:54:11: __main__: OGGM is done! Time needed: 0:03:20

Some analyses
-------------

The output directory contains many output files, most of them in the
individual glacier directories. Most often, users will use the compiled
data files, where the most relevant model outputs are stored together:

- the ``compile_glacier_statistics.csv`` file contains various information
  for each glacier (here the output is limited because we used a preprocessing
  level of 4 - see other examples for more information).
- the ``run_output_*.nc`` files contain the volume, area and length
  timeseries of each inddividual glacier.

Let's have a look at them:

.. literalinclude:: _code/example_analysis_rgi_region.py

This code snippet should produce the following plots:

.. figure:: ../_static/rgi_region_all.png
    :width: 100%

The graphics above show the basin sums of glacier volume (km\ :sup:`3`) and
area (km\ :sup:`2`)
in a random climate corresponding to the period [1985-2015] (i.e. each year is
picked randomly out of this period). This is a "commitment" run, i.e.
showing the expected glacier change even if climate doesn't change any more
in the future. The time axis shows the number of years since the glacier inventory
date (here, 2003).

.. note::

    The glacier area and length plots can be noisy in certain
    conditions because OGGM currently doesn't differentiate between snow and
    ice, i.e. occasional years with large snowfall can artificially increase
    the glacier area. The effect on volume is negligible, though. A good
    way to deal with this noise is to smooth the time series: see
    `our dedicated tutorial <https://mybinder.org/v2/gh/OGGM/oggm-edu/master?urlpath=lab/tree/notebooks/oggm-tuto/area_length_filter.ipynb>`_
    for a possible way to deal with this.

The graphics below are for the Hintereisferner glacier only, and they
show glacier volume and glacier length evolution:

.. figure:: ../_static/rgi_region_sel.png
    :width: 100%
