pybob.ddem_tools

pybob.ddem_tools provides a number of tools for working with DEM differencing and calculating volume changes. Primarily
designed for glaciers, but could be useful for calculating other volume changes as well.
pybob.ddem_tools.area_alt_dist(DEM, glacier_shapes, glacier_inds=None, bin_width=None)[source]

Calculate an Area-Altitude Distribution for a glacier outline(s), given an input DEM.

Parameters:
  • DEM (pybob.GeoImg) – input DEM.
  • glacier_shapes (array-like) – mask representing glacier outlines. Can be boolean or integer depending on whether one or several AADs should be calculated.
  • glacier_inds (array-like) – array representing glacier indices in glacier_shapes. If unspecified, only one AAD is returned.
  • bin_width (float) – width of elevation bands to calculate area distribution in. If unspecified, result will be the minimum of 50m or 10% of the elevation range.
Returns bins, aads:
 

array, or list of arrays, representing elevation bands and glacier area (in DEM horizontal units) per elevation band.

pybob.ddem_tools.calculate_dV_curve(aad, dh_curve)[source]

Given a dh(z) curve and AAD values, calculate volume change.

Parameters:
  • aad (np.array) – Area-Altitude Distribution/Hypsometry with which to calculate volume change.
  • dh_curve (np.array) – dh(z) curve to use.
Returns dV:

glacier volume change given input curves.

pybob.ddem_tools.calculate_dV_map(dDEM, ind_glac_mask, ind_glac_vals)[source]

Calculate glacier volume changes from a dDEM using a map of glacier outlines.

Parameters:
  • dDEM (pybob.GeoImg) – difference DEM to get elevation changes from
  • ind_glac_mask (array-like) – glacier mask with different values for each glacier
  • ind_glac_vals (array-like) – list of unique index values in glacier mask for which to calculate volume changes.
Returns ind_glac_vals, ind_vol_chgs:
 

index and volume changes for the input indices.

pybob.ddem_tools.get_bins(DEM, glacier_mask=None, bin_width=None)[source]
Get elevation bins for a DEM, given an optional glacier mask and an optional width. If unspecified,
bin_width is calculated as the minimum of 50 units, or 10% of the DEM (or glacier, if mask provided) elevation range. Bin values represent the lower bound of the elevation band, and are rounded to be a multiple of the bin width.
Parameters:
  • DEM (array-like) – The DEM to get elevation bins for.
  • glacier_mask (array-like) – mask representing glacier outline, or region of interest.
  • bin_width (float) – width of bins to calculate.
Returns bins:

the elevation bins.

pybob.ddem_tools.get_elev_curve(DEM, dDEM, glacier_mask=None, bins=None, mode='mean', outlier=False, fill=False, poly_order=3)[source]
Get a dh(z) curve for a glacier/region of interest, given a DEM and a difference DEM (dDEM). Available modes are
‘mean’/’median’, calculating the mean(median) of each elevation bin, or poly, fitting a polynomial (default third-order) to the means of each elevation bin.
Parameters:
  • DEM (array-like) – DEM to determine z in dh(z)
  • dDEM (array-like) – difference DEM to determine dh in dh(z)
  • glacier_mask (array-like) – mask representing glacier outline
  • bins (array-like) – values representing the lower edge of elevation bins
  • mode (str) – how to determine the dh(z) relationship
  • outlier (bool) – filter outliers using an iterative 3-sigma filter
  • fill (bool) – fill missing bins using a polynomial fit (default third order)
  • poly_order (int) – order for any polynomial fitting
Returns bins, curve, bin_areas:
 

elevation bins, dh(z) curve, and number of pixels per elevation bin.

pybob.ddem_tools.nice_split(fname)[source]

Given a filename of the form dH_DEM1_DEM2, return DEM1, DEM2.

Parameters:fname (str) – filename to split
Returns name1, name2:
 DEM names parsed from input filename.
pybob.ddem_tools.nmad(data, nfact=1.4826)[source]

Calculate the normalized median absolute deviation (NMAD) of an array.

Parameters:
  • data (array-like) – input data
  • nfact (float) – normalization factor for the data; default is 1.4826
Returns nmad:

(normalized) median absolute deviation of data.

pybob.ddem_tools.outlier_removal(bins, DEM, dDEM, nsig=3)[source]

Iteratively remove outliers in an elevation bin using a 3-sigma filter.

Parameters:
  • bins (array-like) – lower bound of elevation bins to use
  • DEM (array-like) – DEM to determine grouping for outlier values
  • dDEM (array-like) – elevation differences to filter outliers from
  • nsig (float) – number of standard deviations before a value is considered an outlier.
Returns new_ddem:
 

ddem with outliers removed (set to NaN)