Glacier working directories

See also: GlacierDirectory

The majority of OGGM tasks are so-called “entity tasks”. They are standalone operations to be realized on one single glacier entity. These tasks are executed sequentially: they often need input generated by the previous task(s). In order to avoid complicated chains of arguments, each task will read the input data from a glacier-specific directory and writes its output into the same directory, making the new data available for further computations.

Initalising a glacier directory

If no directory has been created yet, a GlacierDirectory requires an RGI entity as input:

In [1]: base_dir = os.path.join(oggm.gettempdir(), 'OGGM_docs', 'GlacierDir')

In [2]: entity = gpd.read_file(get_demo_file('HEF_MajDivide.shp')).iloc[0]

In [3]: gdir = oggm.GlacierDirectory(entity, base_dir=base_dir)

In [4]: gdir.dir
Out[4]: '/tmp/OGGM/OGGM_docs/GlacierDir/RGI50-11/RGI50-11.00/RGI50-11.00897'

In [5]: gdir.rgi_id
Out[5]: 'RGI50-11.00897'

Note that this directory has just been created and is empty. The tasks.define_glacier_region() will fill it with the first data files:

In [6]: tasks.define_glacier_region(gdir, entity=entity)
I am densified (external_values, 10 elements)

In [7]: os.listdir(gdir.dir)

This persistence on disk allows for example to continue a workflow that has been previously interrupted. Initialising a GlacierDirectory from a non-empty folder won’t erase its content (you’ll have to set reset=True explicitly if you want that):

In [8]: gdir = oggm.GlacierDirectory(entity, base_dir=base_dir)

In [9]: os.listdir(gdir.dir)  # the directory still contains the data

You can also initialise a non-empty GlacierDirectory with its RGI ID, thus sparing the reading of the shapefile every time:

In [10]: gdir = oggm.GlacierDirectory('RGI50-11.00897', base_dir=base_dir)


This is a list of the files that can be found in the glacier directory or its divides. These data files and their names are standardized and listed in the oggm.cfg module. If you want to implement your own task you’ll have to add an entry to this file too.

Calving output
A list of len n_centerlines, each element conaining a numpy array of the indices in the glacier grid which represent the centerline’s catchment area.
The catchments intersections in the local projection.
A list of Centerline instances, sorted by flow order.
The monthly GCM climate timeseries stored in a netCDF file.
Some information (dictionary) about the climate data and the mass balance parameters for this glacier.
The monthly climate timeseries stored in a netCDF file.
A geotiff file containing the DEM (reprojected into the local grid).
A text file with the source of the topo file (GIMP, SRTM, …).
A dictionary containing runtime diagnostics useful for debugging.
A dict containing the downsteam line geometry as well as the bedshape computed from a parabolic fit.
The flowline catchments in the local projection.
A dict containing the shapely.Polygons of a glacier. The “polygon_hr” entry contains the geometry transformed to the local grid in (i, j) coordinates, while the “polygon_pix” entry contains the geometries transformed into the coarse grid (the i, j elements are integers). The “polygon_area” entry contains the area of the polygon as computed by Shapely.
A salem.Grid handling the georeferencing of the local grid.
A netcdf file containing several gridded data variables such as topography, the glacier masks and more (see the netCDF file metadata).
A hypsometry file as provided by RGI (useful for diagnostics).
The glacier intersects in the local projection.
A “better” version of the Centerlines, now on a regular spacing i.e., not on the gridded (i, j) indices. The tails of the tributaries are cut out to make more realistic junctions. They are now “1.5D” i.e., with a width.
List of dicts containing the data needed for the inversion.
List of dicts containing the output data from the inversion.
Dict of fs and fd as computed by the inversion optimisation.
When using a linear mass-balance for the inversion, this dict stores the optimal ela_h and grad.
A dict containing the glacier’s t*, bias, and the flowlines’ mu*
A netcdf file containing the model diagnostics (volume, mass-balance, length…).
List of flowlines ready to be run by the model.
A netcdf file containing enough information to reconstruct the entire flowline glacier along the run (can be data expensive).
The glacier outlines in the local projection.