oggm.GlacierDirectory#
- class oggm.GlacierDirectory(rgi_entity, base_dir=None, reset=False, from_tar=False, delete_tar=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 directories for more information.
- Attributes
- dirstr
path to the directory
- base_dirstr
path to the base directory
- rgi_idstr
The glacier’s RGI identifier
- glims_idstr
The glacier’s GLIMS identifier (when available)
rgi_area_km2
floatThe glacier’s RGI area (km2).
- cenlon, cenlatfloat
The glacier centerpoint’s lon/lat
- rgi_dateint
The RGI’s BGNDATE year attribute if available. Otherwise, defaults to the median year for the RGI region
- rgi_regionstr
The RGI region ID
- rgi_subregionstr
The RGI subregion ID
- rgi_versionstr
The RGI version name
- rgi_region_namestr
The RGI region name
- rgi_subregion_namestr
The RGI subregion name
- namestr
The RGI glacier name (if available)
- hemispherestr
nh or sh
- glacier_typestr
The RGI glacier type (‘Glacier’, ‘Ice cap’, ‘Perennial snowfield’, ‘Seasonal snowfield’)
- terminus_typestr
The RGI terminus type (‘Land-terminating’, ‘Marine-terminating’, ‘Lake-terminating’, ‘Dry calving’, ‘Regenerated’, ‘Shelf-terminating’)
- is_tidewaterbool
Is the glacier a calving glacier?
- is_lake_terminatingbool
Is the glacier a lake terminating glacier?
- is_nominalbool
Is the glacier an RGI nominal glacier?
- is_icecapbool
Is the glacier an ice cap?
- extent_lllist
Extent of the glacier in lon/lat
- logfilestr
Path to the log file (txt)
- inversion_calving_ratefloat
Calving rate used for the inversion
grid
A
salem.Grid
handling the georeferencing of the local griddem_info
More detailed information on the acquisition of the DEM data
dem_daterange
Years in which most of the DEM data was acquired
intersects_ids
The glacier’s intersects RGI ids.
rgi_area_m2
The glacier’s RGI area (m2).
rgi_area_km2
The glacier’s RGI area (km2).
- __init__(rgi_entity, base_dir=None, reset=False, from_tar=False, delete_tar=False)[source]#
Creates a new directory or opens an existing one.
- Parameters
- rgi_entitya
geopandas.GeoSeries
or str glacier entity read from the shapefile (or a valid RGI ID if the directory exists)
- base_dirstr
path to the directory where to open the directory. Defaults to cfg.PATHS[‘working_dir’] + /per_glacier/
- resetbool, default=False
empties the directory at construction (careful!)
- from_tarstr or bool, default=False
path to a tar file to extract the gdir data from. If set to True, will check for a tar file at the expected location in base_dir.
- delete_tarbool, default=False
delete the original tar file after extraction.
- rgi_entitya
Methods
__init__
(rgi_entity[, base_dir, reset, ...])Creates a new directory or opens an existing one.
add_to_diagnostics
(key, value)Write a key, value pair to the gdir's runtime diagnostics.
get_climate_info
([input_filesuffix])Convenience function to read attributes of the historical climate.
get_diagnostics
()Read the gdir's runtime diagnostics.
get_error_log
()Reads the directory's log file to find the invalid task (if any).
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 length data from P.
get_ref_mb_data
([y0, y1, input_filesuffix])Get the reference mb data from WGMS (for some glaciers only!).
get_ref_mb_profile
([input_filesuffix, ...])Get the reference mb profile data from WGMS (if available!).
get_task_status
(task_name)Opens this directory's log file to check for a task's outcome.
get_task_time
(task_name)Opens this directory's log file to check for a task's run time.
grid_from_params
()If the glacier_grid.json file is lost, reconstruct it.
has_file
(filename[, filesuffix, ...])Checks if a file exists.
log
(task_name, *[, err, task_time])Logs a message to the glacier directory.
read_json
(filename[, filesuffix, allow_empty])Reads a JSON file located in the directory.
read_pickle
(filename[, use_compression, ...])Reads a pickle located in the directory.
read_shapefile
(filename[, filesuffix])Reads a shapefile located in the directory.
read_text
(filename[, filesuffix])Reads a text file located in the directory.
set_ref_mb_data
([mb_df])Adds reference mass balance data to this glacier.
write_json
(var, filename[, filesuffix])Writes a variable to a pickle on disk.
write_monthly_climate_file
(time, prcp, temp, ...)Creates a netCDF4 file with climate data timeseries.
write_pickle
(var, filename[, ...])Writes a variable to a pickle on disk.
write_shapefile
(var, filename[, filesuffix])Writes a variable to a shapefile on disk.
Attributes
dem_daterange
Years in which most of the DEM data was acquired
dem_info
More detailed information on the acquisition of the DEM data
grid
A
salem.Grid
handling the georeferencing of the local gridintersects_ids
The glacier's intersects RGI ids.
rgi_area_km2
The glacier's RGI area (km2).
rgi_area_m2
The glacier's RGI area (m2).