oggm.GlacierDirectory

class oggm.GlacierDirectory(rgi_entity, base_dir=None, reset=False)[source]

Organizes read and write access to the glacier’s files.

It handles a glacier directory created in a base directory (default is the “per_glacier” folder in the working directory). The role of a GlacierDirectory is to give access to file paths and to I/O operations. The user should not care about where the files are located, but should know their name (see cfg.BASENAMES).

If the directory does not exist, it will be created.

See Glacier working directories for more information.

Attributes

dir (str) path to the directory
rgi_id (str) The glacier’s RGI identifier
glims_id (str) The glacier’s GLIMS identifier (when available)
rgi_area_km2 (float) The glacier’s RGI area (km2)
cenlon, cenlat (float) The glacier centerpoint’s lon/lat
rgi_date (datetime) The RGI’s BGNDATE attribute if available. Otherwise, defaults to 2003-01-01
rgi_region (str) The RGI region name
name (str) The RGI glacier name (if Available)
glacier_type (str) The RGI glacier type (‘Glacier’, ‘Ice cap’, ‘Perennial snowfield’, ‘Seasonal snowfield’)
terminus_type (str) The RGI terminus type (‘Land-terminating’, ‘Marine-terminating’, ‘Lake-terminating’, ‘Dry calving’, ‘Regenerated’, ‘Shelf-terminating’)
is_tidewater (bool) Is the glacier a caving glacier?
inversion_calving_rate (float) Calving rate used for the inversion
__init__(rgi_entity, base_dir=None, reset=False)[source]

Creates a new directory or opens an existing one.

Parameters:

rgi_entity : a GeoSeries or str

glacier entity read from the shapefile (or a valid RGI ID if the directory exists)

base_dir : str

path to the directory where to open the directory. Defaults to cfg.PATHS[‘working_dir’] + /per_glacier/

reset : bool, default=False

empties the directory at construction (careful!)

Methods

__init__(rgi_entity[, base_dir, reset]) Creates a new directory or opens an existing one.
copy_to_basedir(base_dir[, setup]) Copies the glacier directory and its content to a new location.
create_gridded_ncdf_file(fname) Makes a gridded netcdf file template.
get_filepath(filename[, delete, filesuffix]) Absolute path to a specific file.
get_inversion_flowline_hw() Shortcut function to read the heights and widths of the glacier.
get_ref_length_data() Get the glacier lenght data from P.
get_ref_mb_data() Get the reference mb data from WGMS (for some glaciers only!).
get_task_status(task_name) Opens this directory’s log file to see if a task was already run.
has_file(filename) Checks if a file exists.
log(task_name[, err]) Logs a message to the glacier directory.
read_pickle(filename[, use_compression, …]) Reads a pickle located in the directory.
write_monthly_climate_file(time, prcp, temp, …) Creates a netCDF4 file with climate data.
write_pickle(var, filename[, …]) Writes a variable to a pickle on disk.