# API Reference¶

This page lists all available functions and classes in OGGM. It’s a hard work to keep everything up-to-date, so don’t hesitate to let us know (see Get in touch) if something’s missing, or help us (see Contributing to OGGM) to write a better documentation!

## Workflow¶

Tools to set-up and run OGGM.

 cfg.initialize Read the configuration file containing the run’s parameters. cfg.set_logging_config Set the global logger parameters. cfg.set_intersects_db Set the glacier intersection database for OGGM to use. cfg.reset_working_dir Deletes the content of the working directory. workflow.init_glacier_regions Initializes the list of Glacier Directories for this run. workflow.execute_entity_task Execute a task on gdirs. workflow.gis_prepro_tasks Shortcut function: run all flowline preprocessing tasks. workflow.climate_tasks Shortcut function: run all climate related tasks. workflow.inversion_tasks Shortcut function: run all ice thickness inversion tasks. utils.compile_glacier_statistics Gather as much statistics as possible about a list of glaciers. utils.compile_run_output Merge the output of the model runs of several gdirs into one file. utils.compile_climate_input Merge the climate input files in the glacier directories into one file. utils.compile_task_log Gathers the log output for the selected task(s) utils.copy_to_basedir Copies the glacier directories and their content to a new location.

## Troubleshooting¶

 utils.show_versions Prints the OGGM version and other system information.

## Input/Output¶

 utils.get_demo_file Returns the path to the desired OGGM file. utils.get_rgi_dir Path to the RGI directory. utils.get_rgi_region_file Path to the RGI region file. utils.get_rgi_glacier_entities Get a list of glacier oulines selected from their IDs. utils.get_rgi_intersects_dir Path to the RGI directory containing the intersect files. utils.get_rgi_intersects_region_file Path to the RGI regional intersect file. utils.get_rgi_intersects_entities Get a list of glacier intersects selected from their IDs. utils.get_cru_file Returns a path to the desired CRU TS file. utils.get_histalp_file Returns a path to the desired HISTALP file. utils.get_ref_mb_glaciers Get the list of glaciers we have valid data for.

Entity tasks are tasks which are applied on single glaciers individually and do not require information from other glaciers (this encompasses the majority of OGGM’s tasks). They are parallelizable.

 tasks.define_glacier_region Very first task: define the glacier’s local grid. tasks.glacier_masks Makes a gridded mask of the glacier outlines. tasks.compute_centerlines Compute the centerlines following Kienholz et al., (2014). tasks.initialize_flowlines Transforms the geometrical Centerlines in the more “physical” “Inversion Flowlines”. tasks.compute_downstream_line Compute the line continuing the glacier. tasks.compute_downstream_bedshape The bedshape obtained by fitting a parabola to the line’s normals. tasks.catchment_area Compute the catchment areas of each tributary line. tasks.catchment_intersections Computes the intersections between the catchments. tasks.catchment_width_geom Compute geometrical catchment widths for each point of the flowlines. tasks.catchment_width_correction Corrects for NaNs and inconsistencies in the geometrical widths. tasks.process_cru_data Processes and writes the climate data for this glacier. tasks.process_histalp_data Processes and writes the climate data for this glacier. tasks.process_custom_climate_data Processes and writes the climate data from a user-defined climate file. tasks.process_cesm_data Processes and writes GCM climate data for this glacier. tasks.local_t_star Compute the local t* and associated glacier-wide mu*. tasks.mu_star_calibration Compute the flowlines’ mu* and the associated apparent mass-balance. tasks.apparent_mb_from_linear_mb Compute apparent mb from a linear mass-balance assumption (for testing). tasks.glacier_mu_candidates Computes the mu candidates, glacier wide. tasks.prepare_for_inversion Prepares the data needed for the inversion. tasks.mass_conservation_inversion Compute the glacier thickness along the flowlines tasks.filter_inversion_output Filters the last few grid point whilst conserving total volume. tasks.distribute_thickness_per_altitude Compute a thickness map by redistributing mass along altitudinal bands. tasks.distribute_thickness_interp Compute a thickness map by interpolating between centerlines and border. tasks.init_present_time_glacier First task after inversion. tasks.run_random_climate Runs the random mass-balance model for a given number of years. tasks.run_constant_climate Runs the constant mass-balance model for a given number of years. tasks.run_from_climate_data Runs glacier with climate input from CRU or a GCM.

Global tasks are tasks which are run on a set of glaciers (most often: all glaciers in the current run). They are not parallelizable at the user level but might use multiprocessing internally.

 tasks.compute_ref_t_stars Detects the best t* for the reference glaciers. tasks.compile_glacier_statistics Gather as much statistics as possible about a list of glaciers. tasks.compile_run_output Merge the output of the model runs of several gdirs into one file. tasks.compile_climate_input Merge the climate input files in the glacier directories into one file. tasks.compile_task_log Gathers the log output for the selected task(s)

## Classes¶

Listed here are the classes which are relevant at the API level (i.e. classes which are used and re-used across modules and tasks).

 GlacierDirectory Organizes read and write access to the glacier’s files. Centerline A Centerline has geometrical and flow rooting properties. Flowline The is the input flowline for the model.

## Mass-balance¶

Mass-balance models found in the core.massbalance module.

They follow the MassBalanceModel() interface. Here is a quick summary of the units and conventions used by all models:

### Units¶

The computed mass-balance is in units of [m ice s-1] (“meters of ice per second”), unless otherwise specified (e.g. for the utility function get_specific_mb). The conversion from the climatic mass-balance ([kg m-2 s-1] ) therefore assumes an ice density given by cfg.PARAMS['ice_density'] (currently: 900 kg m-3).

### Time¶

The time system used by OGGM is a simple “fraction of year” system, where the floating year can be used for conversion to months and years:

In [1]: from oggm.utils import floatyear_to_date, date_to_floatyear

In [2]: date_to_floatyear(1982, 12)
Out[2]: 1982.9166666666667

In [3]: floatyear_to_date(1.2)
Out[3]: (1, 3)


### Interface¶

 MassBalanceModel Common logic for the mass balance models. MassBalanceModel.get_monthly_mb Monthly mass-balance at given altitude(s) for a moment in time. MassBalanceModel.get_annual_mb Like self.get_monthly_mb(), but for annual MB. MassBalanceModel.get_specific_mb Specific mb for this year and a specific glacier geometry. MassBalanceModel.get_ela Compute the equilibrium line altitude for this year

### Models¶

 LinearMassBalance Constant mass-balance as a linear function of altitude. PastMassBalance Mass balance during the climate data period. ConstantMassBalance Constant mass-balance during a chosen period. RandomMassBalance Random shuffle of all MB years within a given time period. UncertainMassBalance Adding uncertainty to a mass balance model.