Glacier directories

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

See also: GlacierDirectory

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

In [1]: base_dir = gettempdir('GlacierDir_Docs')

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/GlacierDir_Docs/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)

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
The intersections between cathments (shapefile) in the local map projection (Transverse Mercator).
A list of Centerline instances, sorted by flow order.
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).This DEM is not smoothed or gap filles, and is the closest to the original DEM source.
A text file with the source of the topo file (GIMP, SRTM, …).
A dictionary containing runtime diagnostics useful for debugging.
A dictionary containing the downsteam line geometry as well as the bed shape computed from a parabolic fit.
Each flowline has a catchment area computed from flow routing algorithms: this shapefile stores the catchment outlines (in the local map projection (Transverse Mercator).
The monthly GCM climate timeseries stored in a netCDF file.
A dictionary 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. The “catchment_indices” entrycontains a list of len n_centerlines, each element containing a numpy array of the indices in the glacier grid which represent the centerlines catchment area.
A salem.Grid handling the georeferencing of the local grid.
A netcdf file containing several gridded data variables such as topography, the glacier masks, the interpolated 2D glacier bed, and more.
A hypsometry file computed by OGGM and provided in the same format as the RGI (useful for diagnostics).
The glacier intersects in the local map projection (Transverse Mercator).
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 map projection (Transverse Mercator).